babylon.max.js 7.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. /**
  335. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  336. */
  337. this.isRecursive = false;
  338. }
  339. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  340. /**
  341. * Does exist one action manager with at least one trigger
  342. **/
  343. get: function () {
  344. for (var t in AbstractActionManager.Triggers) {
  345. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  346. return true;
  347. }
  348. }
  349. return false;
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  355. /**
  356. * Does exist one action manager with at least one pick trigger
  357. **/
  358. get: function () {
  359. for (var t in AbstractActionManager.Triggers) {
  360. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  361. var t_int = parseInt(t);
  362. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  363. return true;
  364. }
  365. }
  366. }
  367. return false;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Does exist one action manager that handles actions of a given trigger
  374. * @param trigger defines the trigger to be tested
  375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  376. **/
  377. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  378. for (var t in AbstractActionManager.Triggers) {
  379. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  380. var t_int = parseInt(t);
  381. if (t_int === trigger) {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. };
  388. /** Gets the list of active triggers */
  389. AbstractActionManager.Triggers = {};
  390. return AbstractActionManager;
  391. }());
  392. /***/ }),
  393. /***/ "./Actions/action.ts":
  394. /*!***************************!*\
  395. !*** ./Actions/action.ts ***!
  396. \***************************/
  397. /*! exports provided: Action */
  398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  399. "use strict";
  400. __webpack_require__.r(__webpack_exports__);
  401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  402. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  405. /**
  406. * The action to be carried out following a trigger
  407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  408. */
  409. var Action = /** @class */ (function () {
  410. /**
  411. * Creates a new Action
  412. * @param triggerOptions the trigger, with or without parameters, for the action
  413. * @param condition an optional determinant of action
  414. */
  415. function Action(
  416. /** the trigger, with or without parameters, for the action */
  417. triggerOptions, condition) {
  418. this.triggerOptions = triggerOptions;
  419. /**
  420. * An event triggered prior to action being executed.
  421. */
  422. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  423. if (triggerOptions.parameter) {
  424. this.trigger = triggerOptions.trigger;
  425. this._triggerParameter = triggerOptions.parameter;
  426. }
  427. else if (triggerOptions.trigger) {
  428. this.trigger = triggerOptions.trigger;
  429. }
  430. else {
  431. this.trigger = triggerOptions;
  432. }
  433. this._nextActiveAction = this;
  434. this._condition = condition;
  435. }
  436. /**
  437. * Internal only
  438. * @hidden
  439. */
  440. Action.prototype._prepare = function () {
  441. };
  442. /**
  443. * Gets the trigger parameters
  444. * @returns the trigger parameters
  445. */
  446. Action.prototype.getTriggerParameter = function () {
  447. return this._triggerParameter;
  448. };
  449. /**
  450. * Internal only - executes current action event
  451. * @hidden
  452. */
  453. Action.prototype._executeCurrent = function (evt) {
  454. if (this._nextActiveAction._condition) {
  455. var condition = this._nextActiveAction._condition;
  456. var currentRenderId = this._actionManager.getScene().getRenderId();
  457. // We cache the current evaluation for the current frame
  458. if (condition._evaluationId === currentRenderId) {
  459. if (!condition._currentResult) {
  460. return;
  461. }
  462. }
  463. else {
  464. condition._evaluationId = currentRenderId;
  465. if (!condition.isValid()) {
  466. condition._currentResult = false;
  467. return;
  468. }
  469. condition._currentResult = true;
  470. }
  471. }
  472. this.onBeforeExecuteObservable.notifyObservers(this);
  473. this._nextActiveAction.execute(evt);
  474. this.skipToNextActiveAction();
  475. };
  476. /**
  477. * Execute placeholder for child classes
  478. * @param evt optional action event
  479. */
  480. Action.prototype.execute = function (evt) {
  481. };
  482. /**
  483. * Skips to next active action
  484. */
  485. Action.prototype.skipToNextActiveAction = function () {
  486. if (this._nextActiveAction._child) {
  487. if (!this._nextActiveAction._child._actionManager) {
  488. this._nextActiveAction._child._actionManager = this._actionManager;
  489. }
  490. this._nextActiveAction = this._nextActiveAction._child;
  491. }
  492. else {
  493. this._nextActiveAction = this;
  494. }
  495. };
  496. /**
  497. * Adds action to chain of actions, may be a DoNothingAction
  498. * @param action defines the next action to execute
  499. * @returns The action passed in
  500. * @see https://www.babylonjs-playground.com/#1T30HR#0
  501. */
  502. Action.prototype.then = function (action) {
  503. this._child = action;
  504. action._actionManager = this._actionManager;
  505. action._prepare();
  506. return action;
  507. };
  508. /**
  509. * Internal only
  510. * @hidden
  511. */
  512. Action.prototype._getProperty = function (propertyPath) {
  513. return this._actionManager._getProperty(propertyPath);
  514. };
  515. /**
  516. * Internal only
  517. * @hidden
  518. */
  519. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  520. return this._actionManager._getEffectiveTarget(target, propertyPath);
  521. };
  522. /**
  523. * Serialize placeholder for child classes
  524. * @param parent of child
  525. * @returns the serialized object
  526. */
  527. Action.prototype.serialize = function (parent) {
  528. };
  529. /**
  530. * Internal only called by serialize
  531. * @hidden
  532. */
  533. Action.prototype._serialize = function (serializedAction, parent) {
  534. var serializationObject = {
  535. type: 1,
  536. children: [],
  537. name: serializedAction.name,
  538. properties: serializedAction.properties || []
  539. };
  540. // Serialize child
  541. if (this._child) {
  542. this._child.serialize(serializationObject);
  543. }
  544. // Check if "this" has a condition
  545. if (this._condition) {
  546. var serializedCondition = this._condition.serialize();
  547. serializedCondition.children.push(serializationObject);
  548. if (parent) {
  549. parent.children.push(serializedCondition);
  550. }
  551. return serializedCondition;
  552. }
  553. if (parent) {
  554. parent.children.push(serializationObject);
  555. }
  556. return serializationObject;
  557. };
  558. /**
  559. * Internal only
  560. * @hidden
  561. */
  562. Action._SerializeValueAsString = function (value) {
  563. if (typeof value === "number") {
  564. return value.toString();
  565. }
  566. if (typeof value === "boolean") {
  567. return value ? "true" : "false";
  568. }
  569. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  570. return value.x + ", " + value.y;
  571. }
  572. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  573. return value.x + ", " + value.y + ", " + value.z;
  574. }
  575. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  576. return value.r + ", " + value.g + ", " + value.b;
  577. }
  578. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  579. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  580. }
  581. return value; // string
  582. };
  583. /**
  584. * Internal only
  585. * @hidden
  586. */
  587. Action._GetTargetProperty = function (target) {
  588. return {
  589. name: "target",
  590. targetType: target._isMesh ? "MeshProperties"
  591. : target._isLight ? "LightProperties"
  592. : target._isCamera ? "CameraProperties"
  593. : "SceneProperties",
  594. value: target._isScene ? "Scene" : target.name
  595. };
  596. };
  597. return Action;
  598. }());
  599. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  600. /***/ }),
  601. /***/ "./Actions/actionEvent.ts":
  602. /*!********************************!*\
  603. !*** ./Actions/actionEvent.ts ***!
  604. \********************************/
  605. /*! exports provided: ActionEvent */
  606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  610. /**
  611. * ActionEvent is the event being sent when an action is triggered.
  612. */
  613. var ActionEvent = /** @class */ (function () {
  614. /**
  615. * Creates a new ActionEvent
  616. * @param source The mesh or sprite that triggered the action
  617. * @param pointerX The X mouse cursor position at the time of the event
  618. * @param pointerY The Y mouse cursor position at the time of the event
  619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  621. * @param additionalData additional data for the event
  622. */
  623. function ActionEvent(
  624. /** The mesh or sprite that triggered the action */
  625. source,
  626. /** The X mouse cursor position at the time of the event */
  627. pointerX,
  628. /** The Y mouse cursor position at the time of the event */
  629. pointerY,
  630. /** The mesh that is currently pointed at (can be null) */
  631. meshUnderPointer,
  632. /** the original (browser) event that triggered the ActionEvent */
  633. sourceEvent,
  634. /** additional data for the event */
  635. additionalData) {
  636. this.source = source;
  637. this.pointerX = pointerX;
  638. this.pointerY = pointerY;
  639. this.meshUnderPointer = meshUnderPointer;
  640. this.sourceEvent = sourceEvent;
  641. this.additionalData = additionalData;
  642. }
  643. /**
  644. * Helper function to auto-create an ActionEvent from a source mesh.
  645. * @param source The source mesh that triggered the event
  646. * @param evt The original (browser) event
  647. * @param additionalData additional data for the event
  648. * @returns the new ActionEvent
  649. */
  650. ActionEvent.CreateNew = function (source, evt, additionalData) {
  651. var scene = source.getScene();
  652. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  653. };
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source sprite
  656. * @param source The source sprite that triggered the event
  657. * @param scene Scene associated with the sprite
  658. * @param evt The original (browser) event
  659. * @param additionalData additional data for the event
  660. * @returns the new ActionEvent
  661. */
  662. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  667. * @param scene the scene where the event occurred
  668. * @param evt The original (browser) event
  669. * @returns the new ActionEvent
  670. */
  671. ActionEvent.CreateNewFromScene = function (scene, evt) {
  672. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  673. };
  674. /**
  675. * Helper function to auto-create an ActionEvent from a primitive
  676. * @param prim defines the target primitive
  677. * @param pointerPos defines the pointer position
  678. * @param evt The original (browser) event
  679. * @param additionalData additional data for the event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  683. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  684. };
  685. return ActionEvent;
  686. }());
  687. /***/ }),
  688. /***/ "./Actions/actionManager.ts":
  689. /*!**********************************!*\
  690. !*** ./Actions/actionManager.ts ***!
  691. \**********************************/
  692. /*! exports provided: ActionManager */
  693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  694. "use strict";
  695. __webpack_require__.r(__webpack_exports__);
  696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  699. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  700. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  701. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  703. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  704. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  705. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  706. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  708. /**
  709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  712. */
  713. var ActionManager = /** @class */ (function (_super) {
  714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  715. /**
  716. * Creates a new action manager
  717. * @param scene defines the hosting scene
  718. */
  719. function ActionManager(scene) {
  720. var _this = _super.call(this) || this;
  721. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  722. scene.actionManagers.push(_this);
  723. return _this;
  724. }
  725. // Methods
  726. /**
  727. * Releases all associated resources
  728. */
  729. ActionManager.prototype.dispose = function () {
  730. var index = this._scene.actionManagers.indexOf(this);
  731. for (var i = 0; i < this.actions.length; i++) {
  732. var action = this.actions[i];
  733. ActionManager.Triggers[action.trigger]--;
  734. if (ActionManager.Triggers[action.trigger] === 0) {
  735. delete ActionManager.Triggers[action.trigger];
  736. }
  737. }
  738. if (index > -1) {
  739. this._scene.actionManagers.splice(index, 1);
  740. }
  741. };
  742. /**
  743. * Gets hosting scene
  744. * @returns the hosting scene
  745. */
  746. ActionManager.prototype.getScene = function () {
  747. return this._scene;
  748. };
  749. /**
  750. * Does this action manager handles actions of any of the given triggers
  751. * @param triggers defines the triggers to be tested
  752. * @return a boolean indicating whether one (or more) of the triggers is handled
  753. */
  754. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  755. for (var index = 0; index < this.actions.length; index++) {
  756. var action = this.actions[index];
  757. if (triggers.indexOf(action.trigger) > -1) {
  758. return true;
  759. }
  760. }
  761. return false;
  762. };
  763. /**
  764. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  765. * speed.
  766. * @param triggerA defines the trigger to be tested
  767. * @param triggerB defines the trigger to be tested
  768. * @return a boolean indicating whether one (or more) of the triggers is handled
  769. */
  770. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  771. for (var index = 0; index < this.actions.length; index++) {
  772. var action = this.actions[index];
  773. if (triggerA == action.trigger || triggerB == action.trigger) {
  774. return true;
  775. }
  776. }
  777. return false;
  778. };
  779. /**
  780. * Does this action manager handles actions of a given trigger
  781. * @param trigger defines the trigger to be tested
  782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  783. * @return whether the trigger is handled
  784. */
  785. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  786. for (var index = 0; index < this.actions.length; index++) {
  787. var action = this.actions[index];
  788. if (action.trigger === trigger) {
  789. if (parameterPredicate) {
  790. if (parameterPredicate(action.getTriggerParameter())) {
  791. return true;
  792. }
  793. }
  794. else {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. };
  801. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  802. /**
  803. * Does this action manager has pointer triggers
  804. */
  805. get: function () {
  806. for (var index = 0; index < this.actions.length; index++) {
  807. var action = this.actions[index];
  808. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  809. return true;
  810. }
  811. }
  812. return false;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  818. /**
  819. * Does this action manager has pick triggers
  820. */
  821. get: function () {
  822. for (var index = 0; index < this.actions.length; index++) {
  823. var action = this.actions[index];
  824. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  825. return true;
  826. }
  827. }
  828. return false;
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. /**
  834. * Registers an action to this action manager
  835. * @param action defines the action to be registered
  836. * @return the action amended (prepared) after registration
  837. */
  838. ActionManager.prototype.registerAction = function (action) {
  839. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  840. if (this.getScene().actionManager !== this) {
  841. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  842. return null;
  843. }
  844. }
  845. this.actions.push(action);
  846. if (ActionManager.Triggers[action.trigger]) {
  847. ActionManager.Triggers[action.trigger]++;
  848. }
  849. else {
  850. ActionManager.Triggers[action.trigger] = 1;
  851. }
  852. action._actionManager = this;
  853. action._prepare();
  854. return action;
  855. };
  856. /**
  857. * Unregisters an action to this action manager
  858. * @param action defines the action to be unregistered
  859. * @return a boolean indicating whether the action has been unregistered
  860. */
  861. ActionManager.prototype.unregisterAction = function (action) {
  862. var index = this.actions.indexOf(action);
  863. if (index !== -1) {
  864. this.actions.splice(index, 1);
  865. ActionManager.Triggers[action.trigger] -= 1;
  866. if (ActionManager.Triggers[action.trigger] === 0) {
  867. delete ActionManager.Triggers[action.trigger];
  868. }
  869. delete action._actionManager;
  870. return true;
  871. }
  872. return false;
  873. };
  874. /**
  875. * Process a specific trigger
  876. * @param trigger defines the trigger to process
  877. * @param evt defines the event details to be processed
  878. */
  879. ActionManager.prototype.processTrigger = function (trigger, evt) {
  880. for (var index = 0; index < this.actions.length; index++) {
  881. var action = this.actions[index];
  882. if (action.trigger === trigger) {
  883. if (evt) {
  884. if (trigger === ActionManager.OnKeyUpTrigger
  885. || trigger === ActionManager.OnKeyDownTrigger) {
  886. var parameter = action.getTriggerParameter();
  887. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  888. if (!parameter.toLowerCase) {
  889. continue;
  890. }
  891. var lowerCase = parameter.toLowerCase();
  892. if (lowerCase !== evt.sourceEvent.key) {
  893. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  894. var actualkey = String.fromCharCode(unicode).toLowerCase();
  895. if (actualkey !== lowerCase) {
  896. continue;
  897. }
  898. }
  899. }
  900. }
  901. }
  902. action._executeCurrent(evt);
  903. }
  904. }
  905. };
  906. /** @hidden */
  907. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  908. var properties = propertyPath.split(".");
  909. for (var index = 0; index < properties.length - 1; index++) {
  910. target = target[properties[index]];
  911. }
  912. return target;
  913. };
  914. /** @hidden */
  915. ActionManager.prototype._getProperty = function (propertyPath) {
  916. var properties = propertyPath.split(".");
  917. return properties[properties.length - 1];
  918. };
  919. /**
  920. * Serialize this manager to a JSON object
  921. * @param name defines the property name to store this manager
  922. * @returns a JSON representation of this manager
  923. */
  924. ActionManager.prototype.serialize = function (name) {
  925. var root = {
  926. children: new Array(),
  927. name: name,
  928. type: 3,
  929. properties: new Array() // Empty for root but required
  930. };
  931. for (var i = 0; i < this.actions.length; i++) {
  932. var triggerObject = {
  933. type: 0,
  934. children: new Array(),
  935. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  936. properties: new Array()
  937. };
  938. var triggerOptions = this.actions[i].triggerOptions;
  939. if (triggerOptions && typeof triggerOptions !== "number") {
  940. if (triggerOptions.parameter instanceof Node) {
  941. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  942. }
  943. else {
  944. var parameter = {};
  945. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  946. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  947. parameter._meshId = triggerOptions.parameter.mesh.id;
  948. }
  949. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  950. }
  951. }
  952. // Serialize child action, recursively
  953. this.actions[i].serialize(triggerObject);
  954. // Add serialized trigger
  955. root.children.push(triggerObject);
  956. }
  957. return root;
  958. };
  959. /**
  960. * Creates a new ActionManager from a JSON data
  961. * @param parsedActions defines the JSON data to read from
  962. * @param object defines the hosting mesh
  963. * @param scene defines the hosting scene
  964. */
  965. ActionManager.Parse = function (parsedActions, object, scene) {
  966. var actionManager = new ActionManager(scene);
  967. if (object === null) {
  968. scene.actionManager = actionManager;
  969. }
  970. else {
  971. object.actionManager = actionManager;
  972. }
  973. // instanciate a new object
  974. var instanciate = function (name, params) {
  975. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  976. if (internalClassType) {
  977. var newInstance = Object.create(internalClassType.prototype);
  978. newInstance.constructor.apply(newInstance, params);
  979. return newInstance;
  980. }
  981. };
  982. var parseParameter = function (name, value, target, propertyPath) {
  983. if (propertyPath === null) {
  984. // String, boolean or float
  985. var floatValue = parseFloat(value);
  986. if (value === "true" || value === "false") {
  987. return value === "true";
  988. }
  989. else {
  990. return isNaN(floatValue) ? value : floatValue;
  991. }
  992. }
  993. var effectiveTarget = propertyPath.split(".");
  994. var values = value.split(",");
  995. // Get effective Target
  996. for (var i = 0; i < effectiveTarget.length; i++) {
  997. target = target[effectiveTarget[i]];
  998. }
  999. // Return appropriate value with its type
  1000. if (typeof (target) === "boolean") {
  1001. return values[0] === "true";
  1002. }
  1003. if (typeof (target) === "string") {
  1004. return values[0];
  1005. }
  1006. // Parameters with multiple values such as Vector3 etc.
  1007. var split = new Array();
  1008. for (var i = 0; i < values.length; i++) {
  1009. split.push(parseFloat(values[i]));
  1010. }
  1011. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1012. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1013. }
  1014. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1015. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1016. }
  1017. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1018. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1019. }
  1020. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1022. }
  1023. return parseFloat(values[0]);
  1024. };
  1025. // traverse graph per trigger
  1026. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1027. if (combineArray === void 0) { combineArray = null; }
  1028. if (parsedAction.detached) {
  1029. return;
  1030. }
  1031. var parameters = new Array();
  1032. var target = null;
  1033. var propertyPath = null;
  1034. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1035. // Parameters
  1036. if (parsedAction.type === 2) {
  1037. parameters.push(actionManager);
  1038. }
  1039. else {
  1040. parameters.push(trigger);
  1041. }
  1042. if (combine) {
  1043. var actions = new Array();
  1044. for (var j = 0; j < parsedAction.combine.length; j++) {
  1045. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1046. }
  1047. parameters.push(actions);
  1048. }
  1049. else {
  1050. for (var i = 0; i < parsedAction.properties.length; i++) {
  1051. var value = parsedAction.properties[i].value;
  1052. var name = parsedAction.properties[i].name;
  1053. var targetType = parsedAction.properties[i].targetType;
  1054. if (name === "target") {
  1055. if (targetType !== null && targetType === "SceneProperties") {
  1056. value = target = scene;
  1057. }
  1058. else {
  1059. value = target = scene.getNodeByName(value);
  1060. }
  1061. }
  1062. else if (name === "parent") {
  1063. value = scene.getNodeByName(value);
  1064. }
  1065. else if (name === "sound") {
  1066. // Can not externalize to component, so only checks for the presence off the API.
  1067. if (scene.getSoundByName) {
  1068. value = scene.getSoundByName(value);
  1069. }
  1070. }
  1071. else if (name !== "propertyPath") {
  1072. if (parsedAction.type === 2 && name === "operator") {
  1073. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1074. }
  1075. else {
  1076. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1077. }
  1078. }
  1079. else {
  1080. propertyPath = value;
  1081. }
  1082. parameters.push(value);
  1083. }
  1084. }
  1085. if (combineArray === null) {
  1086. parameters.push(condition);
  1087. }
  1088. else {
  1089. parameters.push(null);
  1090. }
  1091. // If interpolate value action
  1092. if (parsedAction.name === "InterpolateValueAction") {
  1093. var param = parameters[parameters.length - 2];
  1094. parameters[parameters.length - 1] = param;
  1095. parameters[parameters.length - 2] = condition;
  1096. }
  1097. // Action or condition(s) and not CombineAction
  1098. var newAction = instanciate(parsedAction.name, parameters);
  1099. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1100. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1101. if (action) {
  1102. action.then(nothing);
  1103. }
  1104. else {
  1105. actionManager.registerAction(nothing);
  1106. }
  1107. action = nothing;
  1108. }
  1109. if (combineArray === null) {
  1110. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1111. condition = newAction;
  1112. newAction = action;
  1113. }
  1114. else {
  1115. condition = null;
  1116. if (action) {
  1117. action.then(newAction);
  1118. }
  1119. else {
  1120. actionManager.registerAction(newAction);
  1121. }
  1122. }
  1123. }
  1124. else {
  1125. combineArray.push(newAction);
  1126. }
  1127. for (var i = 0; i < parsedAction.children.length; i++) {
  1128. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1129. }
  1130. };
  1131. // triggers
  1132. for (var i = 0; i < parsedActions.children.length; i++) {
  1133. var triggerParams;
  1134. var trigger = parsedActions.children[i];
  1135. if (trigger.properties.length > 0) {
  1136. var param = trigger.properties[0].value;
  1137. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1138. if (value._meshId) {
  1139. value.mesh = scene.getMeshByID(value._meshId);
  1140. }
  1141. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1142. }
  1143. else {
  1144. triggerParams = ActionManager[trigger.name];
  1145. }
  1146. for (var j = 0; j < trigger.children.length; j++) {
  1147. if (!trigger.detached) {
  1148. traverse(trigger.children[j], triggerParams, null, null);
  1149. }
  1150. }
  1151. }
  1152. };
  1153. /**
  1154. * Get a trigger name by index
  1155. * @param trigger defines the trigger index
  1156. * @returns a trigger name
  1157. */
  1158. ActionManager.GetTriggerName = function (trigger) {
  1159. switch (trigger) {
  1160. case 0: return "NothingTrigger";
  1161. case 1: return "OnPickTrigger";
  1162. case 2: return "OnLeftPickTrigger";
  1163. case 3: return "OnRightPickTrigger";
  1164. case 4: return "OnCenterPickTrigger";
  1165. case 5: return "OnPickDownTrigger";
  1166. case 6: return "OnPickUpTrigger";
  1167. case 7: return "OnLongPressTrigger";
  1168. case 8: return "OnPointerOverTrigger";
  1169. case 9: return "OnPointerOutTrigger";
  1170. case 10: return "OnEveryFrameTrigger";
  1171. case 11: return "OnIntersectionEnterTrigger";
  1172. case 12: return "OnIntersectionExitTrigger";
  1173. case 13: return "OnKeyDownTrigger";
  1174. case 14: return "OnKeyUpTrigger";
  1175. case 15: return "OnPickOutTrigger";
  1176. default: return "";
  1177. }
  1178. };
  1179. /**
  1180. * Nothing
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1182. */
  1183. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1184. /**
  1185. * On pick
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1187. */
  1188. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1189. /**
  1190. * On left pick
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1194. /**
  1195. * On right pick
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1199. /**
  1200. * On center pick
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1204. /**
  1205. * On pick down
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1209. /**
  1210. * On double pick
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1214. /**
  1215. * On pick up
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1219. /**
  1220. * On pick out.
  1221. * This trigger will only be raised if you also declared a OnPickDown
  1222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1223. */
  1224. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1225. /**
  1226. * On long press
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1228. */
  1229. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1230. /**
  1231. * On pointer over
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1233. */
  1234. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1235. /**
  1236. * On pointer out
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1238. */
  1239. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1240. /**
  1241. * On every frame
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1243. */
  1244. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1245. /**
  1246. * On intersection enter
  1247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1248. */
  1249. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1250. /**
  1251. * On intersection exit
  1252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1253. */
  1254. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1255. /**
  1256. * On key down
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1258. */
  1259. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1260. /**
  1261. * On key up
  1262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1263. */
  1264. ActionManager.OnKeyUpTrigger = 15;
  1265. return ActionManager;
  1266. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1267. /***/ }),
  1268. /***/ "./Actions/condition.ts":
  1269. /*!******************************!*\
  1270. !*** ./Actions/condition.ts ***!
  1271. \******************************/
  1272. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1274. "use strict";
  1275. __webpack_require__.r(__webpack_exports__);
  1276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1281. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1283. /**
  1284. * A Condition applied to an Action
  1285. */
  1286. var Condition = /** @class */ (function () {
  1287. /**
  1288. * Creates a new Condition
  1289. * @param actionManager the manager of the action the condition is applied to
  1290. */
  1291. function Condition(actionManager) {
  1292. this._actionManager = actionManager;
  1293. }
  1294. /**
  1295. * Check if the current condition is valid
  1296. * @returns a boolean
  1297. */
  1298. Condition.prototype.isValid = function () {
  1299. return true;
  1300. };
  1301. /**
  1302. * Internal only
  1303. * @hidden
  1304. */
  1305. Condition.prototype._getProperty = function (propertyPath) {
  1306. return this._actionManager._getProperty(propertyPath);
  1307. };
  1308. /**
  1309. * Internal only
  1310. * @hidden
  1311. */
  1312. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1313. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1314. };
  1315. /**
  1316. * Serialize placeholder for child classes
  1317. * @returns the serialized object
  1318. */
  1319. Condition.prototype.serialize = function () {
  1320. };
  1321. /**
  1322. * Internal only
  1323. * @hidden
  1324. */
  1325. Condition.prototype._serialize = function (serializedCondition) {
  1326. return {
  1327. type: 2,
  1328. children: [],
  1329. name: serializedCondition.name,
  1330. properties: serializedCondition.properties
  1331. };
  1332. };
  1333. return Condition;
  1334. }());
  1335. /**
  1336. * Defines specific conditional operators as extensions of Condition
  1337. */
  1338. var ValueCondition = /** @class */ (function (_super) {
  1339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1340. /**
  1341. * Creates a new ValueCondition
  1342. * @param actionManager manager for the action the condition applies to
  1343. * @param target for the action
  1344. * @param propertyPath path to specify the property of the target the conditional operator uses
  1345. * @param value the value compared by the conditional operator against the current value of the property
  1346. * @param operator the conditional operator, default ValueCondition.IsEqual
  1347. */
  1348. function ValueCondition(actionManager, target,
  1349. /** path to specify the property of the target the conditional operator uses */
  1350. propertyPath,
  1351. /** the value compared by the conditional operator against the current value of the property */
  1352. value,
  1353. /** the conditional operator, default ValueCondition.IsEqual */
  1354. operator) {
  1355. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1356. var _this = _super.call(this, actionManager) || this;
  1357. _this.propertyPath = propertyPath;
  1358. _this.value = value;
  1359. _this.operator = operator;
  1360. _this._target = target;
  1361. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1362. _this._property = _this._getProperty(_this.propertyPath);
  1363. return _this;
  1364. }
  1365. Object.defineProperty(ValueCondition, "IsEqual", {
  1366. /**
  1367. * returns the number for IsEqual
  1368. */
  1369. get: function () {
  1370. return ValueCondition._IsEqual;
  1371. },
  1372. enumerable: true,
  1373. configurable: true
  1374. });
  1375. Object.defineProperty(ValueCondition, "IsDifferent", {
  1376. /**
  1377. * Returns the number for IsDifferent
  1378. */
  1379. get: function () {
  1380. return ValueCondition._IsDifferent;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(ValueCondition, "IsGreater", {
  1386. /**
  1387. * Returns the number for IsGreater
  1388. */
  1389. get: function () {
  1390. return ValueCondition._IsGreater;
  1391. },
  1392. enumerable: true,
  1393. configurable: true
  1394. });
  1395. Object.defineProperty(ValueCondition, "IsLesser", {
  1396. /**
  1397. * Returns the number for IsLesser
  1398. */
  1399. get: function () {
  1400. return ValueCondition._IsLesser;
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. /**
  1406. * Compares the given value with the property value for the specified conditional operator
  1407. * @returns the result of the comparison
  1408. */
  1409. ValueCondition.prototype.isValid = function () {
  1410. switch (this.operator) {
  1411. case ValueCondition.IsGreater:
  1412. return this._effectiveTarget[this._property] > this.value;
  1413. case ValueCondition.IsLesser:
  1414. return this._effectiveTarget[this._property] < this.value;
  1415. case ValueCondition.IsEqual:
  1416. case ValueCondition.IsDifferent:
  1417. var check;
  1418. if (this.value.equals) {
  1419. check = this.value.equals(this._effectiveTarget[this._property]);
  1420. }
  1421. else {
  1422. check = this.value === this._effectiveTarget[this._property];
  1423. }
  1424. return this.operator === ValueCondition.IsEqual ? check : !check;
  1425. }
  1426. return false;
  1427. };
  1428. /**
  1429. * Serialize the ValueCondition into a JSON compatible object
  1430. * @returns serialization object
  1431. */
  1432. ValueCondition.prototype.serialize = function () {
  1433. return this._serialize({
  1434. name: "ValueCondition",
  1435. properties: [
  1436. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1437. { name: "propertyPath", value: this.propertyPath },
  1438. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1439. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1440. ]
  1441. });
  1442. };
  1443. /**
  1444. * Gets the name of the conditional operator for the ValueCondition
  1445. * @param operator the conditional operator
  1446. * @returns the name
  1447. */
  1448. ValueCondition.GetOperatorName = function (operator) {
  1449. switch (operator) {
  1450. case ValueCondition._IsEqual: return "IsEqual";
  1451. case ValueCondition._IsDifferent: return "IsDifferent";
  1452. case ValueCondition._IsGreater: return "IsGreater";
  1453. case ValueCondition._IsLesser: return "IsLesser";
  1454. default: return "";
  1455. }
  1456. };
  1457. /**
  1458. * Internal only
  1459. * @hidden
  1460. */
  1461. ValueCondition._IsEqual = 0;
  1462. /**
  1463. * Internal only
  1464. * @hidden
  1465. */
  1466. ValueCondition._IsDifferent = 1;
  1467. /**
  1468. * Internal only
  1469. * @hidden
  1470. */
  1471. ValueCondition._IsGreater = 2;
  1472. /**
  1473. * Internal only
  1474. * @hidden
  1475. */
  1476. ValueCondition._IsLesser = 3;
  1477. return ValueCondition;
  1478. }(Condition));
  1479. /**
  1480. * Defines a predicate condition as an extension of Condition
  1481. */
  1482. var PredicateCondition = /** @class */ (function (_super) {
  1483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1484. /**
  1485. * Creates a new PredicateCondition
  1486. * @param actionManager manager for the action the condition applies to
  1487. * @param predicate defines the predicate function used to validate the condition
  1488. */
  1489. function PredicateCondition(actionManager,
  1490. /** defines the predicate function used to validate the condition */
  1491. predicate) {
  1492. var _this = _super.call(this, actionManager) || this;
  1493. _this.predicate = predicate;
  1494. return _this;
  1495. }
  1496. /**
  1497. * @returns the validity of the predicate condition
  1498. */
  1499. PredicateCondition.prototype.isValid = function () {
  1500. return this.predicate();
  1501. };
  1502. return PredicateCondition;
  1503. }(Condition));
  1504. /**
  1505. * Defines a state condition as an extension of Condition
  1506. */
  1507. var StateCondition = /** @class */ (function (_super) {
  1508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1509. /**
  1510. * Creates a new StateCondition
  1511. * @param actionManager manager for the action the condition applies to
  1512. * @param target of the condition
  1513. * @param value to compare with target state
  1514. */
  1515. function StateCondition(actionManager, target,
  1516. /** Value to compare with target state */
  1517. value) {
  1518. var _this = _super.call(this, actionManager) || this;
  1519. _this.value = value;
  1520. _this._target = target;
  1521. return _this;
  1522. }
  1523. /**
  1524. * Gets a boolean indicating if the current condition is met
  1525. * @returns the validity of the state
  1526. */
  1527. StateCondition.prototype.isValid = function () {
  1528. return this._target.state === this.value;
  1529. };
  1530. /**
  1531. * Serialize the StateCondition into a JSON compatible object
  1532. * @returns serialization object
  1533. */
  1534. StateCondition.prototype.serialize = function () {
  1535. return this._serialize({
  1536. name: "StateCondition",
  1537. properties: [
  1538. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1539. { name: "value", value: this.value }
  1540. ]
  1541. });
  1542. };
  1543. return StateCondition;
  1544. }(Condition));
  1545. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1548. /***/ }),
  1549. /***/ "./Actions/directActions.ts":
  1550. /*!**********************************!*\
  1551. !*** ./Actions/directActions.ts ***!
  1552. \**********************************/
  1553. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1568. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1569. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1570. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1572. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1573. /**
  1574. * This defines an action responsible to toggle a boolean once triggered.
  1575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1576. */
  1577. var SwitchBooleanAction = /** @class */ (function (_super) {
  1578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1579. /**
  1580. * Instantiate the action
  1581. * @param triggerOptions defines the trigger options
  1582. * @param target defines the object containing the boolean
  1583. * @param propertyPath defines the path to the boolean property in the target object
  1584. * @param condition defines the trigger related conditions
  1585. */
  1586. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1587. var _this = _super.call(this, triggerOptions, condition) || this;
  1588. _this.propertyPath = propertyPath;
  1589. _this._target = _this._effectiveTarget = target;
  1590. return _this;
  1591. }
  1592. /** @hidden */
  1593. SwitchBooleanAction.prototype._prepare = function () {
  1594. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1595. this._property = this._getProperty(this.propertyPath);
  1596. };
  1597. /**
  1598. * Execute the action toggle the boolean value.
  1599. */
  1600. SwitchBooleanAction.prototype.execute = function () {
  1601. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1602. };
  1603. /**
  1604. * Serializes the actions and its related information.
  1605. * @param parent defines the object to serialize in
  1606. * @returns the serialized object
  1607. */
  1608. SwitchBooleanAction.prototype.serialize = function (parent) {
  1609. return _super.prototype._serialize.call(this, {
  1610. name: "SwitchBooleanAction",
  1611. properties: [
  1612. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1613. { name: "propertyPath", value: this.propertyPath }
  1614. ]
  1615. }, parent);
  1616. };
  1617. return SwitchBooleanAction;
  1618. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1619. /**
  1620. * This defines an action responsible to set a the state field of the target
  1621. * to a desired value once triggered.
  1622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1623. */
  1624. var SetStateAction = /** @class */ (function (_super) {
  1625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1626. /**
  1627. * Instantiate the action
  1628. * @param triggerOptions defines the trigger options
  1629. * @param target defines the object containing the state property
  1630. * @param value defines the value to store in the state field
  1631. * @param condition defines the trigger related conditions
  1632. */
  1633. function SetStateAction(triggerOptions, target, value, condition) {
  1634. var _this = _super.call(this, triggerOptions, condition) || this;
  1635. _this.value = value;
  1636. _this._target = target;
  1637. return _this;
  1638. }
  1639. /**
  1640. * Execute the action and store the value on the target state property.
  1641. */
  1642. SetStateAction.prototype.execute = function () {
  1643. this._target.state = this.value;
  1644. };
  1645. /**
  1646. * Serializes the actions and its related information.
  1647. * @param parent defines the object to serialize in
  1648. * @returns the serialized object
  1649. */
  1650. SetStateAction.prototype.serialize = function (parent) {
  1651. return _super.prototype._serialize.call(this, {
  1652. name: "SetStateAction",
  1653. properties: [
  1654. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1655. { name: "value", value: this.value }
  1656. ]
  1657. }, parent);
  1658. };
  1659. return SetStateAction;
  1660. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1661. /**
  1662. * This defines an action responsible to set a property of the target
  1663. * to a desired value once triggered.
  1664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1665. */
  1666. var SetValueAction = /** @class */ (function (_super) {
  1667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1668. /**
  1669. * Instantiate the action
  1670. * @param triggerOptions defines the trigger options
  1671. * @param target defines the object containing the property
  1672. * @param propertyPath defines the path of the property to set in the target
  1673. * @param value defines the value to set in the property
  1674. * @param condition defines the trigger related conditions
  1675. */
  1676. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1677. var _this = _super.call(this, triggerOptions, condition) || this;
  1678. _this.propertyPath = propertyPath;
  1679. _this.value = value;
  1680. _this._target = _this._effectiveTarget = target;
  1681. return _this;
  1682. }
  1683. /** @hidden */
  1684. SetValueAction.prototype._prepare = function () {
  1685. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1686. this._property = this._getProperty(this.propertyPath);
  1687. };
  1688. /**
  1689. * Execute the action and set the targetted property to the desired value.
  1690. */
  1691. SetValueAction.prototype.execute = function () {
  1692. this._effectiveTarget[this._property] = this.value;
  1693. if (this._target.markAsDirty) {
  1694. this._target.markAsDirty(this._property);
  1695. }
  1696. };
  1697. /**
  1698. * Serializes the actions and its related information.
  1699. * @param parent defines the object to serialize in
  1700. * @returns the serialized object
  1701. */
  1702. SetValueAction.prototype.serialize = function (parent) {
  1703. return _super.prototype._serialize.call(this, {
  1704. name: "SetValueAction",
  1705. properties: [
  1706. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1707. { name: "propertyPath", value: this.propertyPath },
  1708. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1709. ]
  1710. }, parent);
  1711. };
  1712. return SetValueAction;
  1713. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1714. /**
  1715. * This defines an action responsible to increment the target value
  1716. * to a desired value once triggered.
  1717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1718. */
  1719. var IncrementValueAction = /** @class */ (function (_super) {
  1720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1721. /**
  1722. * Instantiate the action
  1723. * @param triggerOptions defines the trigger options
  1724. * @param target defines the object containing the property
  1725. * @param propertyPath defines the path of the property to increment in the target
  1726. * @param value defines the value value we should increment the property by
  1727. * @param condition defines the trigger related conditions
  1728. */
  1729. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1730. var _this = _super.call(this, triggerOptions, condition) || this;
  1731. _this.propertyPath = propertyPath;
  1732. _this.value = value;
  1733. _this._target = _this._effectiveTarget = target;
  1734. return _this;
  1735. }
  1736. /** @hidden */
  1737. IncrementValueAction.prototype._prepare = function () {
  1738. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1739. this._property = this._getProperty(this.propertyPath);
  1740. if (typeof this._effectiveTarget[this._property] !== "number") {
  1741. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1742. }
  1743. };
  1744. /**
  1745. * Execute the action and increment the target of the value amount.
  1746. */
  1747. IncrementValueAction.prototype.execute = function () {
  1748. this._effectiveTarget[this._property] += this.value;
  1749. if (this._target.markAsDirty) {
  1750. this._target.markAsDirty(this._property);
  1751. }
  1752. };
  1753. /**
  1754. * Serializes the actions and its related information.
  1755. * @param parent defines the object to serialize in
  1756. * @returns the serialized object
  1757. */
  1758. IncrementValueAction.prototype.serialize = function (parent) {
  1759. return _super.prototype._serialize.call(this, {
  1760. name: "IncrementValueAction",
  1761. properties: [
  1762. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1763. { name: "propertyPath", value: this.propertyPath },
  1764. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1765. ]
  1766. }, parent);
  1767. };
  1768. return IncrementValueAction;
  1769. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1770. /**
  1771. * This defines an action responsible to start an animation once triggered.
  1772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1773. */
  1774. var PlayAnimationAction = /** @class */ (function (_super) {
  1775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1776. /**
  1777. * Instantiate the action
  1778. * @param triggerOptions defines the trigger options
  1779. * @param target defines the target animation or animation name
  1780. * @param from defines from where the animation should start (animation frame)
  1781. * @param end defines where the animation should stop (animation frame)
  1782. * @param loop defines if the animation should loop or stop after the first play
  1783. * @param condition defines the trigger related conditions
  1784. */
  1785. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1786. var _this = _super.call(this, triggerOptions, condition) || this;
  1787. _this.from = from;
  1788. _this.to = to;
  1789. _this.loop = loop;
  1790. _this._target = target;
  1791. return _this;
  1792. }
  1793. /** @hidden */
  1794. PlayAnimationAction.prototype._prepare = function () {
  1795. };
  1796. /**
  1797. * Execute the action and play the animation.
  1798. */
  1799. PlayAnimationAction.prototype.execute = function () {
  1800. var scene = this._actionManager.getScene();
  1801. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1802. };
  1803. /**
  1804. * Serializes the actions and its related information.
  1805. * @param parent defines the object to serialize in
  1806. * @returns the serialized object
  1807. */
  1808. PlayAnimationAction.prototype.serialize = function (parent) {
  1809. return _super.prototype._serialize.call(this, {
  1810. name: "PlayAnimationAction",
  1811. properties: [
  1812. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1813. { name: "from", value: String(this.from) },
  1814. { name: "to", value: String(this.to) },
  1815. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1816. ]
  1817. }, parent);
  1818. };
  1819. return PlayAnimationAction;
  1820. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1821. /**
  1822. * This defines an action responsible to stop an animation once triggered.
  1823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1824. */
  1825. var StopAnimationAction = /** @class */ (function (_super) {
  1826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1827. /**
  1828. * Instantiate the action
  1829. * @param triggerOptions defines the trigger options
  1830. * @param target defines the target animation or animation name
  1831. * @param condition defines the trigger related conditions
  1832. */
  1833. function StopAnimationAction(triggerOptions, target, condition) {
  1834. var _this = _super.call(this, triggerOptions, condition) || this;
  1835. _this._target = target;
  1836. return _this;
  1837. }
  1838. /** @hidden */
  1839. StopAnimationAction.prototype._prepare = function () {
  1840. };
  1841. /**
  1842. * Execute the action and stop the animation.
  1843. */
  1844. StopAnimationAction.prototype.execute = function () {
  1845. var scene = this._actionManager.getScene();
  1846. scene.stopAnimation(this._target);
  1847. };
  1848. /**
  1849. * Serializes the actions and its related information.
  1850. * @param parent defines the object to serialize in
  1851. * @returns the serialized object
  1852. */
  1853. StopAnimationAction.prototype.serialize = function (parent) {
  1854. return _super.prototype._serialize.call(this, {
  1855. name: "StopAnimationAction",
  1856. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1857. }, parent);
  1858. };
  1859. return StopAnimationAction;
  1860. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1861. /**
  1862. * This defines an action responsible that does nothing once triggered.
  1863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1864. */
  1865. var DoNothingAction = /** @class */ (function (_super) {
  1866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1867. /**
  1868. * Instantiate the action
  1869. * @param triggerOptions defines the trigger options
  1870. * @param condition defines the trigger related conditions
  1871. */
  1872. function DoNothingAction(triggerOptions, condition) {
  1873. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1874. return _super.call(this, triggerOptions, condition) || this;
  1875. }
  1876. /**
  1877. * Execute the action and do nothing.
  1878. */
  1879. DoNothingAction.prototype.execute = function () {
  1880. };
  1881. /**
  1882. * Serializes the actions and its related information.
  1883. * @param parent defines the object to serialize in
  1884. * @returns the serialized object
  1885. */
  1886. DoNothingAction.prototype.serialize = function (parent) {
  1887. return _super.prototype._serialize.call(this, {
  1888. name: "DoNothingAction",
  1889. properties: []
  1890. }, parent);
  1891. };
  1892. return DoNothingAction;
  1893. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1894. /**
  1895. * This defines an action responsible to trigger several actions once triggered.
  1896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1897. */
  1898. var CombineAction = /** @class */ (function (_super) {
  1899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1900. /**
  1901. * Instantiate the action
  1902. * @param triggerOptions defines the trigger options
  1903. * @param children defines the list of aggregated animations to run
  1904. * @param condition defines the trigger related conditions
  1905. */
  1906. function CombineAction(triggerOptions, children, condition) {
  1907. var _this = _super.call(this, triggerOptions, condition) || this;
  1908. _this.children = children;
  1909. return _this;
  1910. }
  1911. /** @hidden */
  1912. CombineAction.prototype._prepare = function () {
  1913. for (var index = 0; index < this.children.length; index++) {
  1914. this.children[index]._actionManager = this._actionManager;
  1915. this.children[index]._prepare();
  1916. }
  1917. };
  1918. /**
  1919. * Execute the action and executes all the aggregated actions.
  1920. */
  1921. CombineAction.prototype.execute = function (evt) {
  1922. for (var index = 0; index < this.children.length; index++) {
  1923. this.children[index].execute(evt);
  1924. }
  1925. };
  1926. /**
  1927. * Serializes the actions and its related information.
  1928. * @param parent defines the object to serialize in
  1929. * @returns the serialized object
  1930. */
  1931. CombineAction.prototype.serialize = function (parent) {
  1932. var serializationObject = _super.prototype._serialize.call(this, {
  1933. name: "CombineAction",
  1934. properties: [],
  1935. combine: []
  1936. }, parent);
  1937. for (var i = 0; i < this.children.length; i++) {
  1938. serializationObject.combine.push(this.children[i].serialize(null));
  1939. }
  1940. return serializationObject;
  1941. };
  1942. return CombineAction;
  1943. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1944. /**
  1945. * This defines an action responsible to run code (external event) once triggered.
  1946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1947. */
  1948. var ExecuteCodeAction = /** @class */ (function (_super) {
  1949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1950. /**
  1951. * Instantiate the action
  1952. * @param triggerOptions defines the trigger options
  1953. * @param func defines the callback function to run
  1954. * @param condition defines the trigger related conditions
  1955. */
  1956. function ExecuteCodeAction(triggerOptions, func, condition) {
  1957. var _this = _super.call(this, triggerOptions, condition) || this;
  1958. _this.func = func;
  1959. return _this;
  1960. }
  1961. /**
  1962. * Execute the action and run the attached code.
  1963. */
  1964. ExecuteCodeAction.prototype.execute = function (evt) {
  1965. this.func(evt);
  1966. };
  1967. return ExecuteCodeAction;
  1968. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1969. /**
  1970. * This defines an action responsible to set the parent property of the target once triggered.
  1971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1972. */
  1973. var SetParentAction = /** @class */ (function (_super) {
  1974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1975. /**
  1976. * Instantiate the action
  1977. * @param triggerOptions defines the trigger options
  1978. * @param target defines the target containing the parent property
  1979. * @param parent defines from where the animation should start (animation frame)
  1980. * @param condition defines the trigger related conditions
  1981. */
  1982. function SetParentAction(triggerOptions, target, parent, condition) {
  1983. var _this = _super.call(this, triggerOptions, condition) || this;
  1984. _this._target = target;
  1985. _this._parent = parent;
  1986. return _this;
  1987. }
  1988. /** @hidden */
  1989. SetParentAction.prototype._prepare = function () {
  1990. };
  1991. /**
  1992. * Execute the action and set the parent property.
  1993. */
  1994. SetParentAction.prototype.execute = function () {
  1995. if (this._target.parent === this._parent) {
  1996. return;
  1997. }
  1998. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1999. invertParentWorldMatrix.invert();
  2000. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2001. this._target.parent = this._parent;
  2002. };
  2003. /**
  2004. * Serializes the actions and its related information.
  2005. * @param parent defines the object to serialize in
  2006. * @returns the serialized object
  2007. */
  2008. SetParentAction.prototype.serialize = function (parent) {
  2009. return _super.prototype._serialize.call(this, {
  2010. name: "SetParentAction",
  2011. properties: [
  2012. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2013. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2014. ]
  2015. }, parent);
  2016. };
  2017. return SetParentAction;
  2018. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2024. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2025. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2026. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2027. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2028. /***/ }),
  2029. /***/ "./Actions/directAudioActions.ts":
  2030. /*!***************************************!*\
  2031. !*** ./Actions/directAudioActions.ts ***!
  2032. \***************************************/
  2033. /*! exports provided: PlaySoundAction, StopSoundAction */
  2034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2035. "use strict";
  2036. __webpack_require__.r(__webpack_exports__);
  2037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2040. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2042. /**
  2043. * This defines an action helpful to play a defined sound on a triggered action.
  2044. */
  2045. var PlaySoundAction = /** @class */ (function (_super) {
  2046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2047. /**
  2048. * Instantiate the action
  2049. * @param triggerOptions defines the trigger options
  2050. * @param sound defines the sound to play
  2051. * @param condition defines the trigger related conditions
  2052. */
  2053. function PlaySoundAction(triggerOptions, sound, condition) {
  2054. var _this = _super.call(this, triggerOptions, condition) || this;
  2055. _this._sound = sound;
  2056. return _this;
  2057. }
  2058. /** @hidden */
  2059. PlaySoundAction.prototype._prepare = function () {
  2060. };
  2061. /**
  2062. * Execute the action and play the sound.
  2063. */
  2064. PlaySoundAction.prototype.execute = function () {
  2065. if (this._sound !== undefined) {
  2066. this._sound.play();
  2067. }
  2068. };
  2069. /**
  2070. * Serializes the actions and its related information.
  2071. * @param parent defines the object to serialize in
  2072. * @returns the serialized object
  2073. */
  2074. PlaySoundAction.prototype.serialize = function (parent) {
  2075. return _super.prototype._serialize.call(this, {
  2076. name: "PlaySoundAction",
  2077. properties: [{ name: "sound", value: this._sound.name }]
  2078. }, parent);
  2079. };
  2080. return PlaySoundAction;
  2081. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2082. /**
  2083. * This defines an action helpful to stop a defined sound on a triggered action.
  2084. */
  2085. var StopSoundAction = /** @class */ (function (_super) {
  2086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2087. /**
  2088. * Instantiate the action
  2089. * @param triggerOptions defines the trigger options
  2090. * @param sound defines the sound to stop
  2091. * @param condition defines the trigger related conditions
  2092. */
  2093. function StopSoundAction(triggerOptions, sound, condition) {
  2094. var _this = _super.call(this, triggerOptions, condition) || this;
  2095. _this._sound = sound;
  2096. return _this;
  2097. }
  2098. /** @hidden */
  2099. StopSoundAction.prototype._prepare = function () {
  2100. };
  2101. /**
  2102. * Execute the action and stop the sound.
  2103. */
  2104. StopSoundAction.prototype.execute = function () {
  2105. if (this._sound !== undefined) {
  2106. this._sound.stop();
  2107. }
  2108. };
  2109. /**
  2110. * Serializes the actions and its related information.
  2111. * @param parent defines the object to serialize in
  2112. * @returns the serialized object
  2113. */
  2114. StopSoundAction.prototype.serialize = function (parent) {
  2115. return _super.prototype._serialize.call(this, {
  2116. name: "StopSoundAction",
  2117. properties: [{ name: "sound", value: this._sound.name }]
  2118. }, parent);
  2119. };
  2120. return StopSoundAction;
  2121. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2122. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2123. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2124. /***/ }),
  2125. /***/ "./Actions/index.ts":
  2126. /*!**************************!*\
  2127. !*** ./Actions/index.ts ***!
  2128. \**************************/
  2129. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2131. "use strict";
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2135. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2137. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2139. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2144. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2155. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2158. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2160. /***/ }),
  2161. /***/ "./Actions/interpolateValueAction.ts":
  2162. /*!*******************************************!*\
  2163. !*** ./Actions/interpolateValueAction.ts ***!
  2164. \*******************************************/
  2165. /*! exports provided: InterpolateValueAction */
  2166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2167. "use strict";
  2168. __webpack_require__.r(__webpack_exports__);
  2169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2171. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2173. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2175. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2176. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2177. /**
  2178. * This defines an action responsible to change the value of a property
  2179. * by interpolating between its current value and the newly set one once triggered.
  2180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2181. */
  2182. var InterpolateValueAction = /** @class */ (function (_super) {
  2183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2184. /**
  2185. * Instantiate the action
  2186. * @param triggerOptions defines the trigger options
  2187. * @param target defines the object containing the value to interpolate
  2188. * @param propertyPath defines the path to the property in the target object
  2189. * @param value defines the target value at the end of the interpolation
  2190. * @param duration deines the time it will take for the property to interpolate to the value.
  2191. * @param condition defines the trigger related conditions
  2192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2194. */
  2195. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2196. if (duration === void 0) { duration = 1000; }
  2197. var _this = _super.call(this, triggerOptions, condition) || this;
  2198. /**
  2199. * Defines the time it will take for the property to interpolate to the value.
  2200. */
  2201. _this.duration = 1000;
  2202. /**
  2203. * Observable triggered once the interpolation animation has been done.
  2204. */
  2205. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2206. _this.propertyPath = propertyPath;
  2207. _this.value = value;
  2208. _this.duration = duration;
  2209. _this.stopOtherAnimations = stopOtherAnimations;
  2210. _this.onInterpolationDone = onInterpolationDone;
  2211. _this._target = _this._effectiveTarget = target;
  2212. return _this;
  2213. }
  2214. /** @hidden */
  2215. InterpolateValueAction.prototype._prepare = function () {
  2216. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2217. this._property = this._getProperty(this.propertyPath);
  2218. };
  2219. /**
  2220. * Execute the action starts the value interpolation.
  2221. */
  2222. InterpolateValueAction.prototype.execute = function () {
  2223. var _this = this;
  2224. var scene = this._actionManager.getScene();
  2225. var keys = [
  2226. {
  2227. frame: 0,
  2228. value: this._effectiveTarget[this._property]
  2229. }, {
  2230. frame: 100,
  2231. value: this.value
  2232. }
  2233. ];
  2234. var dataType;
  2235. if (typeof this.value === "number") {
  2236. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2237. }
  2238. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2239. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2240. }
  2241. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2242. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2243. }
  2244. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2245. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2246. }
  2247. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2248. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2249. }
  2250. else {
  2251. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2252. return;
  2253. }
  2254. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2255. animation.setKeys(keys);
  2256. if (this.stopOtherAnimations) {
  2257. scene.stopAnimation(this._effectiveTarget);
  2258. }
  2259. var wrapper = function () {
  2260. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2261. if (_this.onInterpolationDone) {
  2262. _this.onInterpolationDone();
  2263. }
  2264. };
  2265. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2266. };
  2267. /**
  2268. * Serializes the actions and its related information.
  2269. * @param parent defines the object to serialize in
  2270. * @returns the serialized object
  2271. */
  2272. InterpolateValueAction.prototype.serialize = function (parent) {
  2273. return _super.prototype._serialize.call(this, {
  2274. name: "InterpolateValueAction",
  2275. properties: [
  2276. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2277. { name: "propertyPath", value: this.propertyPath },
  2278. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2279. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2280. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2281. ]
  2282. }, parent);
  2283. };
  2284. return InterpolateValueAction;
  2285. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2286. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = InterpolateValueAction;
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. /**
  2350. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2351. * This will only apply for non looping animation (default is true)
  2352. */
  2353. this.disposeOnEnd = true;
  2354. /**
  2355. * Gets a boolean indicating if the animation has started
  2356. */
  2357. this.animationStarted = false;
  2358. /**
  2359. * Observer raised when the animation ends
  2360. */
  2361. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. /**
  2363. * Observer raised when the animation loops
  2364. */
  2365. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2366. this._scene = scene;
  2367. if (animations) {
  2368. this.appendAnimations(target, animations);
  2369. }
  2370. this._speedRatio = speedRatio;
  2371. scene._activeAnimatables.push(this);
  2372. }
  2373. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2374. /**
  2375. * Gets the root Animatable used to synchronize and normalize animations
  2376. */
  2377. get: function () {
  2378. return this._syncRoot;
  2379. },
  2380. enumerable: true,
  2381. configurable: true
  2382. });
  2383. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2384. /**
  2385. * Gets the current frame of the first RuntimeAnimation
  2386. * Used to synchronize Animatables
  2387. */
  2388. get: function () {
  2389. if (this._runtimeAnimations.length === 0) {
  2390. return 0;
  2391. }
  2392. return this._runtimeAnimations[0].currentFrame;
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. Object.defineProperty(Animatable.prototype, "weight", {
  2398. /**
  2399. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2400. */
  2401. get: function () {
  2402. return this._weight;
  2403. },
  2404. set: function (value) {
  2405. if (value === -1) { // -1 is ok and means no weight
  2406. this._weight = -1;
  2407. return;
  2408. }
  2409. // Else weight must be in [0, 1] range
  2410. this._weight = Math.min(Math.max(value, 0), 1.0);
  2411. },
  2412. enumerable: true,
  2413. configurable: true
  2414. });
  2415. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2416. /**
  2417. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2418. */
  2419. get: function () {
  2420. return this._speedRatio;
  2421. },
  2422. set: function (value) {
  2423. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2424. var animation = this._runtimeAnimations[index];
  2425. animation._prepareForSpeedRatioChange(value);
  2426. }
  2427. this._speedRatio = value;
  2428. },
  2429. enumerable: true,
  2430. configurable: true
  2431. });
  2432. // Methods
  2433. /**
  2434. * Synchronize and normalize current Animatable with a source Animatable
  2435. * This is useful when using animation weights and when animations are not of the same length
  2436. * @param root defines the root Animatable to synchronize with
  2437. * @returns the current Animatable
  2438. */
  2439. Animatable.prototype.syncWith = function (root) {
  2440. this._syncRoot = root;
  2441. if (root) {
  2442. // Make sure this animatable will animate after the root
  2443. var index = this._scene._activeAnimatables.indexOf(this);
  2444. if (index > -1) {
  2445. this._scene._activeAnimatables.splice(index, 1);
  2446. this._scene._activeAnimatables.push(this);
  2447. }
  2448. }
  2449. return this;
  2450. };
  2451. /**
  2452. * Gets the list of runtime animations
  2453. * @returns an array of RuntimeAnimation
  2454. */
  2455. Animatable.prototype.getAnimations = function () {
  2456. return this._runtimeAnimations;
  2457. };
  2458. /**
  2459. * Adds more animations to the current animatable
  2460. * @param target defines the target of the animations
  2461. * @param animations defines the new animations to add
  2462. */
  2463. Animatable.prototype.appendAnimations = function (target, animations) {
  2464. for (var index = 0; index < animations.length; index++) {
  2465. var animation = animations[index];
  2466. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2467. }
  2468. };
  2469. /**
  2470. * Gets the source animation for a specific property
  2471. * @param property defines the propertyu to look for
  2472. * @returns null or the source animation for the given property
  2473. */
  2474. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2475. var runtimeAnimations = this._runtimeAnimations;
  2476. for (var index = 0; index < runtimeAnimations.length; index++) {
  2477. if (runtimeAnimations[index].animation.targetProperty === property) {
  2478. return runtimeAnimations[index].animation;
  2479. }
  2480. }
  2481. return null;
  2482. };
  2483. /**
  2484. * Gets the runtime animation for a specific property
  2485. * @param property defines the propertyu to look for
  2486. * @returns null or the runtime animation for the given property
  2487. */
  2488. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2489. var runtimeAnimations = this._runtimeAnimations;
  2490. for (var index = 0; index < runtimeAnimations.length; index++) {
  2491. if (runtimeAnimations[index].animation.targetProperty === property) {
  2492. return runtimeAnimations[index];
  2493. }
  2494. }
  2495. return null;
  2496. };
  2497. /**
  2498. * Resets the animatable to its original state
  2499. */
  2500. Animatable.prototype.reset = function () {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. for (var index = 0; index < runtimeAnimations.length; index++) {
  2503. runtimeAnimations[index].reset(true);
  2504. }
  2505. this._localDelayOffset = null;
  2506. this._pausedDelay = null;
  2507. };
  2508. /**
  2509. * Allows the animatable to blend with current running animations
  2510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2511. * @param blendingSpeed defines the blending speed to use
  2512. */
  2513. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2514. var runtimeAnimations = this._runtimeAnimations;
  2515. for (var index = 0; index < runtimeAnimations.length; index++) {
  2516. runtimeAnimations[index].animation.enableBlending = true;
  2517. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2518. }
  2519. };
  2520. /**
  2521. * Disable animation blending
  2522. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2523. */
  2524. Animatable.prototype.disableBlending = function () {
  2525. var runtimeAnimations = this._runtimeAnimations;
  2526. for (var index = 0; index < runtimeAnimations.length; index++) {
  2527. runtimeAnimations[index].animation.enableBlending = false;
  2528. }
  2529. };
  2530. /**
  2531. * Jump directly to a given frame
  2532. * @param frame defines the frame to jump to
  2533. */
  2534. Animatable.prototype.goToFrame = function (frame) {
  2535. var runtimeAnimations = this._runtimeAnimations;
  2536. if (runtimeAnimations[0]) {
  2537. var fps = runtimeAnimations[0].animation.framePerSecond;
  2538. var currentFrame = runtimeAnimations[0].currentFrame;
  2539. var adjustTime = frame - currentFrame;
  2540. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2541. if (this._localDelayOffset === null) {
  2542. this._localDelayOffset = 0;
  2543. }
  2544. this._localDelayOffset -= delay;
  2545. }
  2546. for (var index = 0; index < runtimeAnimations.length; index++) {
  2547. runtimeAnimations[index].goToFrame(frame);
  2548. }
  2549. };
  2550. /**
  2551. * Pause the animation
  2552. */
  2553. Animatable.prototype.pause = function () {
  2554. if (this._paused) {
  2555. return;
  2556. }
  2557. this._paused = true;
  2558. };
  2559. /**
  2560. * Restart the animation
  2561. */
  2562. Animatable.prototype.restart = function () {
  2563. this._paused = false;
  2564. };
  2565. Animatable.prototype._raiseOnAnimationEnd = function () {
  2566. if (this.onAnimationEnd) {
  2567. this.onAnimationEnd();
  2568. }
  2569. this.onAnimationEndObservable.notifyObservers(this);
  2570. };
  2571. /**
  2572. * Stop and delete the current animation
  2573. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2574. * @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)
  2575. */
  2576. Animatable.prototype.stop = function (animationName, targetMask) {
  2577. if (animationName || targetMask) {
  2578. var idx = this._scene._activeAnimatables.indexOf(this);
  2579. if (idx > -1) {
  2580. var runtimeAnimations = this._runtimeAnimations;
  2581. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2582. var runtimeAnimation = runtimeAnimations[index];
  2583. if (animationName && runtimeAnimation.animation.name != animationName) {
  2584. continue;
  2585. }
  2586. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2587. continue;
  2588. }
  2589. runtimeAnimation.dispose();
  2590. runtimeAnimations.splice(index, 1);
  2591. }
  2592. if (runtimeAnimations.length == 0) {
  2593. this._scene._activeAnimatables.splice(idx, 1);
  2594. this._raiseOnAnimationEnd();
  2595. }
  2596. }
  2597. }
  2598. else {
  2599. var index = this._scene._activeAnimatables.indexOf(this);
  2600. if (index > -1) {
  2601. this._scene._activeAnimatables.splice(index, 1);
  2602. var runtimeAnimations = this._runtimeAnimations;
  2603. for (var index = 0; index < runtimeAnimations.length; index++) {
  2604. runtimeAnimations[index].dispose();
  2605. }
  2606. this._raiseOnAnimationEnd();
  2607. }
  2608. }
  2609. };
  2610. /**
  2611. * Wait asynchronously for the animation to end
  2612. * @returns a promise which will be fullfilled when the animation ends
  2613. */
  2614. Animatable.prototype.waitAsync = function () {
  2615. var _this = this;
  2616. return new Promise(function (resolve, reject) {
  2617. _this.onAnimationEndObservable.add(function () {
  2618. resolve(_this);
  2619. }, undefined, undefined, _this, true);
  2620. });
  2621. };
  2622. /** @hidden */
  2623. Animatable.prototype._animate = function (delay) {
  2624. var _this = this;
  2625. if (this._paused) {
  2626. this.animationStarted = false;
  2627. if (this._pausedDelay === null) {
  2628. this._pausedDelay = delay;
  2629. }
  2630. return true;
  2631. }
  2632. if (this._localDelayOffset === null) {
  2633. this._localDelayOffset = delay;
  2634. this._pausedDelay = null;
  2635. }
  2636. else if (this._pausedDelay !== null) {
  2637. this._localDelayOffset += delay - this._pausedDelay;
  2638. this._pausedDelay = null;
  2639. }
  2640. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2641. return true;
  2642. }
  2643. // Animating
  2644. var running = false;
  2645. var runtimeAnimations = this._runtimeAnimations;
  2646. var index;
  2647. for (index = 0; index < runtimeAnimations.length; index++) {
  2648. var animation = runtimeAnimations[index];
  2649. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2650. _this.onAnimationLoopObservable.notifyObservers(_this);
  2651. if (_this.onAnimationLoop) {
  2652. _this.onAnimationLoop();
  2653. }
  2654. });
  2655. running = running || isRunning;
  2656. }
  2657. this.animationStarted = running;
  2658. if (!running) {
  2659. if (this.disposeOnEnd) {
  2660. // Remove from active animatables
  2661. index = this._scene._activeAnimatables.indexOf(this);
  2662. this._scene._activeAnimatables.splice(index, 1);
  2663. // Dispose all runtime animations
  2664. for (index = 0; index < runtimeAnimations.length; index++) {
  2665. runtimeAnimations[index].dispose();
  2666. }
  2667. }
  2668. this._raiseOnAnimationEnd();
  2669. if (this.disposeOnEnd) {
  2670. this.onAnimationEnd = null;
  2671. this.onAnimationLoop = null;
  2672. this.onAnimationLoopObservable.clear();
  2673. this.onAnimationEndObservable.clear();
  2674. }
  2675. }
  2676. return running;
  2677. };
  2678. return Animatable;
  2679. }());
  2680. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2681. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2682. return;
  2683. }
  2684. // Getting time
  2685. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2686. if (!this._animationTimeLast) {
  2687. if (this._pendingData.length > 0) {
  2688. return;
  2689. }
  2690. this._animationTimeLast = now;
  2691. }
  2692. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2693. this._animationTime += deltaTime;
  2694. this._animationTimeLast = now;
  2695. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2696. this._activeAnimatables[index]._animate(this._animationTime);
  2697. }
  2698. // Late animation bindings
  2699. this._processLateAnimationBindings();
  2700. };
  2701. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2702. if (weight === void 0) { weight = 1.0; }
  2703. if (speedRatio === void 0) { speedRatio = 1.0; }
  2704. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2705. returnedAnimatable.weight = weight;
  2706. return returnedAnimatable;
  2707. };
  2708. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2709. if (speedRatio === void 0) { speedRatio = 1.0; }
  2710. if (stopCurrent === void 0) { stopCurrent = true; }
  2711. if (from > to && speedRatio > 0) {
  2712. speedRatio *= -1;
  2713. }
  2714. if (stopCurrent) {
  2715. this.stopAnimation(target, undefined, targetMask);
  2716. }
  2717. if (!animatable) {
  2718. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2719. }
  2720. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2721. // Local animations
  2722. if (target.animations && shouldRunTargetAnimations) {
  2723. animatable.appendAnimations(target, target.animations);
  2724. }
  2725. // Children animations
  2726. if (target.getAnimatables) {
  2727. var animatables = target.getAnimatables();
  2728. for (var index = 0; index < animatables.length; index++) {
  2729. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2730. }
  2731. }
  2732. animatable.reset();
  2733. return animatable;
  2734. };
  2735. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2736. if (speedRatio === void 0) { speedRatio = 1.0; }
  2737. if (stopCurrent === void 0) { stopCurrent = true; }
  2738. var children = target.getDescendants(directDescendantsOnly);
  2739. var result = [];
  2740. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2741. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2742. var child = children_1[_i];
  2743. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2744. }
  2745. return result;
  2746. };
  2747. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2748. if (speedRatio === undefined) {
  2749. speedRatio = 1.0;
  2750. }
  2751. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2752. return animatable;
  2753. };
  2754. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2755. var children = target.getDescendants(directDescendantsOnly);
  2756. var result = [];
  2757. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2758. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2759. var child = children_2[_i];
  2760. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2761. }
  2762. return result;
  2763. };
  2764. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2765. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2766. if (this._activeAnimatables[index].target === target) {
  2767. return this._activeAnimatables[index];
  2768. }
  2769. }
  2770. return null;
  2771. };
  2772. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2773. var result = [];
  2774. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2775. if (this._activeAnimatables[index].target === target) {
  2776. result.push(this._activeAnimatables[index]);
  2777. }
  2778. }
  2779. return result;
  2780. };
  2781. /**
  2782. * Will stop the animation of the given target
  2783. * @param target - the target
  2784. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2785. * @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)
  2786. */
  2787. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2788. var animatables = this.getAllAnimatablesByTarget(target);
  2789. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2790. var animatable = animatables_1[_i];
  2791. animatable.stop(animationName, targetMask);
  2792. }
  2793. };
  2794. /**
  2795. * Stops and removes all animations that have been applied to the scene
  2796. */
  2797. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2798. if (this._activeAnimatables) {
  2799. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2800. this._activeAnimatables[i].stop();
  2801. }
  2802. this._activeAnimatables = [];
  2803. }
  2804. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2805. var group = _a[_i];
  2806. group.stop();
  2807. }
  2808. };
  2809. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2810. var target = runtimeAnimation.target;
  2811. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2812. if (!target._lateAnimationHolders) {
  2813. target._lateAnimationHolders = {};
  2814. }
  2815. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2816. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2817. totalWeight: 0,
  2818. animations: [],
  2819. originalValue: originalValue
  2820. };
  2821. }
  2822. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2823. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2824. };
  2825. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2826. var normalizer = 1.0;
  2827. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2828. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2829. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2830. var startIndex = 0;
  2831. var originalAnimation = holder.animations[0];
  2832. var originalValue = holder.originalValue;
  2833. var scale = 1;
  2834. if (holder.totalWeight < 1.0) {
  2835. // We need to mix the original value in
  2836. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2837. scale = 1.0 - holder.totalWeight;
  2838. }
  2839. else {
  2840. startIndex = 1;
  2841. // We need to normalize the weights
  2842. normalizer = holder.totalWeight;
  2843. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2844. scale = originalAnimation.weight / normalizer;
  2845. if (scale == 1) {
  2846. return originalAnimation.currentValue;
  2847. }
  2848. }
  2849. finalScaling.scaleInPlace(scale);
  2850. finalPosition.scaleInPlace(scale);
  2851. finalQuaternion.scaleInPlace(scale);
  2852. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2853. var runtimeAnimation = holder.animations[animIndex];
  2854. var scale = runtimeAnimation.weight / normalizer;
  2855. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2856. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2857. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2858. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2859. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2860. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2861. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2862. }
  2863. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2864. return originalAnimation._workValue;
  2865. };
  2866. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2867. var originalAnimation = holder.animations[0];
  2868. var originalValue = holder.originalValue;
  2869. if (holder.animations.length === 1) {
  2870. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2871. return refQuaternion;
  2872. }
  2873. var normalizer = 1.0;
  2874. var quaternions;
  2875. var weights;
  2876. if (holder.totalWeight < 1.0) {
  2877. var scale = 1.0 - holder.totalWeight;
  2878. quaternions = [];
  2879. weights = [];
  2880. quaternions.push(originalValue);
  2881. weights.push(scale);
  2882. }
  2883. else {
  2884. if (holder.animations.length === 2) { // Slerp as soon as we can
  2885. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2886. return refQuaternion;
  2887. }
  2888. quaternions = [];
  2889. weights = [];
  2890. normalizer = holder.totalWeight;
  2891. }
  2892. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2893. var runtimeAnimation = holder.animations[animIndex];
  2894. quaternions.push(runtimeAnimation.currentValue);
  2895. weights.push(runtimeAnimation.weight / normalizer);
  2896. }
  2897. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2898. var cumulativeAmount = 0;
  2899. var cumulativeQuaternion = null;
  2900. for (var index = 0; index < quaternions.length;) {
  2901. if (!cumulativeQuaternion) {
  2902. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2903. cumulativeQuaternion = refQuaternion;
  2904. cumulativeAmount = weights[index] + weights[index + 1];
  2905. index += 2;
  2906. continue;
  2907. }
  2908. cumulativeAmount += weights[index];
  2909. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2910. index++;
  2911. }
  2912. return cumulativeQuaternion;
  2913. };
  2914. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2915. if (!this._registeredForLateAnimationBindings.length) {
  2916. return;
  2917. }
  2918. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2919. var target = this._registeredForLateAnimationBindings.data[index];
  2920. for (var path in target._lateAnimationHolders) {
  2921. var holder = target._lateAnimationHolders[path];
  2922. var originalAnimation = holder.animations[0];
  2923. var originalValue = holder.originalValue;
  2924. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2925. var finalValue = target[path];
  2926. if (matrixDecomposeMode) {
  2927. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2928. }
  2929. else {
  2930. var quaternionMode = originalValue.w !== undefined;
  2931. if (quaternionMode) {
  2932. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2933. }
  2934. else {
  2935. var startIndex = 0;
  2936. var normalizer = 1.0;
  2937. if (holder.totalWeight < 1.0) {
  2938. // We need to mix the original value in
  2939. if (originalValue.scale) {
  2940. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2941. }
  2942. else {
  2943. finalValue = originalValue * (1.0 - holder.totalWeight);
  2944. }
  2945. }
  2946. else {
  2947. // We need to normalize the weights
  2948. normalizer = holder.totalWeight;
  2949. var scale_1 = originalAnimation.weight / normalizer;
  2950. if (scale_1 !== 1) {
  2951. if (originalAnimation.currentValue.scale) {
  2952. finalValue = originalAnimation.currentValue.scale(scale_1);
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue * scale_1;
  2956. }
  2957. }
  2958. else {
  2959. finalValue = originalAnimation.currentValue;
  2960. }
  2961. startIndex = 1;
  2962. }
  2963. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2964. var runtimeAnimation = holder.animations[animIndex];
  2965. var scale = runtimeAnimation.weight / normalizer;
  2966. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2967. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2968. }
  2969. else {
  2970. finalValue += runtimeAnimation.currentValue * scale;
  2971. }
  2972. }
  2973. }
  2974. }
  2975. target[path] = finalValue;
  2976. }
  2977. target._lateAnimationHolders = {};
  2978. }
  2979. this._registeredForLateAnimationBindings.reset();
  2980. };
  2981. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2982. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2983. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2984. // all animation may be coming from a library skeleton, so may need to create animation
  2985. if (this.animations.length === 0) {
  2986. 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));
  2987. this.animations[0].setKeys([]);
  2988. }
  2989. // get animation info / verify there is such a range from the source bone
  2990. var sourceRange = source.animations[0].getRange(rangeName);
  2991. if (!sourceRange) {
  2992. return false;
  2993. }
  2994. var from = sourceRange.from;
  2995. var to = sourceRange.to;
  2996. var sourceKeys = source.animations[0].getKeys();
  2997. // rescaling prep
  2998. var sourceBoneLength = source.length;
  2999. var sourceParent = source.getParent();
  3000. var parent = this.getParent();
  3001. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3002. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3003. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3004. var destKeys = this.animations[0].getKeys();
  3005. // loop vars declaration
  3006. var orig;
  3007. var origTranslation;
  3008. var mat;
  3009. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3010. orig = sourceKeys[key];
  3011. if (orig.frame >= from && orig.frame <= to) {
  3012. if (rescaleAsRequired) {
  3013. mat = orig.value.clone();
  3014. // scale based on parent ratio, when bone has parent
  3015. if (parentScalingReqd) {
  3016. origTranslation = mat.getTranslation();
  3017. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3018. // scale based on skeleton dimension ratio when root bone, and value is passed
  3019. }
  3020. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3021. origTranslation = mat.getTranslation();
  3022. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3023. // use original when root bone, and no data for skelDimensionsRatio
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. }
  3029. else {
  3030. mat = orig.value;
  3031. }
  3032. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3033. }
  3034. }
  3035. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3036. return true;
  3037. };
  3038. /***/ }),
  3039. /***/ "./Animations/animation.ts":
  3040. /*!*********************************!*\
  3041. !*** ./Animations/animation.ts ***!
  3042. \*********************************/
  3043. /*! exports provided: Animation */
  3044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3045. "use strict";
  3046. __webpack_require__.r(__webpack_exports__);
  3047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3049. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3050. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3051. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3052. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3053. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3054. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3055. /**
  3056. * Class used to store any kind of animation
  3057. */
  3058. var Animation = /** @class */ (function () {
  3059. /**
  3060. * Initializes the animation
  3061. * @param name Name of the animation
  3062. * @param targetProperty Property to animate
  3063. * @param framePerSecond The frames per second of the animation
  3064. * @param dataType The data type of the animation
  3065. * @param loopMode The loop mode of the animation
  3066. * @param enableBlending Specifies if blending should be enabled
  3067. */
  3068. function Animation(
  3069. /**Name of the animation */
  3070. name,
  3071. /**Property to animate */
  3072. targetProperty,
  3073. /**The frames per second of the animation */
  3074. framePerSecond,
  3075. /**The data type of the animation */
  3076. dataType,
  3077. /**The loop mode of the animation */
  3078. loopMode,
  3079. /**Specifies if blending should be enabled */
  3080. enableBlending) {
  3081. this.name = name;
  3082. this.targetProperty = targetProperty;
  3083. this.framePerSecond = framePerSecond;
  3084. this.dataType = dataType;
  3085. this.loopMode = loopMode;
  3086. this.enableBlending = enableBlending;
  3087. /**
  3088. * @hidden Internal use only
  3089. */
  3090. this._runtimeAnimations = new Array();
  3091. /**
  3092. * The set of event that will be linked to this animation
  3093. */
  3094. this._events = new Array();
  3095. /**
  3096. * Stores the blending speed of the animation
  3097. */
  3098. this.blendingSpeed = 0.01;
  3099. /**
  3100. * Stores the animation ranges for the animation
  3101. */
  3102. this._ranges = {};
  3103. this.targetPropertyPath = targetProperty.split(".");
  3104. this.dataType = dataType;
  3105. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3106. }
  3107. /**
  3108. * @hidden Internal use
  3109. */
  3110. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3111. var dataType = undefined;
  3112. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3113. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3114. }
  3115. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3116. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3117. }
  3118. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3119. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3120. }
  3121. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3122. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3123. }
  3124. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3125. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3126. }
  3127. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3128. dataType = Animation.ANIMATIONTYPE_SIZE;
  3129. }
  3130. if (dataType == undefined) {
  3131. return null;
  3132. }
  3133. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3134. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3135. animation.setKeys(keys);
  3136. if (easingFunction !== undefined) {
  3137. animation.setEasingFunction(easingFunction);
  3138. }
  3139. return animation;
  3140. };
  3141. /**
  3142. * Sets up an animation
  3143. * @param property The property to animate
  3144. * @param animationType The animation type to apply
  3145. * @param framePerSecond The frames per second of the animation
  3146. * @param easingFunction The easing function used in the animation
  3147. * @returns The created animation
  3148. */
  3149. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3150. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3151. animation.setEasingFunction(easingFunction);
  3152. return animation;
  3153. };
  3154. /**
  3155. * Create and start an animation on a node
  3156. * @param name defines the name of the global animation that will be run on all nodes
  3157. * @param node defines the root node where the animation will take place
  3158. * @param targetProperty defines property to animate
  3159. * @param framePerSecond defines the number of frame per second yo use
  3160. * @param totalFrame defines the number of frames in total
  3161. * @param from defines the initial value
  3162. * @param to defines the final value
  3163. * @param loopMode defines which loop mode you want to use (off by default)
  3164. * @param easingFunction defines the easing function to use (linear by default)
  3165. * @param onAnimationEnd defines the callback to call when animation end
  3166. * @returns the animatable created for this animation
  3167. */
  3168. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3169. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3170. if (!animation) {
  3171. return null;
  3172. }
  3173. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3174. };
  3175. /**
  3176. * Create and start an animation on a node and its descendants
  3177. * @param name defines the name of the global animation that will be run on all nodes
  3178. * @param node defines the root node where the animation will take place
  3179. * @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
  3180. * @param targetProperty defines property to animate
  3181. * @param framePerSecond defines the number of frame per second to use
  3182. * @param totalFrame defines the number of frames in total
  3183. * @param from defines the initial value
  3184. * @param to defines the final value
  3185. * @param loopMode defines which loop mode you want to use (off by default)
  3186. * @param easingFunction defines the easing function to use (linear by default)
  3187. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3188. * @returns the list of animatables created for all nodes
  3189. * @example https://www.babylonjs-playground.com/#MH0VLI
  3190. */
  3191. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3192. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3193. if (!animation) {
  3194. return null;
  3195. }
  3196. var scene = node.getScene();
  3197. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3198. };
  3199. /**
  3200. * Creates a new animation, merges it with the existing animations and starts it
  3201. * @param name Name of the animation
  3202. * @param node Node which contains the scene that begins the animations
  3203. * @param targetProperty Specifies which property to animate
  3204. * @param framePerSecond The frames per second of the animation
  3205. * @param totalFrame The total number of frames
  3206. * @param from The frame at the beginning of the animation
  3207. * @param to The frame at the end of the animation
  3208. * @param loopMode Specifies the loop mode of the animation
  3209. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3210. * @param onAnimationEnd Callback to run once the animation is complete
  3211. * @returns Nullable animation
  3212. */
  3213. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3214. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3215. if (!animation) {
  3216. return null;
  3217. }
  3218. node.animations.push(animation);
  3219. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3220. };
  3221. /**
  3222. * Transition property of an host to the target Value
  3223. * @param property The property to transition
  3224. * @param targetValue The target Value of the property
  3225. * @param host The object where the property to animate belongs
  3226. * @param scene Scene used to run the animation
  3227. * @param frameRate Framerate (in frame/s) to use
  3228. * @param transition The transition type we want to use
  3229. * @param duration The duration of the animation, in milliseconds
  3230. * @param onAnimationEnd Callback trigger at the end of the animation
  3231. * @returns Nullable animation
  3232. */
  3233. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3234. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3235. if (duration <= 0) {
  3236. host[property] = targetValue;
  3237. if (onAnimationEnd) {
  3238. onAnimationEnd();
  3239. }
  3240. return null;
  3241. }
  3242. var endFrame = frameRate * (duration / 1000);
  3243. transition.setKeys([{
  3244. frame: 0,
  3245. value: host[property].clone ? host[property].clone() : host[property]
  3246. },
  3247. {
  3248. frame: endFrame,
  3249. value: targetValue
  3250. }]);
  3251. if (!host.animations) {
  3252. host.animations = [];
  3253. }
  3254. host.animations.push(transition);
  3255. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3256. animation.onAnimationEnd = onAnimationEnd;
  3257. return animation;
  3258. };
  3259. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3260. /**
  3261. * Return the array of runtime animations currently using this animation
  3262. */
  3263. get: function () {
  3264. return this._runtimeAnimations;
  3265. },
  3266. enumerable: true,
  3267. configurable: true
  3268. });
  3269. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3270. /**
  3271. * Specifies if any of the runtime animations are currently running
  3272. */
  3273. get: function () {
  3274. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3275. var runtimeAnimation = _a[_i];
  3276. if (!runtimeAnimation.isStopped) {
  3277. return true;
  3278. }
  3279. }
  3280. return false;
  3281. },
  3282. enumerable: true,
  3283. configurable: true
  3284. });
  3285. // Methods
  3286. /**
  3287. * Converts the animation to a string
  3288. * @param fullDetails support for multiple levels of logging within scene loading
  3289. * @returns String form of the animation
  3290. */
  3291. Animation.prototype.toString = function (fullDetails) {
  3292. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3293. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3294. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3295. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3296. if (fullDetails) {
  3297. ret += ", Ranges: {";
  3298. var first = true;
  3299. for (var name in this._ranges) {
  3300. if (first) {
  3301. ret += ", ";
  3302. first = false;
  3303. }
  3304. ret += name;
  3305. }
  3306. ret += "}";
  3307. }
  3308. return ret;
  3309. };
  3310. /**
  3311. * Add an event to this animation
  3312. * @param event Event to add
  3313. */
  3314. Animation.prototype.addEvent = function (event) {
  3315. this._events.push(event);
  3316. };
  3317. /**
  3318. * Remove all events found at the given frame
  3319. * @param frame The frame to remove events from
  3320. */
  3321. Animation.prototype.removeEvents = function (frame) {
  3322. for (var index = 0; index < this._events.length; index++) {
  3323. if (this._events[index].frame === frame) {
  3324. this._events.splice(index, 1);
  3325. index--;
  3326. }
  3327. }
  3328. };
  3329. /**
  3330. * Retrieves all the events from the animation
  3331. * @returns Events from the animation
  3332. */
  3333. Animation.prototype.getEvents = function () {
  3334. return this._events;
  3335. };
  3336. /**
  3337. * Creates an animation range
  3338. * @param name Name of the animation range
  3339. * @param from Starting frame of the animation range
  3340. * @param to Ending frame of the animation
  3341. */
  3342. Animation.prototype.createRange = function (name, from, to) {
  3343. // check name not already in use; could happen for bones after serialized
  3344. if (!this._ranges[name]) {
  3345. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3346. }
  3347. };
  3348. /**
  3349. * Deletes an animation range by name
  3350. * @param name Name of the animation range to delete
  3351. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3352. */
  3353. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3354. if (deleteFrames === void 0) { deleteFrames = true; }
  3355. var range = this._ranges[name];
  3356. if (!range) {
  3357. return;
  3358. }
  3359. if (deleteFrames) {
  3360. var from = range.from;
  3361. var to = range.to;
  3362. // this loop MUST go high to low for multiple splices to work
  3363. for (var key = this._keys.length - 1; key >= 0; key--) {
  3364. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3365. this._keys.splice(key, 1);
  3366. }
  3367. }
  3368. }
  3369. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3370. };
  3371. /**
  3372. * Gets the animation range by name, or null if not defined
  3373. * @param name Name of the animation range
  3374. * @returns Nullable animation range
  3375. */
  3376. Animation.prototype.getRange = function (name) {
  3377. return this._ranges[name];
  3378. };
  3379. /**
  3380. * Gets the key frames from the animation
  3381. * @returns The key frames of the animation
  3382. */
  3383. Animation.prototype.getKeys = function () {
  3384. return this._keys;
  3385. };
  3386. /**
  3387. * Gets the highest frame rate of the animation
  3388. * @returns Highest frame rate of the animation
  3389. */
  3390. Animation.prototype.getHighestFrame = function () {
  3391. var ret = 0;
  3392. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3393. if (ret < this._keys[key].frame) {
  3394. ret = this._keys[key].frame;
  3395. }
  3396. }
  3397. return ret;
  3398. };
  3399. /**
  3400. * Gets the easing function of the animation
  3401. * @returns Easing function of the animation
  3402. */
  3403. Animation.prototype.getEasingFunction = function () {
  3404. return this._easingFunction;
  3405. };
  3406. /**
  3407. * Sets the easing function of the animation
  3408. * @param easingFunction A custom mathematical formula for animation
  3409. */
  3410. Animation.prototype.setEasingFunction = function (easingFunction) {
  3411. this._easingFunction = easingFunction;
  3412. };
  3413. /**
  3414. * Interpolates a scalar linearly
  3415. * @param startValue Start value of the animation curve
  3416. * @param endValue End value of the animation curve
  3417. * @param gradient Scalar amount to interpolate
  3418. * @returns Interpolated scalar value
  3419. */
  3420. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3421. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3422. };
  3423. /**
  3424. * Interpolates a scalar cubically
  3425. * @param startValue Start value of the animation curve
  3426. * @param outTangent End tangent of the animation
  3427. * @param endValue End value of the animation curve
  3428. * @param inTangent Start tangent of the animation curve
  3429. * @param gradient Scalar amount to interpolate
  3430. * @returns Interpolated scalar value
  3431. */
  3432. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3433. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3434. };
  3435. /**
  3436. * Interpolates a quaternion using a spherical linear interpolation
  3437. * @param startValue Start value of the animation curve
  3438. * @param endValue End value of the animation curve
  3439. * @param gradient Scalar amount to interpolate
  3440. * @returns Interpolated quaternion value
  3441. */
  3442. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Interpolates a quaternion cubically
  3447. * @param startValue Start value of the animation curve
  3448. * @param outTangent End tangent of the animation curve
  3449. * @param endValue End value of the animation curve
  3450. * @param inTangent Start tangent of the animation curve
  3451. * @param gradient Scalar amount to interpolate
  3452. * @returns Interpolated quaternion value
  3453. */
  3454. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3455. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3456. };
  3457. /**
  3458. * Interpolates a Vector3 linearl
  3459. * @param startValue Start value of the animation curve
  3460. * @param endValue End value of the animation curve
  3461. * @param gradient Scalar amount to interpolate
  3462. * @returns Interpolated scalar value
  3463. */
  3464. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3465. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3466. };
  3467. /**
  3468. * Interpolates a Vector3 cubically
  3469. * @param startValue Start value of the animation curve
  3470. * @param outTangent End tangent of the animation
  3471. * @param endValue End value of the animation curve
  3472. * @param inTangent Start tangent of the animation curve
  3473. * @param gradient Scalar amount to interpolate
  3474. * @returns InterpolatedVector3 value
  3475. */
  3476. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3477. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3478. };
  3479. /**
  3480. * Interpolates a Vector2 linearly
  3481. * @param startValue Start value of the animation curve
  3482. * @param endValue End value of the animation curve
  3483. * @param gradient Scalar amount to interpolate
  3484. * @returns Interpolated Vector2 value
  3485. */
  3486. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3487. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3488. };
  3489. /**
  3490. * Interpolates a Vector2 cubically
  3491. * @param startValue Start value of the animation curve
  3492. * @param outTangent End tangent of the animation
  3493. * @param endValue End value of the animation curve
  3494. * @param inTangent Start tangent of the animation curve
  3495. * @param gradient Scalar amount to interpolate
  3496. * @returns Interpolated Vector2 value
  3497. */
  3498. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3499. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3500. };
  3501. /**
  3502. * Interpolates a size linearly
  3503. * @param startValue Start value of the animation curve
  3504. * @param endValue End value of the animation curve
  3505. * @param gradient Scalar amount to interpolate
  3506. * @returns Interpolated Size value
  3507. */
  3508. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3509. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3510. };
  3511. /**
  3512. * Interpolates a Color3 linearly
  3513. * @param startValue Start value of the animation curve
  3514. * @param endValue End value of the animation curve
  3515. * @param gradient Scalar amount to interpolate
  3516. * @returns Interpolated Color3 value
  3517. */
  3518. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3519. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3520. };
  3521. /**
  3522. * @hidden Internal use only
  3523. */
  3524. Animation.prototype._getKeyValue = function (value) {
  3525. if (typeof value === "function") {
  3526. return value();
  3527. }
  3528. return value;
  3529. };
  3530. /**
  3531. * @hidden Internal use only
  3532. */
  3533. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3534. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3535. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3536. }
  3537. var keys = this.getKeys();
  3538. if (keys.length === 1) {
  3539. return this._getKeyValue(keys[0].value);
  3540. }
  3541. // Try to get a hash to find the right key
  3542. 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));
  3543. if (keys[startKeyIndex].frame >= currentFrame) {
  3544. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3545. startKeyIndex--;
  3546. }
  3547. }
  3548. for (var key = startKeyIndex; key < keys.length; key++) {
  3549. var endKey = keys[key + 1];
  3550. if (endKey.frame >= currentFrame) {
  3551. var startKey = keys[key];
  3552. var startValue = this._getKeyValue(startKey.value);
  3553. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3554. return startValue;
  3555. }
  3556. var endValue = this._getKeyValue(endKey.value);
  3557. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3558. var frameDelta = endKey.frame - startKey.frame;
  3559. // gradient : percent of currentFrame between the frame inf and the frame sup
  3560. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3561. // check for easingFunction and correction of gradient
  3562. var easingFunction = this.getEasingFunction();
  3563. if (easingFunction != null) {
  3564. gradient = easingFunction.ease(gradient);
  3565. }
  3566. switch (this.dataType) {
  3567. // Float
  3568. case Animation.ANIMATIONTYPE_FLOAT:
  3569. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3570. switch (loopMode) {
  3571. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3572. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3573. return floatValue;
  3574. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3575. return offsetValue * repeatCount + floatValue;
  3576. }
  3577. break;
  3578. // Quaternion
  3579. case Animation.ANIMATIONTYPE_QUATERNION:
  3580. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3581. switch (loopMode) {
  3582. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3583. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3584. return quatValue;
  3585. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3586. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3587. }
  3588. return quatValue;
  3589. // Vector3
  3590. case Animation.ANIMATIONTYPE_VECTOR3:
  3591. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3592. switch (loopMode) {
  3593. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3594. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3595. return vec3Value;
  3596. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3597. return vec3Value.add(offsetValue.scale(repeatCount));
  3598. }
  3599. // Vector2
  3600. case Animation.ANIMATIONTYPE_VECTOR2:
  3601. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3602. switch (loopMode) {
  3603. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3604. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3605. return vec2Value;
  3606. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3607. return vec2Value.add(offsetValue.scale(repeatCount));
  3608. }
  3609. // Size
  3610. case Animation.ANIMATIONTYPE_SIZE:
  3611. switch (loopMode) {
  3612. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3613. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3614. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3615. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3616. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3617. }
  3618. // Color3
  3619. case Animation.ANIMATIONTYPE_COLOR3:
  3620. switch (loopMode) {
  3621. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3622. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3623. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3624. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3625. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3626. }
  3627. // Matrix
  3628. case Animation.ANIMATIONTYPE_MATRIX:
  3629. switch (loopMode) {
  3630. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3631. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3632. if (Animation.AllowMatricesInterpolation) {
  3633. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3634. }
  3635. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3636. return startValue;
  3637. }
  3638. default:
  3639. break;
  3640. }
  3641. break;
  3642. }
  3643. }
  3644. return this._getKeyValue(keys[keys.length - 1].value);
  3645. };
  3646. /**
  3647. * Defines the function to use to interpolate matrices
  3648. * @param startValue defines the start matrix
  3649. * @param endValue defines the end matrix
  3650. * @param gradient defines the gradient between both matrices
  3651. * @param result defines an optional target matrix where to store the interpolation
  3652. * @returns the interpolated matrix
  3653. */
  3654. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3655. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3656. if (result) {
  3657. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3658. return result;
  3659. }
  3660. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3661. }
  3662. if (result) {
  3663. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3664. return result;
  3665. }
  3666. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3667. };
  3668. /**
  3669. * Makes a copy of the animation
  3670. * @returns Cloned animation
  3671. */
  3672. Animation.prototype.clone = function () {
  3673. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3674. clone.enableBlending = this.enableBlending;
  3675. clone.blendingSpeed = this.blendingSpeed;
  3676. if (this._keys) {
  3677. clone.setKeys(this._keys);
  3678. }
  3679. if (this._ranges) {
  3680. clone._ranges = {};
  3681. for (var name in this._ranges) {
  3682. var range = this._ranges[name];
  3683. if (!range) {
  3684. continue;
  3685. }
  3686. clone._ranges[name] = range.clone();
  3687. }
  3688. }
  3689. return clone;
  3690. };
  3691. /**
  3692. * Sets the key frames of the animation
  3693. * @param values The animation key frames to set
  3694. */
  3695. Animation.prototype.setKeys = function (values) {
  3696. this._keys = values.slice(0);
  3697. };
  3698. /**
  3699. * Serializes the animation to an object
  3700. * @returns Serialized object
  3701. */
  3702. Animation.prototype.serialize = function () {
  3703. var serializationObject = {};
  3704. serializationObject.name = this.name;
  3705. serializationObject.property = this.targetProperty;
  3706. serializationObject.framePerSecond = this.framePerSecond;
  3707. serializationObject.dataType = this.dataType;
  3708. serializationObject.loopBehavior = this.loopMode;
  3709. serializationObject.enableBlending = this.enableBlending;
  3710. serializationObject.blendingSpeed = this.blendingSpeed;
  3711. var dataType = this.dataType;
  3712. serializationObject.keys = [];
  3713. var keys = this.getKeys();
  3714. for (var index = 0; index < keys.length; index++) {
  3715. var animationKey = keys[index];
  3716. var key = {};
  3717. key.frame = animationKey.frame;
  3718. switch (dataType) {
  3719. case Animation.ANIMATIONTYPE_FLOAT:
  3720. key.values = [animationKey.value];
  3721. break;
  3722. case Animation.ANIMATIONTYPE_QUATERNION:
  3723. case Animation.ANIMATIONTYPE_MATRIX:
  3724. case Animation.ANIMATIONTYPE_VECTOR3:
  3725. case Animation.ANIMATIONTYPE_COLOR3:
  3726. key.values = animationKey.value.asArray();
  3727. break;
  3728. }
  3729. serializationObject.keys.push(key);
  3730. }
  3731. serializationObject.ranges = [];
  3732. for (var name in this._ranges) {
  3733. var source = this._ranges[name];
  3734. if (!source) {
  3735. continue;
  3736. }
  3737. var range = {};
  3738. range.name = name;
  3739. range.from = source.from;
  3740. range.to = source.to;
  3741. serializationObject.ranges.push(range);
  3742. }
  3743. return serializationObject;
  3744. };
  3745. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3746. /**
  3747. * Get the float animation type
  3748. */
  3749. get: function () {
  3750. return Animation._ANIMATIONTYPE_FLOAT;
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3756. /**
  3757. * Get the Vector3 animation type
  3758. */
  3759. get: function () {
  3760. return Animation._ANIMATIONTYPE_VECTOR3;
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3766. /**
  3767. * Get the Vector2 animation type
  3768. */
  3769. get: function () {
  3770. return Animation._ANIMATIONTYPE_VECTOR2;
  3771. },
  3772. enumerable: true,
  3773. configurable: true
  3774. });
  3775. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3776. /**
  3777. * Get the Size animation type
  3778. */
  3779. get: function () {
  3780. return Animation._ANIMATIONTYPE_SIZE;
  3781. },
  3782. enumerable: true,
  3783. configurable: true
  3784. });
  3785. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3786. /**
  3787. * Get the Quaternion animation type
  3788. */
  3789. get: function () {
  3790. return Animation._ANIMATIONTYPE_QUATERNION;
  3791. },
  3792. enumerable: true,
  3793. configurable: true
  3794. });
  3795. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3796. /**
  3797. * Get the Matrix animation type
  3798. */
  3799. get: function () {
  3800. return Animation._ANIMATIONTYPE_MATRIX;
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3806. /**
  3807. * Get the Color3 animation type
  3808. */
  3809. get: function () {
  3810. return Animation._ANIMATIONTYPE_COLOR3;
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3816. /**
  3817. * Get the Relative Loop Mode
  3818. */
  3819. get: function () {
  3820. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3826. /**
  3827. * Get the Cycle Loop Mode
  3828. */
  3829. get: function () {
  3830. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3831. },
  3832. enumerable: true,
  3833. configurable: true
  3834. });
  3835. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3836. /**
  3837. * Get the Constant Loop Mode
  3838. */
  3839. get: function () {
  3840. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. /** @hidden */
  3846. Animation._UniversalLerp = function (left, right, amount) {
  3847. var constructor = left.constructor;
  3848. if (constructor.Lerp) { // Lerp supported
  3849. return constructor.Lerp(left, right, amount);
  3850. }
  3851. else if (constructor.Slerp) { // Slerp supported
  3852. return constructor.Slerp(left, right, amount);
  3853. }
  3854. else if (left.toFixed) { // Number
  3855. return left * (1.0 - amount) + amount * right;
  3856. }
  3857. else { // Blending not supported
  3858. return right;
  3859. }
  3860. };
  3861. /**
  3862. * Parses an animation object and creates an animation
  3863. * @param parsedAnimation Parsed animation object
  3864. * @returns Animation object
  3865. */
  3866. Animation.Parse = function (parsedAnimation) {
  3867. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3868. var dataType = parsedAnimation.dataType;
  3869. var keys = [];
  3870. var data;
  3871. var index;
  3872. if (parsedAnimation.enableBlending) {
  3873. animation.enableBlending = parsedAnimation.enableBlending;
  3874. }
  3875. if (parsedAnimation.blendingSpeed) {
  3876. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3877. }
  3878. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3879. var key = parsedAnimation.keys[index];
  3880. var inTangent;
  3881. var outTangent;
  3882. switch (dataType) {
  3883. case Animation.ANIMATIONTYPE_FLOAT:
  3884. data = key.values[0];
  3885. if (key.values.length >= 1) {
  3886. inTangent = key.values[1];
  3887. }
  3888. if (key.values.length >= 2) {
  3889. outTangent = key.values[2];
  3890. }
  3891. break;
  3892. case Animation.ANIMATIONTYPE_QUATERNION:
  3893. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3894. if (key.values.length >= 8) {
  3895. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3896. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3897. inTangent = _inTangent;
  3898. }
  3899. }
  3900. if (key.values.length >= 12) {
  3901. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3902. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3903. outTangent = _outTangent;
  3904. }
  3905. }
  3906. break;
  3907. case Animation.ANIMATIONTYPE_MATRIX:
  3908. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3909. break;
  3910. case Animation.ANIMATIONTYPE_COLOR3:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3912. break;
  3913. case Animation.ANIMATIONTYPE_VECTOR3:
  3914. default:
  3915. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3916. break;
  3917. }
  3918. var keyData = {};
  3919. keyData.frame = key.frame;
  3920. keyData.value = data;
  3921. if (inTangent != undefined) {
  3922. keyData.inTangent = inTangent;
  3923. }
  3924. if (outTangent != undefined) {
  3925. keyData.outTangent = outTangent;
  3926. }
  3927. keys.push(keyData);
  3928. }
  3929. animation.setKeys(keys);
  3930. if (parsedAnimation.ranges) {
  3931. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3932. data = parsedAnimation.ranges[index];
  3933. animation.createRange(data.name, data.from, data.to);
  3934. }
  3935. }
  3936. return animation;
  3937. };
  3938. /**
  3939. * Appends the serialized animations from the source animations
  3940. * @param source Source containing the animations
  3941. * @param destination Target to store the animations
  3942. */
  3943. Animation.AppendSerializedAnimations = function (source, destination) {
  3944. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3945. };
  3946. /**
  3947. * Use matrix interpolation instead of using direct key value when animating matrices
  3948. */
  3949. Animation.AllowMatricesInterpolation = false;
  3950. /**
  3951. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3952. */
  3953. Animation.AllowMatrixDecomposeForInterpolation = true;
  3954. // Statics
  3955. /**
  3956. * Float animation type
  3957. */
  3958. Animation._ANIMATIONTYPE_FLOAT = 0;
  3959. /**
  3960. * Vector3 animation type
  3961. */
  3962. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3963. /**
  3964. * Quaternion animation type
  3965. */
  3966. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3967. /**
  3968. * Matrix animation type
  3969. */
  3970. Animation._ANIMATIONTYPE_MATRIX = 3;
  3971. /**
  3972. * Color3 animation type
  3973. */
  3974. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3975. /**
  3976. * Vector2 animation type
  3977. */
  3978. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3979. /**
  3980. * Size animation type
  3981. */
  3982. Animation._ANIMATIONTYPE_SIZE = 6;
  3983. /**
  3984. * Relative Loop Mode
  3985. */
  3986. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3987. /**
  3988. * Cycle Loop Mode
  3989. */
  3990. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3991. /**
  3992. * Constant Loop Mode
  3993. */
  3994. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3995. return Animation;
  3996. }());
  3997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3998. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3999. /***/ }),
  4000. /***/ "./Animations/animationEvent.ts":
  4001. /*!**************************************!*\
  4002. !*** ./Animations/animationEvent.ts ***!
  4003. \**************************************/
  4004. /*! exports provided: AnimationEvent */
  4005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4006. "use strict";
  4007. __webpack_require__.r(__webpack_exports__);
  4008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4009. /**
  4010. * Composed of a frame, and an action function
  4011. */
  4012. var AnimationEvent = /** @class */ (function () {
  4013. /**
  4014. * Initializes the animation event
  4015. * @param frame The frame for which the event is triggered
  4016. * @param action The event to perform when triggered
  4017. * @param onlyOnce Specifies if the event should be triggered only once
  4018. */
  4019. function AnimationEvent(
  4020. /** The frame for which the event is triggered **/
  4021. frame,
  4022. /** The event to perform when triggered **/
  4023. action,
  4024. /** Specifies if the event should be triggered only once**/
  4025. onlyOnce) {
  4026. this.frame = frame;
  4027. this.action = action;
  4028. this.onlyOnce = onlyOnce;
  4029. /**
  4030. * Specifies if the animation event is done
  4031. */
  4032. this.isDone = false;
  4033. }
  4034. /** @hidden */
  4035. AnimationEvent.prototype._clone = function () {
  4036. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4037. };
  4038. return AnimationEvent;
  4039. }());
  4040. /***/ }),
  4041. /***/ "./Animations/animationGroup.ts":
  4042. /*!**************************************!*\
  4043. !*** ./Animations/animationGroup.ts ***!
  4044. \**************************************/
  4045. /*! exports provided: TargetedAnimation, AnimationGroup */
  4046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4047. "use strict";
  4048. __webpack_require__.r(__webpack_exports__);
  4049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4051. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4053. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4054. /**
  4055. * This class defines the direct association between an animation and a target
  4056. */
  4057. var TargetedAnimation = /** @class */ (function () {
  4058. function TargetedAnimation() {
  4059. }
  4060. return TargetedAnimation;
  4061. }());
  4062. /**
  4063. * Use this class to create coordinated animations on multiple targets
  4064. */
  4065. var AnimationGroup = /** @class */ (function () {
  4066. /**
  4067. * Instantiates a new Animation Group.
  4068. * This helps managing several animations at once.
  4069. * @see http://doc.babylonjs.com/how_to/group
  4070. * @param name Defines the name of the group
  4071. * @param scene Defines the scene the group belongs to
  4072. */
  4073. function AnimationGroup(
  4074. /** The name of the animation group */
  4075. name, scene) {
  4076. if (scene === void 0) { scene = null; }
  4077. this.name = name;
  4078. this._targetedAnimations = new Array();
  4079. this._animatables = new Array();
  4080. this._from = Number.MAX_VALUE;
  4081. this._to = -Number.MAX_VALUE;
  4082. this._speedRatio = 1;
  4083. /**
  4084. * This observable will notify when one animation have ended
  4085. */
  4086. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4087. /**
  4088. * Observer raised when one animation loops
  4089. */
  4090. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4091. /**
  4092. * This observable will notify when all animations have ended.
  4093. */
  4094. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4095. /**
  4096. * This observable will notify when all animations have paused.
  4097. */
  4098. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4099. /**
  4100. * This observable will notify when all animations are playing.
  4101. */
  4102. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4103. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4104. this.uniqueId = this._scene.getUniqueId();
  4105. this._scene.animationGroups.push(this);
  4106. }
  4107. Object.defineProperty(AnimationGroup.prototype, "from", {
  4108. /**
  4109. * Gets the first frame
  4110. */
  4111. get: function () {
  4112. return this._from;
  4113. },
  4114. enumerable: true,
  4115. configurable: true
  4116. });
  4117. Object.defineProperty(AnimationGroup.prototype, "to", {
  4118. /**
  4119. * Gets the last frame
  4120. */
  4121. get: function () {
  4122. return this._to;
  4123. },
  4124. enumerable: true,
  4125. configurable: true
  4126. });
  4127. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4128. /**
  4129. * Define if the animations are started
  4130. */
  4131. get: function () {
  4132. return this._isStarted;
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4138. /**
  4139. * Gets a value indicating that the current group is playing
  4140. */
  4141. get: function () {
  4142. return this._isStarted && !this._isPaused;
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4148. /**
  4149. * Gets or sets the speed ratio to use for all animations
  4150. */
  4151. get: function () {
  4152. return this._speedRatio;
  4153. },
  4154. /**
  4155. * Gets or sets the speed ratio to use for all animations
  4156. */
  4157. set: function (value) {
  4158. if (this._speedRatio === value) {
  4159. return;
  4160. }
  4161. this._speedRatio = value;
  4162. for (var index = 0; index < this._animatables.length; index++) {
  4163. var animatable = this._animatables[index];
  4164. animatable.speedRatio = this._speedRatio;
  4165. }
  4166. },
  4167. enumerable: true,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4171. /**
  4172. * Gets the targeted animations for this animation group
  4173. */
  4174. get: function () {
  4175. return this._targetedAnimations;
  4176. },
  4177. enumerable: true,
  4178. configurable: true
  4179. });
  4180. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4181. /**
  4182. * returning the list of animatables controlled by this animation group.
  4183. */
  4184. get: function () {
  4185. return this._animatables;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. /**
  4191. * Add an animation (with its target) in the group
  4192. * @param animation defines the animation we want to add
  4193. * @param target defines the target of the animation
  4194. * @returns the TargetedAnimation object
  4195. */
  4196. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4197. var targetedAnimation = {
  4198. animation: animation,
  4199. target: target
  4200. };
  4201. var keys = animation.getKeys();
  4202. if (this._from > keys[0].frame) {
  4203. this._from = keys[0].frame;
  4204. }
  4205. if (this._to < keys[keys.length - 1].frame) {
  4206. this._to = keys[keys.length - 1].frame;
  4207. }
  4208. this._targetedAnimations.push(targetedAnimation);
  4209. return targetedAnimation;
  4210. };
  4211. /**
  4212. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4213. * It can add constant keys at begin or end
  4214. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4215. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4216. * @returns the animation group
  4217. */
  4218. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4219. if (beginFrame === void 0) { beginFrame = null; }
  4220. if (endFrame === void 0) { endFrame = null; }
  4221. if (beginFrame == null) {
  4222. beginFrame = this._from;
  4223. }
  4224. if (endFrame == null) {
  4225. endFrame = this._to;
  4226. }
  4227. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4228. var targetedAnimation = this._targetedAnimations[index];
  4229. var keys = targetedAnimation.animation.getKeys();
  4230. var startKey = keys[0];
  4231. var endKey = keys[keys.length - 1];
  4232. if (startKey.frame > beginFrame) {
  4233. var newKey = {
  4234. frame: beginFrame,
  4235. value: startKey.value,
  4236. inTangent: startKey.inTangent,
  4237. outTangent: startKey.outTangent,
  4238. interpolation: startKey.interpolation
  4239. };
  4240. keys.splice(0, 0, newKey);
  4241. }
  4242. if (endKey.frame < endFrame) {
  4243. var newKey = {
  4244. frame: endFrame,
  4245. value: endKey.value,
  4246. inTangent: endKey.outTangent,
  4247. outTangent: endKey.outTangent,
  4248. interpolation: endKey.interpolation
  4249. };
  4250. keys.push(newKey);
  4251. }
  4252. }
  4253. this._from = beginFrame;
  4254. this._to = endFrame;
  4255. return this;
  4256. };
  4257. /**
  4258. * Start all animations on given targets
  4259. * @param loop defines if animations must loop
  4260. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4261. * @param from defines the from key (optional)
  4262. * @param to defines the to key (optional)
  4263. * @returns the current animation group
  4264. */
  4265. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4266. var _this = this;
  4267. if (loop === void 0) { loop = false; }
  4268. if (speedRatio === void 0) { speedRatio = 1; }
  4269. if (this._isStarted || this._targetedAnimations.length === 0) {
  4270. return this;
  4271. }
  4272. var _loop_1 = function (targetedAnimation) {
  4273. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4274. animatable.onAnimationEnd = function () {
  4275. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4276. _this._checkAnimationGroupEnded(animatable);
  4277. };
  4278. animatable.onAnimationLoop = function () {
  4279. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4280. };
  4281. this_1._animatables.push(animatable);
  4282. };
  4283. var this_1 = this;
  4284. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4285. var targetedAnimation = _a[_i];
  4286. _loop_1(targetedAnimation);
  4287. }
  4288. this._speedRatio = speedRatio;
  4289. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4290. this._speedRatio = -speedRatio;
  4291. }
  4292. this._isStarted = true;
  4293. this._isPaused = false;
  4294. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4295. return this;
  4296. };
  4297. /**
  4298. * Pause all animations
  4299. * @returns the animation group
  4300. */
  4301. AnimationGroup.prototype.pause = function () {
  4302. if (!this._isStarted) {
  4303. return this;
  4304. }
  4305. this._isPaused = true;
  4306. for (var index = 0; index < this._animatables.length; index++) {
  4307. var animatable = this._animatables[index];
  4308. animatable.pause();
  4309. }
  4310. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4311. return this;
  4312. };
  4313. /**
  4314. * Play all animations to initial state
  4315. * This function will start() the animations if they were not started or will restart() them if they were paused
  4316. * @param loop defines if animations must loop
  4317. * @returns the animation group
  4318. */
  4319. AnimationGroup.prototype.play = function (loop) {
  4320. // only if all animatables are ready and exist
  4321. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4322. if (loop !== undefined) {
  4323. for (var index = 0; index < this._animatables.length; index++) {
  4324. var animatable = this._animatables[index];
  4325. animatable.loopAnimation = loop;
  4326. }
  4327. }
  4328. this.restart();
  4329. }
  4330. else {
  4331. this.stop();
  4332. this.start(loop, this._speedRatio);
  4333. }
  4334. this._isPaused = false;
  4335. return this;
  4336. };
  4337. /**
  4338. * Reset all animations to initial state
  4339. * @returns the animation group
  4340. */
  4341. AnimationGroup.prototype.reset = function () {
  4342. if (!this._isStarted) {
  4343. return this;
  4344. }
  4345. for (var index = 0; index < this._animatables.length; index++) {
  4346. var animatable = this._animatables[index];
  4347. animatable.reset();
  4348. }
  4349. return this;
  4350. };
  4351. /**
  4352. * Restart animations from key 0
  4353. * @returns the animation group
  4354. */
  4355. AnimationGroup.prototype.restart = function () {
  4356. if (!this._isStarted) {
  4357. return this;
  4358. }
  4359. for (var index = 0; index < this._animatables.length; index++) {
  4360. var animatable = this._animatables[index];
  4361. animatable.restart();
  4362. }
  4363. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4364. return this;
  4365. };
  4366. /**
  4367. * Stop all animations
  4368. * @returns the animation group
  4369. */
  4370. AnimationGroup.prototype.stop = function () {
  4371. if (!this._isStarted) {
  4372. return this;
  4373. }
  4374. var list = this._animatables.slice();
  4375. for (var index = 0; index < list.length; index++) {
  4376. list[index].stop();
  4377. }
  4378. this._isStarted = false;
  4379. return this;
  4380. };
  4381. /**
  4382. * Set animation weight for all animatables
  4383. * @param weight defines the weight to use
  4384. * @return the animationGroup
  4385. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4386. */
  4387. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4388. for (var index = 0; index < this._animatables.length; index++) {
  4389. var animatable = this._animatables[index];
  4390. animatable.weight = weight;
  4391. }
  4392. return this;
  4393. };
  4394. /**
  4395. * Synchronize and normalize all animatables with a source animatable
  4396. * @param root defines the root animatable to synchronize with
  4397. * @return the animationGroup
  4398. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4399. */
  4400. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4401. for (var index = 0; index < this._animatables.length; index++) {
  4402. var animatable = this._animatables[index];
  4403. animatable.syncWith(root);
  4404. }
  4405. return this;
  4406. };
  4407. /**
  4408. * Goes to a specific frame in this animation group
  4409. * @param frame the frame number to go to
  4410. * @return the animationGroup
  4411. */
  4412. AnimationGroup.prototype.goToFrame = function (frame) {
  4413. if (!this._isStarted) {
  4414. return this;
  4415. }
  4416. for (var index = 0; index < this._animatables.length; index++) {
  4417. var animatable = this._animatables[index];
  4418. animatable.goToFrame(frame);
  4419. }
  4420. return this;
  4421. };
  4422. /**
  4423. * Dispose all associated resources
  4424. */
  4425. AnimationGroup.prototype.dispose = function () {
  4426. this._targetedAnimations = [];
  4427. this._animatables = [];
  4428. var index = this._scene.animationGroups.indexOf(this);
  4429. if (index > -1) {
  4430. this._scene.animationGroups.splice(index, 1);
  4431. }
  4432. this.onAnimationEndObservable.clear();
  4433. this.onAnimationGroupEndObservable.clear();
  4434. this.onAnimationGroupPauseObservable.clear();
  4435. this.onAnimationGroupPlayObservable.clear();
  4436. this.onAnimationLoopObservable.clear();
  4437. };
  4438. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4439. // animatable should be taken out of the array
  4440. var idx = this._animatables.indexOf(animatable);
  4441. if (idx > -1) {
  4442. this._animatables.splice(idx, 1);
  4443. }
  4444. // all animatables were removed? animation group ended!
  4445. if (this._animatables.length === 0) {
  4446. this._isStarted = false;
  4447. this.onAnimationGroupEndObservable.notifyObservers(this);
  4448. }
  4449. };
  4450. /**
  4451. * Clone the current animation group and returns a copy
  4452. * @param newName defines the name of the new group
  4453. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4454. * @returns the new aniamtion group
  4455. */
  4456. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4457. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4458. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4459. var targetAnimation = _a[_i];
  4460. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4461. }
  4462. return newGroup;
  4463. };
  4464. // Statics
  4465. /**
  4466. * Returns a new AnimationGroup object parsed from the source provided.
  4467. * @param parsedAnimationGroup defines the source
  4468. * @param scene defines the scene that will receive the animationGroup
  4469. * @returns a new AnimationGroup
  4470. */
  4471. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4472. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4473. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4474. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4475. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4476. var id = targetedAnimation.targetId;
  4477. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4478. var morphTarget = scene.getMorphTargetById(id);
  4479. if (morphTarget) {
  4480. animationGroup.addTargetedAnimation(animation, morphTarget);
  4481. }
  4482. }
  4483. else {
  4484. var targetNode = scene.getNodeByID(id);
  4485. if (targetNode != null) {
  4486. animationGroup.addTargetedAnimation(animation, targetNode);
  4487. }
  4488. }
  4489. }
  4490. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4491. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4492. }
  4493. return animationGroup;
  4494. };
  4495. /**
  4496. * Returns the string "AnimationGroup"
  4497. * @returns "AnimationGroup"
  4498. */
  4499. AnimationGroup.prototype.getClassName = function () {
  4500. return "AnimationGroup";
  4501. };
  4502. /**
  4503. * Creates a detailled string about the object
  4504. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4505. * @returns a string representing the object
  4506. */
  4507. AnimationGroup.prototype.toString = function (fullDetails) {
  4508. var ret = "Name: " + this.name;
  4509. ret += ", type: " + this.getClassName();
  4510. if (fullDetails) {
  4511. ret += ", from: " + this._from;
  4512. ret += ", to: " + this._to;
  4513. ret += ", isStarted: " + this._isStarted;
  4514. ret += ", speedRatio: " + this._speedRatio;
  4515. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4516. ret += ", animatables length: " + this._animatables;
  4517. }
  4518. return ret;
  4519. };
  4520. return AnimationGroup;
  4521. }());
  4522. /***/ }),
  4523. /***/ "./Animations/animationKey.ts":
  4524. /*!************************************!*\
  4525. !*** ./Animations/animationKey.ts ***!
  4526. \************************************/
  4527. /*! exports provided: AnimationKeyInterpolation */
  4528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4529. "use strict";
  4530. __webpack_require__.r(__webpack_exports__);
  4531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4532. /**
  4533. * Enum for the animation key frame interpolation type
  4534. */
  4535. var AnimationKeyInterpolation;
  4536. (function (AnimationKeyInterpolation) {
  4537. /**
  4538. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4539. */
  4540. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4541. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4542. /***/ }),
  4543. /***/ "./Animations/animationPropertiesOverride.ts":
  4544. /*!***************************************************!*\
  4545. !*** ./Animations/animationPropertiesOverride.ts ***!
  4546. \***************************************************/
  4547. /*! exports provided: AnimationPropertiesOverride */
  4548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4549. "use strict";
  4550. __webpack_require__.r(__webpack_exports__);
  4551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4552. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4553. /**
  4554. * Class used to override all child animations of a given target
  4555. */
  4556. var AnimationPropertiesOverride = /** @class */ (function () {
  4557. function AnimationPropertiesOverride() {
  4558. /**
  4559. * Gets or sets a value indicating if animation blending must be used
  4560. */
  4561. this.enableBlending = false;
  4562. /**
  4563. * Gets or sets the blending speed to use when enableBlending is true
  4564. */
  4565. this.blendingSpeed = 0.01;
  4566. /**
  4567. * Gets or sets the default loop mode to use
  4568. */
  4569. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4570. }
  4571. return AnimationPropertiesOverride;
  4572. }());
  4573. /***/ }),
  4574. /***/ "./Animations/animationRange.ts":
  4575. /*!**************************************!*\
  4576. !*** ./Animations/animationRange.ts ***!
  4577. \**************************************/
  4578. /*! exports provided: AnimationRange */
  4579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4580. "use strict";
  4581. __webpack_require__.r(__webpack_exports__);
  4582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4583. /**
  4584. * Represents the range of an animation
  4585. */
  4586. var AnimationRange = /** @class */ (function () {
  4587. /**
  4588. * Initializes the range of an animation
  4589. * @param name The name of the animation range
  4590. * @param from The starting frame of the animation
  4591. * @param to The ending frame of the animation
  4592. */
  4593. function AnimationRange(
  4594. /**The name of the animation range**/
  4595. name,
  4596. /**The starting frame of the animation */
  4597. from,
  4598. /**The ending frame of the animation*/
  4599. to) {
  4600. this.name = name;
  4601. this.from = from;
  4602. this.to = to;
  4603. }
  4604. /**
  4605. * Makes a copy of the animation range
  4606. * @returns A copy of the animation range
  4607. */
  4608. AnimationRange.prototype.clone = function () {
  4609. return new AnimationRange(this.name, this.from, this.to);
  4610. };
  4611. return AnimationRange;
  4612. }());
  4613. /***/ }),
  4614. /***/ "./Animations/easing.ts":
  4615. /*!******************************!*\
  4616. !*** ./Animations/easing.ts ***!
  4617. \******************************/
  4618. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4620. "use strict";
  4621. __webpack_require__.r(__webpack_exports__);
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4637. /**
  4638. * Base class used for every default easing function.
  4639. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4640. */
  4641. var EasingFunction = /** @class */ (function () {
  4642. function EasingFunction() {
  4643. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4644. }
  4645. /**
  4646. * Sets the easing mode of the current function.
  4647. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4648. */
  4649. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4650. var n = Math.min(Math.max(easingMode, 0), 2);
  4651. this._easingMode = n;
  4652. };
  4653. /**
  4654. * Gets the current easing mode.
  4655. * @returns the easing mode
  4656. */
  4657. EasingFunction.prototype.getEasingMode = function () {
  4658. return this._easingMode;
  4659. };
  4660. /**
  4661. * @hidden
  4662. */
  4663. EasingFunction.prototype.easeInCore = function (gradient) {
  4664. throw new Error('You must implement this method');
  4665. };
  4666. /**
  4667. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4668. * of the easing function.
  4669. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4670. * @returns the corresponding value on the curve defined by the easing function
  4671. */
  4672. EasingFunction.prototype.ease = function (gradient) {
  4673. switch (this._easingMode) {
  4674. case EasingFunction.EASINGMODE_EASEIN:
  4675. return this.easeInCore(gradient);
  4676. case EasingFunction.EASINGMODE_EASEOUT:
  4677. return (1 - this.easeInCore(1 - gradient));
  4678. }
  4679. if (gradient >= 0.5) {
  4680. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4681. }
  4682. return (this.easeInCore(gradient * 2) * 0.5);
  4683. };
  4684. /**
  4685. * Interpolation follows the mathematical formula associated with the easing function.
  4686. */
  4687. EasingFunction.EASINGMODE_EASEIN = 0;
  4688. /**
  4689. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4690. */
  4691. EasingFunction.EASINGMODE_EASEOUT = 1;
  4692. /**
  4693. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4694. */
  4695. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4696. return EasingFunction;
  4697. }());
  4698. /**
  4699. * Easing function with a circle shape (see link below).
  4700. * @see https://easings.net/#easeInCirc
  4701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4702. */
  4703. var CircleEase = /** @class */ (function (_super) {
  4704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4705. function CircleEase() {
  4706. return _super !== null && _super.apply(this, arguments) || this;
  4707. }
  4708. /** @hidden */
  4709. CircleEase.prototype.easeInCore = function (gradient) {
  4710. gradient = Math.max(0, Math.min(1, gradient));
  4711. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4712. };
  4713. return CircleEase;
  4714. }(EasingFunction));
  4715. /**
  4716. * Easing function with a ease back shape (see link below).
  4717. * @see https://easings.net/#easeInBack
  4718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4719. */
  4720. var BackEase = /** @class */ (function (_super) {
  4721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4722. /**
  4723. * Instantiates a back ease easing
  4724. * @see https://easings.net/#easeInBack
  4725. * @param amplitude Defines the amplitude of the function
  4726. */
  4727. function BackEase(
  4728. /** Defines the amplitude of the function */
  4729. amplitude) {
  4730. if (amplitude === void 0) { amplitude = 1; }
  4731. var _this = _super.call(this) || this;
  4732. _this.amplitude = amplitude;
  4733. return _this;
  4734. }
  4735. /** @hidden */
  4736. BackEase.prototype.easeInCore = function (gradient) {
  4737. var num = Math.max(0, this.amplitude);
  4738. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4739. };
  4740. return BackEase;
  4741. }(EasingFunction));
  4742. /**
  4743. * Easing function with a bouncing shape (see link below).
  4744. * @see https://easings.net/#easeInBounce
  4745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4746. */
  4747. var BounceEase = /** @class */ (function (_super) {
  4748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4749. /**
  4750. * Instantiates a bounce easing
  4751. * @see https://easings.net/#easeInBounce
  4752. * @param bounces Defines the number of bounces
  4753. * @param bounciness Defines the amplitude of the bounce
  4754. */
  4755. function BounceEase(
  4756. /** Defines the number of bounces */
  4757. bounces,
  4758. /** Defines the amplitude of the bounce */
  4759. bounciness) {
  4760. if (bounces === void 0) { bounces = 3; }
  4761. if (bounciness === void 0) { bounciness = 2; }
  4762. var _this = _super.call(this) || this;
  4763. _this.bounces = bounces;
  4764. _this.bounciness = bounciness;
  4765. return _this;
  4766. }
  4767. /** @hidden */
  4768. BounceEase.prototype.easeInCore = function (gradient) {
  4769. var y = Math.max(0.0, this.bounces);
  4770. var bounciness = this.bounciness;
  4771. if (bounciness <= 1.0) {
  4772. bounciness = 1.001;
  4773. }
  4774. var num9 = Math.pow(bounciness, y);
  4775. var num5 = 1.0 - bounciness;
  4776. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4777. var num15 = gradient * num4;
  4778. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4779. var num3 = Math.floor(num65);
  4780. var num13 = num3 + 1.0;
  4781. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4782. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4783. var num7 = (num8 + num12) * 0.5;
  4784. var num6 = gradient - num7;
  4785. var num2 = num7 - num8;
  4786. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4787. };
  4788. return BounceEase;
  4789. }(EasingFunction));
  4790. /**
  4791. * Easing function with a power of 3 shape (see link below).
  4792. * @see https://easings.net/#easeInCubic
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. var CubicEase = /** @class */ (function (_super) {
  4796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4797. function CubicEase() {
  4798. return _super !== null && _super.apply(this, arguments) || this;
  4799. }
  4800. /** @hidden */
  4801. CubicEase.prototype.easeInCore = function (gradient) {
  4802. return (gradient * gradient * gradient);
  4803. };
  4804. return CubicEase;
  4805. }(EasingFunction));
  4806. /**
  4807. * Easing function with an elastic shape (see link below).
  4808. * @see https://easings.net/#easeInElastic
  4809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4810. */
  4811. var ElasticEase = /** @class */ (function (_super) {
  4812. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4813. /**
  4814. * Instantiates an elastic easing function
  4815. * @see https://easings.net/#easeInElastic
  4816. * @param oscillations Defines the number of oscillations
  4817. * @param springiness Defines the amplitude of the oscillations
  4818. */
  4819. function ElasticEase(
  4820. /** Defines the number of oscillations*/
  4821. oscillations,
  4822. /** Defines the amplitude of the oscillations*/
  4823. springiness) {
  4824. if (oscillations === void 0) { oscillations = 3; }
  4825. if (springiness === void 0) { springiness = 3; }
  4826. var _this = _super.call(this) || this;
  4827. _this.oscillations = oscillations;
  4828. _this.springiness = springiness;
  4829. return _this;
  4830. }
  4831. /** @hidden */
  4832. ElasticEase.prototype.easeInCore = function (gradient) {
  4833. var num2;
  4834. var num3 = Math.max(0.0, this.oscillations);
  4835. var num = Math.max(0.0, this.springiness);
  4836. if (num == 0) {
  4837. num2 = gradient;
  4838. }
  4839. else {
  4840. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4841. }
  4842. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4843. };
  4844. return ElasticEase;
  4845. }(EasingFunction));
  4846. /**
  4847. * Easing function with an exponential shape (see link below).
  4848. * @see https://easings.net/#easeInExpo
  4849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4850. */
  4851. var ExponentialEase = /** @class */ (function (_super) {
  4852. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4853. /**
  4854. * Instantiates an exponential easing function
  4855. * @see https://easings.net/#easeInExpo
  4856. * @param exponent Defines the exponent of the function
  4857. */
  4858. function ExponentialEase(
  4859. /** Defines the exponent of the function */
  4860. exponent) {
  4861. if (exponent === void 0) { exponent = 2; }
  4862. var _this = _super.call(this) || this;
  4863. _this.exponent = exponent;
  4864. return _this;
  4865. }
  4866. /** @hidden */
  4867. ExponentialEase.prototype.easeInCore = function (gradient) {
  4868. if (this.exponent <= 0) {
  4869. return gradient;
  4870. }
  4871. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4872. };
  4873. return ExponentialEase;
  4874. }(EasingFunction));
  4875. /**
  4876. * Easing function with a power shape (see link below).
  4877. * @see https://easings.net/#easeInQuad
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. var PowerEase = /** @class */ (function (_super) {
  4881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4882. /**
  4883. * Instantiates an power base easing function
  4884. * @see https://easings.net/#easeInQuad
  4885. * @param power Defines the power of the function
  4886. */
  4887. function PowerEase(
  4888. /** Defines the power of the function */
  4889. power) {
  4890. if (power === void 0) { power = 2; }
  4891. var _this = _super.call(this) || this;
  4892. _this.power = power;
  4893. return _this;
  4894. }
  4895. /** @hidden */
  4896. PowerEase.prototype.easeInCore = function (gradient) {
  4897. var y = Math.max(0.0, this.power);
  4898. return Math.pow(gradient, y);
  4899. };
  4900. return PowerEase;
  4901. }(EasingFunction));
  4902. /**
  4903. * Easing function with a power of 2 shape (see link below).
  4904. * @see https://easings.net/#easeInQuad
  4905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4906. */
  4907. var QuadraticEase = /** @class */ (function (_super) {
  4908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4909. function QuadraticEase() {
  4910. return _super !== null && _super.apply(this, arguments) || this;
  4911. }
  4912. /** @hidden */
  4913. QuadraticEase.prototype.easeInCore = function (gradient) {
  4914. return (gradient * gradient);
  4915. };
  4916. return QuadraticEase;
  4917. }(EasingFunction));
  4918. /**
  4919. * Easing function with a power of 4 shape (see link below).
  4920. * @see https://easings.net/#easeInQuart
  4921. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4922. */
  4923. var QuarticEase = /** @class */ (function (_super) {
  4924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4925. function QuarticEase() {
  4926. return _super !== null && _super.apply(this, arguments) || this;
  4927. }
  4928. /** @hidden */
  4929. QuarticEase.prototype.easeInCore = function (gradient) {
  4930. return (gradient * gradient * gradient * gradient);
  4931. };
  4932. return QuarticEase;
  4933. }(EasingFunction));
  4934. /**
  4935. * Easing function with a power of 5 shape (see link below).
  4936. * @see https://easings.net/#easeInQuint
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. var QuinticEase = /** @class */ (function (_super) {
  4940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4941. function QuinticEase() {
  4942. return _super !== null && _super.apply(this, arguments) || this;
  4943. }
  4944. /** @hidden */
  4945. QuinticEase.prototype.easeInCore = function (gradient) {
  4946. return (gradient * gradient * gradient * gradient * gradient);
  4947. };
  4948. return QuinticEase;
  4949. }(EasingFunction));
  4950. /**
  4951. * Easing function with a sin shape (see link below).
  4952. * @see https://easings.net/#easeInSine
  4953. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4954. */
  4955. var SineEase = /** @class */ (function (_super) {
  4956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4957. function SineEase() {
  4958. return _super !== null && _super.apply(this, arguments) || this;
  4959. }
  4960. /** @hidden */
  4961. SineEase.prototype.easeInCore = function (gradient) {
  4962. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4963. };
  4964. return SineEase;
  4965. }(EasingFunction));
  4966. /**
  4967. * Easing function with a bezier shape (see link below).
  4968. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. var BezierCurveEase = /** @class */ (function (_super) {
  4972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4973. /**
  4974. * Instantiates a bezier function
  4975. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4976. * @param x1 Defines the x component of the start tangent in the bezier curve
  4977. * @param y1 Defines the y component of the start tangent in the bezier curve
  4978. * @param x2 Defines the x component of the end tangent in the bezier curve
  4979. * @param y2 Defines the y component of the end tangent in the bezier curve
  4980. */
  4981. function BezierCurveEase(
  4982. /** Defines the x component of the start tangent in the bezier curve */
  4983. x1,
  4984. /** Defines the y component of the start tangent in the bezier curve */
  4985. y1,
  4986. /** Defines the x component of the end tangent in the bezier curve */
  4987. x2,
  4988. /** Defines the y component of the end tangent in the bezier curve */
  4989. y2) {
  4990. if (x1 === void 0) { x1 = 0; }
  4991. if (y1 === void 0) { y1 = 0; }
  4992. if (x2 === void 0) { x2 = 1; }
  4993. if (y2 === void 0) { y2 = 1; }
  4994. var _this = _super.call(this) || this;
  4995. _this.x1 = x1;
  4996. _this.y1 = y1;
  4997. _this.x2 = x2;
  4998. _this.y2 = y2;
  4999. return _this;
  5000. }
  5001. /** @hidden */
  5002. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5003. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5004. };
  5005. return BezierCurveEase;
  5006. }(EasingFunction));
  5007. /***/ }),
  5008. /***/ "./Animations/index.ts":
  5009. /*!*****************************!*\
  5010. !*** ./Animations/index.ts ***!
  5011. \*****************************/
  5012. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5014. "use strict";
  5015. __webpack_require__.r(__webpack_exports__);
  5016. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5018. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5020. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5023. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5025. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5039. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5041. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5043. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5045. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5047. /***/ }),
  5048. /***/ "./Animations/runtimeAnimation.ts":
  5049. /*!****************************************!*\
  5050. !*** ./Animations/runtimeAnimation.ts ***!
  5051. \****************************************/
  5052. /*! exports provided: RuntimeAnimation */
  5053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5054. "use strict";
  5055. __webpack_require__.r(__webpack_exports__);
  5056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5058. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5059. // Static values to help the garbage collector
  5060. // Quaternion
  5061. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5062. // Vector3
  5063. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5064. // Vector2
  5065. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5066. // Size
  5067. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5068. // Color3
  5069. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5070. /**
  5071. * Defines a runtime animation
  5072. */
  5073. var RuntimeAnimation = /** @class */ (function () {
  5074. /**
  5075. * Create a new RuntimeAnimation object
  5076. * @param target defines the target of the animation
  5077. * @param animation defines the source animation object
  5078. * @param scene defines the hosting scene
  5079. * @param host defines the initiating Animatable
  5080. */
  5081. function RuntimeAnimation(target, animation, scene, host) {
  5082. var _this = this;
  5083. this._events = new Array();
  5084. /**
  5085. * The current frame of the runtime animation
  5086. */
  5087. this._currentFrame = 0;
  5088. /**
  5089. * The original value of the runtime animation
  5090. */
  5091. this._originalValue = new Array();
  5092. /**
  5093. * The offsets cache of the runtime animation
  5094. */
  5095. this._offsetsCache = {};
  5096. /**
  5097. * The high limits cache of the runtime animation
  5098. */
  5099. this._highLimitsCache = {};
  5100. /**
  5101. * Specifies if the runtime animation has been stopped
  5102. */
  5103. this._stopped = false;
  5104. /**
  5105. * The blending factor of the runtime animation
  5106. */
  5107. this._blendingFactor = 0;
  5108. /**
  5109. * The target path of the runtime animation
  5110. */
  5111. this._targetPath = "";
  5112. /**
  5113. * The weight of the runtime animation
  5114. */
  5115. this._weight = 1.0;
  5116. /**
  5117. * The ratio offset of the runtime animation
  5118. */
  5119. this._ratioOffset = 0;
  5120. /**
  5121. * The previous delay of the runtime animation
  5122. */
  5123. this._previousDelay = 0;
  5124. /**
  5125. * The previous ratio of the runtime animation
  5126. */
  5127. this._previousRatio = 0;
  5128. this._animation = animation;
  5129. this._target = target;
  5130. this._scene = scene;
  5131. this._host = host;
  5132. animation._runtimeAnimations.push(this);
  5133. // Cloning events locally
  5134. var events = animation.getEvents();
  5135. if (events && events.length > 0) {
  5136. events.forEach(function (e) {
  5137. _this._events.push(e._clone());
  5138. });
  5139. }
  5140. }
  5141. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5142. /**
  5143. * Gets the current frame of the runtime animation
  5144. */
  5145. get: function () {
  5146. return this._currentFrame;
  5147. },
  5148. enumerable: true,
  5149. configurable: true
  5150. });
  5151. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5152. /**
  5153. * Gets the weight of the runtime animation
  5154. */
  5155. get: function () {
  5156. return this._weight;
  5157. },
  5158. enumerable: true,
  5159. configurable: true
  5160. });
  5161. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5162. /**
  5163. * Gets the current value of the runtime animation
  5164. */
  5165. get: function () {
  5166. return this._currentValue;
  5167. },
  5168. enumerable: true,
  5169. configurable: true
  5170. });
  5171. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5172. /**
  5173. * Gets the target path of the runtime animation
  5174. */
  5175. get: function () {
  5176. return this._targetPath;
  5177. },
  5178. enumerable: true,
  5179. configurable: true
  5180. });
  5181. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5182. /**
  5183. * Gets the actual target of the runtime animation
  5184. */
  5185. get: function () {
  5186. return this._activeTarget;
  5187. },
  5188. enumerable: true,
  5189. configurable: true
  5190. });
  5191. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5192. /**
  5193. * Gets the animation from the runtime animation
  5194. */
  5195. get: function () {
  5196. return this._animation;
  5197. },
  5198. enumerable: true,
  5199. configurable: true
  5200. });
  5201. /**
  5202. * Resets the runtime animation to the beginning
  5203. * @param restoreOriginal defines whether to restore the target property to the original value
  5204. */
  5205. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5206. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5207. if (restoreOriginal) {
  5208. if (this._target instanceof Array) {
  5209. var index = 0;
  5210. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5211. var target = _a[_i];
  5212. if (this._originalValue[index] !== undefined) {
  5213. this._setValue(target, this._originalValue[index], -1);
  5214. }
  5215. index++;
  5216. }
  5217. }
  5218. else {
  5219. if (this._originalValue[0] !== undefined) {
  5220. this._setValue(this._target, this._originalValue[0], -1);
  5221. }
  5222. }
  5223. }
  5224. this._offsetsCache = {};
  5225. this._highLimitsCache = {};
  5226. this._currentFrame = 0;
  5227. this._blendingFactor = 0;
  5228. this._originalValue = new Array();
  5229. // Events
  5230. for (var index = 0; index < this._events.length; index++) {
  5231. this._events[index].isDone = false;
  5232. }
  5233. };
  5234. /**
  5235. * Specifies if the runtime animation is stopped
  5236. * @returns Boolean specifying if the runtime animation is stopped
  5237. */
  5238. RuntimeAnimation.prototype.isStopped = function () {
  5239. return this._stopped;
  5240. };
  5241. /**
  5242. * Disposes of the runtime animation
  5243. */
  5244. RuntimeAnimation.prototype.dispose = function () {
  5245. var index = this._animation.runtimeAnimations.indexOf(this);
  5246. if (index > -1) {
  5247. this._animation.runtimeAnimations.splice(index, 1);
  5248. }
  5249. };
  5250. /**
  5251. * Interpolates the animation from the current frame
  5252. * @param currentFrame The frame to interpolate the animation to
  5253. * @param repeatCount The number of times that the animation should loop
  5254. * @param loopMode The type of looping mode to use
  5255. * @param offsetValue Animation offset value
  5256. * @param highLimitValue The high limit value
  5257. * @returns The interpolated value
  5258. */
  5259. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5260. this._currentFrame = currentFrame;
  5261. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5262. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5263. }
  5264. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5265. };
  5266. /**
  5267. * Apply the interpolated value to the target
  5268. * @param currentValue defines the value computed by the animation
  5269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5270. */
  5271. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5272. if (weight === void 0) { weight = 1.0; }
  5273. if (this._target instanceof Array) {
  5274. var index = 0;
  5275. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5276. var target = _a[_i];
  5277. this._setValue(target, currentValue, weight, index);
  5278. index++;
  5279. }
  5280. }
  5281. else {
  5282. this._setValue(this._target, currentValue, weight);
  5283. }
  5284. };
  5285. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5286. if (targetIndex === void 0) { targetIndex = 0; }
  5287. // Set value
  5288. var path;
  5289. var destination;
  5290. var targetPropertyPath = this._animation.targetPropertyPath;
  5291. if (targetPropertyPath.length > 1) {
  5292. var property = target[targetPropertyPath[0]];
  5293. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5294. property = property[targetPropertyPath[index]];
  5295. }
  5296. path = targetPropertyPath[targetPropertyPath.length - 1];
  5297. destination = property;
  5298. }
  5299. else {
  5300. path = targetPropertyPath[0];
  5301. destination = target;
  5302. }
  5303. this._targetPath = path;
  5304. this._activeTarget = destination;
  5305. this._weight = weight;
  5306. if (this._originalValue[targetIndex] === undefined) {
  5307. var originalValue = void 0;
  5308. if (destination.getRestPose && path === "_matrix") { // For bones
  5309. originalValue = destination.getRestPose();
  5310. }
  5311. else {
  5312. originalValue = destination[path];
  5313. }
  5314. if (originalValue && originalValue.clone) {
  5315. this._originalValue[targetIndex] = originalValue.clone();
  5316. }
  5317. else {
  5318. this._originalValue[targetIndex] = originalValue;
  5319. }
  5320. }
  5321. // Blending
  5322. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5323. if (enableBlending && this._blendingFactor <= 1.0) {
  5324. if (!this._originalBlendValue) {
  5325. var originalValue = destination[path];
  5326. if (originalValue.clone) {
  5327. this._originalBlendValue = originalValue.clone();
  5328. }
  5329. else {
  5330. this._originalBlendValue = originalValue;
  5331. }
  5332. }
  5333. if (this._originalBlendValue.m) { // Matrix
  5334. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5335. if (this._currentValue) {
  5336. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5337. }
  5338. else {
  5339. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5340. }
  5341. }
  5342. else {
  5343. if (this._currentValue) {
  5344. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5345. }
  5346. else {
  5347. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5348. }
  5349. }
  5350. }
  5351. else {
  5352. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5353. }
  5354. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5355. this._blendingFactor += blendingSpeed;
  5356. }
  5357. else {
  5358. this._currentValue = currentValue;
  5359. }
  5360. if (weight !== -1.0) {
  5361. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5362. }
  5363. else {
  5364. destination[path] = this._currentValue;
  5365. }
  5366. if (target.markAsDirty) {
  5367. target.markAsDirty(this._animation.targetProperty);
  5368. }
  5369. };
  5370. /**
  5371. * Gets the loop pmode of the runtime animation
  5372. * @returns Loop Mode
  5373. */
  5374. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5375. if (this._target && this._target.animationPropertiesOverride) {
  5376. return this._target.animationPropertiesOverride.loopMode;
  5377. }
  5378. return this._animation.loopMode;
  5379. };
  5380. /**
  5381. * Move the current animation to a given frame
  5382. * @param frame defines the frame to move to
  5383. */
  5384. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5385. var keys = this._animation.getKeys();
  5386. if (frame < keys[0].frame) {
  5387. frame = keys[0].frame;
  5388. }
  5389. else if (frame > keys[keys.length - 1].frame) {
  5390. frame = keys[keys.length - 1].frame;
  5391. }
  5392. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5393. this.setValue(currentValue, -1);
  5394. };
  5395. /**
  5396. * @hidden Internal use only
  5397. */
  5398. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5399. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5400. this._ratioOffset = this._previousRatio - newRatio;
  5401. };
  5402. /**
  5403. * Execute the current animation
  5404. * @param delay defines the delay to add to the current frame
  5405. * @param from defines the lower bound of the animation range
  5406. * @param to defines the upper bound of the animation range
  5407. * @param loop defines if the current animation must loop
  5408. * @param speedRatio defines the current speed ratio
  5409. * @param weight defines the weight of the animation (default is -1 so no weight)
  5410. * @param onLoop optional callback called when animation loops
  5411. * @returns a boolean indicating if the animation is running
  5412. */
  5413. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5414. if (weight === void 0) { weight = -1.0; }
  5415. var targetPropertyPath = this._animation.targetPropertyPath;
  5416. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5417. this._stopped = true;
  5418. return false;
  5419. }
  5420. var returnValue = true;
  5421. var keys = this._animation.getKeys();
  5422. var min = keys[0].frame;
  5423. var max = keys[keys.length - 1].frame;
  5424. // Add a start key at frame 0 if missing
  5425. if (min !== 0) {
  5426. var newKey = { frame: 0, value: keys[0].value };
  5427. keys.splice(0, 0, newKey);
  5428. }
  5429. // Check limits
  5430. if (from < min || from > max) {
  5431. from = min;
  5432. }
  5433. if (to < min || to > max) {
  5434. to = max;
  5435. }
  5436. var range = to - from;
  5437. var offsetValue;
  5438. // Compute ratio which represents the frame delta between from and to
  5439. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5440. var highLimitValue = 0;
  5441. this._previousDelay = delay;
  5442. this._previousRatio = ratio;
  5443. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5444. returnValue = false;
  5445. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5446. }
  5447. else {
  5448. // Get max value if required
  5449. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5450. var keyOffset = to.toString() + from.toString();
  5451. if (!this._offsetsCache[keyOffset]) {
  5452. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5453. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5454. switch (this._animation.dataType) {
  5455. // Float
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5457. this._offsetsCache[keyOffset] = toValue - fromValue;
  5458. break;
  5459. // Quaternion
  5460. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5461. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5462. break;
  5463. // Vector3
  5464. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5465. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5466. // Vector2
  5467. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5468. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5469. // Size
  5470. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5471. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5472. // Color3
  5473. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5474. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5475. default:
  5476. break;
  5477. }
  5478. this._highLimitsCache[keyOffset] = toValue;
  5479. }
  5480. highLimitValue = this._highLimitsCache[keyOffset];
  5481. offsetValue = this._offsetsCache[keyOffset];
  5482. }
  5483. }
  5484. if (offsetValue === undefined) {
  5485. switch (this._animation.dataType) {
  5486. // Float
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5488. offsetValue = 0;
  5489. break;
  5490. // Quaternion
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5492. offsetValue = _staticOffsetValueQuaternion;
  5493. break;
  5494. // Vector3
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5496. offsetValue = _staticOffsetValueVector3;
  5497. break;
  5498. // Vector2
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5500. offsetValue = _staticOffsetValueVector2;
  5501. break;
  5502. // Size
  5503. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5504. offsetValue = _staticOffsetValueSize;
  5505. break;
  5506. // Color3
  5507. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5508. offsetValue = _staticOffsetValueColor3;
  5509. }
  5510. }
  5511. // Compute value
  5512. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5513. // Need to normalize?
  5514. if (this._host && this._host.syncRoot) {
  5515. var syncRoot = this._host.syncRoot;
  5516. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5517. currentFrame = from + (to - from) * hostNormalizedFrame;
  5518. }
  5519. // Reset events if looping
  5520. var events = this._events;
  5521. if (range > 0 && this.currentFrame > currentFrame ||
  5522. range < 0 && this.currentFrame < currentFrame) {
  5523. if (onLoop) {
  5524. onLoop();
  5525. }
  5526. // Need to reset animation events
  5527. for (var index = 0; index < events.length; index++) {
  5528. if (!events[index].onlyOnce) {
  5529. // reset event, the animation is looping
  5530. events[index].isDone = false;
  5531. }
  5532. }
  5533. }
  5534. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5535. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5536. // Set value
  5537. this.setValue(currentValue, weight);
  5538. // Check events
  5539. for (var index = 0; index < events.length; index++) {
  5540. // Make sure current frame has passed event frame and that event frame is within the current range
  5541. // Also, handle both forward and reverse animations
  5542. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5543. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5544. var event = events[index];
  5545. if (!event.isDone) {
  5546. // If event should be done only once, remove it.
  5547. if (event.onlyOnce) {
  5548. events.splice(index, 1);
  5549. index--;
  5550. }
  5551. event.isDone = true;
  5552. event.action(currentFrame);
  5553. } // Don't do anything if the event has already be done.
  5554. }
  5555. }
  5556. if (!returnValue) {
  5557. this._stopped = true;
  5558. }
  5559. return returnValue;
  5560. };
  5561. return RuntimeAnimation;
  5562. }());
  5563. /***/ }),
  5564. /***/ "./Audio/analyser.ts":
  5565. /*!***************************!*\
  5566. !*** ./Audio/analyser.ts ***!
  5567. \***************************/
  5568. /*! exports provided: Analyser */
  5569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5570. "use strict";
  5571. __webpack_require__.r(__webpack_exports__);
  5572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5573. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5574. /**
  5575. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5577. */
  5578. var Analyser = /** @class */ (function () {
  5579. /**
  5580. * Creates a new analyser
  5581. * @param scene defines hosting scene
  5582. */
  5583. function Analyser(scene) {
  5584. /**
  5585. * Gets or sets the smoothing
  5586. * @ignorenaming
  5587. */
  5588. this.SMOOTHING = 0.75;
  5589. /**
  5590. * Gets or sets the FFT table size
  5591. * @ignorenaming
  5592. */
  5593. this.FFT_SIZE = 512;
  5594. /**
  5595. * Gets or sets the bar graph amplitude
  5596. * @ignorenaming
  5597. */
  5598. this.BARGRAPHAMPLITUDE = 256;
  5599. /**
  5600. * Gets or sets the position of the debug canvas
  5601. * @ignorenaming
  5602. */
  5603. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5604. /**
  5605. * Gets or sets the debug canvas size
  5606. * @ignorenaming
  5607. */
  5608. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5609. this._scene = scene;
  5610. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5611. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5612. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5613. this._webAudioAnalyser.minDecibels = -140;
  5614. this._webAudioAnalyser.maxDecibels = 0;
  5615. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5616. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5617. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5618. }
  5619. }
  5620. /**
  5621. * Get the number of data values you will have to play with for the visualization
  5622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5623. * @returns a number
  5624. */
  5625. Analyser.prototype.getFrequencyBinCount = function () {
  5626. if (this._audioEngine.canUseWebAudio) {
  5627. return this._webAudioAnalyser.frequencyBinCount;
  5628. }
  5629. else {
  5630. return 0;
  5631. }
  5632. };
  5633. /**
  5634. * Gets the current frequency data as a byte array
  5635. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5636. * @returns a Uint8Array
  5637. */
  5638. Analyser.prototype.getByteFrequencyData = function () {
  5639. if (this._audioEngine.canUseWebAudio) {
  5640. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5641. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5642. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5643. }
  5644. return this._byteFreqs;
  5645. };
  5646. /**
  5647. * Gets the current waveform as a byte array
  5648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5649. * @returns a Uint8Array
  5650. */
  5651. Analyser.prototype.getByteTimeDomainData = function () {
  5652. if (this._audioEngine.canUseWebAudio) {
  5653. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5654. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5655. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5656. }
  5657. return this._byteTime;
  5658. };
  5659. /**
  5660. * Gets the current frequency data as a float array
  5661. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5662. * @returns a Float32Array
  5663. */
  5664. Analyser.prototype.getFloatFrequencyData = function () {
  5665. if (this._audioEngine.canUseWebAudio) {
  5666. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5667. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5668. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5669. }
  5670. return this._floatFreqs;
  5671. };
  5672. /**
  5673. * Renders the debug canvas
  5674. */
  5675. Analyser.prototype.drawDebugCanvas = function () {
  5676. var _this = this;
  5677. if (this._audioEngine.canUseWebAudio) {
  5678. if (!this._debugCanvas) {
  5679. this._debugCanvas = document.createElement("canvas");
  5680. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5681. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5682. this._debugCanvas.style.position = "absolute";
  5683. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5684. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5685. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5686. document.body.appendChild(this._debugCanvas);
  5687. this._registerFunc = function () {
  5688. _this.drawDebugCanvas();
  5689. };
  5690. this._scene.registerBeforeRender(this._registerFunc);
  5691. }
  5692. if (this._registerFunc && this._debugCanvasContext) {
  5693. var workingArray = this.getByteFrequencyData();
  5694. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5695. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5696. // Draw the frequency domain chart.
  5697. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5698. var value = workingArray[i];
  5699. var percent = value / this.BARGRAPHAMPLITUDE;
  5700. var height = this.DEBUGCANVASSIZE.height * percent;
  5701. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5702. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5703. var hue = i / this.getFrequencyBinCount() * 360;
  5704. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5705. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5706. }
  5707. }
  5708. }
  5709. };
  5710. /**
  5711. * Stops rendering the debug canvas and removes it
  5712. */
  5713. Analyser.prototype.stopDebugCanvas = function () {
  5714. if (this._debugCanvas) {
  5715. if (this._registerFunc) {
  5716. this._scene.unregisterBeforeRender(this._registerFunc);
  5717. this._registerFunc = null;
  5718. }
  5719. document.body.removeChild(this._debugCanvas);
  5720. this._debugCanvas = null;
  5721. this._debugCanvasContext = null;
  5722. }
  5723. };
  5724. /**
  5725. * Connects two audio nodes
  5726. * @param inputAudioNode defines first node to connect
  5727. * @param outputAudioNode defines second node to connect
  5728. */
  5729. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5730. if (this._audioEngine.canUseWebAudio) {
  5731. inputAudioNode.connect(this._webAudioAnalyser);
  5732. this._webAudioAnalyser.connect(outputAudioNode);
  5733. }
  5734. };
  5735. /**
  5736. * Releases all associated resources
  5737. */
  5738. Analyser.prototype.dispose = function () {
  5739. if (this._audioEngine.canUseWebAudio) {
  5740. this._webAudioAnalyser.disconnect();
  5741. }
  5742. };
  5743. return Analyser;
  5744. }());
  5745. /***/ }),
  5746. /***/ "./Audio/audioEngine.ts":
  5747. /*!******************************!*\
  5748. !*** ./Audio/audioEngine.ts ***!
  5749. \******************************/
  5750. /*! exports provided: AudioEngine */
  5751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5752. "use strict";
  5753. __webpack_require__.r(__webpack_exports__);
  5754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5755. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5756. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5757. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5758. // Sets the default audio engine to Babylon.js
  5759. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5760. /**
  5761. * This represents the default audio engine used in babylon.
  5762. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5764. */
  5765. var AudioEngine = /** @class */ (function () {
  5766. /**
  5767. * Instantiates a new audio engine.
  5768. *
  5769. * There should be only one per page as some browsers restrict the number
  5770. * of audio contexts you can create.
  5771. * @param hostElement defines the host element where to display the mute icon if necessary
  5772. */
  5773. function AudioEngine(hostElement) {
  5774. if (hostElement === void 0) { hostElement = null; }
  5775. var _this = this;
  5776. this._audioContext = null;
  5777. this._audioContextInitialized = false;
  5778. this._muteButton = null;
  5779. /**
  5780. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5781. */
  5782. this.canUseWebAudio = false;
  5783. /**
  5784. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5785. * @ignoreNaming
  5786. */
  5787. this.WarnedWebAudioUnsupported = false;
  5788. /**
  5789. * Gets whether or not mp3 are supported by your browser.
  5790. */
  5791. this.isMP3supported = false;
  5792. /**
  5793. * Gets whether or not ogg are supported by your browser.
  5794. */
  5795. this.isOGGsupported = false;
  5796. /**
  5797. * Gets whether audio has been unlocked on the device.
  5798. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5799. * a user interaction has happened.
  5800. */
  5801. this.unlocked = true;
  5802. /**
  5803. * Defines if the audio engine relies on a custom unlocked button.
  5804. * In this case, the embedded button will not be displayed.
  5805. */
  5806. this.useCustomUnlockedButton = false;
  5807. /**
  5808. * Event raised when audio has been unlocked on the browser.
  5809. */
  5810. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5811. /**
  5812. * Event raised when audio has been locked on the browser.
  5813. */
  5814. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5815. this._tryToRun = false;
  5816. this._onResize = function () {
  5817. _this._moveButtonToTopLeft();
  5818. };
  5819. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5820. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5821. this.canUseWebAudio = true;
  5822. }
  5823. var audioElem = document.createElement('audio');
  5824. this._hostElement = hostElement;
  5825. try {
  5826. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5827. this.isMP3supported = true;
  5828. }
  5829. }
  5830. catch (e) {
  5831. // protect error during capability check.
  5832. }
  5833. try {
  5834. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5835. this.isOGGsupported = true;
  5836. }
  5837. }
  5838. catch (e) {
  5839. // protect error during capability check.
  5840. }
  5841. }
  5842. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5843. /**
  5844. * Gets the current AudioContext if available.
  5845. */
  5846. get: function () {
  5847. if (!this._audioContextInitialized) {
  5848. this._initializeAudioContext();
  5849. }
  5850. else {
  5851. if (!this.unlocked && !this._muteButton) {
  5852. this._displayMuteButton();
  5853. }
  5854. }
  5855. return this._audioContext;
  5856. },
  5857. enumerable: true,
  5858. configurable: true
  5859. });
  5860. /**
  5861. * Flags the audio engine in Locked state.
  5862. * This happens due to new browser policies preventing audio to autoplay.
  5863. */
  5864. AudioEngine.prototype.lock = function () {
  5865. this._triggerSuspendedState();
  5866. };
  5867. /**
  5868. * Unlocks the audio engine once a user action has been done on the dom.
  5869. * This is helpful to resume play once browser policies have been satisfied.
  5870. */
  5871. AudioEngine.prototype.unlock = function () {
  5872. this._triggerRunningState();
  5873. };
  5874. AudioEngine.prototype._resumeAudioContext = function () {
  5875. var result;
  5876. if (this._audioContext.resume) {
  5877. result = this._audioContext.resume();
  5878. }
  5879. return result || Promise.resolve();
  5880. };
  5881. AudioEngine.prototype._initializeAudioContext = function () {
  5882. try {
  5883. if (this.canUseWebAudio) {
  5884. this._audioContext = new AudioContext();
  5885. // create a global volume gain node
  5886. this.masterGain = this._audioContext.createGain();
  5887. this.masterGain.gain.value = 1;
  5888. this.masterGain.connect(this._audioContext.destination);
  5889. this._audioContextInitialized = true;
  5890. if (this._audioContext.state === "running") {
  5891. // Do not wait for the promise to unlock.
  5892. this._triggerRunningState();
  5893. }
  5894. }
  5895. }
  5896. catch (e) {
  5897. this.canUseWebAudio = false;
  5898. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5899. }
  5900. };
  5901. AudioEngine.prototype._triggerRunningState = function () {
  5902. var _this = this;
  5903. if (this._tryToRun) {
  5904. return;
  5905. }
  5906. this._tryToRun = true;
  5907. this._resumeAudioContext()
  5908. .then(function () {
  5909. _this._tryToRun = false;
  5910. if (_this._muteButton) {
  5911. _this._hideMuteButton();
  5912. }
  5913. }).catch(function () {
  5914. _this._tryToRun = false;
  5915. _this.unlocked = false;
  5916. });
  5917. // Notify users that the audio stack is unlocked/unmuted
  5918. this.unlocked = true;
  5919. this.onAudioUnlockedObservable.notifyObservers(this);
  5920. };
  5921. AudioEngine.prototype._triggerSuspendedState = function () {
  5922. this.unlocked = false;
  5923. this.onAudioLockedObservable.notifyObservers(this);
  5924. this._displayMuteButton();
  5925. };
  5926. AudioEngine.prototype._displayMuteButton = function () {
  5927. var _this = this;
  5928. if (this.useCustomUnlockedButton || this._muteButton) {
  5929. return;
  5930. }
  5931. this._muteButton = document.createElement("BUTTON");
  5932. this._muteButton.className = "babylonUnmuteIcon";
  5933. this._muteButton.id = "babylonUnmuteIconBtn";
  5934. this._muteButton.title = "Unmute";
  5935. 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) }";
  5936. var style = document.createElement('style');
  5937. style.appendChild(document.createTextNode(css));
  5938. document.getElementsByTagName('head')[0].appendChild(style);
  5939. document.body.appendChild(this._muteButton);
  5940. this._moveButtonToTopLeft();
  5941. this._muteButton.addEventListener('touchend', function () {
  5942. _this._triggerRunningState();
  5943. }, true);
  5944. this._muteButton.addEventListener('click', function () {
  5945. _this._triggerRunningState();
  5946. }, true);
  5947. window.addEventListener("resize", this._onResize);
  5948. };
  5949. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5950. if (this._hostElement && this._muteButton) {
  5951. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5952. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5953. }
  5954. };
  5955. AudioEngine.prototype._hideMuteButton = function () {
  5956. if (this._muteButton) {
  5957. document.body.removeChild(this._muteButton);
  5958. this._muteButton = null;
  5959. }
  5960. };
  5961. /**
  5962. * Destroy and release the resources associated with the audio ccontext.
  5963. */
  5964. AudioEngine.prototype.dispose = function () {
  5965. if (this.canUseWebAudio && this._audioContextInitialized) {
  5966. if (this._connectedAnalyser && this._audioContext) {
  5967. this._connectedAnalyser.stopDebugCanvas();
  5968. this._connectedAnalyser.dispose();
  5969. this.masterGain.disconnect();
  5970. this.masterGain.connect(this._audioContext.destination);
  5971. this._connectedAnalyser = null;
  5972. }
  5973. this.masterGain.gain.value = 1;
  5974. }
  5975. this.WarnedWebAudioUnsupported = false;
  5976. this._hideMuteButton();
  5977. window.removeEventListener("resize", this._onResize);
  5978. this.onAudioUnlockedObservable.clear();
  5979. this.onAudioLockedObservable.clear();
  5980. };
  5981. /**
  5982. * Gets the global volume sets on the master gain.
  5983. * @returns the global volume if set or -1 otherwise
  5984. */
  5985. AudioEngine.prototype.getGlobalVolume = function () {
  5986. if (this.canUseWebAudio && this._audioContextInitialized) {
  5987. return this.masterGain.gain.value;
  5988. }
  5989. else {
  5990. return -1;
  5991. }
  5992. };
  5993. /**
  5994. * Sets the global volume of your experience (sets on the master gain).
  5995. * @param newVolume Defines the new global volume of the application
  5996. */
  5997. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5998. if (this.canUseWebAudio && this._audioContextInitialized) {
  5999. this.masterGain.gain.value = newVolume;
  6000. }
  6001. };
  6002. /**
  6003. * Connect the audio engine to an audio analyser allowing some amazing
  6004. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6006. * @param analyser The analyser to connect to the engine
  6007. */
  6008. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6009. if (this._connectedAnalyser) {
  6010. this._connectedAnalyser.stopDebugCanvas();
  6011. }
  6012. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6013. this._connectedAnalyser = analyser;
  6014. this.masterGain.disconnect();
  6015. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6016. }
  6017. };
  6018. return AudioEngine;
  6019. }());
  6020. /***/ }),
  6021. /***/ "./Audio/audioSceneComponent.ts":
  6022. /*!**************************************!*\
  6023. !*** ./Audio/audioSceneComponent.ts ***!
  6024. \**************************************/
  6025. /*! exports provided: AudioSceneComponent */
  6026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6027. "use strict";
  6028. __webpack_require__.r(__webpack_exports__);
  6029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6030. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6031. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6032. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6033. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6034. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6035. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6036. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6037. // Adds the parser to the scene parsers.
  6038. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6039. // TODO: add sound
  6040. var loadedSounds = [];
  6041. var loadedSound;
  6042. container.sounds = container.sounds || [];
  6043. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6044. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6045. var parsedSound = parsedData.sounds[index];
  6046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6047. if (!parsedSound.url) {
  6048. parsedSound.url = parsedSound.name;
  6049. }
  6050. if (!loadedSounds[parsedSound.url]) {
  6051. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6052. loadedSounds[parsedSound.url] = loadedSound;
  6053. container.sounds.push(loadedSound);
  6054. }
  6055. else {
  6056. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6057. }
  6058. }
  6059. else {
  6060. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6061. }
  6062. }
  6063. }
  6064. loadedSounds = [];
  6065. });
  6066. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6067. get: function () {
  6068. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6069. if (!compo) {
  6070. compo = new AudioSceneComponent(this);
  6071. this._addComponent(compo);
  6072. }
  6073. if (!this._mainSoundTrack) {
  6074. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6075. }
  6076. return this._mainSoundTrack;
  6077. },
  6078. enumerable: true,
  6079. configurable: true
  6080. });
  6081. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6082. var index;
  6083. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6084. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6085. return this.mainSoundTrack.soundCollection[index];
  6086. }
  6087. }
  6088. if (this.soundTracks) {
  6089. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6090. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6091. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6092. return this.soundTracks[sdIndex].soundCollection[index];
  6093. }
  6094. }
  6095. }
  6096. }
  6097. return null;
  6098. };
  6099. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6100. get: function () {
  6101. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6102. if (!compo) {
  6103. compo = new AudioSceneComponent(this);
  6104. this._addComponent(compo);
  6105. }
  6106. return compo.audioEnabled;
  6107. },
  6108. set: function (value) {
  6109. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6110. if (!compo) {
  6111. compo = new AudioSceneComponent(this);
  6112. this._addComponent(compo);
  6113. }
  6114. if (value) {
  6115. compo.enableAudio();
  6116. }
  6117. else {
  6118. compo.disableAudio();
  6119. }
  6120. },
  6121. enumerable: true,
  6122. configurable: true
  6123. });
  6124. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6125. get: function () {
  6126. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6127. if (!compo) {
  6128. compo = new AudioSceneComponent(this);
  6129. this._addComponent(compo);
  6130. }
  6131. return compo.headphone;
  6132. },
  6133. set: function (value) {
  6134. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6135. if (!compo) {
  6136. compo = new AudioSceneComponent(this);
  6137. this._addComponent(compo);
  6138. }
  6139. if (value) {
  6140. compo.switchAudioModeForHeadphones();
  6141. }
  6142. else {
  6143. compo.switchAudioModeForNormalSpeakers();
  6144. }
  6145. },
  6146. enumerable: true,
  6147. configurable: true
  6148. });
  6149. /**
  6150. * Defines the sound scene component responsible to manage any sounds
  6151. * in a given scene.
  6152. */
  6153. var AudioSceneComponent = /** @class */ (function () {
  6154. /**
  6155. * Creates a new instance of the component for the given scene
  6156. * @param scene Defines the scene to register the component in
  6157. */
  6158. function AudioSceneComponent(scene) {
  6159. /**
  6160. * The component name helpfull to identify the component in the list of scene components.
  6161. */
  6162. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6163. this._audioEnabled = true;
  6164. this._headphone = false;
  6165. this.scene = scene;
  6166. scene.soundTracks = new Array();
  6167. scene.sounds = new Array();
  6168. }
  6169. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6170. /**
  6171. * Gets whether audio is enabled or not.
  6172. * Please use related enable/disable method to switch state.
  6173. */
  6174. get: function () {
  6175. return this._audioEnabled;
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6181. /**
  6182. * Gets whether audio is outputing to headphone or not.
  6183. * Please use the according Switch methods to change output.
  6184. */
  6185. get: function () {
  6186. return this._headphone;
  6187. },
  6188. enumerable: true,
  6189. configurable: true
  6190. });
  6191. /**
  6192. * Registers the component in a given scene
  6193. */
  6194. AudioSceneComponent.prototype.register = function () {
  6195. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6196. };
  6197. /**
  6198. * Rebuilds the elements related to this component in case of
  6199. * context lost for instance.
  6200. */
  6201. AudioSceneComponent.prototype.rebuild = function () {
  6202. // Nothing to do here. (Not rendering related)
  6203. };
  6204. /**
  6205. * Serializes the component data to the specified json object
  6206. * @param serializationObject The object to serialize to
  6207. */
  6208. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6209. serializationObject.sounds = [];
  6210. if (this.scene.soundTracks) {
  6211. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6212. var soundtrack = this.scene.soundTracks[index];
  6213. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6214. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6215. }
  6216. }
  6217. }
  6218. };
  6219. /**
  6220. * Adds all the element from the container to the scene
  6221. * @param container the container holding the elements
  6222. */
  6223. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6224. var _this = this;
  6225. if (!container.sounds) {
  6226. return;
  6227. }
  6228. container.sounds.forEach(function (sound) {
  6229. sound.play();
  6230. sound.autoplay = true;
  6231. _this.scene.mainSoundTrack.AddSound(sound);
  6232. });
  6233. };
  6234. /**
  6235. * Removes all the elements in the container from the scene
  6236. * @param container contains the elements to remove
  6237. */
  6238. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6239. var _this = this;
  6240. if (!container.sounds) {
  6241. return;
  6242. }
  6243. container.sounds.forEach(function (sound) {
  6244. sound.stop();
  6245. sound.autoplay = false;
  6246. _this.scene.mainSoundTrack.RemoveSound(sound);
  6247. });
  6248. };
  6249. /**
  6250. * Disposes the component and the associated ressources.
  6251. */
  6252. AudioSceneComponent.prototype.dispose = function () {
  6253. var scene = this.scene;
  6254. if (scene._mainSoundTrack) {
  6255. scene.mainSoundTrack.dispose();
  6256. }
  6257. if (scene.soundTracks) {
  6258. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6259. scene.soundTracks[scIndex].dispose();
  6260. }
  6261. }
  6262. };
  6263. /**
  6264. * Disables audio in the associated scene.
  6265. */
  6266. AudioSceneComponent.prototype.disableAudio = function () {
  6267. var scene = this.scene;
  6268. this._audioEnabled = false;
  6269. var i;
  6270. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6271. scene.mainSoundTrack.soundCollection[i].pause();
  6272. }
  6273. if (scene.soundTracks) {
  6274. for (i = 0; i < scene.soundTracks.length; i++) {
  6275. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6276. scene.soundTracks[i].soundCollection[j].pause();
  6277. }
  6278. }
  6279. }
  6280. };
  6281. /**
  6282. * Enables audio in the associated scene.
  6283. */
  6284. AudioSceneComponent.prototype.enableAudio = function () {
  6285. var scene = this.scene;
  6286. this._audioEnabled = true;
  6287. var i;
  6288. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6289. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6290. scene.mainSoundTrack.soundCollection[i].play();
  6291. }
  6292. }
  6293. if (scene.soundTracks) {
  6294. for (i = 0; i < scene.soundTracks.length; i++) {
  6295. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6296. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6297. scene.soundTracks[i].soundCollection[j].play();
  6298. }
  6299. }
  6300. }
  6301. }
  6302. };
  6303. /**
  6304. * Switch audio to headphone output.
  6305. */
  6306. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6307. var scene = this.scene;
  6308. this._headphone = true;
  6309. scene.mainSoundTrack.switchPanningModelToHRTF();
  6310. if (scene.soundTracks) {
  6311. for (var i = 0; i < scene.soundTracks.length; i++) {
  6312. scene.soundTracks[i].switchPanningModelToHRTF();
  6313. }
  6314. }
  6315. };
  6316. /**
  6317. * Switch audio to normal speakers.
  6318. */
  6319. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6320. var scene = this.scene;
  6321. this._headphone = false;
  6322. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6323. if (scene.soundTracks) {
  6324. for (var i = 0; i < scene.soundTracks.length; i++) {
  6325. scene.soundTracks[i].switchPanningModelToEqualPower();
  6326. }
  6327. }
  6328. };
  6329. AudioSceneComponent.prototype._afterRender = function () {
  6330. var scene = this.scene;
  6331. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6332. return;
  6333. }
  6334. var listeningCamera;
  6335. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6336. if (scene.activeCameras.length > 0) {
  6337. listeningCamera = scene.activeCameras[0];
  6338. }
  6339. else {
  6340. listeningCamera = scene.activeCamera;
  6341. }
  6342. if (listeningCamera && audioEngine.audioContext) {
  6343. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6344. // for VR cameras
  6345. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6346. listeningCamera = listeningCamera.rigCameras[0];
  6347. }
  6348. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6349. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6350. cameraDirection.normalize();
  6351. // To avoid some errors on GearVR
  6352. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6353. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6354. }
  6355. var i;
  6356. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6357. var sound = scene.mainSoundTrack.soundCollection[i];
  6358. if (sound.useCustomAttenuation) {
  6359. sound.updateDistanceFromListener();
  6360. }
  6361. }
  6362. if (scene.soundTracks) {
  6363. for (i = 0; i < scene.soundTracks.length; i++) {
  6364. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6365. sound = scene.soundTracks[i].soundCollection[j];
  6366. if (sound.useCustomAttenuation) {
  6367. sound.updateDistanceFromListener();
  6368. }
  6369. }
  6370. }
  6371. }
  6372. }
  6373. };
  6374. return AudioSceneComponent;
  6375. }());
  6376. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6377. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6378. if (!compo) {
  6379. compo = new AudioSceneComponent(scene);
  6380. scene._addComponent(compo);
  6381. }
  6382. };
  6383. /***/ }),
  6384. /***/ "./Audio/index.ts":
  6385. /*!************************!*\
  6386. !*** ./Audio/index.ts ***!
  6387. \************************/
  6388. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6390. "use strict";
  6391. __webpack_require__.r(__webpack_exports__);
  6392. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6394. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6396. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6398. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6400. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6402. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6404. /***/ }),
  6405. /***/ "./Audio/sound.ts":
  6406. /*!************************!*\
  6407. !*** ./Audio/sound.ts ***!
  6408. \************************/
  6409. /*! exports provided: Sound */
  6410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6411. "use strict";
  6412. __webpack_require__.r(__webpack_exports__);
  6413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6414. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6415. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6416. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6417. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6418. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6419. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6420. /**
  6421. * Defines a sound that can be played in the application.
  6422. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6424. */
  6425. var Sound = /** @class */ (function () {
  6426. /**
  6427. * Create a sound and attach it to a scene
  6428. * @param name Name of your sound
  6429. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6430. * @param scene defines the scene the sound belongs to
  6431. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6432. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6433. */
  6434. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6435. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6436. var _this = this;
  6437. /**
  6438. * Does the sound autoplay once loaded.
  6439. */
  6440. this.autoplay = false;
  6441. /**
  6442. * Does the sound loop after it finishes playing once.
  6443. */
  6444. this.loop = false;
  6445. /**
  6446. * Does the sound use a custom attenuation curve to simulate the falloff
  6447. * happening when the source gets further away from the camera.
  6448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6449. */
  6450. this.useCustomAttenuation = false;
  6451. /**
  6452. * Is this sound currently played.
  6453. */
  6454. this.isPlaying = false;
  6455. /**
  6456. * Is this sound currently paused.
  6457. */
  6458. this.isPaused = false;
  6459. /**
  6460. * Does this sound enables spatial sound.
  6461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6462. */
  6463. this.spatialSound = false;
  6464. /**
  6465. * Define the reference distance the sound should be heard perfectly.
  6466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6467. */
  6468. this.refDistance = 1;
  6469. /**
  6470. * Define the roll off factor of spatial sounds.
  6471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6472. */
  6473. this.rolloffFactor = 1;
  6474. /**
  6475. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6477. */
  6478. this.maxDistance = 100;
  6479. /**
  6480. * Define the distance attenuation model the sound will follow.
  6481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6482. */
  6483. this.distanceModel = "linear";
  6484. /**
  6485. * Observable event when the current playing sound finishes.
  6486. */
  6487. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6488. this._panningModel = "equalpower";
  6489. this._playbackRate = 1;
  6490. this._streaming = false;
  6491. this._startTime = 0;
  6492. this._startOffset = 0;
  6493. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6494. /** @hidden */
  6495. this._positionInEmitterSpace = false;
  6496. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6497. this._volume = 1;
  6498. this._isReadyToPlay = false;
  6499. this._isDirectional = false;
  6500. // Used if you'd like to create a directional sound.
  6501. // If not set, the sound will be omnidirectional
  6502. this._coneInnerAngle = 360;
  6503. this._coneOuterAngle = 360;
  6504. this._coneOuterGain = 0;
  6505. this._isOutputConnected = false;
  6506. this._urlType = "Unknown";
  6507. this.name = name;
  6508. this._scene = scene;
  6509. Sound._SceneComponentInitialization(scene);
  6510. this._readyToPlayCallback = readyToPlayCallback;
  6511. // Default custom attenuation function is a linear attenuation
  6512. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6513. if (currentDistance < maxDistance) {
  6514. return currentVolume * (1 - currentDistance / maxDistance);
  6515. }
  6516. else {
  6517. return 0;
  6518. }
  6519. };
  6520. if (options) {
  6521. this.autoplay = options.autoplay || false;
  6522. this.loop = options.loop || false;
  6523. // if volume === 0, we need another way to check this option
  6524. if (options.volume !== undefined) {
  6525. this._volume = options.volume;
  6526. }
  6527. this.spatialSound = options.spatialSound || false;
  6528. this.maxDistance = options.maxDistance || 100;
  6529. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6530. this.rolloffFactor = options.rolloffFactor || 1;
  6531. this.refDistance = options.refDistance || 1;
  6532. this.distanceModel = options.distanceModel || "linear";
  6533. this._playbackRate = options.playbackRate || 1;
  6534. this._streaming = options.streaming || false;
  6535. }
  6536. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6537. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6538. this._soundGain.gain.value = this._volume;
  6539. this._inputAudioNode = this._soundGain;
  6540. this._outputAudioNode = this._soundGain;
  6541. if (this.spatialSound) {
  6542. this._createSpatialParameters();
  6543. }
  6544. this._scene.mainSoundTrack.AddSound(this);
  6545. var validParameter = true;
  6546. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6547. if (urlOrArrayBuffer) {
  6548. try {
  6549. if (typeof (urlOrArrayBuffer) === "string") {
  6550. this._urlType = "String";
  6551. }
  6552. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6553. this._urlType = "ArrayBuffer";
  6554. }
  6555. else if (urlOrArrayBuffer instanceof MediaStream) {
  6556. this._urlType = "MediaStream";
  6557. }
  6558. else if (Array.isArray(urlOrArrayBuffer)) {
  6559. this._urlType = "Array";
  6560. }
  6561. var urls = [];
  6562. var codecSupportedFound = false;
  6563. switch (this._urlType) {
  6564. case "MediaStream":
  6565. this._streaming = true;
  6566. this._isReadyToPlay = true;
  6567. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6568. if (this.autoplay) {
  6569. this.play();
  6570. }
  6571. if (this._readyToPlayCallback) {
  6572. this._readyToPlayCallback();
  6573. }
  6574. break;
  6575. case "ArrayBuffer":
  6576. if (urlOrArrayBuffer.byteLength > 0) {
  6577. codecSupportedFound = true;
  6578. this._soundLoaded(urlOrArrayBuffer);
  6579. }
  6580. break;
  6581. case "String":
  6582. urls.push(urlOrArrayBuffer);
  6583. case "Array":
  6584. if (urls.length === 0) {
  6585. urls = urlOrArrayBuffer;
  6586. }
  6587. // If we found a supported format, we load it immediately and stop the loop
  6588. for (var i = 0; i < urls.length; i++) {
  6589. var url = urls[i];
  6590. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6591. codecSupportedFound = true;
  6592. }
  6593. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6594. codecSupportedFound = true;
  6595. }
  6596. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6597. codecSupportedFound = true;
  6598. }
  6599. if (url.indexOf("blob:") !== -1) {
  6600. codecSupportedFound = true;
  6601. }
  6602. if (codecSupportedFound) {
  6603. // Loading sound using XHR2
  6604. if (!this._streaming) {
  6605. this._scene._loadFile(url, function (data) {
  6606. _this._soundLoaded(data);
  6607. }, undefined, true, true, function (exception) {
  6608. if (exception) {
  6609. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6610. }
  6611. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6612. _this._scene.mainSoundTrack.RemoveSound(_this);
  6613. });
  6614. }
  6615. // Streaming sound using HTML5 Audio tag
  6616. else {
  6617. this._htmlAudioElement = new Audio(url);
  6618. this._htmlAudioElement.controls = false;
  6619. this._htmlAudioElement.loop = this.loop;
  6620. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6621. this._htmlAudioElement.preload = "auto";
  6622. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6623. _this._isReadyToPlay = true;
  6624. if (_this.autoplay) {
  6625. _this.play();
  6626. }
  6627. if (_this._readyToPlayCallback) {
  6628. _this._readyToPlayCallback();
  6629. }
  6630. });
  6631. document.body.appendChild(this._htmlAudioElement);
  6632. this._htmlAudioElement.load();
  6633. }
  6634. break;
  6635. }
  6636. }
  6637. break;
  6638. default:
  6639. validParameter = false;
  6640. break;
  6641. }
  6642. if (!validParameter) {
  6643. _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.");
  6644. }
  6645. else {
  6646. if (!codecSupportedFound) {
  6647. this._isReadyToPlay = true;
  6648. // Simulating a ready to play event to avoid breaking code path
  6649. if (this._readyToPlayCallback) {
  6650. window.setTimeout(function () {
  6651. if (_this._readyToPlayCallback) {
  6652. _this._readyToPlayCallback();
  6653. }
  6654. }, 1000);
  6655. }
  6656. }
  6657. }
  6658. }
  6659. catch (ex) {
  6660. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6661. this._scene.mainSoundTrack.RemoveSound(this);
  6662. }
  6663. }
  6664. }
  6665. else {
  6666. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6667. this._scene.mainSoundTrack.AddSound(this);
  6668. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6669. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6670. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6671. }
  6672. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6673. if (this._readyToPlayCallback) {
  6674. window.setTimeout(function () {
  6675. if (_this._readyToPlayCallback) {
  6676. _this._readyToPlayCallback();
  6677. }
  6678. }, 1000);
  6679. }
  6680. }
  6681. }
  6682. /**
  6683. * Release the sound and its associated resources
  6684. */
  6685. Sound.prototype.dispose = function () {
  6686. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6687. if (this.isPlaying) {
  6688. this.stop();
  6689. }
  6690. this._isReadyToPlay = false;
  6691. if (this.soundTrackId === -1) {
  6692. this._scene.mainSoundTrack.RemoveSound(this);
  6693. }
  6694. else if (this._scene.soundTracks) {
  6695. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6696. }
  6697. if (this._soundGain) {
  6698. this._soundGain.disconnect();
  6699. this._soundGain = null;
  6700. }
  6701. if (this._soundPanner) {
  6702. this._soundPanner.disconnect();
  6703. this._soundPanner = null;
  6704. }
  6705. if (this._soundSource) {
  6706. this._soundSource.disconnect();
  6707. this._soundSource = null;
  6708. }
  6709. this._audioBuffer = null;
  6710. if (this._htmlAudioElement) {
  6711. this._htmlAudioElement.pause();
  6712. this._htmlAudioElement.src = "";
  6713. document.body.removeChild(this._htmlAudioElement);
  6714. }
  6715. if (this._streamingSource) {
  6716. this._streamingSource.disconnect();
  6717. }
  6718. if (this._connectedTransformNode && this._registerFunc) {
  6719. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6720. this._connectedTransformNode = null;
  6721. }
  6722. }
  6723. };
  6724. /**
  6725. * Gets if the sounds is ready to be played or not.
  6726. * @returns true if ready, otherwise false
  6727. */
  6728. Sound.prototype.isReady = function () {
  6729. return this._isReadyToPlay;
  6730. };
  6731. Sound.prototype._soundLoaded = function (audioData) {
  6732. var _this = this;
  6733. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6734. return;
  6735. }
  6736. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6737. _this._audioBuffer = buffer;
  6738. _this._isReadyToPlay = true;
  6739. if (_this.autoplay) {
  6740. _this.play();
  6741. }
  6742. if (_this._readyToPlayCallback) {
  6743. _this._readyToPlayCallback();
  6744. }
  6745. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6746. };
  6747. /**
  6748. * Sets the data of the sound from an audiobuffer
  6749. * @param audioBuffer The audioBuffer containing the data
  6750. */
  6751. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6752. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6753. this._audioBuffer = audioBuffer;
  6754. this._isReadyToPlay = true;
  6755. }
  6756. };
  6757. /**
  6758. * Updates the current sounds options such as maxdistance, loop...
  6759. * @param options A JSON object containing values named as the object properties
  6760. */
  6761. Sound.prototype.updateOptions = function (options) {
  6762. if (options) {
  6763. this.loop = options.loop || this.loop;
  6764. this.maxDistance = options.maxDistance || this.maxDistance;
  6765. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6766. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6767. this.refDistance = options.refDistance || this.refDistance;
  6768. this.distanceModel = options.distanceModel || this.distanceModel;
  6769. this._playbackRate = options.playbackRate || this._playbackRate;
  6770. this._updateSpatialParameters();
  6771. if (this.isPlaying) {
  6772. if (this._streaming && this._htmlAudioElement) {
  6773. this._htmlAudioElement.playbackRate = this._playbackRate;
  6774. }
  6775. else {
  6776. if (this._soundSource) {
  6777. this._soundSource.playbackRate.value = this._playbackRate;
  6778. }
  6779. }
  6780. }
  6781. }
  6782. };
  6783. Sound.prototype._createSpatialParameters = function () {
  6784. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6785. if (this._scene.headphone) {
  6786. this._panningModel = "HRTF";
  6787. }
  6788. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6789. this._updateSpatialParameters();
  6790. this._soundPanner.connect(this._outputAudioNode);
  6791. this._inputAudioNode = this._soundPanner;
  6792. }
  6793. };
  6794. Sound.prototype._updateSpatialParameters = function () {
  6795. if (this.spatialSound && this._soundPanner) {
  6796. if (this.useCustomAttenuation) {
  6797. // Tricks to disable in a way embedded Web Audio attenuation
  6798. this._soundPanner.distanceModel = "linear";
  6799. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6800. this._soundPanner.refDistance = 1;
  6801. this._soundPanner.rolloffFactor = 1;
  6802. this._soundPanner.panningModel = this._panningModel;
  6803. }
  6804. else {
  6805. this._soundPanner.distanceModel = this.distanceModel;
  6806. this._soundPanner.maxDistance = this.maxDistance;
  6807. this._soundPanner.refDistance = this.refDistance;
  6808. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6809. this._soundPanner.panningModel = this._panningModel;
  6810. }
  6811. }
  6812. };
  6813. /**
  6814. * Switch the panning model to HRTF:
  6815. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6817. */
  6818. Sound.prototype.switchPanningModelToHRTF = function () {
  6819. this._panningModel = "HRTF";
  6820. this._switchPanningModel();
  6821. };
  6822. /**
  6823. * Switch the panning model to Equal Power:
  6824. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6826. */
  6827. Sound.prototype.switchPanningModelToEqualPower = function () {
  6828. this._panningModel = "equalpower";
  6829. this._switchPanningModel();
  6830. };
  6831. Sound.prototype._switchPanningModel = function () {
  6832. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6833. this._soundPanner.panningModel = this._panningModel;
  6834. }
  6835. };
  6836. /**
  6837. * Connect this sound to a sound track audio node like gain...
  6838. * @param soundTrackAudioNode the sound track audio node to connect to
  6839. */
  6840. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6841. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6842. if (this._isOutputConnected) {
  6843. this._outputAudioNode.disconnect();
  6844. }
  6845. this._outputAudioNode.connect(soundTrackAudioNode);
  6846. this._isOutputConnected = true;
  6847. }
  6848. };
  6849. /**
  6850. * Transform this sound into a directional source
  6851. * @param coneInnerAngle Size of the inner cone in degree
  6852. * @param coneOuterAngle Size of the outer cone in degree
  6853. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6854. */
  6855. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6856. if (coneOuterAngle < coneInnerAngle) {
  6857. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6858. return;
  6859. }
  6860. this._coneInnerAngle = coneInnerAngle;
  6861. this._coneOuterAngle = coneOuterAngle;
  6862. this._coneOuterGain = coneOuterGain;
  6863. this._isDirectional = true;
  6864. if (this.isPlaying && this.loop) {
  6865. this.stop();
  6866. this.play();
  6867. }
  6868. };
  6869. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6870. /**
  6871. * Gets or sets the inner angle for the directional cone.
  6872. */
  6873. get: function () {
  6874. return this._coneInnerAngle;
  6875. },
  6876. /**
  6877. * Gets or sets the inner angle for the directional cone.
  6878. */
  6879. set: function (value) {
  6880. if (value != this._coneInnerAngle) {
  6881. if (this._coneOuterAngle < value) {
  6882. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6883. return;
  6884. }
  6885. this._coneInnerAngle = value;
  6886. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6887. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6888. }
  6889. }
  6890. },
  6891. enumerable: true,
  6892. configurable: true
  6893. });
  6894. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6895. /**
  6896. * Gets or sets the outer angle for the directional cone.
  6897. */
  6898. get: function () {
  6899. return this._coneOuterAngle;
  6900. },
  6901. /**
  6902. * Gets or sets the outer angle for the directional cone.
  6903. */
  6904. set: function (value) {
  6905. if (value != this._coneOuterAngle) {
  6906. if (value < this._coneInnerAngle) {
  6907. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6908. return;
  6909. }
  6910. this._coneOuterAngle = value;
  6911. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6912. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6913. }
  6914. }
  6915. },
  6916. enumerable: true,
  6917. configurable: true
  6918. });
  6919. /**
  6920. * Sets the position of the emitter if spatial sound is enabled
  6921. * @param newPosition Defines the new posisiton
  6922. */
  6923. Sound.prototype.setPosition = function (newPosition) {
  6924. this._position = newPosition;
  6925. 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)) {
  6926. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6927. }
  6928. };
  6929. /**
  6930. * Sets the local direction of the emitter if spatial sound is enabled
  6931. * @param newLocalDirection Defines the new local direction
  6932. */
  6933. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6934. this._localDirection = newLocalDirection;
  6935. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6936. this._updateDirection();
  6937. }
  6938. };
  6939. Sound.prototype._updateDirection = function () {
  6940. if (!this._connectedTransformNode || !this._soundPanner) {
  6941. return;
  6942. }
  6943. var mat = this._connectedTransformNode.getWorldMatrix();
  6944. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6945. direction.normalize();
  6946. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6947. };
  6948. /** @hidden */
  6949. Sound.prototype.updateDistanceFromListener = function () {
  6950. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6951. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6952. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6953. }
  6954. };
  6955. /**
  6956. * Sets a new custom attenuation function for the sound.
  6957. * @param callback Defines the function used for the attenuation
  6958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6959. */
  6960. Sound.prototype.setAttenuationFunction = function (callback) {
  6961. this._customAttenuationFunction = callback;
  6962. };
  6963. /**
  6964. * Play the sound
  6965. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6966. * @param offset (optional) Start the sound setting it at a specific time
  6967. */
  6968. Sound.prototype.play = function (time, offset) {
  6969. var _this = this;
  6970. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6971. try {
  6972. if (this._startOffset < 0) {
  6973. time = -this._startOffset;
  6974. this._startOffset = 0;
  6975. }
  6976. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6977. if (!this._soundSource || !this._streamingSource) {
  6978. if (this.spatialSound && this._soundPanner) {
  6979. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6980. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6981. }
  6982. if (this._isDirectional) {
  6983. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6984. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6985. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6986. if (this._connectedTransformNode) {
  6987. this._updateDirection();
  6988. }
  6989. else {
  6990. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6991. }
  6992. }
  6993. }
  6994. }
  6995. if (this._streaming) {
  6996. if (!this._streamingSource) {
  6997. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6998. this._htmlAudioElement.onended = function () { _this._onended(); };
  6999. this._htmlAudioElement.playbackRate = this._playbackRate;
  7000. }
  7001. this._streamingSource.disconnect();
  7002. this._streamingSource.connect(this._inputAudioNode);
  7003. if (this._htmlAudioElement) {
  7004. // required to manage properly the new suspended default state of Chrome
  7005. // When the option 'streaming: true' is used, we need first to wait for
  7006. // the audio engine to be unlocked by a user gesture before trying to play
  7007. // an HTML Audio elememt
  7008. var tryToPlay = function () {
  7009. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7010. var playPromise = _this._htmlAudioElement.play();
  7011. // In browsers that don’t yet support this functionality,
  7012. // playPromise won’t be defined.
  7013. if (playPromise !== undefined) {
  7014. playPromise.catch(function (error) {
  7015. // Automatic playback failed.
  7016. // Waiting for the audio engine to be unlocked by user click on unmute
  7017. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7018. if (_this.loop || _this.autoplay) {
  7019. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7020. }
  7021. });
  7022. }
  7023. }
  7024. else {
  7025. if (_this.loop || _this.autoplay) {
  7026. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7027. }
  7028. }
  7029. };
  7030. tryToPlay();
  7031. }
  7032. }
  7033. else {
  7034. var tryToPlay = function () {
  7035. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7036. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7037. _this._soundSource.buffer = _this._audioBuffer;
  7038. _this._soundSource.connect(_this._inputAudioNode);
  7039. _this._soundSource.loop = _this.loop;
  7040. _this._soundSource.playbackRate.value = _this._playbackRate;
  7041. _this._soundSource.onended = function () { _this._onended(); };
  7042. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7043. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7044. }
  7045. };
  7046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7047. // Wait a bit for FF as context seems late to be ready.
  7048. setTimeout(function () {
  7049. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7050. // Automatic playback failed.
  7051. // Waiting for the audio engine to be unlocked by user click on unmute
  7052. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7053. if (_this.loop || _this.autoplay) {
  7054. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7055. }
  7056. }
  7057. else {
  7058. tryToPlay();
  7059. }
  7060. }, 500);
  7061. }
  7062. else {
  7063. tryToPlay();
  7064. }
  7065. }
  7066. this._startTime = startTime;
  7067. this.isPlaying = true;
  7068. this.isPaused = false;
  7069. }
  7070. catch (ex) {
  7071. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7072. }
  7073. }
  7074. };
  7075. Sound.prototype._onended = function () {
  7076. this.isPlaying = false;
  7077. if (this.onended) {
  7078. this.onended();
  7079. }
  7080. this.onEndedObservable.notifyObservers(this);
  7081. };
  7082. /**
  7083. * Stop the sound
  7084. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7085. */
  7086. Sound.prototype.stop = function (time) {
  7087. var _this = this;
  7088. if (this.isPlaying) {
  7089. if (this._streaming) {
  7090. if (this._htmlAudioElement) {
  7091. this._htmlAudioElement.pause();
  7092. // Test needed for Firefox or it will generate an Invalid State Error
  7093. if (this._htmlAudioElement.currentTime > 0) {
  7094. this._htmlAudioElement.currentTime = 0;
  7095. }
  7096. }
  7097. else {
  7098. this._streamingSource.disconnect();
  7099. }
  7100. this.isPlaying = false;
  7101. }
  7102. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7103. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7104. this._soundSource.stop(stopTime);
  7105. this._soundSource.onended = function () { _this.isPlaying = false; };
  7106. if (!this.isPaused) {
  7107. this._startOffset = 0;
  7108. }
  7109. }
  7110. }
  7111. };
  7112. /**
  7113. * Put the sound in pause
  7114. */
  7115. Sound.prototype.pause = function () {
  7116. if (this.isPlaying) {
  7117. this.isPaused = true;
  7118. if (this._streaming) {
  7119. if (this._htmlAudioElement) {
  7120. this._htmlAudioElement.pause();
  7121. }
  7122. else {
  7123. this._streamingSource.disconnect();
  7124. }
  7125. }
  7126. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7127. this.stop(0);
  7128. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7129. }
  7130. }
  7131. };
  7132. /**
  7133. * Sets a dedicated volume for this sounds
  7134. * @param newVolume Define the new volume of the sound
  7135. * @param time Define in how long the sound should be at this value
  7136. */
  7137. Sound.prototype.setVolume = function (newVolume, time) {
  7138. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7139. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7140. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7141. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7142. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7143. }
  7144. else {
  7145. this._soundGain.gain.value = newVolume;
  7146. }
  7147. }
  7148. this._volume = newVolume;
  7149. };
  7150. /**
  7151. * Set the sound play back rate
  7152. * @param newPlaybackRate Define the playback rate the sound should be played at
  7153. */
  7154. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7155. this._playbackRate = newPlaybackRate;
  7156. if (this.isPlaying) {
  7157. if (this._streaming && this._htmlAudioElement) {
  7158. this._htmlAudioElement.playbackRate = this._playbackRate;
  7159. }
  7160. else if (this._soundSource) {
  7161. this._soundSource.playbackRate.value = this._playbackRate;
  7162. }
  7163. }
  7164. };
  7165. /**
  7166. * Gets the volume of the sound.
  7167. * @returns the volume of the sound
  7168. */
  7169. Sound.prototype.getVolume = function () {
  7170. return this._volume;
  7171. };
  7172. /**
  7173. * Attach the sound to a dedicated mesh
  7174. * @param transformNode The transform node to connect the sound with
  7175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7176. */
  7177. Sound.prototype.attachToMesh = function (transformNode) {
  7178. var _this = this;
  7179. if (this._connectedTransformNode && this._registerFunc) {
  7180. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7181. this._registerFunc = null;
  7182. }
  7183. this._connectedTransformNode = transformNode;
  7184. if (!this.spatialSound) {
  7185. this.spatialSound = true;
  7186. this._createSpatialParameters();
  7187. if (this.isPlaying && this.loop) {
  7188. this.stop();
  7189. this.play();
  7190. }
  7191. }
  7192. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7193. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7194. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7195. };
  7196. /**
  7197. * Detach the sound from the previously attached mesh
  7198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7199. */
  7200. Sound.prototype.detachFromMesh = function () {
  7201. if (this._connectedTransformNode && this._registerFunc) {
  7202. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7203. this._registerFunc = null;
  7204. this._connectedTransformNode = null;
  7205. }
  7206. };
  7207. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7208. if (!node.getBoundingInfo) {
  7209. return;
  7210. }
  7211. var mesh = node;
  7212. if (this._positionInEmitterSpace) {
  7213. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7214. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7215. }
  7216. else {
  7217. var boundingInfo = mesh.getBoundingInfo();
  7218. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7219. }
  7220. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7221. this._updateDirection();
  7222. }
  7223. };
  7224. /**
  7225. * Clone the current sound in the scene.
  7226. * @returns the new sound clone
  7227. */
  7228. Sound.prototype.clone = function () {
  7229. var _this = this;
  7230. if (!this._streaming) {
  7231. var setBufferAndRun = function () {
  7232. if (_this._isReadyToPlay) {
  7233. clonedSound._audioBuffer = _this.getAudioBuffer();
  7234. clonedSound._isReadyToPlay = true;
  7235. if (clonedSound.autoplay) {
  7236. clonedSound.play();
  7237. }
  7238. }
  7239. else {
  7240. window.setTimeout(setBufferAndRun, 300);
  7241. }
  7242. };
  7243. var currentOptions = {
  7244. autoplay: this.autoplay, loop: this.loop,
  7245. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7246. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7247. refDistance: this.refDistance, distanceModel: this.distanceModel
  7248. };
  7249. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7250. if (this.useCustomAttenuation) {
  7251. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7252. }
  7253. clonedSound.setPosition(this._position);
  7254. clonedSound.setPlaybackRate(this._playbackRate);
  7255. setBufferAndRun();
  7256. return clonedSound;
  7257. }
  7258. // Can't clone a streaming sound
  7259. else {
  7260. return null;
  7261. }
  7262. };
  7263. /**
  7264. * Gets the current underlying audio buffer containing the data
  7265. * @returns the audio buffer
  7266. */
  7267. Sound.prototype.getAudioBuffer = function () {
  7268. return this._audioBuffer;
  7269. };
  7270. /**
  7271. * Serializes the Sound in a JSON representation
  7272. * @returns the JSON representation of the sound
  7273. */
  7274. Sound.prototype.serialize = function () {
  7275. var serializationObject = {
  7276. name: this.name,
  7277. url: this.name,
  7278. autoplay: this.autoplay,
  7279. loop: this.loop,
  7280. volume: this._volume,
  7281. spatialSound: this.spatialSound,
  7282. maxDistance: this.maxDistance,
  7283. rolloffFactor: this.rolloffFactor,
  7284. refDistance: this.refDistance,
  7285. distanceModel: this.distanceModel,
  7286. playbackRate: this._playbackRate,
  7287. panningModel: this._panningModel,
  7288. soundTrackId: this.soundTrackId
  7289. };
  7290. if (this.spatialSound) {
  7291. if (this._connectedTransformNode) {
  7292. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7293. }
  7294. serializationObject.position = this._position.asArray();
  7295. serializationObject.refDistance = this.refDistance;
  7296. serializationObject.distanceModel = this.distanceModel;
  7297. serializationObject.isDirectional = this._isDirectional;
  7298. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7299. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7300. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7301. serializationObject.coneOuterGain = this._coneOuterGain;
  7302. }
  7303. return serializationObject;
  7304. };
  7305. /**
  7306. * Parse a JSON representation of a sound to innstantiate in a given scene
  7307. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7308. * @param scene Define the scene the new parsed sound should be created in
  7309. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7310. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7311. * @returns the newly parsed sound
  7312. */
  7313. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7314. var soundName = parsedSound.name;
  7315. var soundUrl;
  7316. if (parsedSound.url) {
  7317. soundUrl = rootUrl + parsedSound.url;
  7318. }
  7319. else {
  7320. soundUrl = rootUrl + soundName;
  7321. }
  7322. var options = {
  7323. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7324. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7325. rolloffFactor: parsedSound.rolloffFactor,
  7326. refDistance: parsedSound.refDistance,
  7327. distanceModel: parsedSound.distanceModel,
  7328. playbackRate: parsedSound.playbackRate
  7329. };
  7330. var newSound;
  7331. if (!sourceSound) {
  7332. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7333. scene._addPendingData(newSound);
  7334. }
  7335. else {
  7336. var setBufferAndRun = function () {
  7337. if (sourceSound._isReadyToPlay) {
  7338. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7339. newSound._isReadyToPlay = true;
  7340. if (newSound.autoplay) {
  7341. newSound.play();
  7342. }
  7343. }
  7344. else {
  7345. window.setTimeout(setBufferAndRun, 300);
  7346. }
  7347. };
  7348. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7349. setBufferAndRun();
  7350. }
  7351. if (parsedSound.position) {
  7352. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7353. newSound.setPosition(soundPosition);
  7354. }
  7355. if (parsedSound.isDirectional) {
  7356. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7357. if (parsedSound.localDirectionToMesh) {
  7358. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7359. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7360. }
  7361. }
  7362. if (parsedSound.connectedMeshId) {
  7363. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7364. if (connectedMesh) {
  7365. newSound.attachToMesh(connectedMesh);
  7366. }
  7367. }
  7368. return newSound;
  7369. };
  7370. /** @hidden */
  7371. Sound._SceneComponentInitialization = function (_) {
  7372. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7373. };
  7374. return Sound;
  7375. }());
  7376. /***/ }),
  7377. /***/ "./Audio/soundTrack.ts":
  7378. /*!*****************************!*\
  7379. !*** ./Audio/soundTrack.ts ***!
  7380. \*****************************/
  7381. /*! exports provided: SoundTrack */
  7382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7383. "use strict";
  7384. __webpack_require__.r(__webpack_exports__);
  7385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7386. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7387. /**
  7388. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7389. * It will be also used in a future release to apply effects on a specific track.
  7390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7391. */
  7392. var SoundTrack = /** @class */ (function () {
  7393. /**
  7394. * Creates a new sound track.
  7395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7396. * @param scene Define the scene the sound track belongs to
  7397. * @param options
  7398. */
  7399. function SoundTrack(scene, options) {
  7400. if (options === void 0) { options = {}; }
  7401. /**
  7402. * The unique identifier of the sound track in the scene.
  7403. */
  7404. this.id = -1;
  7405. this._isMainTrack = false;
  7406. this._isInitialized = false;
  7407. this._scene = scene;
  7408. this.soundCollection = new Array();
  7409. this._options = options;
  7410. if (!this._isMainTrack && this._scene.soundTracks) {
  7411. this._scene.soundTracks.push(this);
  7412. this.id = this._scene.soundTracks.length - 1;
  7413. }
  7414. }
  7415. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7416. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7417. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7418. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7419. if (this._options) {
  7420. if (this._options.volume) {
  7421. this._outputAudioNode.gain.value = this._options.volume;
  7422. }
  7423. if (this._options.mainTrack) {
  7424. this._isMainTrack = this._options.mainTrack;
  7425. }
  7426. }
  7427. this._isInitialized = true;
  7428. }
  7429. };
  7430. /**
  7431. * Release the sound track and its associated resources
  7432. */
  7433. SoundTrack.prototype.dispose = function () {
  7434. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7435. if (this._connectedAnalyser) {
  7436. this._connectedAnalyser.stopDebugCanvas();
  7437. }
  7438. while (this.soundCollection.length) {
  7439. this.soundCollection[0].dispose();
  7440. }
  7441. if (this._outputAudioNode) {
  7442. this._outputAudioNode.disconnect();
  7443. }
  7444. this._outputAudioNode = null;
  7445. }
  7446. };
  7447. /**
  7448. * Adds a sound to this sound track
  7449. * @param sound define the cound to add
  7450. * @ignoreNaming
  7451. */
  7452. SoundTrack.prototype.AddSound = function (sound) {
  7453. if (!this._isInitialized) {
  7454. this._initializeSoundTrackAudioGraph();
  7455. }
  7456. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7457. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7458. }
  7459. if (sound.soundTrackId) {
  7460. if (sound.soundTrackId === -1) {
  7461. this._scene.mainSoundTrack.RemoveSound(sound);
  7462. }
  7463. else if (this._scene.soundTracks) {
  7464. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7465. }
  7466. }
  7467. this.soundCollection.push(sound);
  7468. sound.soundTrackId = this.id;
  7469. };
  7470. /**
  7471. * Removes a sound to this sound track
  7472. * @param sound define the cound to remove
  7473. * @ignoreNaming
  7474. */
  7475. SoundTrack.prototype.RemoveSound = function (sound) {
  7476. var index = this.soundCollection.indexOf(sound);
  7477. if (index !== -1) {
  7478. this.soundCollection.splice(index, 1);
  7479. }
  7480. };
  7481. /**
  7482. * Set a global volume for the full sound track.
  7483. * @param newVolume Define the new volume of the sound track
  7484. */
  7485. SoundTrack.prototype.setVolume = function (newVolume) {
  7486. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7487. this._outputAudioNode.gain.value = newVolume;
  7488. }
  7489. };
  7490. /**
  7491. * Switch the panning model to HRTF:
  7492. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7494. */
  7495. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7496. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7497. for (var i = 0; i < this.soundCollection.length; i++) {
  7498. this.soundCollection[i].switchPanningModelToHRTF();
  7499. }
  7500. }
  7501. };
  7502. /**
  7503. * Switch the panning model to Equal Power:
  7504. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7506. */
  7507. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7508. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7509. for (var i = 0; i < this.soundCollection.length; i++) {
  7510. this.soundCollection[i].switchPanningModelToEqualPower();
  7511. }
  7512. }
  7513. };
  7514. /**
  7515. * Connect the sound track to an audio analyser allowing some amazing
  7516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7518. * @param analyser The analyser to connect to the engine
  7519. */
  7520. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7521. if (this._connectedAnalyser) {
  7522. this._connectedAnalyser.stopDebugCanvas();
  7523. }
  7524. this._connectedAnalyser = analyser;
  7525. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7526. this._outputAudioNode.disconnect();
  7527. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7528. }
  7529. };
  7530. return SoundTrack;
  7531. }());
  7532. /***/ }),
  7533. /***/ "./Audio/weightedsound.ts":
  7534. /*!********************************!*\
  7535. !*** ./Audio/weightedsound.ts ***!
  7536. \********************************/
  7537. /*! exports provided: WeightedSound */
  7538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7539. "use strict";
  7540. __webpack_require__.r(__webpack_exports__);
  7541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7542. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7543. /**
  7544. * Wraps one or more Sound objects and selects one with random weight for playback.
  7545. */
  7546. var WeightedSound = /** @class */ (function () {
  7547. /**
  7548. * Creates a new WeightedSound from the list of sounds given.
  7549. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7550. * @param sounds Array of Sounds that will be selected from.
  7551. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7552. */
  7553. function WeightedSound(loop, sounds, weights) {
  7554. var _this = this;
  7555. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7556. this.loop = false;
  7557. this._coneInnerAngle = 360;
  7558. this._coneOuterAngle = 360;
  7559. this._volume = 1;
  7560. /** A Sound is currently playing. */
  7561. this.isPlaying = false;
  7562. /** A Sound is currently paused. */
  7563. this.isPaused = false;
  7564. this._sounds = [];
  7565. this._weights = [];
  7566. if (sounds.length !== weights.length) {
  7567. throw new Error('Sounds length does not equal weights length');
  7568. }
  7569. this.loop = loop;
  7570. this._weights = weights;
  7571. // Normalize the weights
  7572. var weightSum = 0;
  7573. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7574. var weight = weights_1[_i];
  7575. weightSum += weight;
  7576. }
  7577. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7578. for (var i = 0; i < this._weights.length; i++) {
  7579. this._weights[i] *= invWeightSum;
  7580. }
  7581. this._sounds = sounds;
  7582. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7583. var sound = _b[_a];
  7584. sound.onEndedObservable.add(function () { _this._onended(); });
  7585. }
  7586. }
  7587. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7588. /**
  7589. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7590. */
  7591. get: function () {
  7592. return this._coneInnerAngle;
  7593. },
  7594. /**
  7595. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7596. */
  7597. set: function (value) {
  7598. if (value !== this._coneInnerAngle) {
  7599. if (this._coneOuterAngle < value) {
  7600. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7601. return;
  7602. }
  7603. this._coneInnerAngle = value;
  7604. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7605. var sound = _a[_i];
  7606. sound.directionalConeInnerAngle = value;
  7607. }
  7608. }
  7609. },
  7610. enumerable: true,
  7611. configurable: true
  7612. });
  7613. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7614. /**
  7615. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7616. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7617. */
  7618. get: function () {
  7619. return this._coneOuterAngle;
  7620. },
  7621. /**
  7622. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7623. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7624. */
  7625. set: function (value) {
  7626. if (value !== this._coneOuterAngle) {
  7627. if (value < this._coneInnerAngle) {
  7628. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7629. return;
  7630. }
  7631. this._coneOuterAngle = value;
  7632. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7633. var sound = _a[_i];
  7634. sound.directionalConeOuterAngle = value;
  7635. }
  7636. }
  7637. },
  7638. enumerable: true,
  7639. configurable: true
  7640. });
  7641. Object.defineProperty(WeightedSound.prototype, "volume", {
  7642. /**
  7643. * Playback volume.
  7644. */
  7645. get: function () {
  7646. return this._volume;
  7647. },
  7648. /**
  7649. * Playback volume.
  7650. */
  7651. set: function (value) {
  7652. if (value !== this._volume) {
  7653. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7654. var sound = _a[_i];
  7655. sound.setVolume(value);
  7656. }
  7657. }
  7658. },
  7659. enumerable: true,
  7660. configurable: true
  7661. });
  7662. WeightedSound.prototype._onended = function () {
  7663. if (this._currentIndex !== undefined) {
  7664. this._sounds[this._currentIndex].autoplay = false;
  7665. }
  7666. if (this.loop && this.isPlaying) {
  7667. this.play();
  7668. }
  7669. else {
  7670. this.isPlaying = false;
  7671. }
  7672. };
  7673. /**
  7674. * Suspend playback
  7675. */
  7676. WeightedSound.prototype.pause = function () {
  7677. this.isPaused = true;
  7678. if (this._currentIndex !== undefined) {
  7679. this._sounds[this._currentIndex].pause();
  7680. }
  7681. };
  7682. /**
  7683. * Stop playback
  7684. */
  7685. WeightedSound.prototype.stop = function () {
  7686. this.isPlaying = false;
  7687. if (this._currentIndex !== undefined) {
  7688. this._sounds[this._currentIndex].stop();
  7689. }
  7690. };
  7691. /**
  7692. * Start playback.
  7693. * @param startOffset Position the clip head at a specific time in seconds.
  7694. */
  7695. WeightedSound.prototype.play = function (startOffset) {
  7696. if (!this.isPaused) {
  7697. this.stop();
  7698. var randomValue = Math.random();
  7699. var total = 0;
  7700. for (var i = 0; i < this._weights.length; i++) {
  7701. total += this._weights[i];
  7702. if (randomValue <= total) {
  7703. this._currentIndex = i;
  7704. break;
  7705. }
  7706. }
  7707. }
  7708. var sound = this._sounds[this._currentIndex];
  7709. if (sound.isReady()) {
  7710. sound.play(0, this.isPaused ? undefined : startOffset);
  7711. }
  7712. else {
  7713. sound.autoplay = true;
  7714. }
  7715. this.isPlaying = true;
  7716. this.isPaused = false;
  7717. };
  7718. return WeightedSound;
  7719. }());
  7720. /***/ }),
  7721. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7722. /*!***************************************************!*\
  7723. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7724. \***************************************************/
  7725. /*! exports provided: AutoRotationBehavior */
  7726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7727. "use strict";
  7728. __webpack_require__.r(__webpack_exports__);
  7729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7730. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7731. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7732. /**
  7733. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7734. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7735. */
  7736. var AutoRotationBehavior = /** @class */ (function () {
  7737. function AutoRotationBehavior() {
  7738. this._zoomStopsAnimation = false;
  7739. this._idleRotationSpeed = 0.05;
  7740. this._idleRotationWaitTime = 2000;
  7741. this._idleRotationSpinupTime = 2000;
  7742. this._isPointerDown = false;
  7743. this._lastFrameTime = null;
  7744. this._lastInteractionTime = -Infinity;
  7745. this._cameraRotationSpeed = 0;
  7746. this._lastFrameRadius = 0;
  7747. }
  7748. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7749. /**
  7750. * Gets the name of the behavior.
  7751. */
  7752. get: function () {
  7753. return "AutoRotation";
  7754. },
  7755. enumerable: true,
  7756. configurable: true
  7757. });
  7758. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7759. /**
  7760. * Gets the flag that indicates if user zooming should stop animation.
  7761. */
  7762. get: function () {
  7763. return this._zoomStopsAnimation;
  7764. },
  7765. /**
  7766. * Sets the flag that indicates if user zooming should stop animation.
  7767. */
  7768. set: function (flag) {
  7769. this._zoomStopsAnimation = flag;
  7770. },
  7771. enumerable: true,
  7772. configurable: true
  7773. });
  7774. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7775. /**
  7776. * Gets the default speed at which the camera rotates around the model.
  7777. */
  7778. get: function () {
  7779. return this._idleRotationSpeed;
  7780. },
  7781. /**
  7782. * Sets the default speed at which the camera rotates around the model.
  7783. */
  7784. set: function (speed) {
  7785. this._idleRotationSpeed = speed;
  7786. },
  7787. enumerable: true,
  7788. configurable: true
  7789. });
  7790. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7791. /**
  7792. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7793. */
  7794. get: function () {
  7795. return this._idleRotationWaitTime;
  7796. },
  7797. /**
  7798. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7799. */
  7800. set: function (time) {
  7801. this._idleRotationWaitTime = time;
  7802. },
  7803. enumerable: true,
  7804. configurable: true
  7805. });
  7806. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7807. /**
  7808. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7809. */
  7810. get: function () {
  7811. return this._idleRotationSpinupTime;
  7812. },
  7813. /**
  7814. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7815. */
  7816. set: function (time) {
  7817. this._idleRotationSpinupTime = time;
  7818. },
  7819. enumerable: true,
  7820. configurable: true
  7821. });
  7822. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7823. /**
  7824. * Gets a value indicating if the camera is currently rotating because of this behavior
  7825. */
  7826. get: function () {
  7827. return Math.abs(this._cameraRotationSpeed) > 0;
  7828. },
  7829. enumerable: true,
  7830. configurable: true
  7831. });
  7832. /**
  7833. * Initializes the behavior.
  7834. */
  7835. AutoRotationBehavior.prototype.init = function () {
  7836. // Do notihng
  7837. };
  7838. /**
  7839. * Attaches the behavior to its arc rotate camera.
  7840. * @param camera Defines the camera to attach the behavior to
  7841. */
  7842. AutoRotationBehavior.prototype.attach = function (camera) {
  7843. var _this = this;
  7844. this._attachedCamera = camera;
  7845. var scene = this._attachedCamera.getScene();
  7846. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7847. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7848. _this._isPointerDown = true;
  7849. return;
  7850. }
  7851. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7852. _this._isPointerDown = false;
  7853. }
  7854. });
  7855. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7856. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7857. var dt = 0;
  7858. if (_this._lastFrameTime != null) {
  7859. dt = now - _this._lastFrameTime;
  7860. }
  7861. _this._lastFrameTime = now;
  7862. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7863. _this._applyUserInteraction();
  7864. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7865. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7866. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7867. // Step camera rotation by rotation speed
  7868. if (_this._attachedCamera) {
  7869. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7870. }
  7871. });
  7872. };
  7873. /**
  7874. * Detaches the behavior from its current arc rotate camera.
  7875. */
  7876. AutoRotationBehavior.prototype.detach = function () {
  7877. if (!this._attachedCamera) {
  7878. return;
  7879. }
  7880. var scene = this._attachedCamera.getScene();
  7881. if (this._onPrePointerObservableObserver) {
  7882. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7883. }
  7884. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7885. this._attachedCamera = null;
  7886. };
  7887. /**
  7888. * Returns true if user is scrolling.
  7889. * @return true if user is scrolling.
  7890. */
  7891. AutoRotationBehavior.prototype._userIsZooming = function () {
  7892. if (!this._attachedCamera) {
  7893. return false;
  7894. }
  7895. return this._attachedCamera.inertialRadiusOffset !== 0;
  7896. };
  7897. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7898. if (!this._attachedCamera) {
  7899. return false;
  7900. }
  7901. var zoomHasHitLimit = false;
  7902. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7903. zoomHasHitLimit = true;
  7904. }
  7905. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7906. this._lastFrameRadius = this._attachedCamera.radius;
  7907. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7908. };
  7909. /**
  7910. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7911. */
  7912. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7913. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7914. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7915. }
  7916. };
  7917. // Tools
  7918. AutoRotationBehavior.prototype._userIsMoving = function () {
  7919. if (!this._attachedCamera) {
  7920. return false;
  7921. }
  7922. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7923. this._attachedCamera.inertialBetaOffset !== 0 ||
  7924. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7925. this._attachedCamera.inertialPanningX !== 0 ||
  7926. this._attachedCamera.inertialPanningY !== 0 ||
  7927. this._isPointerDown;
  7928. };
  7929. return AutoRotationBehavior;
  7930. }());
  7931. /***/ }),
  7932. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7933. /*!***********************************************!*\
  7934. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7935. \***********************************************/
  7936. /*! exports provided: BouncingBehavior */
  7937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7938. "use strict";
  7939. __webpack_require__.r(__webpack_exports__);
  7940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7941. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7942. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7943. /**
  7944. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7946. */
  7947. var BouncingBehavior = /** @class */ (function () {
  7948. function BouncingBehavior() {
  7949. /**
  7950. * The duration of the animation, in milliseconds
  7951. */
  7952. this.transitionDuration = 450;
  7953. /**
  7954. * Length of the distance animated by the transition when lower radius is reached
  7955. */
  7956. this.lowerRadiusTransitionRange = 2;
  7957. /**
  7958. * Length of the distance animated by the transition when upper radius is reached
  7959. */
  7960. this.upperRadiusTransitionRange = -2;
  7961. this._autoTransitionRange = false;
  7962. // Animations
  7963. this._radiusIsAnimating = false;
  7964. this._radiusBounceTransition = null;
  7965. this._animatables = new Array();
  7966. }
  7967. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7968. /**
  7969. * Gets the name of the behavior.
  7970. */
  7971. get: function () {
  7972. return "Bouncing";
  7973. },
  7974. enumerable: true,
  7975. configurable: true
  7976. });
  7977. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7978. /**
  7979. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7980. */
  7981. get: function () {
  7982. return this._autoTransitionRange;
  7983. },
  7984. /**
  7985. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7986. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7987. */
  7988. set: function (value) {
  7989. var _this = this;
  7990. if (this._autoTransitionRange === value) {
  7991. return;
  7992. }
  7993. this._autoTransitionRange = value;
  7994. var camera = this._attachedCamera;
  7995. if (!camera) {
  7996. return;
  7997. }
  7998. if (value) {
  7999. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8000. if (!mesh) {
  8001. return;
  8002. }
  8003. mesh.computeWorldMatrix(true);
  8004. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8005. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8006. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8007. });
  8008. }
  8009. else if (this._onMeshTargetChangedObserver) {
  8010. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8011. }
  8012. },
  8013. enumerable: true,
  8014. configurable: true
  8015. });
  8016. /**
  8017. * Initializes the behavior.
  8018. */
  8019. BouncingBehavior.prototype.init = function () {
  8020. // Do notihng
  8021. };
  8022. /**
  8023. * Attaches the behavior to its arc rotate camera.
  8024. * @param camera Defines the camera to attach the behavior to
  8025. */
  8026. BouncingBehavior.prototype.attach = function (camera) {
  8027. var _this = this;
  8028. this._attachedCamera = camera;
  8029. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8030. if (!_this._attachedCamera) {
  8031. return;
  8032. }
  8033. // Add the bounce animation to the lower radius limit
  8034. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8035. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8036. }
  8037. // Add the bounce animation to the upper radius limit
  8038. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8039. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8040. }
  8041. });
  8042. };
  8043. /**
  8044. * Detaches the behavior from its current arc rotate camera.
  8045. */
  8046. BouncingBehavior.prototype.detach = function () {
  8047. if (!this._attachedCamera) {
  8048. return;
  8049. }
  8050. if (this._onAfterCheckInputsObserver) {
  8051. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8052. }
  8053. if (this._onMeshTargetChangedObserver) {
  8054. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8055. }
  8056. this._attachedCamera = null;
  8057. };
  8058. /**
  8059. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8060. * @param radiusLimit The limit to check against.
  8061. * @return Bool to indicate if at limit.
  8062. */
  8063. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8064. if (!this._attachedCamera) {
  8065. return false;
  8066. }
  8067. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8068. return true;
  8069. }
  8070. return false;
  8071. };
  8072. /**
  8073. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8074. * @param radiusDelta The delta by which to animate to. Can be negative.
  8075. */
  8076. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8077. var _this = this;
  8078. if (!this._attachedCamera) {
  8079. return;
  8080. }
  8081. if (!this._radiusBounceTransition) {
  8082. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8083. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8084. }
  8085. // Prevent zoom until bounce has completed
  8086. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8087. this._attachedCamera.wheelPrecision = Infinity;
  8088. this._attachedCamera.inertialRadiusOffset = 0;
  8089. // Animate to the radius limit
  8090. this.stopAllAnimations();
  8091. this._radiusIsAnimating = true;
  8092. 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(); });
  8093. if (animatable) {
  8094. this._animatables.push(animatable);
  8095. }
  8096. };
  8097. /**
  8098. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8099. */
  8100. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8101. this._radiusIsAnimating = false;
  8102. if (this._attachedCamera) {
  8103. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8104. }
  8105. };
  8106. /**
  8107. * Stops and removes all animations that have been applied to the camera
  8108. */
  8109. BouncingBehavior.prototype.stopAllAnimations = function () {
  8110. if (this._attachedCamera) {
  8111. this._attachedCamera.animations = [];
  8112. }
  8113. while (this._animatables.length) {
  8114. this._animatables[0].onAnimationEnd = null;
  8115. this._animatables[0].stop();
  8116. this._animatables.shift();
  8117. }
  8118. };
  8119. /**
  8120. * The easing function used by animations
  8121. */
  8122. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8123. /**
  8124. * The easing mode used by animations
  8125. */
  8126. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8127. return BouncingBehavior;
  8128. }());
  8129. /***/ }),
  8130. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8131. /*!**********************************************!*\
  8132. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8133. \**********************************************/
  8134. /*! exports provided: FramingBehavior */
  8135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8136. "use strict";
  8137. __webpack_require__.r(__webpack_exports__);
  8138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8139. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8140. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8141. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8142. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8143. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8144. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8145. /**
  8146. * 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.
  8147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8148. */
  8149. var FramingBehavior = /** @class */ (function () {
  8150. function FramingBehavior() {
  8151. this._mode = FramingBehavior.FitFrustumSidesMode;
  8152. this._radiusScale = 1.0;
  8153. this._positionScale = 0.5;
  8154. this._defaultElevation = 0.3;
  8155. this._elevationReturnTime = 1500;
  8156. this._elevationReturnWaitTime = 1000;
  8157. this._zoomStopsAnimation = false;
  8158. this._framingTime = 1500;
  8159. /**
  8160. * Define if the behavior should automatically change the configured
  8161. * camera limits and sensibilities.
  8162. */
  8163. this.autoCorrectCameraLimitsAndSensibility = true;
  8164. this._isPointerDown = false;
  8165. this._lastInteractionTime = -Infinity;
  8166. // Framing control
  8167. this._animatables = new Array();
  8168. this._betaIsAnimating = false;
  8169. }
  8170. Object.defineProperty(FramingBehavior.prototype, "name", {
  8171. /**
  8172. * Gets the name of the behavior.
  8173. */
  8174. get: function () {
  8175. return "Framing";
  8176. },
  8177. enumerable: true,
  8178. configurable: true
  8179. });
  8180. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8181. /**
  8182. * Gets current mode used by the behavior.
  8183. */
  8184. get: function () {
  8185. return this._mode;
  8186. },
  8187. /**
  8188. * Sets the current mode used by the behavior
  8189. */
  8190. set: function (mode) {
  8191. this._mode = mode;
  8192. },
  8193. enumerable: true,
  8194. configurable: true
  8195. });
  8196. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8197. /**
  8198. * Gets the scale applied to the radius
  8199. */
  8200. get: function () {
  8201. return this._radiusScale;
  8202. },
  8203. /**
  8204. * Sets the scale applied to the radius (1 by default)
  8205. */
  8206. set: function (radius) {
  8207. this._radiusScale = radius;
  8208. },
  8209. enumerable: true,
  8210. configurable: true
  8211. });
  8212. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8213. /**
  8214. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8215. */
  8216. get: function () {
  8217. return this._positionScale;
  8218. },
  8219. /**
  8220. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8221. */
  8222. set: function (scale) {
  8223. this._positionScale = scale;
  8224. },
  8225. enumerable: true,
  8226. configurable: true
  8227. });
  8228. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8229. /**
  8230. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8231. * behaviour is triggered, in radians.
  8232. */
  8233. get: function () {
  8234. return this._defaultElevation;
  8235. },
  8236. /**
  8237. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8238. * behaviour is triggered, in radians.
  8239. */
  8240. set: function (elevation) {
  8241. this._defaultElevation = elevation;
  8242. },
  8243. enumerable: true,
  8244. configurable: true
  8245. });
  8246. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8247. /**
  8248. * Gets the time (in milliseconds) taken to return to the default beta position.
  8249. * Negative value indicates camera should not return to default.
  8250. */
  8251. get: function () {
  8252. return this._elevationReturnTime;
  8253. },
  8254. /**
  8255. * Sets the time (in milliseconds) taken to return to the default beta position.
  8256. * Negative value indicates camera should not return to default.
  8257. */
  8258. set: function (speed) {
  8259. this._elevationReturnTime = speed;
  8260. },
  8261. enumerable: true,
  8262. configurable: true
  8263. });
  8264. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8265. /**
  8266. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8267. */
  8268. get: function () {
  8269. return this._elevationReturnWaitTime;
  8270. },
  8271. /**
  8272. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8273. */
  8274. set: function (time) {
  8275. this._elevationReturnWaitTime = time;
  8276. },
  8277. enumerable: true,
  8278. configurable: true
  8279. });
  8280. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8281. /**
  8282. * Gets the flag that indicates if user zooming should stop animation.
  8283. */
  8284. get: function () {
  8285. return this._zoomStopsAnimation;
  8286. },
  8287. /**
  8288. * Sets the flag that indicates if user zooming should stop animation.
  8289. */
  8290. set: function (flag) {
  8291. this._zoomStopsAnimation = flag;
  8292. },
  8293. enumerable: true,
  8294. configurable: true
  8295. });
  8296. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8297. /**
  8298. * Gets the transition time when framing the mesh, in milliseconds
  8299. */
  8300. get: function () {
  8301. return this._framingTime;
  8302. },
  8303. /**
  8304. * Sets the transition time when framing the mesh, in milliseconds
  8305. */
  8306. set: function (time) {
  8307. this._framingTime = time;
  8308. },
  8309. enumerable: true,
  8310. configurable: true
  8311. });
  8312. /**
  8313. * Initializes the behavior.
  8314. */
  8315. FramingBehavior.prototype.init = function () {
  8316. // Do notihng
  8317. };
  8318. /**
  8319. * Attaches the behavior to its arc rotate camera.
  8320. * @param camera Defines the camera to attach the behavior to
  8321. */
  8322. FramingBehavior.prototype.attach = function (camera) {
  8323. var _this = this;
  8324. this._attachedCamera = camera;
  8325. var scene = this._attachedCamera.getScene();
  8326. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8327. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8328. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8329. _this._isPointerDown = true;
  8330. return;
  8331. }
  8332. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8333. _this._isPointerDown = false;
  8334. }
  8335. });
  8336. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8337. if (mesh) {
  8338. _this.zoomOnMesh(mesh);
  8339. }
  8340. });
  8341. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8342. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8343. _this._applyUserInteraction();
  8344. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8345. // back to the default position after a given timeout
  8346. _this._maintainCameraAboveGround();
  8347. });
  8348. };
  8349. /**
  8350. * Detaches the behavior from its current arc rotate camera.
  8351. */
  8352. FramingBehavior.prototype.detach = function () {
  8353. if (!this._attachedCamera) {
  8354. return;
  8355. }
  8356. var scene = this._attachedCamera.getScene();
  8357. if (this._onPrePointerObservableObserver) {
  8358. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8359. }
  8360. if (this._onAfterCheckInputsObserver) {
  8361. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8362. }
  8363. if (this._onMeshTargetChangedObserver) {
  8364. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8365. }
  8366. this._attachedCamera = null;
  8367. };
  8368. /**
  8369. * Targets the given mesh and updates zoom level accordingly.
  8370. * @param mesh The mesh to target.
  8371. * @param radius Optional. If a cached radius position already exists, overrides default.
  8372. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8373. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8374. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8375. */
  8376. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8377. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8378. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8379. mesh.computeWorldMatrix(true);
  8380. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8381. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8382. };
  8383. /**
  8384. * Targets the given mesh with its children and updates zoom level accordingly.
  8385. * @param mesh The mesh to target.
  8386. * @param radius Optional. If a cached radius position already exists, overrides default.
  8387. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8388. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8389. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8390. */
  8391. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8392. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8393. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8394. mesh.computeWorldMatrix(true);
  8395. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8396. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8397. };
  8398. /**
  8399. * Targets the given meshes with their children and updates zoom level accordingly.
  8400. * @param meshes The mesh to target.
  8401. * @param radius Optional. If a cached radius position already exists, overrides default.
  8402. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8403. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8404. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8405. */
  8406. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8407. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8408. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8409. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8410. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8411. for (var i = 0; i < meshes.length; i++) {
  8412. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8413. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8414. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8415. }
  8416. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8417. };
  8418. /**
  8419. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8420. * @param minimumWorld Determines the smaller position of the bounding box extend
  8421. * @param maximumWorld Determines the bigger position of the bounding box extend
  8422. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8423. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8424. */
  8425. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8426. var _this = this;
  8427. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8428. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8429. var zoomTarget;
  8430. if (!this._attachedCamera) {
  8431. return;
  8432. }
  8433. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8434. var bottom = minimumWorld.y;
  8435. var top = maximumWorld.y;
  8436. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8437. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8438. if (focusOnOriginXZ) {
  8439. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8440. }
  8441. else {
  8442. var centerWorld = minimumWorld.add(radiusWorld);
  8443. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8444. }
  8445. if (!this._vectorTransition) {
  8446. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8447. }
  8448. this._betaIsAnimating = true;
  8449. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8450. if (animatable) {
  8451. this._animatables.push(animatable);
  8452. }
  8453. // sets the radius and lower radius bounds
  8454. // Small delta ensures camera is not always at lower zoom limit.
  8455. var radius = 0;
  8456. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8457. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8458. if (this.autoCorrectCameraLimitsAndSensibility) {
  8459. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8460. }
  8461. radius = position;
  8462. }
  8463. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8464. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8465. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8466. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8467. }
  8468. }
  8469. // Set sensibilities
  8470. if (this.autoCorrectCameraLimitsAndSensibility) {
  8471. var extend = maximumWorld.subtract(minimumWorld).length();
  8472. this._attachedCamera.panningSensibility = 5000 / extend;
  8473. this._attachedCamera.wheelPrecision = 100 / radius;
  8474. }
  8475. // transition to new radius
  8476. if (!this._radiusTransition) {
  8477. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8478. }
  8479. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8480. _this.stopAllAnimations();
  8481. if (onAnimationEnd) {
  8482. onAnimationEnd();
  8483. }
  8484. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8485. _this._attachedCamera.storeState();
  8486. }
  8487. });
  8488. if (animatable) {
  8489. this._animatables.push(animatable);
  8490. }
  8491. };
  8492. /**
  8493. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8494. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8495. * frustum width.
  8496. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8497. * to fully enclose the mesh in the viewing frustum.
  8498. */
  8499. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8500. var size = maximumWorld.subtract(minimumWorld);
  8501. var boxVectorGlobalDiagonal = size.length();
  8502. var frustumSlope = this._getFrustumSlope();
  8503. // Formula for setting distance
  8504. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8505. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8506. // Horizon distance
  8507. var radius = radiusWithoutFraming * this._radiusScale;
  8508. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8509. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8510. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8511. var camera = this._attachedCamera;
  8512. if (!camera) {
  8513. return 0;
  8514. }
  8515. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8516. // Don't exceed the requested limit
  8517. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8518. }
  8519. // Don't exceed the upper radius limit
  8520. if (camera.upperRadiusLimit) {
  8521. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8522. }
  8523. return distance;
  8524. };
  8525. /**
  8526. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8527. * is automatically returned to its default position (expected to be above ground plane).
  8528. */
  8529. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8530. var _this = this;
  8531. if (this._elevationReturnTime < 0) {
  8532. return;
  8533. }
  8534. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8535. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8536. var limitBeta = Math.PI * 0.5;
  8537. // Bring the camera back up if below the ground plane
  8538. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8539. this._betaIsAnimating = true;
  8540. //Transition to new position
  8541. this.stopAllAnimations();
  8542. if (!this._betaTransition) {
  8543. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8544. }
  8545. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8546. _this._clearAnimationLocks();
  8547. _this.stopAllAnimations();
  8548. });
  8549. if (animatabe) {
  8550. this._animatables.push(animatabe);
  8551. }
  8552. }
  8553. };
  8554. /**
  8555. * Returns the frustum slope based on the canvas ratio and camera FOV
  8556. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8557. */
  8558. FramingBehavior.prototype._getFrustumSlope = function () {
  8559. // Calculate the viewport ratio
  8560. // Aspect Ratio is Height/Width.
  8561. var camera = this._attachedCamera;
  8562. if (!camera) {
  8563. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8564. }
  8565. var engine = camera.getScene().getEngine();
  8566. var aspectRatio = engine.getAspectRatio(camera);
  8567. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8568. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8569. var frustumSlopeY = Math.tan(camera.fov / 2);
  8570. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8571. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8572. // along the forward vector.
  8573. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8574. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8575. };
  8576. /**
  8577. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8578. */
  8579. FramingBehavior.prototype._clearAnimationLocks = function () {
  8580. this._betaIsAnimating = false;
  8581. };
  8582. /**
  8583. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8584. */
  8585. FramingBehavior.prototype._applyUserInteraction = function () {
  8586. if (this.isUserIsMoving) {
  8587. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8588. this.stopAllAnimations();
  8589. this._clearAnimationLocks();
  8590. }
  8591. };
  8592. /**
  8593. * Stops and removes all animations that have been applied to the camera
  8594. */
  8595. FramingBehavior.prototype.stopAllAnimations = function () {
  8596. if (this._attachedCamera) {
  8597. this._attachedCamera.animations = [];
  8598. }
  8599. while (this._animatables.length) {
  8600. if (this._animatables[0]) {
  8601. this._animatables[0].onAnimationEnd = null;
  8602. this._animatables[0].stop();
  8603. }
  8604. this._animatables.shift();
  8605. }
  8606. };
  8607. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8608. /**
  8609. * Gets a value indicating if the user is moving the camera
  8610. */
  8611. get: function () {
  8612. if (!this._attachedCamera) {
  8613. return false;
  8614. }
  8615. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8616. this._attachedCamera.inertialBetaOffset !== 0 ||
  8617. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8618. this._attachedCamera.inertialPanningX !== 0 ||
  8619. this._attachedCamera.inertialPanningY !== 0 ||
  8620. this._isPointerDown;
  8621. },
  8622. enumerable: true,
  8623. configurable: true
  8624. });
  8625. /**
  8626. * The easing function used by animations
  8627. */
  8628. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8629. /**
  8630. * The easing mode used by animations
  8631. */
  8632. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8633. // Statics
  8634. /**
  8635. * The camera can move all the way towards the mesh.
  8636. */
  8637. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8638. /**
  8639. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8640. */
  8641. FramingBehavior.FitFrustumSidesMode = 1;
  8642. return FramingBehavior;
  8643. }());
  8644. /***/ }),
  8645. /***/ "./Behaviors/Cameras/index.ts":
  8646. /*!************************************!*\
  8647. !*** ./Behaviors/Cameras/index.ts ***!
  8648. \************************************/
  8649. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8651. "use strict";
  8652. __webpack_require__.r(__webpack_exports__);
  8653. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8655. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8657. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8659. /***/ }),
  8660. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8661. /*!*************************************************!*\
  8662. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8663. \*************************************************/
  8664. /*! exports provided: AttachToBoxBehavior */
  8665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8666. "use strict";
  8667. __webpack_require__.r(__webpack_exports__);
  8668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8669. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8670. /**
  8671. * @hidden
  8672. */
  8673. var FaceDirectionInfo = /** @class */ (function () {
  8674. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8675. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8676. if (diff === void 0) { diff = 0; }
  8677. if (ignore === void 0) { ignore = false; }
  8678. this.direction = direction;
  8679. this.rotatedDirection = rotatedDirection;
  8680. this.diff = diff;
  8681. this.ignore = ignore;
  8682. }
  8683. return FaceDirectionInfo;
  8684. }());
  8685. /**
  8686. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8687. */
  8688. var AttachToBoxBehavior = /** @class */ (function () {
  8689. /**
  8690. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8691. * @param ui The transform node that should be attched to the mesh
  8692. */
  8693. function AttachToBoxBehavior(ui) {
  8694. this.ui = ui;
  8695. /**
  8696. * The name of the behavior
  8697. */
  8698. this.name = "AttachToBoxBehavior";
  8699. /**
  8700. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8701. */
  8702. this.distanceAwayFromFace = 0.15;
  8703. /**
  8704. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8705. */
  8706. this.distanceAwayFromBottomOfFace = 0.15;
  8707. 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))];
  8708. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8709. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8710. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8711. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8712. /* Does nothing */
  8713. }
  8714. /**
  8715. * Initializes the behavior
  8716. */
  8717. AttachToBoxBehavior.prototype.init = function () {
  8718. /* Does nothing */
  8719. };
  8720. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8721. var _this = this;
  8722. // Go over each face and calculate the angle between the face's normal and targetDirection
  8723. this._faceVectors.forEach(function (v) {
  8724. if (!_this._target.rotationQuaternion) {
  8725. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8726. }
  8727. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8728. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8729. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8730. });
  8731. // Return the face information of the one with the normal closeset to target direction
  8732. return this._faceVectors.reduce(function (min, p) {
  8733. if (min.ignore) {
  8734. return p;
  8735. }
  8736. else if (p.ignore) {
  8737. return min;
  8738. }
  8739. else {
  8740. return min.diff < p.diff ? min : p;
  8741. }
  8742. }, this._faceVectors[0]);
  8743. };
  8744. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8745. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8746. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8747. this._lookAtTmpMatrix.invert();
  8748. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8749. };
  8750. /**
  8751. * Attaches the AttachToBoxBehavior to the passed in mesh
  8752. * @param target The mesh that the specified node will be attached to
  8753. */
  8754. AttachToBoxBehavior.prototype.attach = function (target) {
  8755. var _this = this;
  8756. this._target = target;
  8757. this._scene = this._target.getScene();
  8758. // Every frame, update the app bars position
  8759. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8760. if (!_this._scene.activeCamera) {
  8761. return;
  8762. }
  8763. // Find the face closest to the cameras position
  8764. var cameraPos = _this._scene.activeCamera.position;
  8765. if (_this._scene.activeCamera.devicePosition) {
  8766. cameraPos = _this._scene.activeCamera.devicePosition;
  8767. }
  8768. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8769. if (_this._scene.activeCamera.leftCamera) {
  8770. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8771. }
  8772. else {
  8773. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8774. }
  8775. // Get camera up direction
  8776. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8777. // Ignore faces to not select a parrelel face for the up vector of the UI
  8778. _this._faceVectors.forEach(function (v) {
  8779. if (facing.direction.x && v.direction.x) {
  8780. v.ignore = true;
  8781. }
  8782. if (facing.direction.y && v.direction.y) {
  8783. v.ignore = true;
  8784. }
  8785. if (facing.direction.z && v.direction.z) {
  8786. v.ignore = true;
  8787. }
  8788. });
  8789. var facingUp = _this._closestFace(_this._tmpVector);
  8790. // Unignore faces
  8791. _this._faceVectors.forEach(function (v) {
  8792. v.ignore = false;
  8793. });
  8794. // Position the app bar on that face
  8795. _this.ui.position.copyFrom(target.position);
  8796. if (facing.direction.x) {
  8797. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8798. _this.ui.position.addInPlace(_this._tmpVector);
  8799. }
  8800. if (facing.direction.y) {
  8801. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8802. _this.ui.position.addInPlace(_this._tmpVector);
  8803. }
  8804. if (facing.direction.z) {
  8805. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8806. _this.ui.position.addInPlace(_this._tmpVector);
  8807. }
  8808. // Rotate to be oriented properly to the camera
  8809. if (!_this.ui.rotationQuaternion) {
  8810. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8811. }
  8812. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8813. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8814. // Place ui the correct distance from the bottom of the mesh
  8815. if (facingUp.direction.x) {
  8816. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8817. }
  8818. if (facingUp.direction.y) {
  8819. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8820. }
  8821. if (facingUp.direction.z) {
  8822. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8823. }
  8824. _this.ui.position.addInPlace(_this._tmpVector);
  8825. });
  8826. };
  8827. /**
  8828. * Detaches the behavior from the mesh
  8829. */
  8830. AttachToBoxBehavior.prototype.detach = function () {
  8831. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8832. };
  8833. return AttachToBoxBehavior;
  8834. }());
  8835. /***/ }),
  8836. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8837. /*!***********************************************!*\
  8838. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8839. \***********************************************/
  8840. /*! exports provided: FadeInOutBehavior */
  8841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8842. "use strict";
  8843. __webpack_require__.r(__webpack_exports__);
  8844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8845. /**
  8846. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8847. */
  8848. var FadeInOutBehavior = /** @class */ (function () {
  8849. /**
  8850. * Instatiates the FadeInOutBehavior
  8851. */
  8852. function FadeInOutBehavior() {
  8853. var _this = this;
  8854. /**
  8855. * Time in milliseconds to delay before fading in (Default: 0)
  8856. */
  8857. this.delay = 0;
  8858. /**
  8859. * Time in milliseconds for the mesh to fade in (Default: 300)
  8860. */
  8861. this.fadeInTime = 300;
  8862. this._millisecondsPerFrame = 1000 / 60;
  8863. this._hovered = false;
  8864. this._hoverValue = 0;
  8865. this._ownerNode = null;
  8866. this._update = function () {
  8867. if (_this._ownerNode) {
  8868. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8869. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8870. if (_this._ownerNode.visibility > 1) {
  8871. _this._setAllVisibility(_this._ownerNode, 1);
  8872. _this._hoverValue = _this.fadeInTime + _this.delay;
  8873. return;
  8874. }
  8875. else if (_this._ownerNode.visibility < 0) {
  8876. _this._setAllVisibility(_this._ownerNode, 0);
  8877. if (_this._hoverValue < 0) {
  8878. _this._hoverValue = 0;
  8879. return;
  8880. }
  8881. }
  8882. setTimeout(_this._update, _this._millisecondsPerFrame);
  8883. }
  8884. };
  8885. }
  8886. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8887. /**
  8888. * The name of the behavior
  8889. */
  8890. get: function () {
  8891. return "FadeInOut";
  8892. },
  8893. enumerable: true,
  8894. configurable: true
  8895. });
  8896. /**
  8897. * Initializes the behavior
  8898. */
  8899. FadeInOutBehavior.prototype.init = function () {
  8900. };
  8901. /**
  8902. * Attaches the fade behavior on the passed in mesh
  8903. * @param ownerNode The mesh that will be faded in/out once attached
  8904. */
  8905. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8906. this._ownerNode = ownerNode;
  8907. this._setAllVisibility(this._ownerNode, 0);
  8908. };
  8909. /**
  8910. * Detaches the behavior from the mesh
  8911. */
  8912. FadeInOutBehavior.prototype.detach = function () {
  8913. this._ownerNode = null;
  8914. };
  8915. /**
  8916. * Triggers the mesh to begin fading in or out
  8917. * @param value if the object should fade in or out (true to fade in)
  8918. */
  8919. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8920. this._hovered = value;
  8921. this._update();
  8922. };
  8923. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8924. var _this = this;
  8925. mesh.visibility = value;
  8926. mesh.getChildMeshes().forEach(function (c) {
  8927. _this._setAllVisibility(c, value);
  8928. });
  8929. };
  8930. return FadeInOutBehavior;
  8931. }());
  8932. /***/ }),
  8933. /***/ "./Behaviors/Meshes/index.ts":
  8934. /*!***********************************!*\
  8935. !*** ./Behaviors/Meshes/index.ts ***!
  8936. \***********************************/
  8937. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8939. "use strict";
  8940. __webpack_require__.r(__webpack_exports__);
  8941. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8943. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8945. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8947. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8949. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8951. /***/ }),
  8952. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8953. /*!*******************************************************!*\
  8954. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8955. \*******************************************************/
  8956. /*! exports provided: MultiPointerScaleBehavior */
  8957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8958. "use strict";
  8959. __webpack_require__.r(__webpack_exports__);
  8960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8961. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8962. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8963. /**
  8964. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8965. */
  8966. var MultiPointerScaleBehavior = /** @class */ (function () {
  8967. /**
  8968. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8969. */
  8970. function MultiPointerScaleBehavior() {
  8971. this._startDistance = 0;
  8972. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8973. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8974. this._sceneRenderObserver = null;
  8975. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8976. this._dragBehaviorA.moveAttached = false;
  8977. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8978. this._dragBehaviorB.moveAttached = false;
  8979. }
  8980. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8981. /**
  8982. * The name of the behavior
  8983. */
  8984. get: function () {
  8985. return "MultiPointerScale";
  8986. },
  8987. enumerable: true,
  8988. configurable: true
  8989. });
  8990. /**
  8991. * Initializes the behavior
  8992. */
  8993. MultiPointerScaleBehavior.prototype.init = function () { };
  8994. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8995. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8996. };
  8997. /**
  8998. * Attaches the scale behavior the passed in mesh
  8999. * @param ownerNode The mesh that will be scaled around once attached
  9000. */
  9001. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9002. var _this = this;
  9003. this._ownerNode = ownerNode;
  9004. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9005. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9006. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9007. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9008. _this._dragBehaviorA.releaseDrag();
  9009. }
  9010. else {
  9011. _this._initialScale.copyFrom(ownerNode.scaling);
  9012. _this._startDistance = _this._getCurrentDistance();
  9013. }
  9014. }
  9015. });
  9016. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9017. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9018. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9019. _this._dragBehaviorB.releaseDrag();
  9020. }
  9021. else {
  9022. _this._initialScale.copyFrom(ownerNode.scaling);
  9023. _this._startDistance = _this._getCurrentDistance();
  9024. }
  9025. }
  9026. });
  9027. // Once both drag behaviors are active scale based on the distance between the two pointers
  9028. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9029. behavior.onDragObservable.add(function () {
  9030. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9031. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9032. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9033. }
  9034. });
  9035. });
  9036. ownerNode.addBehavior(this._dragBehaviorA);
  9037. ownerNode.addBehavior(this._dragBehaviorB);
  9038. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9039. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9040. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9041. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9042. if (change.length() > 0.01) {
  9043. ownerNode.scaling.addInPlace(change);
  9044. }
  9045. }
  9046. });
  9047. };
  9048. /**
  9049. * Detaches the behavior from the mesh
  9050. */
  9051. MultiPointerScaleBehavior.prototype.detach = function () {
  9052. var _this = this;
  9053. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9054. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9055. behavior.onDragStartObservable.clear();
  9056. behavior.onDragObservable.clear();
  9057. _this._ownerNode.removeBehavior(behavior);
  9058. });
  9059. };
  9060. return MultiPointerScaleBehavior;
  9061. }());
  9062. /***/ }),
  9063. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9064. /*!*************************************************!*\
  9065. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9066. \*************************************************/
  9067. /*! exports provided: PointerDragBehavior */
  9068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9069. "use strict";
  9070. __webpack_require__.r(__webpack_exports__);
  9071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9072. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9073. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9074. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9075. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9076. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9077. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9078. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9079. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9080. /**
  9081. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9082. */
  9083. var PointerDragBehavior = /** @class */ (function () {
  9084. /**
  9085. * Creates a pointer drag behavior that can be attached to a mesh
  9086. * @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)
  9087. */
  9088. function PointerDragBehavior(options) {
  9089. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9090. /**
  9091. * 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)
  9092. */
  9093. this.maxDragAngle = 0;
  9094. /**
  9095. * @hidden
  9096. */
  9097. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9098. /**
  9099. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9100. */
  9101. this.currentDraggingPointerID = -1;
  9102. /**
  9103. * If the behavior is currently in a dragging state
  9104. */
  9105. this.dragging = false;
  9106. /**
  9107. * 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)
  9108. */
  9109. this.dragDeltaRatio = 0.2;
  9110. /**
  9111. * If the drag plane orientation should be updated during the dragging (Default: true)
  9112. */
  9113. this.updateDragPlane = true;
  9114. // Debug mode will display drag planes to help visualize behavior
  9115. this._debugMode = false;
  9116. this._moving = false;
  9117. /**
  9118. * Fires each time the attached mesh is dragged with the pointer
  9119. * * delta between last drag position and current drag position in world space
  9120. * * dragDistance along the drag axis
  9121. * * dragPlaneNormal normal of the current drag plane used during the drag
  9122. * * dragPlanePoint in world space where the drag intersects the drag plane
  9123. */
  9124. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9125. /**
  9126. * Fires each time a drag begins (eg. mouse down on mesh)
  9127. */
  9128. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9129. /**
  9130. * Fires each time a drag ends (eg. mouse release after drag)
  9131. */
  9132. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9133. /**
  9134. * If the attached mesh should be moved when dragged
  9135. */
  9136. this.moveAttached = true;
  9137. /**
  9138. * If the drag behavior will react to drag events (Default: true)
  9139. */
  9140. this.enabled = true;
  9141. /**
  9142. * If camera controls should be detached during the drag
  9143. */
  9144. this.detachCameraControls = true;
  9145. /**
  9146. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9147. */
  9148. this.useObjectOrienationForDragging = true;
  9149. /**
  9150. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9151. */
  9152. this.validateDrag = function (targetPosition) { return true; };
  9153. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9154. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9155. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9156. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9157. this._attachedElement = null;
  9158. 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"]());
  9159. this._lastPointerRay = {};
  9160. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9161. // Variables to avoid instantiation in the below method
  9162. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9163. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9164. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9165. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9166. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9167. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9168. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9169. this._options = options ? options : {};
  9170. var optionCount = 0;
  9171. if (this._options.dragAxis) {
  9172. optionCount++;
  9173. }
  9174. if (this._options.dragPlaneNormal) {
  9175. optionCount++;
  9176. }
  9177. if (optionCount > 1) {
  9178. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9179. }
  9180. }
  9181. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9182. /**
  9183. * The name of the behavior
  9184. */
  9185. get: function () {
  9186. return "PointerDrag";
  9187. },
  9188. enumerable: true,
  9189. configurable: true
  9190. });
  9191. /**
  9192. * Initializes the behavior
  9193. */
  9194. PointerDragBehavior.prototype.init = function () { };
  9195. /**
  9196. * Attaches the drag behavior the passed in mesh
  9197. * @param ownerNode The mesh that will be dragged around once attached
  9198. */
  9199. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9200. var _this = this;
  9201. this._scene = ownerNode.getScene();
  9202. this._attachedNode = ownerNode;
  9203. // Initialize drag plane to not interfere with existing scene
  9204. if (!PointerDragBehavior._planeScene) {
  9205. if (this._debugMode) {
  9206. PointerDragBehavior._planeScene = this._scene;
  9207. }
  9208. else {
  9209. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9210. PointerDragBehavior._planeScene.detachControl();
  9211. this._scene.getEngine().scenes.pop();
  9212. this._scene.onDisposeObservable.addOnce(function () {
  9213. PointerDragBehavior._planeScene.dispose();
  9214. PointerDragBehavior._planeScene = null;
  9215. });
  9216. }
  9217. }
  9218. 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);
  9219. // State of the drag
  9220. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9221. var pickPredicate = function (m) {
  9222. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9223. };
  9224. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9225. if (!_this.enabled) {
  9226. return;
  9227. }
  9228. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9229. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9230. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9231. }
  9232. }
  9233. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9234. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9235. _this.releaseDrag();
  9236. }
  9237. }
  9238. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9239. var pointerId = pointerInfo.event.pointerId;
  9240. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9241. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9242. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9243. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9244. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9245. }
  9246. _this.currentDraggingPointerID = pointerId;
  9247. }
  9248. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9249. if (!_this._lastPointerRay[pointerId]) {
  9250. _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"]());
  9251. }
  9252. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9253. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9254. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9255. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9256. _this._moveDrag(pointerInfo.pickInfo.ray);
  9257. }
  9258. }
  9259. }
  9260. });
  9261. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9262. if (_this._moving && _this.moveAttached) {
  9263. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9264. // Slowly move mesh to avoid jitter
  9265. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9266. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9267. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9268. if (_this.validateDrag(_this._tmpVector)) {
  9269. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9270. }
  9271. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9272. }
  9273. });
  9274. };
  9275. /**
  9276. * Force relase the drag action by code.
  9277. */
  9278. PointerDragBehavior.prototype.releaseDrag = function () {
  9279. this.dragging = false;
  9280. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9281. this.currentDraggingPointerID = -1;
  9282. this._moving = false;
  9283. // Reattach camera controls
  9284. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9285. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9286. }
  9287. };
  9288. /**
  9289. * Simulates the start of a pointer drag event on the behavior
  9290. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9291. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9292. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9293. */
  9294. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9295. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9296. this._startDrag(pointerId, fromRay, startPickedPoint);
  9297. var lastRay = this._lastPointerRay[pointerId];
  9298. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9299. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9300. }
  9301. if (lastRay) {
  9302. // if there was a last pointer ray drag the object there
  9303. this._moveDrag(lastRay);
  9304. }
  9305. };
  9306. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9307. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9308. return;
  9309. }
  9310. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9311. // Create start ray from the camera to the object
  9312. if (fromRay) {
  9313. this._startDragRay.direction.copyFrom(fromRay.direction);
  9314. this._startDragRay.origin.copyFrom(fromRay.origin);
  9315. }
  9316. else {
  9317. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9318. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9319. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9320. }
  9321. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9322. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9323. if (pickedPoint) {
  9324. this.dragging = true;
  9325. this.currentDraggingPointerID = pointerId;
  9326. this.lastDragPosition.copyFrom(pickedPoint);
  9327. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9328. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9329. // Detatch camera controls
  9330. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9331. if (this._scene.activeCamera.inputs.attachedElement) {
  9332. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9333. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9334. }
  9335. else {
  9336. this._attachedElement = null;
  9337. }
  9338. }
  9339. }
  9340. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9341. };
  9342. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9343. this._moving = true;
  9344. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9345. if (pickedPoint) {
  9346. if (this.updateDragPlane) {
  9347. this._updateDragPlanePosition(ray, pickedPoint);
  9348. }
  9349. var dragLength = 0;
  9350. // depending on the drag mode option drag accordingly
  9351. if (this._options.dragAxis) {
  9352. // Convert local drag axis to world
  9353. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9354. // Project delta drag from the drag plane onto the drag axis
  9355. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9356. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9357. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9358. }
  9359. else {
  9360. dragLength = this._dragDelta.length();
  9361. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9362. }
  9363. this._targetPosition.addInPlace(this._dragDelta);
  9364. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9365. this.lastDragPosition.copyFrom(pickedPoint);
  9366. }
  9367. };
  9368. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9369. var _this = this;
  9370. if (!ray) {
  9371. return null;
  9372. }
  9373. // Calculate angle between plane normal and ray
  9374. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9375. // Correct if ray is casted from oposite side
  9376. if (angle > Math.PI / 2) {
  9377. angle = Math.PI - angle;
  9378. }
  9379. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9380. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9381. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9382. // Invert ray direction along the towards object axis
  9383. this._tmpVector.copyFrom(ray.direction);
  9384. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9385. this._alternatePickedPoint.normalize();
  9386. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9387. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9388. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9389. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9390. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9391. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9392. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9393. return this._alternatePickedPoint;
  9394. }
  9395. else {
  9396. return null;
  9397. }
  9398. }
  9399. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9400. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9401. return pickResult.pickedPoint;
  9402. }
  9403. else {
  9404. return null;
  9405. }
  9406. };
  9407. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9408. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9409. this._pointA.copyFrom(dragPlanePosition);
  9410. if (this._options.dragAxis) {
  9411. 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);
  9412. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9413. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9414. ray.origin.subtractToRef(this._pointA, this._pointC);
  9415. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9416. // Get perpendicular line from direction to camera and drag axis
  9417. this._pointB.subtractToRef(this._pointA, this._lineA);
  9418. this._pointC.subtractToRef(this._pointA, this._lineB);
  9419. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9420. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9421. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9422. this._lookAt.normalize();
  9423. this._dragPlane.position.copyFrom(this._pointA);
  9424. this._pointA.addToRef(this._lookAt, this._lookAt);
  9425. this._dragPlane.lookAt(this._lookAt);
  9426. }
  9427. else if (this._options.dragPlaneNormal) {
  9428. 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);
  9429. this._dragPlane.position.copyFrom(this._pointA);
  9430. this._pointA.addToRef(this._localAxis, this._lookAt);
  9431. this._dragPlane.lookAt(this._lookAt);
  9432. }
  9433. else {
  9434. this._dragPlane.position.copyFrom(this._pointA);
  9435. this._dragPlane.lookAt(ray.origin);
  9436. }
  9437. // 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)
  9438. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9439. this._dragPlane.computeWorldMatrix(true);
  9440. };
  9441. /**
  9442. * Detaches the behavior from the mesh
  9443. */
  9444. PointerDragBehavior.prototype.detach = function () {
  9445. if (this._pointerObserver) {
  9446. this._scene.onPointerObservable.remove(this._pointerObserver);
  9447. }
  9448. if (this._beforeRenderObserver) {
  9449. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9450. }
  9451. this.releaseDrag();
  9452. };
  9453. PointerDragBehavior._AnyMouseID = -2;
  9454. return PointerDragBehavior;
  9455. }());
  9456. /***/ }),
  9457. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9458. /*!************************************************!*\
  9459. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9460. \************************************************/
  9461. /*! exports provided: SixDofDragBehavior */
  9462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9463. "use strict";
  9464. __webpack_require__.r(__webpack_exports__);
  9465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9466. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9467. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9468. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9469. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9470. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9471. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9472. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9473. /**
  9474. * 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
  9475. */
  9476. var SixDofDragBehavior = /** @class */ (function () {
  9477. /**
  9478. * 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
  9479. */
  9480. function SixDofDragBehavior() {
  9481. this._sceneRenderObserver = null;
  9482. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9483. this._moving = false;
  9484. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9485. /**
  9486. * 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)
  9487. */
  9488. this.zDragFactor = 3;
  9489. /**
  9490. * If the object should rotate to face the drag origin
  9491. */
  9492. this.rotateDraggedObject = true;
  9493. /**
  9494. * If the behavior is currently in a dragging state
  9495. */
  9496. this.dragging = false;
  9497. /**
  9498. * 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)
  9499. */
  9500. this.dragDeltaRatio = 0.2;
  9501. /**
  9502. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9503. */
  9504. this.currentDraggingPointerID = -1;
  9505. /**
  9506. * If camera controls should be detached during the drag
  9507. */
  9508. this.detachCameraControls = true;
  9509. /**
  9510. * Fires each time a drag starts
  9511. */
  9512. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9513. /**
  9514. * Fires each time a drag ends (eg. mouse release after drag)
  9515. */
  9516. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9517. }
  9518. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9519. /**
  9520. * The name of the behavior
  9521. */
  9522. get: function () {
  9523. return "SixDofDrag";
  9524. },
  9525. enumerable: true,
  9526. configurable: true
  9527. });
  9528. /**
  9529. * Initializes the behavior
  9530. */
  9531. SixDofDragBehavior.prototype.init = function () { };
  9532. /**
  9533. * Attaches the scale behavior the passed in mesh
  9534. * @param ownerNode The mesh that will be scaled around once attached
  9535. */
  9536. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9537. var _this = this;
  9538. this._ownerNode = ownerNode;
  9539. this._scene = this._ownerNode.getScene();
  9540. if (!SixDofDragBehavior._virtualScene) {
  9541. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9542. SixDofDragBehavior._virtualScene.detachControl();
  9543. this._scene.getEngine().scenes.pop();
  9544. }
  9545. var pickedMesh = null;
  9546. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9547. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9548. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9549. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9550. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9551. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9552. var pickPredicate = function (m) {
  9553. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9554. };
  9555. var attachedElement = null;
  9556. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9557. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9558. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9559. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9560. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9561. }
  9562. pickedMesh = _this._ownerNode;
  9563. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9564. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9565. // Set position and orientation of the controller
  9566. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9567. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9568. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9569. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9570. pickedMesh.computeWorldMatrix();
  9571. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9572. if (!pickedMesh.rotationQuaternion) {
  9573. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9574. }
  9575. var oldParent = pickedMesh.parent;
  9576. pickedMesh.setParent(null);
  9577. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9578. pickedMesh.setParent(oldParent);
  9579. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9580. // Update state
  9581. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9582. _this.dragging = true;
  9583. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9584. // Detatch camera controls
  9585. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9586. if (_this._scene.activeCamera.inputs.attachedElement) {
  9587. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9588. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9589. }
  9590. else {
  9591. attachedElement = null;
  9592. }
  9593. }
  9594. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9595. _this.onDragStartObservable.notifyObservers({});
  9596. }
  9597. }
  9598. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9599. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9600. _this.dragging = false;
  9601. _this._moving = false;
  9602. _this.currentDraggingPointerID = -1;
  9603. pickedMesh = null;
  9604. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9605. // Reattach camera controls
  9606. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9607. _this._scene.activeCamera.attachControl(attachedElement, true);
  9608. }
  9609. _this.onDragEndObservable.notifyObservers({});
  9610. }
  9611. }
  9612. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9613. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9614. var zDragFactor = _this.zDragFactor;
  9615. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9616. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9617. zDragFactor = 0;
  9618. }
  9619. // Calculate controller drag distance in controller space
  9620. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9621. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9622. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9623. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9624. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9625. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9626. if (_this._virtualDragMesh.position.z < 0) {
  9627. _this._virtualDragMesh.position.z = 0;
  9628. }
  9629. // Update the controller position
  9630. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9631. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9632. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9633. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9634. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9635. if (pickedMesh.parent) {
  9636. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9637. }
  9638. if (!_this._moving) {
  9639. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9640. }
  9641. _this._moving = true;
  9642. }
  9643. }
  9644. });
  9645. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9646. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9647. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9648. if (_this.dragging && _this._moving && pickedMesh) {
  9649. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9650. // Slowly move mesh to avoid jitter
  9651. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9652. if (_this.rotateDraggedObject) {
  9653. // Get change in rotation
  9654. tmpQuaternion.copyFrom(_this._startingOrientation);
  9655. tmpQuaternion.x = -tmpQuaternion.x;
  9656. tmpQuaternion.y = -tmpQuaternion.y;
  9657. tmpQuaternion.z = -tmpQuaternion.z;
  9658. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9659. // Convert change in rotation to only y axis rotation
  9660. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9661. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9662. // Slowly move mesh to avoid jitter
  9663. var oldParent = pickedMesh.parent;
  9664. // Only rotate the mesh if it's parent has uniform scaling
  9665. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9666. pickedMesh.setParent(null);
  9667. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9668. pickedMesh.setParent(oldParent);
  9669. }
  9670. }
  9671. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9672. }
  9673. });
  9674. };
  9675. /**
  9676. * Detaches the behavior from the mesh
  9677. */
  9678. SixDofDragBehavior.prototype.detach = function () {
  9679. if (this._scene) {
  9680. this._scene.onPointerObservable.remove(this._pointerObserver);
  9681. }
  9682. if (this._ownerNode) {
  9683. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9684. }
  9685. if (this._virtualOriginMesh) {
  9686. this._virtualOriginMesh.dispose();
  9687. }
  9688. if (this._virtualDragMesh) {
  9689. this._virtualDragMesh.dispose();
  9690. }
  9691. this.onDragEndObservable.clear();
  9692. this.onDragStartObservable.clear();
  9693. };
  9694. return SixDofDragBehavior;
  9695. }());
  9696. /***/ }),
  9697. /***/ "./Behaviors/index.ts":
  9698. /*!****************************!*\
  9699. !*** ./Behaviors/index.ts ***!
  9700. \****************************/
  9701. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9703. "use strict";
  9704. __webpack_require__.r(__webpack_exports__);
  9705. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9709. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9715. /***/ }),
  9716. /***/ "./Bones/bone.ts":
  9717. /*!***********************!*\
  9718. !*** ./Bones/bone.ts ***!
  9719. \***********************/
  9720. /*! exports provided: Bone */
  9721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9722. "use strict";
  9723. __webpack_require__.r(__webpack_exports__);
  9724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9725. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9726. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9727. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9728. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9729. /**
  9730. * Class used to store bone information
  9731. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9732. */
  9733. var Bone = /** @class */ (function (_super) {
  9734. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9735. /**
  9736. * Create a new bone
  9737. * @param name defines the bone name
  9738. * @param skeleton defines the parent skeleton
  9739. * @param parentBone defines the parent (can be null if the bone is the root)
  9740. * @param localMatrix defines the local matrix
  9741. * @param restPose defines the rest pose matrix
  9742. * @param baseMatrix defines the base matrix
  9743. * @param index defines index of the bone in the hiearchy
  9744. */
  9745. function Bone(
  9746. /**
  9747. * defines the bone name
  9748. */
  9749. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9750. if (parentBone === void 0) { parentBone = null; }
  9751. if (localMatrix === void 0) { localMatrix = null; }
  9752. if (restPose === void 0) { restPose = null; }
  9753. if (baseMatrix === void 0) { baseMatrix = null; }
  9754. if (index === void 0) { index = null; }
  9755. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9756. _this.name = name;
  9757. /**
  9758. * Gets the list of child bones
  9759. */
  9760. _this.children = new Array();
  9761. /** Gets the animations associated with this bone */
  9762. _this.animations = new Array();
  9763. /**
  9764. * @hidden Internal only
  9765. * Set this value to map this bone to a different index in the transform matrices
  9766. * Set this value to -1 to exclude the bone from the transform matrices
  9767. */
  9768. _this._index = null;
  9769. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9770. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9771. _this._scalingDeterminant = 1;
  9772. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9773. _this._needToDecompose = true;
  9774. _this._needToCompose = false;
  9775. /** @hidden */
  9776. _this._linkedTransformNode = null;
  9777. _this._skeleton = skeleton;
  9778. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9779. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9780. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9781. _this._index = index;
  9782. skeleton.bones.push(_this);
  9783. _this.setParent(parentBone, false);
  9784. if (baseMatrix || localMatrix) {
  9785. _this._updateDifferenceMatrix();
  9786. }
  9787. return _this;
  9788. }
  9789. Object.defineProperty(Bone.prototype, "_matrix", {
  9790. /** @hidden */
  9791. get: function () {
  9792. this._compose();
  9793. return this._localMatrix;
  9794. },
  9795. /** @hidden */
  9796. set: function (value) {
  9797. this._localMatrix.copyFrom(value);
  9798. this._needToDecompose = true;
  9799. },
  9800. enumerable: true,
  9801. configurable: true
  9802. });
  9803. /**
  9804. * Gets the current object class name.
  9805. * @return the class name
  9806. */
  9807. Bone.prototype.getClassName = function () {
  9808. return "Bone";
  9809. };
  9810. // Members
  9811. /**
  9812. * Gets the parent skeleton
  9813. * @returns a skeleton
  9814. */
  9815. Bone.prototype.getSkeleton = function () {
  9816. return this._skeleton;
  9817. };
  9818. /**
  9819. * Gets parent bone
  9820. * @returns a bone or null if the bone is the root of the bone hierarchy
  9821. */
  9822. Bone.prototype.getParent = function () {
  9823. return this._parent;
  9824. };
  9825. /**
  9826. * Returns an array containing the root bones
  9827. * @returns an array containing the root bones
  9828. */
  9829. Bone.prototype.getChildren = function () {
  9830. return this.children;
  9831. };
  9832. /**
  9833. * Sets the parent bone
  9834. * @param parent defines the parent (can be null if the bone is the root)
  9835. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9836. */
  9837. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9838. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9839. if (this._parent === parent) {
  9840. return;
  9841. }
  9842. if (this._parent) {
  9843. var index = this._parent.children.indexOf(this);
  9844. if (index !== -1) {
  9845. this._parent.children.splice(index, 1);
  9846. }
  9847. }
  9848. this._parent = parent;
  9849. if (this._parent) {
  9850. this._parent.children.push(this);
  9851. }
  9852. if (updateDifferenceMatrix) {
  9853. this._updateDifferenceMatrix();
  9854. }
  9855. this.markAsDirty();
  9856. };
  9857. /**
  9858. * Gets the local matrix
  9859. * @returns a matrix
  9860. */
  9861. Bone.prototype.getLocalMatrix = function () {
  9862. this._compose();
  9863. return this._localMatrix;
  9864. };
  9865. /**
  9866. * Gets the base matrix (initial matrix which remains unchanged)
  9867. * @returns a matrix
  9868. */
  9869. Bone.prototype.getBaseMatrix = function () {
  9870. return this._baseMatrix;
  9871. };
  9872. /**
  9873. * Gets the rest pose matrix
  9874. * @returns a matrix
  9875. */
  9876. Bone.prototype.getRestPose = function () {
  9877. return this._restPose;
  9878. };
  9879. /**
  9880. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9881. */
  9882. Bone.prototype.getWorldMatrix = function () {
  9883. return this._worldTransform;
  9884. };
  9885. /**
  9886. * Sets the local matrix to rest pose matrix
  9887. */
  9888. Bone.prototype.returnToRest = function () {
  9889. this.updateMatrix(this._restPose.clone());
  9890. };
  9891. /**
  9892. * Gets the inverse of the absolute transform matrix.
  9893. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9894. * @returns a matrix
  9895. */
  9896. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9897. return this._invertedAbsoluteTransform;
  9898. };
  9899. /**
  9900. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9901. * @returns a matrix
  9902. */
  9903. Bone.prototype.getAbsoluteTransform = function () {
  9904. return this._absoluteTransform;
  9905. };
  9906. /**
  9907. * Links with the given transform node.
  9908. * The local matrix of this bone is copied from the transform node every frame.
  9909. * @param transformNode defines the transform node to link to
  9910. */
  9911. Bone.prototype.linkTransformNode = function (transformNode) {
  9912. if (this._linkedTransformNode) {
  9913. this._skeleton._numBonesWithLinkedTransformNode--;
  9914. }
  9915. this._linkedTransformNode = transformNode;
  9916. if (this._linkedTransformNode) {
  9917. this._skeleton._numBonesWithLinkedTransformNode++;
  9918. }
  9919. };
  9920. Object.defineProperty(Bone.prototype, "position", {
  9921. // Properties (matches AbstractMesh properties)
  9922. /** Gets or sets current position (in local space) */
  9923. get: function () {
  9924. this._decompose();
  9925. return this._localPosition;
  9926. },
  9927. set: function (newPosition) {
  9928. this._decompose();
  9929. this._localPosition.copyFrom(newPosition);
  9930. this._markAsDirtyAndCompose();
  9931. },
  9932. enumerable: true,
  9933. configurable: true
  9934. });
  9935. Object.defineProperty(Bone.prototype, "rotation", {
  9936. /** Gets or sets current rotation (in local space) */
  9937. get: function () {
  9938. return this.getRotation();
  9939. },
  9940. set: function (newRotation) {
  9941. this.setRotation(newRotation);
  9942. },
  9943. enumerable: true,
  9944. configurable: true
  9945. });
  9946. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9947. /** Gets or sets current rotation quaternion (in local space) */
  9948. get: function () {
  9949. this._decompose();
  9950. return this._localRotation;
  9951. },
  9952. set: function (newRotation) {
  9953. this.setRotationQuaternion(newRotation);
  9954. },
  9955. enumerable: true,
  9956. configurable: true
  9957. });
  9958. Object.defineProperty(Bone.prototype, "scaling", {
  9959. /** Gets or sets current scaling (in local space) */
  9960. get: function () {
  9961. return this.getScale();
  9962. },
  9963. set: function (newScaling) {
  9964. this.setScale(newScaling);
  9965. },
  9966. enumerable: true,
  9967. configurable: true
  9968. });
  9969. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9970. /**
  9971. * Gets the animation properties override
  9972. */
  9973. get: function () {
  9974. return this._skeleton.animationPropertiesOverride;
  9975. },
  9976. enumerable: true,
  9977. configurable: true
  9978. });
  9979. // Methods
  9980. Bone.prototype._decompose = function () {
  9981. if (!this._needToDecompose) {
  9982. return;
  9983. }
  9984. this._needToDecompose = false;
  9985. if (!this._localScaling) {
  9986. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9987. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9988. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9989. }
  9990. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9991. };
  9992. Bone.prototype._compose = function () {
  9993. if (!this._needToCompose) {
  9994. return;
  9995. }
  9996. this._needToCompose = false;
  9997. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9998. };
  9999. /**
  10000. * Update the base and local matrices
  10001. * @param matrix defines the new base or local matrix
  10002. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10003. * @param updateLocalMatrix defines if the local matrix should be updated
  10004. */
  10005. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10006. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10007. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10008. this._baseMatrix.copyFrom(matrix);
  10009. if (updateDifferenceMatrix) {
  10010. this._updateDifferenceMatrix();
  10011. }
  10012. if (updateLocalMatrix) {
  10013. this._localMatrix.copyFrom(matrix);
  10014. this._markAsDirtyAndDecompose();
  10015. }
  10016. else {
  10017. this.markAsDirty();
  10018. }
  10019. };
  10020. /** @hidden */
  10021. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10022. if (updateChildren === void 0) { updateChildren = true; }
  10023. if (!rootMatrix) {
  10024. rootMatrix = this._baseMatrix;
  10025. }
  10026. if (this._parent) {
  10027. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10028. }
  10029. else {
  10030. this._absoluteTransform.copyFrom(rootMatrix);
  10031. }
  10032. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10033. if (updateChildren) {
  10034. for (var index = 0; index < this.children.length; index++) {
  10035. this.children[index]._updateDifferenceMatrix();
  10036. }
  10037. }
  10038. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10039. };
  10040. /**
  10041. * Flag the bone as dirty (Forcing it to update everything)
  10042. */
  10043. Bone.prototype.markAsDirty = function () {
  10044. this._currentRenderId++;
  10045. this._childRenderId++;
  10046. this._skeleton._markAsDirty();
  10047. };
  10048. Bone.prototype._markAsDirtyAndCompose = function () {
  10049. this.markAsDirty();
  10050. this._needToCompose = true;
  10051. };
  10052. Bone.prototype._markAsDirtyAndDecompose = function () {
  10053. this.markAsDirty();
  10054. this._needToDecompose = true;
  10055. };
  10056. /**
  10057. * Translate the bone in local or world space
  10058. * @param vec The amount to translate the bone
  10059. * @param space The space that the translation is in
  10060. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10061. */
  10062. Bone.prototype.translate = function (vec, space, mesh) {
  10063. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10064. var lm = this.getLocalMatrix();
  10065. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10066. lm.addAtIndex(12, vec.x);
  10067. lm.addAtIndex(13, vec.y);
  10068. lm.addAtIndex(14, vec.z);
  10069. }
  10070. else {
  10071. var wm = null;
  10072. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10073. if (mesh) {
  10074. wm = mesh.getWorldMatrix();
  10075. }
  10076. this._skeleton.computeAbsoluteTransforms();
  10077. var tmat = Bone._tmpMats[0];
  10078. var tvec = Bone._tmpVecs[0];
  10079. if (this._parent) {
  10080. if (mesh && wm) {
  10081. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10082. tmat.multiplyToRef(wm, tmat);
  10083. }
  10084. else {
  10085. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10086. }
  10087. }
  10088. tmat.setTranslationFromFloats(0, 0, 0);
  10089. tmat.invert();
  10090. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10091. lm.addAtIndex(12, tvec.x);
  10092. lm.addAtIndex(13, tvec.y);
  10093. lm.addAtIndex(14, tvec.z);
  10094. }
  10095. this._markAsDirtyAndDecompose();
  10096. };
  10097. /**
  10098. * Set the postion of the bone in local or world space
  10099. * @param position The position to set the bone
  10100. * @param space The space that the position is in
  10101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10102. */
  10103. Bone.prototype.setPosition = function (position, space, mesh) {
  10104. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10105. var lm = this.getLocalMatrix();
  10106. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10107. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10108. }
  10109. else {
  10110. var wm = null;
  10111. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10112. if (mesh) {
  10113. wm = mesh.getWorldMatrix();
  10114. }
  10115. this._skeleton.computeAbsoluteTransforms();
  10116. var tmat = Bone._tmpMats[0];
  10117. var vec = Bone._tmpVecs[0];
  10118. if (this._parent) {
  10119. if (mesh && wm) {
  10120. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10121. tmat.multiplyToRef(wm, tmat);
  10122. }
  10123. else {
  10124. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10125. }
  10126. }
  10127. tmat.invert();
  10128. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10129. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10130. }
  10131. this._markAsDirtyAndDecompose();
  10132. };
  10133. /**
  10134. * Set the absolute position of the bone (world space)
  10135. * @param position The position to set the bone
  10136. * @param mesh The mesh that this bone is attached to
  10137. */
  10138. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10139. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10140. };
  10141. /**
  10142. * Scale the bone on the x, y and z axes (in local space)
  10143. * @param x The amount to scale the bone on the x axis
  10144. * @param y The amount to scale the bone on the y axis
  10145. * @param z The amount to scale the bone on the z axis
  10146. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10147. */
  10148. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10149. if (scaleChildren === void 0) { scaleChildren = false; }
  10150. var locMat = this.getLocalMatrix();
  10151. // Apply new scaling on top of current local matrix
  10152. var scaleMat = Bone._tmpMats[0];
  10153. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10154. scaleMat.multiplyToRef(locMat, locMat);
  10155. // Invert scaling matrix and apply the inverse to all children
  10156. scaleMat.invert();
  10157. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10158. var child = _a[_i];
  10159. var cm = child.getLocalMatrix();
  10160. cm.multiplyToRef(scaleMat, cm);
  10161. cm.multiplyAtIndex(12, x);
  10162. cm.multiplyAtIndex(13, y);
  10163. cm.multiplyAtIndex(14, z);
  10164. child._markAsDirtyAndDecompose();
  10165. }
  10166. this._markAsDirtyAndDecompose();
  10167. if (scaleChildren) {
  10168. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10169. var child = _c[_b];
  10170. child.scale(x, y, z, scaleChildren);
  10171. }
  10172. }
  10173. };
  10174. /**
  10175. * Set the bone scaling in local space
  10176. * @param scale defines the scaling vector
  10177. */
  10178. Bone.prototype.setScale = function (scale) {
  10179. this._decompose();
  10180. this._localScaling.copyFrom(scale);
  10181. this._markAsDirtyAndCompose();
  10182. };
  10183. /**
  10184. * Gets the current scaling in local space
  10185. * @returns the current scaling vector
  10186. */
  10187. Bone.prototype.getScale = function () {
  10188. this._decompose();
  10189. return this._localScaling;
  10190. };
  10191. /**
  10192. * Gets the current scaling in local space and stores it in a target vector
  10193. * @param result defines the target vector
  10194. */
  10195. Bone.prototype.getScaleToRef = function (result) {
  10196. this._decompose();
  10197. result.copyFrom(this._localScaling);
  10198. };
  10199. /**
  10200. * Set the yaw, pitch, and roll of the bone in local or world space
  10201. * @param yaw The rotation of the bone on the y axis
  10202. * @param pitch The rotation of the bone on the x axis
  10203. * @param roll The rotation of the bone on the z axis
  10204. * @param space The space that the axes of rotation are in
  10205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10206. */
  10207. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10208. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10209. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10210. var quat = Bone._tmpQuat;
  10211. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10212. this.setRotationQuaternion(quat, space, mesh);
  10213. return;
  10214. }
  10215. var rotMatInv = Bone._tmpMats[0];
  10216. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10217. return;
  10218. }
  10219. var rotMat = Bone._tmpMats[1];
  10220. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10221. rotMatInv.multiplyToRef(rotMat, rotMat);
  10222. this._rotateWithMatrix(rotMat, space, mesh);
  10223. };
  10224. /**
  10225. * Add a rotation to the bone on an axis in local or world space
  10226. * @param axis The axis to rotate the bone on
  10227. * @param amount The amount to rotate the bone
  10228. * @param space The space that the axis is in
  10229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10230. */
  10231. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10232. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10233. var rmat = Bone._tmpMats[0];
  10234. rmat.setTranslationFromFloats(0, 0, 0);
  10235. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10236. this._rotateWithMatrix(rmat, space, mesh);
  10237. };
  10238. /**
  10239. * Set the rotation of the bone to a particular axis angle in local or world space
  10240. * @param axis The axis to rotate the bone on
  10241. * @param angle The angle that the bone should be rotated to
  10242. * @param space The space that the axis is in
  10243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10244. */
  10245. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10246. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10247. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10248. var quat = Bone._tmpQuat;
  10249. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10250. this.setRotationQuaternion(quat, space, mesh);
  10251. return;
  10252. }
  10253. var rotMatInv = Bone._tmpMats[0];
  10254. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10255. return;
  10256. }
  10257. var rotMat = Bone._tmpMats[1];
  10258. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10259. rotMatInv.multiplyToRef(rotMat, rotMat);
  10260. this._rotateWithMatrix(rotMat, space, mesh);
  10261. };
  10262. /**
  10263. * Set the euler rotation of the bone in local of world space
  10264. * @param rotation The euler rotation that the bone should be set to
  10265. * @param space The space that the rotation is in
  10266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10267. */
  10268. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10269. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10270. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10271. };
  10272. /**
  10273. * Set the quaternion rotation of the bone in local of world space
  10274. * @param quat The quaternion rotation that the bone should be set to
  10275. * @param space The space that the rotation is in
  10276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10277. */
  10278. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10279. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10280. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10281. this._decompose();
  10282. this._localRotation.copyFrom(quat);
  10283. this._markAsDirtyAndCompose();
  10284. return;
  10285. }
  10286. var rotMatInv = Bone._tmpMats[0];
  10287. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10288. return;
  10289. }
  10290. var rotMat = Bone._tmpMats[1];
  10291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10292. rotMatInv.multiplyToRef(rotMat, rotMat);
  10293. this._rotateWithMatrix(rotMat, space, mesh);
  10294. };
  10295. /**
  10296. * Set the rotation matrix of the bone in local of world space
  10297. * @param rotMat The rotation matrix that the bone should be set to
  10298. * @param space The space that the rotation is in
  10299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10300. */
  10301. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10302. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10303. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10304. var quat = Bone._tmpQuat;
  10305. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10306. this.setRotationQuaternion(quat, space, mesh);
  10307. return;
  10308. }
  10309. var rotMatInv = Bone._tmpMats[0];
  10310. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10311. return;
  10312. }
  10313. var rotMat2 = Bone._tmpMats[1];
  10314. rotMat2.copyFrom(rotMat);
  10315. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10316. this._rotateWithMatrix(rotMat2, space, mesh);
  10317. };
  10318. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10319. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10320. var lmat = this.getLocalMatrix();
  10321. var lx = lmat.m[12];
  10322. var ly = lmat.m[13];
  10323. var lz = lmat.m[14];
  10324. var parent = this.getParent();
  10325. var parentScale = Bone._tmpMats[3];
  10326. var parentScaleInv = Bone._tmpMats[4];
  10327. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10328. if (mesh) {
  10329. parentScale.copyFrom(mesh.getWorldMatrix());
  10330. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10331. }
  10332. else {
  10333. parentScale.copyFrom(parent.getAbsoluteTransform());
  10334. }
  10335. parentScaleInv.copyFrom(parentScale);
  10336. parentScaleInv.invert();
  10337. lmat.multiplyToRef(parentScale, lmat);
  10338. lmat.multiplyToRef(rmat, lmat);
  10339. lmat.multiplyToRef(parentScaleInv, lmat);
  10340. }
  10341. else {
  10342. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10343. parentScale.copyFrom(mesh.getWorldMatrix());
  10344. parentScaleInv.copyFrom(parentScale);
  10345. parentScaleInv.invert();
  10346. lmat.multiplyToRef(parentScale, lmat);
  10347. lmat.multiplyToRef(rmat, lmat);
  10348. lmat.multiplyToRef(parentScaleInv, lmat);
  10349. }
  10350. else {
  10351. lmat.multiplyToRef(rmat, lmat);
  10352. }
  10353. }
  10354. lmat.setTranslationFromFloats(lx, ly, lz);
  10355. this.computeAbsoluteTransforms();
  10356. this._markAsDirtyAndDecompose();
  10357. };
  10358. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10359. var scaleMatrix = Bone._tmpMats[2];
  10360. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10361. if (mesh) {
  10362. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10363. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10364. }
  10365. rotMatInv.invert();
  10366. if (isNaN(rotMatInv.m[0])) {
  10367. // Matrix failed to invert.
  10368. // This can happen if scale is zero for example.
  10369. return false;
  10370. }
  10371. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10372. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10373. return true;
  10374. };
  10375. /**
  10376. * Get the position of the bone in local or world space
  10377. * @param space The space that the returned position is in
  10378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10379. * @returns The position of the bone
  10380. */
  10381. Bone.prototype.getPosition = function (space, mesh) {
  10382. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10383. if (mesh === void 0) { mesh = null; }
  10384. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10385. this.getPositionToRef(space, mesh, pos);
  10386. return pos;
  10387. };
  10388. /**
  10389. * Copy the position of the bone to a vector3 in local or world space
  10390. * @param space The space that the returned position is in
  10391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10392. * @param result The vector3 to copy the position to
  10393. */
  10394. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10395. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10396. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10397. var lm = this.getLocalMatrix();
  10398. result.x = lm.m[12];
  10399. result.y = lm.m[13];
  10400. result.z = lm.m[14];
  10401. }
  10402. else {
  10403. var wm = null;
  10404. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10405. if (mesh) {
  10406. wm = mesh.getWorldMatrix();
  10407. }
  10408. this._skeleton.computeAbsoluteTransforms();
  10409. var tmat = Bone._tmpMats[0];
  10410. if (mesh && wm) {
  10411. tmat.copyFrom(this.getAbsoluteTransform());
  10412. tmat.multiplyToRef(wm, tmat);
  10413. }
  10414. else {
  10415. tmat = this.getAbsoluteTransform();
  10416. }
  10417. result.x = tmat.m[12];
  10418. result.y = tmat.m[13];
  10419. result.z = tmat.m[14];
  10420. }
  10421. };
  10422. /**
  10423. * Get the absolute position of the bone (world space)
  10424. * @param mesh The mesh that this bone is attached to
  10425. * @returns The absolute position of the bone
  10426. */
  10427. Bone.prototype.getAbsolutePosition = function (mesh) {
  10428. if (mesh === void 0) { mesh = null; }
  10429. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10430. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10431. return pos;
  10432. };
  10433. /**
  10434. * Copy the absolute position of the bone (world space) to the result param
  10435. * @param mesh The mesh that this bone is attached to
  10436. * @param result The vector3 to copy the absolute position to
  10437. */
  10438. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10439. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10440. };
  10441. /**
  10442. * Compute the absolute transforms of this bone and its children
  10443. */
  10444. Bone.prototype.computeAbsoluteTransforms = function () {
  10445. this._compose();
  10446. if (this._parent) {
  10447. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10448. }
  10449. else {
  10450. this._absoluteTransform.copyFrom(this._localMatrix);
  10451. var poseMatrix = this._skeleton.getPoseMatrix();
  10452. if (poseMatrix) {
  10453. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10454. }
  10455. }
  10456. var children = this.children;
  10457. var len = children.length;
  10458. for (var i = 0; i < len; i++) {
  10459. children[i].computeAbsoluteTransforms();
  10460. }
  10461. };
  10462. /**
  10463. * Get the world direction from an axis that is in the local space of the bone
  10464. * @param localAxis The local direction that is used to compute the world direction
  10465. * @param mesh The mesh that this bone is attached to
  10466. * @returns The world direction
  10467. */
  10468. Bone.prototype.getDirection = function (localAxis, mesh) {
  10469. if (mesh === void 0) { mesh = null; }
  10470. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10471. this.getDirectionToRef(localAxis, mesh, result);
  10472. return result;
  10473. };
  10474. /**
  10475. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10476. * @param localAxis The local direction that is used to compute the world direction
  10477. * @param mesh The mesh that this bone is attached to
  10478. * @param result The vector3 that the world direction will be copied to
  10479. */
  10480. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10481. if (mesh === void 0) { mesh = null; }
  10482. var wm = null;
  10483. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10484. if (mesh) {
  10485. wm = mesh.getWorldMatrix();
  10486. }
  10487. this._skeleton.computeAbsoluteTransforms();
  10488. var mat = Bone._tmpMats[0];
  10489. mat.copyFrom(this.getAbsoluteTransform());
  10490. if (mesh && wm) {
  10491. mat.multiplyToRef(wm, mat);
  10492. }
  10493. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10494. result.normalize();
  10495. };
  10496. /**
  10497. * Get the euler rotation of the bone in local or world space
  10498. * @param space The space that the rotation should be in
  10499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10500. * @returns The euler rotation
  10501. */
  10502. Bone.prototype.getRotation = function (space, mesh) {
  10503. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10504. if (mesh === void 0) { mesh = null; }
  10505. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10506. this.getRotationToRef(space, mesh, result);
  10507. return result;
  10508. };
  10509. /**
  10510. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10511. * @param space The space that the rotation should be in
  10512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10513. * @param result The vector3 that the rotation should be copied to
  10514. */
  10515. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10516. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10517. if (mesh === void 0) { mesh = null; }
  10518. var quat = Bone._tmpQuat;
  10519. this.getRotationQuaternionToRef(space, mesh, quat);
  10520. quat.toEulerAnglesToRef(result);
  10521. };
  10522. /**
  10523. * Get the quaternion rotation of the bone in either local or world space
  10524. * @param space The space that the rotation should be in
  10525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10526. * @returns The quaternion rotation
  10527. */
  10528. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10529. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10530. if (mesh === void 0) { mesh = null; }
  10531. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10532. this.getRotationQuaternionToRef(space, mesh, result);
  10533. return result;
  10534. };
  10535. /**
  10536. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10537. * @param space The space that the rotation should be in
  10538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10539. * @param result The quaternion that the rotation should be copied to
  10540. */
  10541. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10542. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10543. if (mesh === void 0) { mesh = null; }
  10544. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10545. this._decompose();
  10546. result.copyFrom(this._localRotation);
  10547. }
  10548. else {
  10549. var mat = Bone._tmpMats[0];
  10550. var amat = this.getAbsoluteTransform();
  10551. if (mesh) {
  10552. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10553. }
  10554. else {
  10555. mat.copyFrom(amat);
  10556. }
  10557. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10558. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10559. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10560. mat.decompose(undefined, result, undefined);
  10561. }
  10562. };
  10563. /**
  10564. * Get the rotation matrix of the bone in local or world space
  10565. * @param space The space that the rotation should be in
  10566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10567. * @returns The rotation matrix
  10568. */
  10569. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10570. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10571. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10572. this.getRotationMatrixToRef(space, mesh, result);
  10573. return result;
  10574. };
  10575. /**
  10576. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10577. * @param space The space that the rotation should be in
  10578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10579. * @param result The quaternion that the rotation should be copied to
  10580. */
  10581. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10582. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10583. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10584. this.getLocalMatrix().getRotationMatrixToRef(result);
  10585. }
  10586. else {
  10587. var mat = Bone._tmpMats[0];
  10588. var amat = this.getAbsoluteTransform();
  10589. if (mesh) {
  10590. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10591. }
  10592. else {
  10593. mat.copyFrom(amat);
  10594. }
  10595. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10596. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10597. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10598. mat.getRotationMatrixToRef(result);
  10599. }
  10600. };
  10601. /**
  10602. * Get the world position of a point that is in the local space of the bone
  10603. * @param position The local position
  10604. * @param mesh The mesh that this bone is attached to
  10605. * @returns The world position
  10606. */
  10607. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10608. if (mesh === void 0) { mesh = null; }
  10609. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10610. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10611. return result;
  10612. };
  10613. /**
  10614. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10615. * @param position The local position
  10616. * @param mesh The mesh that this bone is attached to
  10617. * @param result The vector3 that the world position should be copied to
  10618. */
  10619. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10620. if (mesh === void 0) { mesh = null; }
  10621. var wm = null;
  10622. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10623. if (mesh) {
  10624. wm = mesh.getWorldMatrix();
  10625. }
  10626. this._skeleton.computeAbsoluteTransforms();
  10627. var tmat = Bone._tmpMats[0];
  10628. if (mesh && wm) {
  10629. tmat.copyFrom(this.getAbsoluteTransform());
  10630. tmat.multiplyToRef(wm, tmat);
  10631. }
  10632. else {
  10633. tmat = this.getAbsoluteTransform();
  10634. }
  10635. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10636. };
  10637. /**
  10638. * Get the local position of a point that is in world space
  10639. * @param position The world position
  10640. * @param mesh The mesh that this bone is attached to
  10641. * @returns The local position
  10642. */
  10643. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10644. if (mesh === void 0) { mesh = null; }
  10645. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10646. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10647. return result;
  10648. };
  10649. /**
  10650. * Get the local position of a point that is in world space and copy it to the result param
  10651. * @param position The world position
  10652. * @param mesh The mesh that this bone is attached to
  10653. * @param result The vector3 that the local position should be copied to
  10654. */
  10655. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10656. if (mesh === void 0) { mesh = null; }
  10657. var wm = null;
  10658. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10659. if (mesh) {
  10660. wm = mesh.getWorldMatrix();
  10661. }
  10662. this._skeleton.computeAbsoluteTransforms();
  10663. var tmat = Bone._tmpMats[0];
  10664. tmat.copyFrom(this.getAbsoluteTransform());
  10665. if (mesh && wm) {
  10666. tmat.multiplyToRef(wm, tmat);
  10667. }
  10668. tmat.invert();
  10669. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10670. };
  10671. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10672. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10673. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10674. return Bone;
  10675. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10676. /***/ }),
  10677. /***/ "./Bones/boneIKController.ts":
  10678. /*!***********************************!*\
  10679. !*** ./Bones/boneIKController.ts ***!
  10680. \***********************************/
  10681. /*! exports provided: BoneIKController */
  10682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10683. "use strict";
  10684. __webpack_require__.r(__webpack_exports__);
  10685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10686. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10687. /**
  10688. * Class used to apply inverse kinematics to bones
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10690. */
  10691. var BoneIKController = /** @class */ (function () {
  10692. /**
  10693. * Creates a new BoneIKController
  10694. * @param mesh defines the mesh to control
  10695. * @param bone defines the bone to control
  10696. * @param options defines options to set up the controller
  10697. */
  10698. function BoneIKController(mesh, bone, options) {
  10699. /**
  10700. * Gets or sets the target position
  10701. */
  10702. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10703. /**
  10704. * Gets or sets the pole target position
  10705. */
  10706. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10707. /**
  10708. * Gets or sets the pole target local offset
  10709. */
  10710. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10711. /**
  10712. * Gets or sets the pole angle
  10713. */
  10714. this.poleAngle = 0;
  10715. /**
  10716. * 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)
  10717. */
  10718. this.slerpAmount = 1;
  10719. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10720. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10721. this._bone2Ang = Math.PI;
  10722. this._maxAngle = Math.PI;
  10723. this._rightHandedSystem = false;
  10724. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10725. this._slerping = false;
  10726. this._adjustRoll = 0;
  10727. this._bone2 = bone;
  10728. this._bone1 = bone.getParent();
  10729. if (!this._bone1) {
  10730. return;
  10731. }
  10732. this.mesh = mesh;
  10733. var bonePos = bone.getPosition();
  10734. if (bone.getAbsoluteTransform().determinant() > 0) {
  10735. this._rightHandedSystem = true;
  10736. this._bendAxis.x = 0;
  10737. this._bendAxis.y = 0;
  10738. this._bendAxis.z = -1;
  10739. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10740. this._adjustRoll = Math.PI * .5;
  10741. this._bendAxis.z = 1;
  10742. }
  10743. }
  10744. if (this._bone1.length) {
  10745. var boneScale1 = this._bone1.getScale();
  10746. var boneScale2 = this._bone2.getScale();
  10747. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10748. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10749. }
  10750. else if (this._bone1.children[0]) {
  10751. mesh.computeWorldMatrix(true);
  10752. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10753. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10754. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10755. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10756. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10757. }
  10758. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10759. this.maxAngle = Math.PI;
  10760. if (options) {
  10761. if (options.targetMesh) {
  10762. this.targetMesh = options.targetMesh;
  10763. this.targetMesh.computeWorldMatrix(true);
  10764. }
  10765. if (options.poleTargetMesh) {
  10766. this.poleTargetMesh = options.poleTargetMesh;
  10767. this.poleTargetMesh.computeWorldMatrix(true);
  10768. }
  10769. else if (options.poleTargetBone) {
  10770. this.poleTargetBone = options.poleTargetBone;
  10771. }
  10772. else if (this._bone1.getParent()) {
  10773. this.poleTargetBone = this._bone1.getParent();
  10774. }
  10775. if (options.poleTargetLocalOffset) {
  10776. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10777. }
  10778. if (options.poleAngle) {
  10779. this.poleAngle = options.poleAngle;
  10780. }
  10781. if (options.bendAxis) {
  10782. this._bendAxis.copyFrom(options.bendAxis);
  10783. }
  10784. if (options.maxAngle) {
  10785. this.maxAngle = options.maxAngle;
  10786. }
  10787. if (options.slerpAmount) {
  10788. this.slerpAmount = options.slerpAmount;
  10789. }
  10790. }
  10791. }
  10792. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10793. /**
  10794. * Gets or sets maximum allowed angle
  10795. */
  10796. get: function () {
  10797. return this._maxAngle;
  10798. },
  10799. set: function (value) {
  10800. this._setMaxAngle(value);
  10801. },
  10802. enumerable: true,
  10803. configurable: true
  10804. });
  10805. BoneIKController.prototype._setMaxAngle = function (ang) {
  10806. if (ang < 0) {
  10807. ang = 0;
  10808. }
  10809. if (ang > Math.PI || ang == undefined) {
  10810. ang = Math.PI;
  10811. }
  10812. this._maxAngle = ang;
  10813. var a = this._bone1Length;
  10814. var b = this._bone2Length;
  10815. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10816. };
  10817. /**
  10818. * Force the controller to update the bones
  10819. */
  10820. BoneIKController.prototype.update = function () {
  10821. var bone1 = this._bone1;
  10822. if (!bone1) {
  10823. return;
  10824. }
  10825. var target = this.targetPosition;
  10826. var poleTarget = this.poleTargetPosition;
  10827. var mat1 = BoneIKController._tmpMats[0];
  10828. var mat2 = BoneIKController._tmpMats[1];
  10829. if (this.targetMesh) {
  10830. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10831. }
  10832. if (this.poleTargetBone) {
  10833. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10834. }
  10835. else if (this.poleTargetMesh) {
  10836. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10837. }
  10838. var bonePos = BoneIKController._tmpVecs[0];
  10839. var zaxis = BoneIKController._tmpVecs[1];
  10840. var xaxis = BoneIKController._tmpVecs[2];
  10841. var yaxis = BoneIKController._tmpVecs[3];
  10842. var upAxis = BoneIKController._tmpVecs[4];
  10843. var _tmpQuat = BoneIKController._tmpQuat;
  10844. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10845. poleTarget.subtractToRef(bonePos, upAxis);
  10846. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10847. upAxis.y = 1;
  10848. }
  10849. else {
  10850. upAxis.normalize();
  10851. }
  10852. target.subtractToRef(bonePos, yaxis);
  10853. yaxis.normalize();
  10854. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10855. zaxis.normalize();
  10856. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10857. xaxis.normalize();
  10858. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10859. var a = this._bone1Length;
  10860. var b = this._bone2Length;
  10861. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10862. if (this._maxReach > 0) {
  10863. c = Math.min(this._maxReach, c);
  10864. }
  10865. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10866. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10867. if (acosa > 1) {
  10868. acosa = 1;
  10869. }
  10870. if (acosb > 1) {
  10871. acosb = 1;
  10872. }
  10873. if (acosa < -1) {
  10874. acosa = -1;
  10875. }
  10876. if (acosb < -1) {
  10877. acosb = -1;
  10878. }
  10879. var angA = Math.acos(acosa);
  10880. var angB = Math.acos(acosb);
  10881. var angC = -angA - angB;
  10882. if (this._rightHandedSystem) {
  10883. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10884. mat2.multiplyToRef(mat1, mat1);
  10885. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10886. mat2.multiplyToRef(mat1, mat1);
  10887. }
  10888. else {
  10889. var _tmpVec = BoneIKController._tmpVecs[5];
  10890. _tmpVec.copyFrom(this._bendAxis);
  10891. _tmpVec.x *= -1;
  10892. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10893. mat2.multiplyToRef(mat1, mat1);
  10894. }
  10895. if (this.poleAngle) {
  10896. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10897. mat1.multiplyToRef(mat2, mat1);
  10898. }
  10899. if (this._bone1) {
  10900. if (this.slerpAmount < 1) {
  10901. if (!this._slerping) {
  10902. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10903. }
  10904. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10905. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10906. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10907. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10908. this._slerping = true;
  10909. }
  10910. else {
  10911. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10912. this._bone1Mat.copyFrom(mat1);
  10913. this._slerping = false;
  10914. }
  10915. }
  10916. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10917. this._bone2Ang = angC;
  10918. };
  10919. 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()];
  10920. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10921. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10922. return BoneIKController;
  10923. }());
  10924. /***/ }),
  10925. /***/ "./Bones/boneLookController.ts":
  10926. /*!*************************************!*\
  10927. !*** ./Bones/boneLookController.ts ***!
  10928. \*************************************/
  10929. /*! exports provided: BoneLookController */
  10930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10931. "use strict";
  10932. __webpack_require__.r(__webpack_exports__);
  10933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10934. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10935. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10936. /**
  10937. * Class used to make a bone look toward a point in space
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10939. */
  10940. var BoneLookController = /** @class */ (function () {
  10941. /**
  10942. * Create a BoneLookController
  10943. * @param mesh the mesh that the bone belongs to
  10944. * @param bone the bone that will be looking to the target
  10945. * @param target the target Vector3 to look at
  10946. * @param options optional settings:
  10947. * * maxYaw: the maximum angle the bone will yaw to
  10948. * * minYaw: the minimum angle the bone will yaw to
  10949. * * maxPitch: the maximum angle the bone will pitch to
  10950. * * minPitch: the minimum angle the bone will yaw to
  10951. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10952. * * upAxis: the up axis of the coordinate system
  10953. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10954. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10955. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10956. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10957. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10958. * * adjustRoll: used to make an adjustment to the roll of the bone
  10959. **/
  10960. function BoneLookController(mesh, bone, target, options) {
  10961. /**
  10962. * The up axis of the coordinate system that is used when the bone is rotated
  10963. */
  10964. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10965. /**
  10966. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10967. */
  10968. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10969. /**
  10970. * Used to make an adjustment to the yaw of the bone
  10971. */
  10972. this.adjustYaw = 0;
  10973. /**
  10974. * Used to make an adjustment to the pitch of the bone
  10975. */
  10976. this.adjustPitch = 0;
  10977. /**
  10978. * Used to make an adjustment to the roll of the bone
  10979. */
  10980. this.adjustRoll = 0;
  10981. /**
  10982. * 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)
  10983. */
  10984. this.slerpAmount = 1;
  10985. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10986. this._slerping = false;
  10987. this._firstFrameSkipped = false;
  10988. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10989. this.mesh = mesh;
  10990. this.bone = bone;
  10991. this.target = target;
  10992. if (options) {
  10993. if (options.adjustYaw) {
  10994. this.adjustYaw = options.adjustYaw;
  10995. }
  10996. if (options.adjustPitch) {
  10997. this.adjustPitch = options.adjustPitch;
  10998. }
  10999. if (options.adjustRoll) {
  11000. this.adjustRoll = options.adjustRoll;
  11001. }
  11002. if (options.maxYaw != null) {
  11003. this.maxYaw = options.maxYaw;
  11004. }
  11005. else {
  11006. this.maxYaw = Math.PI;
  11007. }
  11008. if (options.minYaw != null) {
  11009. this.minYaw = options.minYaw;
  11010. }
  11011. else {
  11012. this.minYaw = -Math.PI;
  11013. }
  11014. if (options.maxPitch != null) {
  11015. this.maxPitch = options.maxPitch;
  11016. }
  11017. else {
  11018. this.maxPitch = Math.PI;
  11019. }
  11020. if (options.minPitch != null) {
  11021. this.minPitch = options.minPitch;
  11022. }
  11023. else {
  11024. this.minPitch = -Math.PI;
  11025. }
  11026. if (options.slerpAmount != null) {
  11027. this.slerpAmount = options.slerpAmount;
  11028. }
  11029. if (options.upAxis != null) {
  11030. this.upAxis = options.upAxis;
  11031. }
  11032. if (options.upAxisSpace != null) {
  11033. this.upAxisSpace = options.upAxisSpace;
  11034. }
  11035. if (options.yawAxis != null || options.pitchAxis != null) {
  11036. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11037. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11038. if (options.yawAxis != null) {
  11039. newYawAxis = options.yawAxis.clone();
  11040. newYawAxis.normalize();
  11041. }
  11042. if (options.pitchAxis != null) {
  11043. newPitchAxis = options.pitchAxis.clone();
  11044. newPitchAxis.normalize();
  11045. }
  11046. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11047. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11048. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11049. this._transformYawPitchInv = this._transformYawPitch.clone();
  11050. this._transformYawPitch.invert();
  11051. }
  11052. }
  11053. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11054. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11055. }
  11056. }
  11057. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11058. /**
  11059. * Gets or sets the minimum yaw angle that the bone can look to
  11060. */
  11061. get: function () {
  11062. return this._minYaw;
  11063. },
  11064. set: function (value) {
  11065. this._minYaw = value;
  11066. this._minYawSin = Math.sin(value);
  11067. this._minYawCos = Math.cos(value);
  11068. if (this._maxYaw != null) {
  11069. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11070. this._yawRange = this._maxYaw - this._minYaw;
  11071. }
  11072. },
  11073. enumerable: true,
  11074. configurable: true
  11075. });
  11076. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11077. /**
  11078. * Gets or sets the maximum yaw angle that the bone can look to
  11079. */
  11080. get: function () {
  11081. return this._maxYaw;
  11082. },
  11083. set: function (value) {
  11084. this._maxYaw = value;
  11085. this._maxYawSin = Math.sin(value);
  11086. this._maxYawCos = Math.cos(value);
  11087. if (this._minYaw != null) {
  11088. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11089. this._yawRange = this._maxYaw - this._minYaw;
  11090. }
  11091. },
  11092. enumerable: true,
  11093. configurable: true
  11094. });
  11095. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11096. /**
  11097. * Gets or sets the minimum pitch angle that the bone can look to
  11098. */
  11099. get: function () {
  11100. return this._minPitch;
  11101. },
  11102. set: function (value) {
  11103. this._minPitch = value;
  11104. this._minPitchTan = Math.tan(value);
  11105. },
  11106. enumerable: true,
  11107. configurable: true
  11108. });
  11109. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11110. /**
  11111. * Gets or sets the maximum pitch angle that the bone can look to
  11112. */
  11113. get: function () {
  11114. return this._maxPitch;
  11115. },
  11116. set: function (value) {
  11117. this._maxPitch = value;
  11118. this._maxPitchTan = Math.tan(value);
  11119. },
  11120. enumerable: true,
  11121. configurable: true
  11122. });
  11123. /**
  11124. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11125. */
  11126. BoneLookController.prototype.update = function () {
  11127. //skip the first frame when slerping so that the mesh rotation is correct
  11128. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11129. this._firstFrameSkipped = true;
  11130. return;
  11131. }
  11132. var bone = this.bone;
  11133. var bonePos = BoneLookController._tmpVecs[0];
  11134. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11135. var target = this.target;
  11136. var _tmpMat1 = BoneLookController._tmpMats[0];
  11137. var _tmpMat2 = BoneLookController._tmpMats[1];
  11138. var mesh = this.mesh;
  11139. var parentBone = bone.getParent();
  11140. var upAxis = BoneLookController._tmpVecs[1];
  11141. upAxis.copyFrom(this.upAxis);
  11142. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11143. if (this._transformYawPitch) {
  11144. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11145. }
  11146. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11147. }
  11148. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11149. mesh.getDirectionToRef(upAxis, upAxis);
  11150. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11151. upAxis.normalize();
  11152. }
  11153. }
  11154. var checkYaw = false;
  11155. var checkPitch = false;
  11156. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11157. checkYaw = true;
  11158. }
  11159. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11160. checkPitch = true;
  11161. }
  11162. if (checkYaw || checkPitch) {
  11163. var spaceMat = BoneLookController._tmpMats[2];
  11164. var spaceMatInv = BoneLookController._tmpMats[3];
  11165. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11166. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11167. }
  11168. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11169. spaceMat.copyFrom(mesh.getWorldMatrix());
  11170. }
  11171. else {
  11172. var forwardAxis = BoneLookController._tmpVecs[2];
  11173. forwardAxis.copyFrom(this._fowardAxis);
  11174. if (this._transformYawPitch) {
  11175. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11176. }
  11177. if (parentBone) {
  11178. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11179. }
  11180. else {
  11181. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11182. }
  11183. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11184. rightAxis.normalize();
  11185. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11186. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11187. }
  11188. spaceMat.invertToRef(spaceMatInv);
  11189. var xzlen = null;
  11190. if (checkPitch) {
  11191. var localTarget = BoneLookController._tmpVecs[3];
  11192. target.subtractToRef(bonePos, localTarget);
  11193. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11194. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11195. var pitch = Math.atan2(localTarget.y, xzlen);
  11196. var newPitch = pitch;
  11197. if (pitch > this._maxPitch) {
  11198. localTarget.y = this._maxPitchTan * xzlen;
  11199. newPitch = this._maxPitch;
  11200. }
  11201. else if (pitch < this._minPitch) {
  11202. localTarget.y = this._minPitchTan * xzlen;
  11203. newPitch = this._minPitch;
  11204. }
  11205. if (pitch != newPitch) {
  11206. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11207. localTarget.addInPlace(bonePos);
  11208. target = localTarget;
  11209. }
  11210. }
  11211. if (checkYaw) {
  11212. var localTarget = BoneLookController._tmpVecs[4];
  11213. target.subtractToRef(bonePos, localTarget);
  11214. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11215. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11216. var newYaw = yaw;
  11217. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11218. if (xzlen == null) {
  11219. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11220. }
  11221. if (this._yawRange > Math.PI) {
  11222. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11223. localTarget.z = this._maxYawCos * xzlen;
  11224. localTarget.x = this._maxYawSin * xzlen;
  11225. newYaw = this._maxYaw;
  11226. }
  11227. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11228. localTarget.z = this._minYawCos * xzlen;
  11229. localTarget.x = this._minYawSin * xzlen;
  11230. newYaw = this._minYaw;
  11231. }
  11232. }
  11233. else {
  11234. if (yaw > this._maxYaw) {
  11235. localTarget.z = this._maxYawCos * xzlen;
  11236. localTarget.x = this._maxYawSin * xzlen;
  11237. newYaw = this._maxYaw;
  11238. }
  11239. else if (yaw < this._minYaw) {
  11240. localTarget.z = this._minYawCos * xzlen;
  11241. localTarget.x = this._minYawSin * xzlen;
  11242. newYaw = this._minYaw;
  11243. }
  11244. }
  11245. }
  11246. if (this._slerping && this._yawRange > Math.PI) {
  11247. //are we going to be crossing into the min/max region?
  11248. var boneFwd = BoneLookController._tmpVecs[8];
  11249. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11250. if (this._transformYawPitch) {
  11251. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11252. }
  11253. var boneRotMat = BoneLookController._tmpMats[4];
  11254. this._boneQuat.toRotationMatrix(boneRotMat);
  11255. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11256. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11257. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11258. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11259. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11260. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11261. if (angBtwTar > angBtwMidYaw) {
  11262. if (xzlen == null) {
  11263. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11264. }
  11265. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11266. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11267. if (angBtwMin < angBtwMax) {
  11268. newYaw = boneYaw + Math.PI * .75;
  11269. localTarget.z = Math.cos(newYaw) * xzlen;
  11270. localTarget.x = Math.sin(newYaw) * xzlen;
  11271. }
  11272. else {
  11273. newYaw = boneYaw - Math.PI * .75;
  11274. localTarget.z = Math.cos(newYaw) * xzlen;
  11275. localTarget.x = Math.sin(newYaw) * xzlen;
  11276. }
  11277. }
  11278. }
  11279. if (yaw != newYaw) {
  11280. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11281. localTarget.addInPlace(bonePos);
  11282. target = localTarget;
  11283. }
  11284. }
  11285. }
  11286. var zaxis = BoneLookController._tmpVecs[5];
  11287. var xaxis = BoneLookController._tmpVecs[6];
  11288. var yaxis = BoneLookController._tmpVecs[7];
  11289. var _tmpQuat = BoneLookController._tmpQuat;
  11290. target.subtractToRef(bonePos, zaxis);
  11291. zaxis.normalize();
  11292. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11293. xaxis.normalize();
  11294. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11295. yaxis.normalize();
  11296. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11297. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11298. return;
  11299. }
  11300. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11301. return;
  11302. }
  11303. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11304. return;
  11305. }
  11306. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11307. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11308. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11309. }
  11310. if (this.slerpAmount < 1) {
  11311. if (!this._slerping) {
  11312. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11313. }
  11314. if (this._transformYawPitch) {
  11315. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11316. }
  11317. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11318. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11319. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11320. this._slerping = true;
  11321. }
  11322. else {
  11323. if (this._transformYawPitch) {
  11324. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11325. }
  11326. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11327. this._slerping = false;
  11328. }
  11329. };
  11330. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11331. var angDiff = ang2 - ang1;
  11332. angDiff %= Math.PI * 2;
  11333. if (angDiff > Math.PI) {
  11334. angDiff -= Math.PI * 2;
  11335. }
  11336. else if (angDiff < -Math.PI) {
  11337. angDiff += Math.PI * 2;
  11338. }
  11339. return angDiff;
  11340. };
  11341. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11342. ang1 %= (2 * Math.PI);
  11343. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11344. ang2 %= (2 * Math.PI);
  11345. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11346. var ab = 0;
  11347. if (ang1 < ang2) {
  11348. ab = ang2 - ang1;
  11349. }
  11350. else {
  11351. ab = ang1 - ang2;
  11352. }
  11353. if (ab > Math.PI) {
  11354. ab = Math.PI * 2 - ab;
  11355. }
  11356. return ab;
  11357. };
  11358. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11359. ang %= (2 * Math.PI);
  11360. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11361. ang1 %= (2 * Math.PI);
  11362. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11363. ang2 %= (2 * Math.PI);
  11364. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11365. if (ang1 < ang2) {
  11366. if (ang > ang1 && ang < ang2) {
  11367. return true;
  11368. }
  11369. }
  11370. else {
  11371. if (ang > ang2 && ang < ang1) {
  11372. return true;
  11373. }
  11374. }
  11375. return false;
  11376. };
  11377. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11378. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11379. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11380. return BoneLookController;
  11381. }());
  11382. /***/ }),
  11383. /***/ "./Bones/index.ts":
  11384. /*!************************!*\
  11385. !*** ./Bones/index.ts ***!
  11386. \************************/
  11387. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11389. "use strict";
  11390. __webpack_require__.r(__webpack_exports__);
  11391. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11393. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11395. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11397. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11399. /***/ }),
  11400. /***/ "./Bones/skeleton.ts":
  11401. /*!***************************!*\
  11402. !*** ./Bones/skeleton.ts ***!
  11403. \***************************/
  11404. /*! exports provided: Skeleton */
  11405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11406. "use strict";
  11407. __webpack_require__.r(__webpack_exports__);
  11408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11409. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11410. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11411. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11412. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11413. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11414. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11415. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11416. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11417. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11418. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11419. /**
  11420. * Class used to handle skinning animations
  11421. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11422. */
  11423. var Skeleton = /** @class */ (function () {
  11424. /**
  11425. * Creates a new skeleton
  11426. * @param name defines the skeleton name
  11427. * @param id defines the skeleton Id
  11428. * @param scene defines the hosting scene
  11429. */
  11430. function Skeleton(
  11431. /** defines the skeleton name */
  11432. name,
  11433. /** defines the skeleton Id */
  11434. id, scene) {
  11435. this.name = name;
  11436. this.id = id;
  11437. /**
  11438. * Defines the list of child bones
  11439. */
  11440. this.bones = new Array();
  11441. /**
  11442. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11443. */
  11444. this.needInitialSkinMatrix = false;
  11445. /**
  11446. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11447. */
  11448. this.overrideMesh = null;
  11449. this._isDirty = true;
  11450. this._meshesWithPoseMatrix = new Array();
  11451. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11452. this._ranges = {};
  11453. this._lastAbsoluteTransformsUpdateId = -1;
  11454. this._canUseTextureForBones = false;
  11455. this._uniqueId = 0;
  11456. /** @hidden */
  11457. this._numBonesWithLinkedTransformNode = 0;
  11458. /**
  11459. * Specifies if the skeleton should be serialized
  11460. */
  11461. this.doNotSerialize = false;
  11462. this._useTextureToStoreBoneMatrices = true;
  11463. this._animationPropertiesOverride = null;
  11464. // Events
  11465. /**
  11466. * An observable triggered before computing the skeleton's matrices
  11467. */
  11468. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11469. this.bones = [];
  11470. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11471. this._uniqueId = this._scene.getUniqueId();
  11472. this._scene.addSkeleton(this);
  11473. //make sure it will recalculate the matrix next time prepare is called.
  11474. this._isDirty = true;
  11475. var engineCaps = this._scene.getEngine().getCaps();
  11476. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11477. }
  11478. Object.defineProperty(Skeleton.prototype, "useTextureToStoreBoneMatrices", {
  11479. /**
  11480. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11481. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11482. */
  11483. get: function () {
  11484. return this._useTextureToStoreBoneMatrices;
  11485. },
  11486. set: function (value) {
  11487. this._useTextureToStoreBoneMatrices = value;
  11488. this._markAsDirty();
  11489. },
  11490. enumerable: true,
  11491. configurable: true
  11492. });
  11493. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11494. /**
  11495. * Gets or sets the animation properties override
  11496. */
  11497. get: function () {
  11498. if (!this._animationPropertiesOverride) {
  11499. return this._scene.animationPropertiesOverride;
  11500. }
  11501. return this._animationPropertiesOverride;
  11502. },
  11503. set: function (value) {
  11504. this._animationPropertiesOverride = value;
  11505. },
  11506. enumerable: true,
  11507. configurable: true
  11508. });
  11509. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11510. /**
  11511. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11512. */
  11513. get: function () {
  11514. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11515. },
  11516. enumerable: true,
  11517. configurable: true
  11518. });
  11519. Object.defineProperty(Skeleton.prototype, "uniqueId", {
  11520. /**
  11521. * Gets the unique ID of this skeleton
  11522. */
  11523. get: function () {
  11524. return this._uniqueId;
  11525. },
  11526. enumerable: true,
  11527. configurable: true
  11528. });
  11529. /**
  11530. * Gets the current object class name.
  11531. * @return the class name
  11532. */
  11533. Skeleton.prototype.getClassName = function () {
  11534. return "Skeleton";
  11535. };
  11536. /**
  11537. * Returns an array containing the root bones
  11538. * @returns an array containing the root bones
  11539. */
  11540. Skeleton.prototype.getChildren = function () {
  11541. return this.bones.filter(function (b) { return !b.getParent(); });
  11542. };
  11543. // Members
  11544. /**
  11545. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11546. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11547. * @returns a Float32Array containing matrices data
  11548. */
  11549. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11550. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11551. return mesh._bonesTransformMatrices;
  11552. }
  11553. if (!this._transformMatrices) {
  11554. this.prepare();
  11555. }
  11556. return this._transformMatrices;
  11557. };
  11558. /**
  11559. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11560. * @returns a raw texture containing the data
  11561. */
  11562. Skeleton.prototype.getTransformMatrixTexture = function () {
  11563. return this._transformMatrixTexture;
  11564. };
  11565. /**
  11566. * Gets the current hosting scene
  11567. * @returns a scene object
  11568. */
  11569. Skeleton.prototype.getScene = function () {
  11570. return this._scene;
  11571. };
  11572. // Methods
  11573. /**
  11574. * Gets a string representing the current skeleton data
  11575. * @param fullDetails defines a boolean indicating if we want a verbose version
  11576. * @returns a string representing the current skeleton data
  11577. */
  11578. Skeleton.prototype.toString = function (fullDetails) {
  11579. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11580. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11581. if (fullDetails) {
  11582. ret += ", Ranges: {";
  11583. var first = true;
  11584. for (var name_1 in this._ranges) {
  11585. if (first) {
  11586. ret += ", ";
  11587. first = false;
  11588. }
  11589. ret += name_1;
  11590. }
  11591. ret += "}";
  11592. }
  11593. return ret;
  11594. };
  11595. /**
  11596. * Get bone's index searching by name
  11597. * @param name defines bone's name to search for
  11598. * @return the indice of the bone. Returns -1 if not found
  11599. */
  11600. Skeleton.prototype.getBoneIndexByName = function (name) {
  11601. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11602. if (this.bones[boneIndex].name === name) {
  11603. return boneIndex;
  11604. }
  11605. }
  11606. return -1;
  11607. };
  11608. /**
  11609. * Creater a new animation range
  11610. * @param name defines the name of the range
  11611. * @param from defines the start key
  11612. * @param to defines the end key
  11613. */
  11614. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11615. // check name not already in use
  11616. if (!this._ranges[name]) {
  11617. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11618. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11619. if (this.bones[i].animations[0]) {
  11620. this.bones[i].animations[0].createRange(name, from, to);
  11621. }
  11622. }
  11623. }
  11624. };
  11625. /**
  11626. * Delete a specific animation range
  11627. * @param name defines the name of the range
  11628. * @param deleteFrames defines if frames must be removed as well
  11629. */
  11630. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11631. if (deleteFrames === void 0) { deleteFrames = true; }
  11632. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11633. if (this.bones[i].animations[0]) {
  11634. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11635. }
  11636. }
  11637. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11638. };
  11639. /**
  11640. * Gets a specific animation range
  11641. * @param name defines the name of the range to look for
  11642. * @returns the requested animation range or null if not found
  11643. */
  11644. Skeleton.prototype.getAnimationRange = function (name) {
  11645. return this._ranges[name];
  11646. };
  11647. /**
  11648. * Gets the list of all animation ranges defined on this skeleton
  11649. * @returns an array
  11650. */
  11651. Skeleton.prototype.getAnimationRanges = function () {
  11652. var animationRanges = [];
  11653. var name;
  11654. for (name in this._ranges) {
  11655. animationRanges.push(this._ranges[name]);
  11656. }
  11657. return animationRanges;
  11658. };
  11659. /**
  11660. * Copy animation range from a source skeleton.
  11661. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11662. * @param source defines the source skeleton
  11663. * @param name defines the name of the range to copy
  11664. * @param rescaleAsRequired defines if rescaling must be applied if required
  11665. * @returns true if operation was successful
  11666. */
  11667. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11668. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11669. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11670. return false;
  11671. }
  11672. var ret = true;
  11673. var frameOffset = this._getHighestAnimationFrame() + 1;
  11674. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11675. var boneDict = {};
  11676. var sourceBones = source.bones;
  11677. var nBones;
  11678. var i;
  11679. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11680. boneDict[sourceBones[i].name] = sourceBones[i];
  11681. }
  11682. if (this.bones.length !== sourceBones.length) {
  11683. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11684. ret = false;
  11685. }
  11686. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11687. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11688. var boneName = this.bones[i].name;
  11689. var sourceBone = boneDict[boneName];
  11690. if (sourceBone) {
  11691. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11692. }
  11693. else {
  11694. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11695. ret = false;
  11696. }
  11697. }
  11698. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11699. var range = source.getAnimationRange(name);
  11700. if (range) {
  11701. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11702. }
  11703. return ret;
  11704. };
  11705. /**
  11706. * Forces the skeleton to go to rest pose
  11707. */
  11708. Skeleton.prototype.returnToRest = function () {
  11709. for (var index = 0; index < this.bones.length; index++) {
  11710. this.bones[index].returnToRest();
  11711. }
  11712. };
  11713. Skeleton.prototype._getHighestAnimationFrame = function () {
  11714. var ret = 0;
  11715. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11716. if (this.bones[i].animations[0]) {
  11717. var highest = this.bones[i].animations[0].getHighestFrame();
  11718. if (ret < highest) {
  11719. ret = highest;
  11720. }
  11721. }
  11722. }
  11723. return ret;
  11724. };
  11725. /**
  11726. * Begin a specific animation range
  11727. * @param name defines the name of the range to start
  11728. * @param loop defines if looping must be turned on (false by default)
  11729. * @param speedRatio defines the speed ratio to apply (1 by default)
  11730. * @param onAnimationEnd defines a callback which will be called when animation will end
  11731. * @returns a new animatable
  11732. */
  11733. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11734. var range = this.getAnimationRange(name);
  11735. if (!range) {
  11736. return null;
  11737. }
  11738. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11739. };
  11740. /** @hidden */
  11741. Skeleton.prototype._markAsDirty = function () {
  11742. this._isDirty = true;
  11743. };
  11744. /** @hidden */
  11745. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11746. this._meshesWithPoseMatrix.push(mesh);
  11747. };
  11748. /** @hidden */
  11749. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11750. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11751. if (index > -1) {
  11752. this._meshesWithPoseMatrix.splice(index, 1);
  11753. }
  11754. };
  11755. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11756. this.onBeforeComputeObservable.notifyObservers(this);
  11757. for (var index = 0; index < this.bones.length; index++) {
  11758. var bone = this.bones[index];
  11759. var parentBone = bone.getParent();
  11760. if (parentBone) {
  11761. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11762. }
  11763. else {
  11764. if (initialSkinMatrix) {
  11765. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11766. }
  11767. else {
  11768. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11769. }
  11770. }
  11771. if (bone._index !== -1) {
  11772. var mappedIndex = bone._index === null ? index : bone._index;
  11773. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11774. }
  11775. }
  11776. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11777. };
  11778. /**
  11779. * Build all resources required to render a skeleton
  11780. */
  11781. Skeleton.prototype.prepare = function () {
  11782. // Update the local matrix of bones with linked transform nodes.
  11783. if (this._numBonesWithLinkedTransformNode > 0) {
  11784. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11785. var bone_1 = _a[_i];
  11786. if (bone_1._linkedTransformNode) {
  11787. // Computing the world matrix also computes the local matrix.
  11788. bone_1._linkedTransformNode.computeWorldMatrix();
  11789. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11790. bone_1.markAsDirty();
  11791. }
  11792. }
  11793. }
  11794. if (!this._isDirty) {
  11795. return;
  11796. }
  11797. if (this.needInitialSkinMatrix) {
  11798. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11799. var mesh = this._meshesWithPoseMatrix[index];
  11800. var poseMatrix = mesh.getPoseMatrix();
  11801. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11802. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11803. }
  11804. if (this._synchronizedWithMesh !== mesh) {
  11805. this._synchronizedWithMesh = mesh;
  11806. // Prepare bones
  11807. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11808. var bone = this.bones[boneIndex];
  11809. if (!bone.getParent()) {
  11810. var matrix = bone.getBaseMatrix();
  11811. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11812. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11813. }
  11814. }
  11815. }
  11816. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11817. }
  11818. }
  11819. else {
  11820. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11821. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11822. if (this.isUsingTextureForMatrices) {
  11823. if (this._transformMatrixTexture) {
  11824. this._transformMatrixTexture.dispose();
  11825. }
  11826. 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);
  11827. }
  11828. }
  11829. this._computeTransformMatrices(this._transformMatrices, null);
  11830. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11831. this._transformMatrixTexture.update(this._transformMatrices);
  11832. }
  11833. }
  11834. this._isDirty = false;
  11835. this._scene._activeBones.addCount(this.bones.length, false);
  11836. };
  11837. /**
  11838. * Gets the list of animatables currently running for this skeleton
  11839. * @returns an array of animatables
  11840. */
  11841. Skeleton.prototype.getAnimatables = function () {
  11842. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11843. this._animatables = [];
  11844. for (var index = 0; index < this.bones.length; index++) {
  11845. this._animatables.push(this.bones[index]);
  11846. }
  11847. }
  11848. return this._animatables;
  11849. };
  11850. /**
  11851. * Clone the current skeleton
  11852. * @param name defines the name of the new skeleton
  11853. * @param id defines the id of the enw skeleton
  11854. * @returns the new skeleton
  11855. */
  11856. Skeleton.prototype.clone = function (name, id) {
  11857. var result = new Skeleton(name, id || name, this._scene);
  11858. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11859. for (var index = 0; index < this.bones.length; index++) {
  11860. var source = this.bones[index];
  11861. var parentBone = null;
  11862. var parent_1 = source.getParent();
  11863. if (parent_1) {
  11864. var parentIndex = this.bones.indexOf(parent_1);
  11865. parentBone = result.bones[parentIndex];
  11866. }
  11867. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11868. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11869. }
  11870. if (this._ranges) {
  11871. result._ranges = {};
  11872. for (var rangeName in this._ranges) {
  11873. var range = this._ranges[rangeName];
  11874. if (range) {
  11875. result._ranges[rangeName] = range.clone();
  11876. }
  11877. }
  11878. }
  11879. this._isDirty = true;
  11880. return result;
  11881. };
  11882. /**
  11883. * Enable animation blending for this skeleton
  11884. * @param blendingSpeed defines the blending speed to apply
  11885. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11886. */
  11887. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11888. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11889. this.bones.forEach(function (bone) {
  11890. bone.animations.forEach(function (animation) {
  11891. animation.enableBlending = true;
  11892. animation.blendingSpeed = blendingSpeed;
  11893. });
  11894. });
  11895. };
  11896. /**
  11897. * Releases all resources associated with the current skeleton
  11898. */
  11899. Skeleton.prototype.dispose = function () {
  11900. this._meshesWithPoseMatrix = [];
  11901. // Animations
  11902. this.getScene().stopAnimation(this);
  11903. // Remove from scene
  11904. this.getScene().removeSkeleton(this);
  11905. if (this._transformMatrixTexture) {
  11906. this._transformMatrixTexture.dispose();
  11907. this._transformMatrixTexture = null;
  11908. }
  11909. };
  11910. /**
  11911. * Serialize the skeleton in a JSON object
  11912. * @returns a JSON object
  11913. */
  11914. Skeleton.prototype.serialize = function () {
  11915. var serializationObject = {};
  11916. serializationObject.name = this.name;
  11917. serializationObject.id = this.id;
  11918. if (this.dimensionsAtRest) {
  11919. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11920. }
  11921. serializationObject.bones = [];
  11922. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11923. for (var index = 0; index < this.bones.length; index++) {
  11924. var bone = this.bones[index];
  11925. var parent_2 = bone.getParent();
  11926. var serializedBone = {
  11927. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11928. name: bone.name,
  11929. matrix: bone.getBaseMatrix().toArray(),
  11930. rest: bone.getRestPose().toArray()
  11931. };
  11932. serializationObject.bones.push(serializedBone);
  11933. if (bone.length) {
  11934. serializedBone.length = bone.length;
  11935. }
  11936. if (bone.metadata) {
  11937. serializedBone.metadata = bone.metadata;
  11938. }
  11939. if (bone.animations && bone.animations.length > 0) {
  11940. serializedBone.animation = bone.animations[0].serialize();
  11941. }
  11942. serializationObject.ranges = [];
  11943. for (var name in this._ranges) {
  11944. var source = this._ranges[name];
  11945. if (!source) {
  11946. continue;
  11947. }
  11948. var range = {};
  11949. range.name = name;
  11950. range.from = source.from;
  11951. range.to = source.to;
  11952. serializationObject.ranges.push(range);
  11953. }
  11954. }
  11955. return serializationObject;
  11956. };
  11957. /**
  11958. * Creates a new skeleton from serialized data
  11959. * @param parsedSkeleton defines the serialized data
  11960. * @param scene defines the hosting scene
  11961. * @returns a new skeleton
  11962. */
  11963. Skeleton.Parse = function (parsedSkeleton, scene) {
  11964. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11965. if (parsedSkeleton.dimensionsAtRest) {
  11966. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11967. }
  11968. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11969. var index;
  11970. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11971. var parsedBone = parsedSkeleton.bones[index];
  11972. var parentBone = null;
  11973. if (parsedBone.parentBoneIndex > -1) {
  11974. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11975. }
  11976. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11977. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11978. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11979. bone.id = parsedBone.id;
  11980. }
  11981. if (parsedBone.length) {
  11982. bone.length = parsedBone.length;
  11983. }
  11984. if (parsedBone.metadata) {
  11985. bone.metadata = parsedBone.metadata;
  11986. }
  11987. if (parsedBone.animation) {
  11988. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11989. }
  11990. }
  11991. // placed after bones, so createAnimationRange can cascade down
  11992. if (parsedSkeleton.ranges) {
  11993. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11994. var data = parsedSkeleton.ranges[index];
  11995. skeleton.createAnimationRange(data.name, data.from, data.to);
  11996. }
  11997. }
  11998. return skeleton;
  11999. };
  12000. /**
  12001. * Compute all node absolute transforms
  12002. * @param forceUpdate defines if computation must be done even if cache is up to date
  12003. */
  12004. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  12005. if (forceUpdate === void 0) { forceUpdate = false; }
  12006. var renderId = this._scene.getRenderId();
  12007. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  12008. this.bones[0].computeAbsoluteTransforms();
  12009. this._lastAbsoluteTransformsUpdateId = renderId;
  12010. }
  12011. };
  12012. /**
  12013. * Gets the root pose matrix
  12014. * @returns a matrix
  12015. */
  12016. Skeleton.prototype.getPoseMatrix = function () {
  12017. var poseMatrix = null;
  12018. if (this._meshesWithPoseMatrix.length > 0) {
  12019. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  12020. }
  12021. return poseMatrix;
  12022. };
  12023. /**
  12024. * Sorts bones per internal index
  12025. */
  12026. Skeleton.prototype.sortBones = function () {
  12027. var bones = new Array();
  12028. var visited = new Array(this.bones.length);
  12029. for (var index = 0; index < this.bones.length; index++) {
  12030. this._sortBones(index, bones, visited);
  12031. }
  12032. this.bones = bones;
  12033. };
  12034. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12035. if (visited[index]) {
  12036. return;
  12037. }
  12038. visited[index] = true;
  12039. var bone = this.bones[index];
  12040. if (bone._index === undefined) {
  12041. bone._index = index;
  12042. }
  12043. var parentBone = bone.getParent();
  12044. if (parentBone) {
  12045. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12046. }
  12047. bones.push(bone);
  12048. };
  12049. return Skeleton;
  12050. }());
  12051. /***/ }),
  12052. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12053. /*!***************************************************!*\
  12054. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12055. \***************************************************/
  12056. /*! exports provided: BaseCameraPointersInput */
  12057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12058. "use strict";
  12059. __webpack_require__.r(__webpack_exports__);
  12060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12061. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12062. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12063. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12064. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12065. /**
  12066. * Base class for Camera Pointer Inputs.
  12067. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12068. * for example usage.
  12069. */
  12070. var BaseCameraPointersInput = /** @class */ (function () {
  12071. function BaseCameraPointersInput() {
  12072. /**
  12073. * Defines the buttons associated with the input to handle camera move.
  12074. */
  12075. this.buttons = [0, 1, 2];
  12076. }
  12077. /**
  12078. * Attach the input controls to a specific dom element to get the input from.
  12079. * @param element Defines the element the controls should be listened from
  12080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12081. */
  12082. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12083. var _this = this;
  12084. var engine = this.camera.getEngine();
  12085. var previousPinchSquaredDistance = 0;
  12086. var previousMultiTouchPanPosition = null;
  12087. this.pointA = null;
  12088. this.pointB = null;
  12089. this._altKey = false;
  12090. this._ctrlKey = false;
  12091. this._metaKey = false;
  12092. this._shiftKey = false;
  12093. this._buttonsPressed = 0;
  12094. this._pointerInput = function (p, s) {
  12095. var evt = p.event;
  12096. var isTouch = evt.pointerType === "touch";
  12097. if (engine.isInVRExclusivePointerMode) {
  12098. return;
  12099. }
  12100. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12101. _this.buttons.indexOf(evt.button) === -1) {
  12102. return;
  12103. }
  12104. var srcElement = (evt.srcElement || evt.target);
  12105. _this._altKey = evt.altKey;
  12106. _this._ctrlKey = evt.ctrlKey;
  12107. _this._metaKey = evt.metaKey;
  12108. _this._shiftKey = evt.shiftKey;
  12109. _this._buttonsPressed = evt.buttons;
  12110. if (engine.isPointerLock) {
  12111. var offsetX = evt.movementX ||
  12112. evt.mozMovementX ||
  12113. evt.webkitMovementX ||
  12114. evt.msMovementX ||
  12115. 0;
  12116. var offsetY = evt.movementY ||
  12117. evt.mozMovementY ||
  12118. evt.webkitMovementY ||
  12119. evt.msMovementY ||
  12120. 0;
  12121. _this.onTouch(null, offsetX, offsetY);
  12122. _this.pointA = null;
  12123. _this.pointB = null;
  12124. }
  12125. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12126. try {
  12127. srcElement.setPointerCapture(evt.pointerId);
  12128. }
  12129. catch (e) {
  12130. //Nothing to do with the error. Execution will continue.
  12131. }
  12132. if (_this.pointA === null) {
  12133. _this.pointA = { x: evt.clientX,
  12134. y: evt.clientY,
  12135. pointerId: evt.pointerId,
  12136. type: evt.pointerType };
  12137. }
  12138. else if (_this.pointB === null) {
  12139. _this.pointB = { x: evt.clientX,
  12140. y: evt.clientY,
  12141. pointerId: evt.pointerId,
  12142. type: evt.pointerType };
  12143. }
  12144. _this.onButtonDown(evt);
  12145. if (!noPreventDefault) {
  12146. evt.preventDefault();
  12147. element.focus();
  12148. }
  12149. }
  12150. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12151. _this.onDoubleTap(evt.pointerType);
  12152. }
  12153. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12154. try {
  12155. srcElement.releasePointerCapture(evt.pointerId);
  12156. }
  12157. catch (e) {
  12158. //Nothing to do with the error.
  12159. }
  12160. if (!isTouch) {
  12161. _this.pointB = null; // Mouse and pen are mono pointer
  12162. }
  12163. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12164. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12165. //when changing orientation while pinching camera,
  12166. //one pointer stay pressed forever if we don't release all pointers
  12167. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12168. if (engine._badOS) {
  12169. _this.pointA = _this.pointB = null;
  12170. }
  12171. else {
  12172. //only remove the impacted pointer in case of multitouch allowing on most
  12173. //platforms switching from rotate to zoom and pan seamlessly.
  12174. if (_this.pointB && _this.pointA && _this.pointA.pointerId == evt.pointerId) {
  12175. _this.pointA = _this.pointB;
  12176. _this.pointB = null;
  12177. }
  12178. else if (_this.pointA && _this.pointB &&
  12179. _this.pointB.pointerId == evt.pointerId) {
  12180. _this.pointB = null;
  12181. }
  12182. else {
  12183. _this.pointA = _this.pointB = null;
  12184. }
  12185. }
  12186. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12187. // Previous pinch data is populated but a button has been lifted
  12188. // so pinch has ended.
  12189. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12190. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12191. );
  12192. previousPinchSquaredDistance = 0;
  12193. previousMultiTouchPanPosition = null;
  12194. }
  12195. _this.onButtonUp(evt);
  12196. if (!noPreventDefault) {
  12197. evt.preventDefault();
  12198. }
  12199. }
  12200. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12201. if (!noPreventDefault) {
  12202. evt.preventDefault();
  12203. }
  12204. // One button down
  12205. if (_this.pointA && _this.pointB === null) {
  12206. var offsetX = evt.clientX - _this.pointA.x;
  12207. var offsetY = evt.clientY - _this.pointA.y;
  12208. _this.onTouch(_this.pointA, offsetX, offsetY);
  12209. _this.pointA.x = evt.clientX;
  12210. _this.pointA.y = evt.clientY;
  12211. }
  12212. // Two buttons down: pinch
  12213. else if (_this.pointA && _this.pointB) {
  12214. var ed = (_this.pointA.pointerId === evt.pointerId) ?
  12215. _this.pointA : _this.pointB;
  12216. ed.x = evt.clientX;
  12217. ed.y = evt.clientY;
  12218. var distX = _this.pointA.x - _this.pointB.x;
  12219. var distY = _this.pointA.y - _this.pointB.y;
  12220. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12221. var multiTouchPanPosition = { x: (_this.pointA.x + _this.pointB.x) / 2,
  12222. y: (_this.pointA.y + _this.pointB.y) / 2,
  12223. pointerId: evt.pointerId,
  12224. type: p.type };
  12225. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12226. previousMultiTouchPanPosition = multiTouchPanPosition;
  12227. previousPinchSquaredDistance = pinchSquaredDistance;
  12228. }
  12229. }
  12230. };
  12231. 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 |
  12232. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12233. this._onLostFocus = function () {
  12234. _this.pointA = _this.pointB = null;
  12235. previousPinchSquaredDistance = 0;
  12236. previousMultiTouchPanPosition = null;
  12237. _this.onLostFocus();
  12238. };
  12239. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12240. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12241. { name: "blur", handler: this._onLostFocus }
  12242. ]);
  12243. };
  12244. /**
  12245. * Detach the current controls from the specified dom element.
  12246. * @param element Defines the element to stop listening the inputs from
  12247. */
  12248. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12249. if (this._onLostFocus) {
  12250. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12251. { name: "blur", handler: this._onLostFocus }
  12252. ]);
  12253. }
  12254. if (element && this._observer) {
  12255. this.camera.getScene().onPointerObservable.remove(this._observer);
  12256. this._observer = null;
  12257. if (this.onContextMenu) {
  12258. element.removeEventListener("contextmenu", this.onContextMenu);
  12259. }
  12260. this._onLostFocus = null;
  12261. }
  12262. this._altKey = false;
  12263. this._ctrlKey = false;
  12264. this._metaKey = false;
  12265. this._shiftKey = false;
  12266. this._buttonsPressed = 0;
  12267. };
  12268. /**
  12269. * Gets the class name of the current input.
  12270. * @returns the class name
  12271. */
  12272. BaseCameraPointersInput.prototype.getClassName = function () {
  12273. return "BaseCameraPointersInput";
  12274. };
  12275. /**
  12276. * Get the friendly name associated with the input class.
  12277. * @returns the input friendly name
  12278. */
  12279. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12280. return "pointers";
  12281. };
  12282. /**
  12283. * Called on pointer POINTERDOUBLETAP event.
  12284. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12285. */
  12286. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12287. };
  12288. /**
  12289. * Called on pointer POINTERMOVE event if only a single touch is active.
  12290. * Override this method to provide functionality.
  12291. */
  12292. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12293. };
  12294. /**
  12295. * Called on pointer POINTERMOVE event if multiple touches are active.
  12296. * Override this method to provide functionality.
  12297. */
  12298. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12299. };
  12300. /**
  12301. * Called on JS contextmenu event.
  12302. * Override this method to provide functionality.
  12303. */
  12304. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12305. evt.preventDefault();
  12306. };
  12307. /**
  12308. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12309. * press.
  12310. * Override this method to provide functionality.
  12311. */
  12312. BaseCameraPointersInput.prototype.onButtonDown = function (evt) {
  12313. };
  12314. /**
  12315. * Called each time a new POINTERUP event occurs. Ie, for each button
  12316. * release.
  12317. * Override this method to provide functionality.
  12318. */
  12319. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12320. };
  12321. /**
  12322. * Called when window becomes inactive.
  12323. * Override this method to provide functionality.
  12324. */
  12325. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12326. };
  12327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12329. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12330. return BaseCameraPointersInput;
  12331. }());
  12332. /***/ }),
  12333. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12334. /*!*******************************************************!*\
  12335. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12336. \*******************************************************/
  12337. /*! exports provided: ArcRotateCameraGamepadInput */
  12338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12339. "use strict";
  12340. __webpack_require__.r(__webpack_exports__);
  12341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12342. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12343. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12344. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12345. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12346. /**
  12347. * Manage the gamepad inputs to control an arc rotate camera.
  12348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12349. */
  12350. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12351. function ArcRotateCameraGamepadInput() {
  12352. /**
  12353. * Defines the gamepad rotation sensiblity.
  12354. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12355. */
  12356. this.gamepadRotationSensibility = 80;
  12357. /**
  12358. * Defines the gamepad move sensiblity.
  12359. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12360. */
  12361. this.gamepadMoveSensibility = 40;
  12362. }
  12363. /**
  12364. * Attach the input controls to a specific dom element to get the input from.
  12365. * @param element Defines the element the controls should be listened from
  12366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12367. */
  12368. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12369. var _this = this;
  12370. var manager = this.camera.getScene().gamepadManager;
  12371. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12372. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12373. // prioritize XBOX gamepads.
  12374. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12375. _this.gamepad = gamepad;
  12376. }
  12377. }
  12378. });
  12379. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12380. if (_this.gamepad === gamepad) {
  12381. _this.gamepad = null;
  12382. }
  12383. });
  12384. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12385. };
  12386. /**
  12387. * Detach the current controls from the specified dom element.
  12388. * @param element Defines the element to stop listening the inputs from
  12389. */
  12390. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12391. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12392. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12393. this.gamepad = null;
  12394. };
  12395. /**
  12396. * Update the current camera state depending on the inputs that have been used this frame.
  12397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12398. */
  12399. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12400. if (this.gamepad) {
  12401. var camera = this.camera;
  12402. var RSValues = this.gamepad.rightStick;
  12403. if (RSValues) {
  12404. if (RSValues.x != 0) {
  12405. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12406. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12407. camera.inertialAlphaOffset += normalizedRX;
  12408. }
  12409. }
  12410. if (RSValues.y != 0) {
  12411. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12412. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12413. camera.inertialBetaOffset += normalizedRY;
  12414. }
  12415. }
  12416. }
  12417. var LSValues = this.gamepad.leftStick;
  12418. if (LSValues && LSValues.y != 0) {
  12419. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12420. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12421. this.camera.inertialRadiusOffset -= normalizedLY;
  12422. }
  12423. }
  12424. }
  12425. };
  12426. /**
  12427. * Gets the class name of the current intput.
  12428. * @returns the class name
  12429. */
  12430. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12431. return "ArcRotateCameraGamepadInput";
  12432. };
  12433. /**
  12434. * Get the friendly name associated with the input class.
  12435. * @returns the input friendly name
  12436. */
  12437. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12438. return "gamepad";
  12439. };
  12440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12442. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12445. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12446. return ArcRotateCameraGamepadInput;
  12447. }());
  12448. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12449. /***/ }),
  12450. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12451. /*!************************************************************!*\
  12452. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12453. \************************************************************/
  12454. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12456. "use strict";
  12457. __webpack_require__.r(__webpack_exports__);
  12458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12459. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12460. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12461. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12462. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12463. /**
  12464. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12466. */
  12467. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12468. function ArcRotateCameraKeyboardMoveInput() {
  12469. /**
  12470. * Defines the list of key codes associated with the up action (increase alpha)
  12471. */
  12472. this.keysUp = [38];
  12473. /**
  12474. * Defines the list of key codes associated with the down action (decrease alpha)
  12475. */
  12476. this.keysDown = [40];
  12477. /**
  12478. * Defines the list of key codes associated with the left action (increase beta)
  12479. */
  12480. this.keysLeft = [37];
  12481. /**
  12482. * Defines the list of key codes associated with the right action (decrease beta)
  12483. */
  12484. this.keysRight = [39];
  12485. /**
  12486. * Defines the list of key codes associated with the reset action.
  12487. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12488. */
  12489. this.keysReset = [220];
  12490. /**
  12491. * Defines the panning sensibility of the inputs.
  12492. * (How fast is the camera paning)
  12493. */
  12494. this.panningSensibility = 50.0;
  12495. /**
  12496. * Defines the zooming sensibility of the inputs.
  12497. * (How fast is the camera zooming)
  12498. */
  12499. this.zoomingSensibility = 25.0;
  12500. /**
  12501. * Defines wether maintaining the alt key down switch the movement mode from
  12502. * orientation to zoom.
  12503. */
  12504. this.useAltToZoom = true;
  12505. /**
  12506. * Rotation speed of the camera
  12507. */
  12508. this.angularSpeed = 0.01;
  12509. this._keys = new Array();
  12510. }
  12511. /**
  12512. * Attach the input controls to a specific dom element to get the input from.
  12513. * @param element Defines the element the controls should be listened from
  12514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12515. */
  12516. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12517. var _this = this;
  12518. if (this._onCanvasBlurObserver) {
  12519. return;
  12520. }
  12521. this._scene = this.camera.getScene();
  12522. this._engine = this._scene.getEngine();
  12523. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12524. _this._keys = [];
  12525. });
  12526. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12527. var evt = info.event;
  12528. if (!evt.metaKey) {
  12529. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12530. _this._ctrlPressed = evt.ctrlKey;
  12531. _this._altPressed = evt.altKey;
  12532. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12533. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12534. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12535. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12536. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12537. var index = _this._keys.indexOf(evt.keyCode);
  12538. if (index === -1) {
  12539. _this._keys.push(evt.keyCode);
  12540. }
  12541. if (evt.preventDefault) {
  12542. if (!noPreventDefault) {
  12543. evt.preventDefault();
  12544. }
  12545. }
  12546. }
  12547. }
  12548. else {
  12549. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12550. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12551. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12552. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12553. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12554. var index = _this._keys.indexOf(evt.keyCode);
  12555. if (index >= 0) {
  12556. _this._keys.splice(index, 1);
  12557. }
  12558. if (evt.preventDefault) {
  12559. if (!noPreventDefault) {
  12560. evt.preventDefault();
  12561. }
  12562. }
  12563. }
  12564. }
  12565. }
  12566. });
  12567. };
  12568. /**
  12569. * Detach the current controls from the specified dom element.
  12570. * @param element Defines the element to stop listening the inputs from
  12571. */
  12572. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12573. if (this._scene) {
  12574. if (this._onKeyboardObserver) {
  12575. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12576. }
  12577. if (this._onCanvasBlurObserver) {
  12578. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12579. }
  12580. this._onKeyboardObserver = null;
  12581. this._onCanvasBlurObserver = null;
  12582. }
  12583. this._keys = [];
  12584. };
  12585. /**
  12586. * Update the current camera state depending on the inputs that have been used this frame.
  12587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12588. */
  12589. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12590. if (this._onKeyboardObserver) {
  12591. var camera = this.camera;
  12592. for (var index = 0; index < this._keys.length; index++) {
  12593. var keyCode = this._keys[index];
  12594. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12595. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12596. camera.inertialPanningX -= 1 / this.panningSensibility;
  12597. }
  12598. else {
  12599. camera.inertialAlphaOffset -= this.angularSpeed;
  12600. }
  12601. }
  12602. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12603. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12604. camera.inertialPanningY += 1 / this.panningSensibility;
  12605. }
  12606. else if (this._altPressed && this.useAltToZoom) {
  12607. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12608. }
  12609. else {
  12610. camera.inertialBetaOffset -= this.angularSpeed;
  12611. }
  12612. }
  12613. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12614. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12615. camera.inertialPanningX += 1 / this.panningSensibility;
  12616. }
  12617. else {
  12618. camera.inertialAlphaOffset += this.angularSpeed;
  12619. }
  12620. }
  12621. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12622. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12623. camera.inertialPanningY -= 1 / this.panningSensibility;
  12624. }
  12625. else if (this._altPressed && this.useAltToZoom) {
  12626. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12627. }
  12628. else {
  12629. camera.inertialBetaOffset += this.angularSpeed;
  12630. }
  12631. }
  12632. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12633. if (camera.useInputToRestoreState) {
  12634. camera.restoreState();
  12635. }
  12636. }
  12637. }
  12638. }
  12639. };
  12640. /**
  12641. * Gets the class name of the current intput.
  12642. * @returns the class name
  12643. */
  12644. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12645. return "ArcRotateCameraKeyboardMoveInput";
  12646. };
  12647. /**
  12648. * Get the friendly name associated with the input class.
  12649. * @returns the input friendly name
  12650. */
  12651. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12652. return "keyboard";
  12653. };
  12654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12656. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12659. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12662. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12665. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12668. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12671. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12674. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12677. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12680. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12681. return ArcRotateCameraKeyboardMoveInput;
  12682. }());
  12683. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12684. /***/ }),
  12685. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12686. /*!**********************************************************!*\
  12687. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12688. \**********************************************************/
  12689. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12691. "use strict";
  12692. __webpack_require__.r(__webpack_exports__);
  12693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12694. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12695. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12696. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12697. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12698. /**
  12699. * Manage the mouse wheel inputs to control an arc rotate camera.
  12700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12701. */
  12702. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12703. function ArcRotateCameraMouseWheelInput() {
  12704. /**
  12705. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12706. */
  12707. this.wheelPrecision = 3.0;
  12708. /**
  12709. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12710. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12711. */
  12712. this.wheelDeltaPercentage = 0;
  12713. }
  12714. /**
  12715. * Attach the input controls to a specific dom element to get the input from.
  12716. * @param element Defines the element the controls should be listened from
  12717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12718. */
  12719. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12720. var _this = this;
  12721. this._wheel = function (p, s) {
  12722. //sanity check - this should be a PointerWheel event.
  12723. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12724. return;
  12725. }
  12726. var event = p.event;
  12727. var delta = 0;
  12728. var mouseWheelLegacyEvent = event;
  12729. if (mouseWheelLegacyEvent.wheelDelta) {
  12730. if (_this.wheelDeltaPercentage) {
  12731. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12732. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12733. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12734. }
  12735. else {
  12736. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12737. }
  12738. }
  12739. else {
  12740. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12741. }
  12742. }
  12743. else {
  12744. var deltaValue = event.deltaY || event.detail;
  12745. delta = -deltaValue / _this.wheelPrecision;
  12746. }
  12747. if (delta) {
  12748. _this.camera.inertialRadiusOffset += delta;
  12749. }
  12750. if (event.preventDefault) {
  12751. if (!noPreventDefault) {
  12752. event.preventDefault();
  12753. }
  12754. }
  12755. };
  12756. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12757. };
  12758. /**
  12759. * Detach the current controls from the specified dom element.
  12760. * @param element Defines the element to stop listening the inputs from
  12761. */
  12762. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12763. if (this._observer && element) {
  12764. this.camera.getScene().onPointerObservable.remove(this._observer);
  12765. this._observer = null;
  12766. this._wheel = null;
  12767. }
  12768. };
  12769. /**
  12770. * Gets the class name of the current intput.
  12771. * @returns the class name
  12772. */
  12773. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12774. return "ArcRotateCameraMouseWheelInput";
  12775. };
  12776. /**
  12777. * Get the friendly name associated with the input class.
  12778. * @returns the input friendly name
  12779. */
  12780. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12781. return "mousewheel";
  12782. };
  12783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12785. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12786. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12787. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12788. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12789. return ArcRotateCameraMouseWheelInput;
  12790. }());
  12791. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12792. /***/ }),
  12793. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12794. /*!********************************************************!*\
  12795. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12796. \********************************************************/
  12797. /*! exports provided: ArcRotateCameraPointersInput */
  12798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12799. "use strict";
  12800. __webpack_require__.r(__webpack_exports__);
  12801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12803. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12804. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12805. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12806. /**
  12807. * Manage the pointers inputs to control an arc rotate camera.
  12808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12809. */
  12810. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12811. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12812. function ArcRotateCameraPointersInput() {
  12813. var _this = _super !== null && _super.apply(this, arguments) || this;
  12814. /**
  12815. * Defines the buttons associated with the input to handle camera move.
  12816. */
  12817. _this.buttons = [0, 1, 2];
  12818. /**
  12819. * Defines the pointer angular sensibility along the X axis or how fast is
  12820. * the camera rotating.
  12821. */
  12822. _this.angularSensibilityX = 1000.0;
  12823. /**
  12824. * Defines the pointer angular sensibility along the Y axis or how fast is
  12825. * the camera rotating.
  12826. */
  12827. _this.angularSensibilityY = 1000.0;
  12828. /**
  12829. * Defines the pointer pinch precision or how fast is the camera zooming.
  12830. */
  12831. _this.pinchPrecision = 12.0;
  12832. /**
  12833. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12834. * from 0.
  12835. * It defines the percentage of current camera.radius to use as delta when
  12836. * pinch zoom is used.
  12837. */
  12838. _this.pinchDeltaPercentage = 0;
  12839. /**
  12840. * Defines the pointer panning sensibility or how fast is the camera moving.
  12841. */
  12842. _this.panningSensibility = 1000.0;
  12843. /**
  12844. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12845. */
  12846. _this.multiTouchPanning = true;
  12847. /**
  12848. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12849. * zoom (pinch) through multitouch.
  12850. */
  12851. _this.multiTouchPanAndZoom = true;
  12852. /**
  12853. * Revers pinch action direction.
  12854. */
  12855. _this.pinchInwards = true;
  12856. _this._isPanClick = false;
  12857. _this._twoFingerActivityCount = 0;
  12858. _this._isPinching = false;
  12859. return _this;
  12860. }
  12861. /**
  12862. * Gets the class name of the current input.
  12863. * @returns the class name
  12864. */
  12865. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12866. return "ArcRotateCameraPointersInput";
  12867. };
  12868. /**
  12869. * Called on pointer POINTERMOVE event if only a single touch is active.
  12870. */
  12871. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12872. if (this.panningSensibility !== 0 &&
  12873. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12874. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12875. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12876. }
  12877. else {
  12878. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12879. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12880. }
  12881. };
  12882. /**
  12883. * Called on pointer POINTERDOUBLETAP event.
  12884. */
  12885. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12886. if (this.camera.useInputToRestoreState) {
  12887. this.camera.restoreState();
  12888. }
  12889. };
  12890. /**
  12891. * Called on pointer POINTERMOVE event if multiple touches are active.
  12892. */
  12893. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12894. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  12895. // First time this method is called for new pinch.
  12896. // Next time this is called there will be a
  12897. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  12898. return;
  12899. }
  12900. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  12901. // Last time this method is called at the end of a pinch.
  12902. return;
  12903. }
  12904. var direction = this.pinchInwards ? 1 : -1;
  12905. if (this.multiTouchPanAndZoom) {
  12906. if (this.pinchDeltaPercentage) {
  12907. this.camera.inertialRadiusOffset +=
  12908. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12909. this.camera.radius * this.pinchDeltaPercentage;
  12910. }
  12911. else {
  12912. this.camera.inertialRadiusOffset +=
  12913. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12914. (this.pinchPrecision * direction *
  12915. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12916. }
  12917. if (this.panningSensibility !== 0 &&
  12918. previousMultiTouchPanPosition && multiTouchPanPosition) {
  12919. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12920. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12921. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12922. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12923. }
  12924. }
  12925. else {
  12926. this._twoFingerActivityCount++;
  12927. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  12928. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12929. if (this._isPinching ||
  12930. (this._twoFingerActivityCount < 20 &&
  12931. Math.abs(pinchDistance - previousPinchDistance) >
  12932. this.camera.pinchToPanMaxDistance)) {
  12933. // Since pinch has not been active long, assume we intend to zoom.
  12934. if (this.pinchDeltaPercentage) {
  12935. this.camera.inertialRadiusOffset +=
  12936. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12937. this.camera.radius * this.pinchDeltaPercentage;
  12938. }
  12939. else {
  12940. this.camera.inertialRadiusOffset +=
  12941. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12942. (this.pinchPrecision * direction *
  12943. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12944. }
  12945. // Since we are pinching, remain pinching on next iteration.
  12946. this._isPinching = true;
  12947. }
  12948. else {
  12949. // Pause between pinch starting and moving implies not a zoom event.
  12950. // Pan instead.
  12951. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  12952. multiTouchPanPosition && previousMultiTouchPanPosition) {
  12953. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12954. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12955. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12956. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12957. }
  12958. }
  12959. }
  12960. };
  12961. /**
  12962. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12963. * press.
  12964. */
  12965. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt) {
  12966. this._isPanClick = evt.button === this.camera._panningMouseButton;
  12967. };
  12968. /**
  12969. * Called each time a new POINTERUP event occurs. Ie, for each button
  12970. * release.
  12971. */
  12972. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  12973. this._twoFingerActivityCount = 0;
  12974. this._isPinching = false;
  12975. };
  12976. /**
  12977. * Called when window becomes inactive.
  12978. */
  12979. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  12980. this._isPanClick = false;
  12981. this._twoFingerActivityCount = 0;
  12982. this._isPinching = false;
  12983. };
  12984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12986. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12989. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12992. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12995. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12998. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13001. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  13002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13004. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  13005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13007. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  13008. return ArcRotateCameraPointersInput;
  13009. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  13010. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  13011. ArcRotateCameraPointersInput;
  13012. /***/ }),
  13013. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  13014. /*!*******************************************************************!*\
  13015. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  13016. \*******************************************************************/
  13017. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  13018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13019. "use strict";
  13020. __webpack_require__.r(__webpack_exports__);
  13021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  13022. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13023. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  13024. /**
  13025. * Add orientation input support to the input manager.
  13026. * @returns the current input manager
  13027. */
  13028. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13029. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13030. return this;
  13031. };
  13032. /**
  13033. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13035. */
  13036. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13037. /**
  13038. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13039. */
  13040. function ArcRotateCameraVRDeviceOrientationInput() {
  13041. /**
  13042. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13043. */
  13044. this.alphaCorrection = 1;
  13045. /**
  13046. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13047. */
  13048. this.gammaCorrection = 1;
  13049. this._alpha = 0;
  13050. this._gamma = 0;
  13051. this._dirty = false;
  13052. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13053. }
  13054. /**
  13055. * Attach the input controls to a specific dom element to get the input from.
  13056. * @param element Defines the element the controls should be listened from
  13057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13058. */
  13059. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13060. this.camera.attachControl(element, noPreventDefault);
  13061. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13062. };
  13063. /** @hidden */
  13064. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13065. if (evt.alpha !== null) {
  13066. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13067. }
  13068. if (evt.gamma !== null) {
  13069. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13070. }
  13071. this._dirty = true;
  13072. };
  13073. /**
  13074. * Update the current camera state depending on the inputs that have been used this frame.
  13075. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13076. */
  13077. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13078. if (this._dirty) {
  13079. this._dirty = false;
  13080. if (this._gamma < 0) {
  13081. this._gamma = 180 + this._gamma;
  13082. }
  13083. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13084. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13085. }
  13086. };
  13087. /**
  13088. * Detach the current controls from the specified dom element.
  13089. * @param element Defines the element to stop listening the inputs from
  13090. */
  13091. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13092. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13093. };
  13094. /**
  13095. * Gets the class name of the current intput.
  13096. * @returns the class name
  13097. */
  13098. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13099. return "ArcRotateCameraVRDeviceOrientationInput";
  13100. };
  13101. /**
  13102. * Get the friendly name associated with the input class.
  13103. * @returns the input friendly name
  13104. */
  13105. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13106. return "VRDeviceOrientation";
  13107. };
  13108. return ArcRotateCameraVRDeviceOrientationInput;
  13109. }());
  13110. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13111. /***/ }),
  13112. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13113. /*!**************************************************!*\
  13114. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13115. \**************************************************/
  13116. /*! exports provided: FlyCameraKeyboardInput */
  13117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13118. "use strict";
  13119. __webpack_require__.r(__webpack_exports__);
  13120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13121. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13122. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13123. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13124. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13125. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13126. /**
  13127. * Listen to keyboard events to control the camera.
  13128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13129. */
  13130. var FlyCameraKeyboardInput = /** @class */ (function () {
  13131. function FlyCameraKeyboardInput() {
  13132. /**
  13133. * The list of keyboard keys used to control the forward move of the camera.
  13134. */
  13135. this.keysForward = [87];
  13136. /**
  13137. * The list of keyboard keys used to control the backward move of the camera.
  13138. */
  13139. this.keysBackward = [83];
  13140. /**
  13141. * The list of keyboard keys used to control the forward move of the camera.
  13142. */
  13143. this.keysUp = [69];
  13144. /**
  13145. * The list of keyboard keys used to control the backward move of the camera.
  13146. */
  13147. this.keysDown = [81];
  13148. /**
  13149. * The list of keyboard keys used to control the right strafe move of the camera.
  13150. */
  13151. this.keysRight = [68];
  13152. /**
  13153. * The list of keyboard keys used to control the left strafe move of the camera.
  13154. */
  13155. this.keysLeft = [65];
  13156. this._keys = new Array();
  13157. }
  13158. /**
  13159. * Attach the input controls to a specific dom element to get the input from.
  13160. * @param element Defines the element the controls should be listened from
  13161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13162. */
  13163. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13164. var _this = this;
  13165. if (this._onCanvasBlurObserver) {
  13166. return;
  13167. }
  13168. this._scene = this.camera.getScene();
  13169. this._engine = this._scene.getEngine();
  13170. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13171. _this._keys = [];
  13172. });
  13173. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13174. var evt = info.event;
  13175. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13176. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13177. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13178. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13179. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13180. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13181. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13182. var index = _this._keys.indexOf(evt.keyCode);
  13183. if (index === -1) {
  13184. _this._keys.push(evt.keyCode);
  13185. }
  13186. if (!noPreventDefault) {
  13187. evt.preventDefault();
  13188. }
  13189. }
  13190. }
  13191. else {
  13192. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13193. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13194. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13195. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13196. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13197. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13198. var index = _this._keys.indexOf(evt.keyCode);
  13199. if (index >= 0) {
  13200. _this._keys.splice(index, 1);
  13201. }
  13202. if (!noPreventDefault) {
  13203. evt.preventDefault();
  13204. }
  13205. }
  13206. }
  13207. });
  13208. };
  13209. /**
  13210. * Detach the current controls from the specified dom element.
  13211. * @param element Defines the element to stop listening the inputs from
  13212. */
  13213. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13214. if (this._scene) {
  13215. if (this._onKeyboardObserver) {
  13216. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13217. }
  13218. if (this._onCanvasBlurObserver) {
  13219. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13220. }
  13221. this._onKeyboardObserver = null;
  13222. this._onCanvasBlurObserver = null;
  13223. }
  13224. this._keys = [];
  13225. };
  13226. /**
  13227. * Gets the class name of the current intput.
  13228. * @returns the class name
  13229. */
  13230. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13231. return "FlyCameraKeyboardInput";
  13232. };
  13233. /** @hidden */
  13234. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13235. this._keys = [];
  13236. };
  13237. /**
  13238. * Get the friendly name associated with the input class.
  13239. * @returns the input friendly name
  13240. */
  13241. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13242. return "keyboard";
  13243. };
  13244. /**
  13245. * Update the current camera state depending on the inputs that have been used this frame.
  13246. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13247. */
  13248. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13249. if (this._onKeyboardObserver) {
  13250. var camera = this.camera;
  13251. // Keyboard
  13252. for (var index = 0; index < this._keys.length; index++) {
  13253. var keyCode = this._keys[index];
  13254. var speed = camera._computeLocalCameraSpeed();
  13255. if (this.keysForward.indexOf(keyCode) !== -1) {
  13256. camera._localDirection.copyFromFloats(0, 0, speed);
  13257. }
  13258. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13259. camera._localDirection.copyFromFloats(0, 0, -speed);
  13260. }
  13261. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13262. camera._localDirection.copyFromFloats(0, speed, 0);
  13263. }
  13264. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13265. camera._localDirection.copyFromFloats(0, -speed, 0);
  13266. }
  13267. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13268. camera._localDirection.copyFromFloats(speed, 0, 0);
  13269. }
  13270. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13271. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13272. }
  13273. if (camera.getScene().useRightHandedSystem) {
  13274. camera._localDirection.z *= -1;
  13275. }
  13276. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13277. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13278. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13279. }
  13280. }
  13281. };
  13282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13284. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13287. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13290. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13291. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13292. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13293. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13294. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13296. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13299. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13300. return FlyCameraKeyboardInput;
  13301. }());
  13302. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13303. /***/ }),
  13304. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13305. /*!***********************************************!*\
  13306. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13307. \***********************************************/
  13308. /*! exports provided: FlyCameraMouseInput */
  13309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13310. "use strict";
  13311. __webpack_require__.r(__webpack_exports__);
  13312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13313. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13314. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13315. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13316. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13317. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13318. /**
  13319. * Listen to mouse events to control the camera.
  13320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13321. */
  13322. var FlyCameraMouseInput = /** @class */ (function () {
  13323. /**
  13324. * Listen to mouse events to control the camera.
  13325. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13327. */
  13328. function FlyCameraMouseInput(touchEnabled) {
  13329. if (touchEnabled === void 0) { touchEnabled = true; }
  13330. /**
  13331. * Defines the buttons associated with the input to handle camera rotation.
  13332. */
  13333. this.buttons = [0, 1, 2];
  13334. /**
  13335. * Assign buttons for Yaw control.
  13336. */
  13337. this.buttonsYaw = [-1, 0, 1];
  13338. /**
  13339. * Assign buttons for Pitch control.
  13340. */
  13341. this.buttonsPitch = [-1, 0, 1];
  13342. /**
  13343. * Assign buttons for Roll control.
  13344. */
  13345. this.buttonsRoll = [2];
  13346. /**
  13347. * Detect if any button is being pressed while mouse is moved.
  13348. * -1 = Mouse locked.
  13349. * 0 = Left button.
  13350. * 1 = Middle Button.
  13351. * 2 = Right Button.
  13352. */
  13353. this.activeButton = -1;
  13354. /**
  13355. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13356. * Higher values reduce its sensitivity.
  13357. */
  13358. this.angularSensibility = 1000.0;
  13359. this.previousPosition = null;
  13360. }
  13361. /**
  13362. * Attach the mouse control to the HTML DOM element.
  13363. * @param element Defines the element that listens to the input events.
  13364. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13365. */
  13366. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13367. var _this = this;
  13368. this.element = element;
  13369. this.noPreventDefault = noPreventDefault;
  13370. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13371. _this._pointerInput(p, s);
  13372. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13373. // Correct Roll by rate, if enabled.
  13374. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13375. if (_this.camera.rollCorrect) {
  13376. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13377. }
  13378. });
  13379. // Helper function to keep 'this'.
  13380. this._mousemoveCallback = function (e) {
  13381. _this._onMouseMove(e);
  13382. };
  13383. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13384. };
  13385. /**
  13386. * Detach the current controls from the specified dom element.
  13387. * @param element Defines the element to stop listening the inputs from
  13388. */
  13389. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13390. if (this._observer && element) {
  13391. this.camera.getScene().onPointerObservable.remove(this._observer);
  13392. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13393. if (this._mousemoveCallback) {
  13394. element.removeEventListener("mousemove", this._mousemoveCallback);
  13395. }
  13396. this._observer = null;
  13397. this._rollObserver = null;
  13398. this.previousPosition = null;
  13399. this.noPreventDefault = undefined;
  13400. }
  13401. };
  13402. /**
  13403. * Gets the class name of the current input.
  13404. * @returns the class name.
  13405. */
  13406. FlyCameraMouseInput.prototype.getClassName = function () {
  13407. return "FlyCameraMouseInput";
  13408. };
  13409. /**
  13410. * Get the friendly name associated with the input class.
  13411. * @returns the input's friendly name.
  13412. */
  13413. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13414. return "mouse";
  13415. };
  13416. // Track mouse movement, when the pointer is not locked.
  13417. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13418. var e = p.event;
  13419. var camera = this.camera;
  13420. var engine = camera.getEngine();
  13421. if (engine.isInVRExclusivePointerMode) {
  13422. return;
  13423. }
  13424. if (!this.touchEnabled && e.pointerType === "touch") {
  13425. return;
  13426. }
  13427. // Mouse is moved but an unknown mouse button is pressed.
  13428. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13429. return;
  13430. }
  13431. var srcElement = (e.srcElement || e.target);
  13432. // Mouse down.
  13433. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13434. try {
  13435. srcElement.setPointerCapture(e.pointerId);
  13436. }
  13437. catch (e) {
  13438. // Nothing to do with the error. Execution continues.
  13439. }
  13440. this.previousPosition = {
  13441. x: e.clientX,
  13442. y: e.clientY
  13443. };
  13444. this.activeButton = e.button;
  13445. if (!this.noPreventDefault) {
  13446. e.preventDefault();
  13447. this.element.focus();
  13448. }
  13449. }
  13450. else
  13451. // Mouse up.
  13452. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13453. try {
  13454. srcElement.releasePointerCapture(e.pointerId);
  13455. }
  13456. catch (e) {
  13457. // Nothing to do with the error. Execution continues.
  13458. }
  13459. this.activeButton = -1;
  13460. this.previousPosition = null;
  13461. if (!this.noPreventDefault) {
  13462. e.preventDefault();
  13463. }
  13464. }
  13465. else
  13466. // Mouse move.
  13467. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13468. if (!this.previousPosition || engine.isPointerLock) {
  13469. return;
  13470. }
  13471. var offsetX = e.clientX - this.previousPosition.x;
  13472. var offsetY = e.clientY - this.previousPosition.y;
  13473. this.rotateCamera(offsetX, offsetY);
  13474. this.previousPosition = {
  13475. x: e.clientX,
  13476. y: e.clientY
  13477. };
  13478. if (!this.noPreventDefault) {
  13479. e.preventDefault();
  13480. }
  13481. }
  13482. };
  13483. // Track mouse movement, when pointer is locked.
  13484. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13485. var camera = this.camera;
  13486. var engine = camera.getEngine();
  13487. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13488. return;
  13489. }
  13490. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13491. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13492. this.rotateCamera(offsetX, offsetY);
  13493. this.previousPosition = null;
  13494. if (!this.noPreventDefault) {
  13495. e.preventDefault();
  13496. }
  13497. };
  13498. /**
  13499. * Rotate camera by mouse offset.
  13500. */
  13501. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13502. var _this = this;
  13503. var camera = this.camera;
  13504. var scene = this.camera.getScene();
  13505. if (scene.useRightHandedSystem) {
  13506. offsetX *= -1;
  13507. }
  13508. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13509. offsetX *= -1;
  13510. }
  13511. var x = offsetX / this.angularSensibility;
  13512. var y = offsetY / this.angularSensibility;
  13513. // Initialize to current rotation.
  13514. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13515. var rotationChange;
  13516. // Pitch.
  13517. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13518. // Apply change in Radians to vector Angle.
  13519. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13520. // Apply Pitch to quaternion.
  13521. currentRotation.multiplyInPlace(rotationChange);
  13522. }
  13523. // Yaw.
  13524. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13525. // Apply change in Radians to vector Angle.
  13526. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13527. // Apply Yaw to quaternion.
  13528. currentRotation.multiplyInPlace(rotationChange);
  13529. // Add Roll, if banked turning is enabled, within Roll limit.
  13530. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13531. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13532. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13533. // Apply change in Radians to vector Angle.
  13534. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13535. // Apply Yaw to quaternion.
  13536. currentRotation.multiplyInPlace(rotationChange);
  13537. }
  13538. }
  13539. // Roll.
  13540. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13541. // Apply change in Radians to vector Angle.
  13542. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13543. // Track Rolling.
  13544. camera._trackRoll -= x;
  13545. // Apply Pitch to quaternion.
  13546. currentRotation.multiplyInPlace(rotationChange);
  13547. }
  13548. // Apply rotationQuaternion to Euler camera.rotation.
  13549. currentRotation.toEulerAnglesToRef(camera.rotation);
  13550. };
  13551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13553. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13556. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13557. return FlyCameraMouseInput;
  13558. }());
  13559. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13560. /***/ }),
  13561. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13562. /*!*********************************************************!*\
  13563. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13564. \*********************************************************/
  13565. /*! exports provided: FollowCameraKeyboardMoveInput */
  13566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13567. "use strict";
  13568. __webpack_require__.r(__webpack_exports__);
  13569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13571. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13572. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13573. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13574. /**
  13575. * Manage the keyboard inputs to control the movement of a follow camera.
  13576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13577. */
  13578. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13579. function FollowCameraKeyboardMoveInput() {
  13580. /**
  13581. * Defines the list of key codes associated with the up action (increase heightOffset)
  13582. */
  13583. this.keysHeightOffsetIncr = [38];
  13584. /**
  13585. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13586. */
  13587. this.keysHeightOffsetDecr = [40];
  13588. /**
  13589. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13590. */
  13591. this.keysHeightOffsetModifierAlt = false;
  13592. /**
  13593. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13594. */
  13595. this.keysHeightOffsetModifierCtrl = false;
  13596. /**
  13597. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13598. */
  13599. this.keysHeightOffsetModifierShift = false;
  13600. /**
  13601. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13602. */
  13603. this.keysRotationOffsetIncr = [37];
  13604. /**
  13605. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13606. */
  13607. this.keysRotationOffsetDecr = [39];
  13608. /**
  13609. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13610. */
  13611. this.keysRotationOffsetModifierAlt = false;
  13612. /**
  13613. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13614. */
  13615. this.keysRotationOffsetModifierCtrl = false;
  13616. /**
  13617. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13618. */
  13619. this.keysRotationOffsetModifierShift = false;
  13620. /**
  13621. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13622. */
  13623. this.keysRadiusIncr = [40];
  13624. /**
  13625. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13626. */
  13627. this.keysRadiusDecr = [38];
  13628. /**
  13629. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13630. */
  13631. this.keysRadiusModifierAlt = true;
  13632. /**
  13633. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13634. */
  13635. this.keysRadiusModifierCtrl = false;
  13636. /**
  13637. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13638. */
  13639. this.keysRadiusModifierShift = false;
  13640. /**
  13641. * Defines the rate of change of heightOffset.
  13642. */
  13643. this.heightSensibility = 1;
  13644. /**
  13645. * Defines the rate of change of rotationOffset.
  13646. */
  13647. this.rotationSensibility = 1;
  13648. /**
  13649. * Defines the rate of change of radius.
  13650. */
  13651. this.radiusSensibility = 1;
  13652. this._keys = new Array();
  13653. }
  13654. /**
  13655. * Attach the input controls to a specific dom element to get the input from.
  13656. * @param element Defines the element the controls should be listened from
  13657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13658. */
  13659. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13660. var _this = this;
  13661. if (this._onCanvasBlurObserver) {
  13662. return;
  13663. }
  13664. this._scene = this.camera.getScene();
  13665. this._engine = this._scene.getEngine();
  13666. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13667. _this._keys = [];
  13668. });
  13669. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13670. var evt = info.event;
  13671. if (!evt.metaKey) {
  13672. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13673. _this._ctrlPressed = evt.ctrlKey;
  13674. _this._altPressed = evt.altKey;
  13675. _this._shiftPressed = evt.shiftKey;
  13676. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13677. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13678. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13679. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13680. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13681. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13682. var index = _this._keys.indexOf(evt.keyCode);
  13683. if (index === -1) {
  13684. _this._keys.push(evt.keyCode);
  13685. }
  13686. if (evt.preventDefault) {
  13687. if (!noPreventDefault) {
  13688. evt.preventDefault();
  13689. }
  13690. }
  13691. }
  13692. }
  13693. else {
  13694. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13695. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13696. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13697. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13698. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13699. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13700. var index = _this._keys.indexOf(evt.keyCode);
  13701. if (index >= 0) {
  13702. _this._keys.splice(index, 1);
  13703. }
  13704. if (evt.preventDefault) {
  13705. if (!noPreventDefault) {
  13706. evt.preventDefault();
  13707. }
  13708. }
  13709. }
  13710. }
  13711. }
  13712. });
  13713. };
  13714. /**
  13715. * Detach the current controls from the specified dom element.
  13716. * @param element Defines the element to stop listening the inputs from
  13717. */
  13718. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13719. if (this._scene) {
  13720. if (this._onKeyboardObserver) {
  13721. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13722. }
  13723. if (this._onCanvasBlurObserver) {
  13724. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13725. }
  13726. this._onKeyboardObserver = null;
  13727. this._onCanvasBlurObserver = null;
  13728. }
  13729. this._keys = [];
  13730. };
  13731. /**
  13732. * Update the current camera state depending on the inputs that have been used this frame.
  13733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13734. */
  13735. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13736. var _this = this;
  13737. if (this._onKeyboardObserver) {
  13738. this._keys.forEach(function (keyCode) {
  13739. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13740. _this._modifierHeightOffset()) {
  13741. _this.camera.heightOffset += _this.heightSensibility;
  13742. }
  13743. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13744. _this._modifierHeightOffset()) {
  13745. _this.camera.heightOffset -= _this.heightSensibility;
  13746. }
  13747. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13748. _this._modifierRotationOffset()) {
  13749. _this.camera.rotationOffset += _this.rotationSensibility;
  13750. _this.camera.rotationOffset %= 360;
  13751. }
  13752. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13753. _this._modifierRotationOffset()) {
  13754. _this.camera.rotationOffset -= _this.rotationSensibility;
  13755. _this.camera.rotationOffset %= 360;
  13756. }
  13757. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13758. _this._modifierRadius()) {
  13759. _this.camera.radius += _this.radiusSensibility;
  13760. }
  13761. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13762. _this._modifierRadius()) {
  13763. _this.camera.radius -= _this.radiusSensibility;
  13764. }
  13765. });
  13766. }
  13767. };
  13768. /**
  13769. * Gets the class name of the current input.
  13770. * @returns the class name
  13771. */
  13772. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13773. return "FollowCameraKeyboardMoveInput";
  13774. };
  13775. /**
  13776. * Get the friendly name associated with the input class.
  13777. * @returns the input friendly name
  13778. */
  13779. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13780. return "keyboard";
  13781. };
  13782. /**
  13783. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13784. * allow modification of the heightOffset value.
  13785. */
  13786. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13787. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13788. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13789. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13790. };
  13791. /**
  13792. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13793. * allow modification of the rotationOffset value.
  13794. */
  13795. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13796. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13797. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13798. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13799. };
  13800. /**
  13801. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13802. * allow modification of the radius value.
  13803. */
  13804. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13805. return (this.keysRadiusModifierAlt === this._altPressed &&
  13806. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13807. this.keysRadiusModifierShift === this._shiftPressed);
  13808. };
  13809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13811. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13814. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13817. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13820. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13823. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13826. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13829. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13832. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13835. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13838. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13841. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13844. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13847. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13850. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13853. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13856. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13859. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13862. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13863. return FollowCameraKeyboardMoveInput;
  13864. }());
  13865. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13866. /***/ }),
  13867. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13868. /*!*******************************************************!*\
  13869. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13870. \*******************************************************/
  13871. /*! exports provided: FollowCameraMouseWheelInput */
  13872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13873. "use strict";
  13874. __webpack_require__.r(__webpack_exports__);
  13875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13876. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13877. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13878. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13879. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13880. /**
  13881. * Manage the mouse wheel inputs to control a follow camera.
  13882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13883. */
  13884. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13885. function FollowCameraMouseWheelInput() {
  13886. /**
  13887. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13888. */
  13889. this.axisControlRadius = true;
  13890. /**
  13891. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  13892. */
  13893. this.axisControlHeight = false;
  13894. /**
  13895. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  13896. */
  13897. this.axisControlRotation = false;
  13898. /**
  13899. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13900. * relation to mouseWheel events.
  13901. */
  13902. this.wheelPrecision = 3.0;
  13903. /**
  13904. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13905. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13906. */
  13907. this.wheelDeltaPercentage = 0;
  13908. }
  13909. /**
  13910. * Attach the input controls to a specific dom element to get the input from.
  13911. * @param element Defines the element the controls should be listened from
  13912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13913. */
  13914. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13915. var _this = this;
  13916. this._wheel = function (p, s) {
  13917. // sanity check - this should be a PointerWheel event.
  13918. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13919. return;
  13920. }
  13921. var event = p.event;
  13922. var delta = 0;
  13923. // Chrome, Safari: event.deltaY
  13924. // IE: event.wheelDelta
  13925. // Firefox: event.detail (inverted)
  13926. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13927. if (_this.wheelDeltaPercentage) {
  13928. console.assert((_this.axisControlRadius +
  13929. _this.axisControlHeight +
  13930. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13931. "controlls ONE axis. " +
  13932. "Currently enabled: " +
  13933. "axisControlRadius: " + _this.axisControlRadius +
  13934. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13935. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13936. if (_this.axisControlRadius) {
  13937. delta =
  13938. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13939. _this.camera.radius;
  13940. }
  13941. else if (_this.axisControlHeight) {
  13942. delta =
  13943. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13944. _this.camera.heightOffset;
  13945. }
  13946. else if (_this.axisControlRotation) {
  13947. delta =
  13948. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13949. _this.camera.rotationOffset;
  13950. }
  13951. }
  13952. else {
  13953. delta = wheelDelta * _this.wheelPrecision;
  13954. }
  13955. if (delta) {
  13956. if (_this.axisControlRadius) {
  13957. _this.camera.radius += delta;
  13958. }
  13959. else if (_this.axisControlHeight) {
  13960. _this.camera.heightOffset -= delta;
  13961. }
  13962. else if (_this.axisControlRotation) {
  13963. _this.camera.rotationOffset -= delta;
  13964. }
  13965. }
  13966. if (event.preventDefault) {
  13967. if (!noPreventDefault) {
  13968. event.preventDefault();
  13969. }
  13970. }
  13971. };
  13972. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13973. };
  13974. /**
  13975. * Detach the current controls from the specified dom element.
  13976. * @param element Defines the element to stop listening the inputs from
  13977. */
  13978. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13979. if (this._observer && element) {
  13980. this.camera.getScene().onPointerObservable.remove(this._observer);
  13981. this._observer = null;
  13982. this._wheel = null;
  13983. }
  13984. };
  13985. /**
  13986. * Gets the class name of the current intput.
  13987. * @returns the class name
  13988. */
  13989. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13990. return "ArcRotateCameraMouseWheelInput";
  13991. };
  13992. /**
  13993. * Get the friendly name associated with the input class.
  13994. * @returns the input friendly name
  13995. */
  13996. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13997. return "mousewheel";
  13998. };
  13999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14001. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  14002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14004. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  14005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14007. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  14008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14010. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  14011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14013. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  14014. return FollowCameraMouseWheelInput;
  14015. }());
  14016. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  14017. /***/ }),
  14018. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  14019. /*!*****************************************************!*\
  14020. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  14021. \*****************************************************/
  14022. /*! exports provided: FollowCameraPointersInput */
  14023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14024. "use strict";
  14025. __webpack_require__.r(__webpack_exports__);
  14026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14027. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14028. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14029. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14030. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14031. /**
  14032. * Manage the pointers inputs to control an follow camera.
  14033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14034. */
  14035. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14036. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14037. function FollowCameraPointersInput() {
  14038. var _this = _super !== null && _super.apply(this, arguments) || this;
  14039. /**
  14040. * Defines the pointer angular sensibility along the X axis or how fast is
  14041. * the camera rotating.
  14042. * A negative number will reverse the axis direction.
  14043. */
  14044. _this.angularSensibilityX = 1;
  14045. /**
  14046. * Defines the pointer angular sensibility along the Y axis or how fast is
  14047. * the camera rotating.
  14048. * A negative number will reverse the axis direction.
  14049. */
  14050. _this.angularSensibilityY = 1;
  14051. /**
  14052. * Defines the pointer pinch precision or how fast is the camera zooming.
  14053. * A negative number will reverse the axis direction.
  14054. */
  14055. _this.pinchPrecision = 10000.0;
  14056. /**
  14057. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14058. * from 0.
  14059. * It defines the percentage of current camera.radius to use as delta when
  14060. * pinch zoom is used.
  14061. */
  14062. _this.pinchDeltaPercentage = 0;
  14063. /**
  14064. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14065. */
  14066. _this.axisXControlRadius = false;
  14067. /**
  14068. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14069. */
  14070. _this.axisXControlHeight = false;
  14071. /**
  14072. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14073. */
  14074. _this.axisXControlRotation = true;
  14075. /**
  14076. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14077. */
  14078. _this.axisYControlRadius = false;
  14079. /**
  14080. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14081. */
  14082. _this.axisYControlHeight = true;
  14083. /**
  14084. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14085. */
  14086. _this.axisYControlRotation = false;
  14087. /**
  14088. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14089. */
  14090. _this.axisPinchControlRadius = true;
  14091. /**
  14092. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14093. */
  14094. _this.axisPinchControlHeight = false;
  14095. /**
  14096. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14097. */
  14098. _this.axisPinchControlRotation = false;
  14099. /**
  14100. * Log error messages if basic misconfiguration has occurred.
  14101. */
  14102. _this.warningEnable = true;
  14103. /* Check for obvious misconfiguration. */
  14104. _this._warningCounter = 0;
  14105. return _this;
  14106. }
  14107. /**
  14108. * Gets the class name of the current input.
  14109. * @returns the class name
  14110. */
  14111. FollowCameraPointersInput.prototype.getClassName = function () {
  14112. return "FollowCameraPointersInput";
  14113. };
  14114. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14115. this._warning();
  14116. if (this.axisXControlRotation) {
  14117. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14118. }
  14119. else if (this.axisYControlRotation) {
  14120. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14121. }
  14122. if (this.axisXControlHeight) {
  14123. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14124. }
  14125. else if (this.axisYControlHeight) {
  14126. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14127. }
  14128. if (this.axisXControlRadius) {
  14129. this.camera.radius -= offsetX / this.angularSensibilityY;
  14130. }
  14131. else if (this.axisYControlRadius) {
  14132. this.camera.radius -= offsetY / this.angularSensibilityY;
  14133. }
  14134. };
  14135. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14136. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14137. // First time this method is called for new pinch.
  14138. // Next time this is called there will be a
  14139. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14140. return;
  14141. }
  14142. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14143. // Last time this method is called at the end of a pinch.
  14144. return;
  14145. }
  14146. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14147. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14148. if (this.pinchDeltaPercentage) {
  14149. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14150. if (this.axisPinchControlRotation) {
  14151. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14152. }
  14153. if (this.axisPinchControlHeight) {
  14154. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14155. }
  14156. if (this.axisPinchControlRadius) {
  14157. this.camera.radius -= pinchDelta * this.camera.radius;
  14158. }
  14159. }
  14160. else {
  14161. if (this.axisPinchControlRotation) {
  14162. this.camera.rotationOffset += pinchDelta;
  14163. }
  14164. if (this.axisPinchControlHeight) {
  14165. this.camera.heightOffset += pinchDelta;
  14166. }
  14167. if (this.axisPinchControlRadius) {
  14168. this.camera.radius -= pinchDelta;
  14169. }
  14170. }
  14171. };
  14172. FollowCameraPointersInput.prototype._warning = function () {
  14173. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14174. return;
  14175. }
  14176. var warn = "It probably only makes sense to control ONE camera " +
  14177. "property with each pointer axis. Set 'warningEnable = false' " +
  14178. "if you are sure. Currently enabled: ";
  14179. console.assert((this.axisXControlRotation +
  14180. this.axisXControlHeight +
  14181. this.axisXControlRadius) <= 1, warn +
  14182. "axisXControlRotation: " + this.axisXControlRotation +
  14183. ", axisXControlHeight: " + this.axisXControlHeight +
  14184. ", axisXControlRadius: " + this.axisXControlRadius);
  14185. console.assert((this.axisYControlRotation +
  14186. this.axisYControlHeight +
  14187. this.axisYControlRadius) <= 1, warn +
  14188. "axisYControlRotation: " + this.axisYControlRotation +
  14189. ", axisYControlHeight: " + this.axisYControlHeight +
  14190. ", axisYControlRadius: " + this.axisYControlRadius);
  14191. console.assert((this.axisPinchControlRotation +
  14192. this.axisPinchControlHeight +
  14193. this.axisPinchControlRadius) <= 1, warn +
  14194. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14195. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14196. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14197. };
  14198. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14200. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14201. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14203. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14204. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14206. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14209. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14210. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14211. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14212. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14213. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14214. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14215. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14216. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14218. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14221. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14222. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14223. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14224. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14227. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14230. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14233. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14234. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14236. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14237. return FollowCameraPointersInput;
  14238. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14239. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14240. /***/ }),
  14241. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14242. /*!************************************************************!*\
  14243. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14244. \************************************************************/
  14245. /*! exports provided: FreeCameraDeviceOrientationInput */
  14246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14247. "use strict";
  14248. __webpack_require__.r(__webpack_exports__);
  14249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14250. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14251. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14252. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14253. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14254. /**
  14255. * Add orientation input support to the input manager.
  14256. * @returns the current input manager
  14257. */
  14258. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14259. this.add(new FreeCameraDeviceOrientationInput());
  14260. return this;
  14261. };
  14262. /**
  14263. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14264. * Screen rotation is taken into account.
  14265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14266. */
  14267. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14268. /**
  14269. * Instantiates a new input
  14270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14271. */
  14272. function FreeCameraDeviceOrientationInput() {
  14273. var _this = this;
  14274. this._screenOrientationAngle = 0;
  14275. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14276. this._alpha = 0;
  14277. this._beta = 0;
  14278. this._gamma = 0;
  14279. this._orientationChanged = function () {
  14280. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14281. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14282. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14283. };
  14284. this._deviceOrientation = function (evt) {
  14285. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14286. _this._beta = evt.beta !== null ? evt.beta : 0;
  14287. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14288. };
  14289. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14290. this._orientationChanged();
  14291. }
  14292. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14293. /**
  14294. * Define the camera controlled by the input.
  14295. */
  14296. get: function () {
  14297. return this._camera;
  14298. },
  14299. set: function (camera) {
  14300. this._camera = camera;
  14301. if (this._camera != null && !this._camera.rotationQuaternion) {
  14302. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14303. }
  14304. },
  14305. enumerable: true,
  14306. configurable: true
  14307. });
  14308. /**
  14309. * Attach the input controls to a specific dom element to get the input from.
  14310. * @param element Defines the element the controls should be listened from
  14311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14312. */
  14313. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14314. window.addEventListener("orientationchange", this._orientationChanged);
  14315. window.addEventListener("deviceorientation", this._deviceOrientation);
  14316. //In certain cases, the attach control is called AFTER orientation was changed,
  14317. //So this is needed.
  14318. this._orientationChanged();
  14319. };
  14320. /**
  14321. * Detach the current controls from the specified dom element.
  14322. * @param element Defines the element to stop listening the inputs from
  14323. */
  14324. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14325. window.removeEventListener("orientationchange", this._orientationChanged);
  14326. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14327. this._alpha = 0;
  14328. };
  14329. /**
  14330. * Update the current camera state depending on the inputs that have been used this frame.
  14331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14332. */
  14333. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14334. //if no device orientation provided, don't update the rotation.
  14335. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14336. if (!this._alpha) {
  14337. return;
  14338. }
  14339. _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);
  14340. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14341. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14342. //Mirror on XY Plane
  14343. this._camera.rotationQuaternion.z *= -1;
  14344. this._camera.rotationQuaternion.w *= -1;
  14345. };
  14346. /**
  14347. * Gets the class name of the current intput.
  14348. * @returns the class name
  14349. */
  14350. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14351. return "FreeCameraDeviceOrientationInput";
  14352. };
  14353. /**
  14354. * Get the friendly name associated with the input class.
  14355. * @returns the input friendly name
  14356. */
  14357. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14358. return "deviceOrientation";
  14359. };
  14360. return FreeCameraDeviceOrientationInput;
  14361. }());
  14362. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14363. /***/ }),
  14364. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14365. /*!**************************************************!*\
  14366. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14367. \**************************************************/
  14368. /*! exports provided: FreeCameraGamepadInput */
  14369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14370. "use strict";
  14371. __webpack_require__.r(__webpack_exports__);
  14372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14373. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14374. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14375. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14376. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14377. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14378. /**
  14379. * Manage the gamepad inputs to control a free camera.
  14380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14381. */
  14382. var FreeCameraGamepadInput = /** @class */ (function () {
  14383. function FreeCameraGamepadInput() {
  14384. /**
  14385. * Defines the gamepad rotation sensiblity.
  14386. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14387. */
  14388. this.gamepadAngularSensibility = 200;
  14389. /**
  14390. * Defines the gamepad move sensiblity.
  14391. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14392. */
  14393. this.gamepadMoveSensibility = 40;
  14394. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14395. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14396. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14397. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14398. }
  14399. /**
  14400. * Attach the input controls to a specific dom element to get the input from.
  14401. * @param element Defines the element the controls should be listened from
  14402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14403. */
  14404. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14405. var _this = this;
  14406. var manager = this.camera.getScene().gamepadManager;
  14407. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14408. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14409. // prioritize XBOX gamepads.
  14410. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14411. _this.gamepad = gamepad;
  14412. }
  14413. }
  14414. });
  14415. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14416. if (_this.gamepad === gamepad) {
  14417. _this.gamepad = null;
  14418. }
  14419. });
  14420. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14421. };
  14422. /**
  14423. * Detach the current controls from the specified dom element.
  14424. * @param element Defines the element to stop listening the inputs from
  14425. */
  14426. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14427. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14428. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14429. this.gamepad = null;
  14430. };
  14431. /**
  14432. * Update the current camera state depending on the inputs that have been used this frame.
  14433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14434. */
  14435. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14436. if (this.gamepad && this.gamepad.leftStick) {
  14437. var camera = this.camera;
  14438. var LSValues = this.gamepad.leftStick;
  14439. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14440. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14441. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14442. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14443. var RSValues = this.gamepad.rightStick;
  14444. if (RSValues) {
  14445. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14446. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14447. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14448. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14449. }
  14450. else {
  14451. RSValues = { x: 0, y: 0 };
  14452. }
  14453. if (!camera.rotationQuaternion) {
  14454. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14455. }
  14456. else {
  14457. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14458. }
  14459. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14460. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14461. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14462. camera.cameraDirection.addInPlace(this._deltaTransform);
  14463. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14464. camera.cameraRotation.addInPlace(this._vector2);
  14465. }
  14466. };
  14467. /**
  14468. * Gets the class name of the current intput.
  14469. * @returns the class name
  14470. */
  14471. FreeCameraGamepadInput.prototype.getClassName = function () {
  14472. return "FreeCameraGamepadInput";
  14473. };
  14474. /**
  14475. * Get the friendly name associated with the input class.
  14476. * @returns the input friendly name
  14477. */
  14478. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14479. return "gamepad";
  14480. };
  14481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14482. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14483. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14484. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14485. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14486. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14487. return FreeCameraGamepadInput;
  14488. }());
  14489. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14490. /***/ }),
  14491. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14492. /*!*******************************************************!*\
  14493. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14494. \*******************************************************/
  14495. /*! exports provided: FreeCameraKeyboardMoveInput */
  14496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14497. "use strict";
  14498. __webpack_require__.r(__webpack_exports__);
  14499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14500. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14501. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14502. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14503. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14504. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14505. /**
  14506. * Manage the keyboard inputs to control the movement of a free camera.
  14507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14508. */
  14509. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14510. function FreeCameraKeyboardMoveInput() {
  14511. /**
  14512. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14513. */
  14514. this.keysUp = [38];
  14515. /**
  14516. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14517. */
  14518. this.keysDown = [40];
  14519. /**
  14520. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14521. */
  14522. this.keysLeft = [37];
  14523. /**
  14524. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14525. */
  14526. this.keysRight = [39];
  14527. this._keys = new Array();
  14528. }
  14529. /**
  14530. * Attach the input controls to a specific dom element to get the input from.
  14531. * @param element Defines the element the controls should be listened from
  14532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14533. */
  14534. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14535. var _this = this;
  14536. if (this._onCanvasBlurObserver) {
  14537. return;
  14538. }
  14539. this._scene = this.camera.getScene();
  14540. this._engine = this._scene.getEngine();
  14541. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14542. _this._keys = [];
  14543. });
  14544. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14545. var evt = info.event;
  14546. if (!evt.metaKey) {
  14547. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14548. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14549. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14550. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14551. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14552. var index = _this._keys.indexOf(evt.keyCode);
  14553. if (index === -1) {
  14554. _this._keys.push(evt.keyCode);
  14555. }
  14556. if (!noPreventDefault) {
  14557. evt.preventDefault();
  14558. }
  14559. }
  14560. }
  14561. else {
  14562. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14563. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14564. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14565. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14566. var index = _this._keys.indexOf(evt.keyCode);
  14567. if (index >= 0) {
  14568. _this._keys.splice(index, 1);
  14569. }
  14570. if (!noPreventDefault) {
  14571. evt.preventDefault();
  14572. }
  14573. }
  14574. }
  14575. }
  14576. });
  14577. };
  14578. /**
  14579. * Detach the current controls from the specified dom element.
  14580. * @param element Defines the element to stop listening the inputs from
  14581. */
  14582. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14583. if (this._scene) {
  14584. if (this._onKeyboardObserver) {
  14585. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14586. }
  14587. if (this._onCanvasBlurObserver) {
  14588. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14589. }
  14590. this._onKeyboardObserver = null;
  14591. this._onCanvasBlurObserver = null;
  14592. }
  14593. this._keys = [];
  14594. };
  14595. /**
  14596. * Update the current camera state depending on the inputs that have been used this frame.
  14597. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14598. */
  14599. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14600. if (this._onKeyboardObserver) {
  14601. var camera = this.camera;
  14602. // Keyboard
  14603. for (var index = 0; index < this._keys.length; index++) {
  14604. var keyCode = this._keys[index];
  14605. var speed = camera._computeLocalCameraSpeed();
  14606. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14607. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14608. }
  14609. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14610. camera._localDirection.copyFromFloats(0, 0, speed);
  14611. }
  14612. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14613. camera._localDirection.copyFromFloats(speed, 0, 0);
  14614. }
  14615. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14616. camera._localDirection.copyFromFloats(0, 0, -speed);
  14617. }
  14618. if (camera.getScene().useRightHandedSystem) {
  14619. camera._localDirection.z *= -1;
  14620. }
  14621. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14622. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14623. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14624. }
  14625. }
  14626. };
  14627. /**
  14628. * Gets the class name of the current intput.
  14629. * @returns the class name
  14630. */
  14631. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14632. return "FreeCameraKeyboardMoveInput";
  14633. };
  14634. /** @hidden */
  14635. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14636. this._keys = [];
  14637. };
  14638. /**
  14639. * Get the friendly name associated with the input class.
  14640. * @returns the input friendly name
  14641. */
  14642. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14643. return "keyboard";
  14644. };
  14645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14647. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14650. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14653. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14656. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14657. return FreeCameraKeyboardMoveInput;
  14658. }());
  14659. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14660. /***/ }),
  14661. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14662. /*!************************************************!*\
  14663. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14664. \************************************************/
  14665. /*! exports provided: FreeCameraMouseInput */
  14666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14667. "use strict";
  14668. __webpack_require__.r(__webpack_exports__);
  14669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14670. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14671. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14672. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14673. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14674. /**
  14675. * Manage the mouse inputs to control the movement of a free camera.
  14676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14677. */
  14678. var FreeCameraMouseInput = /** @class */ (function () {
  14679. /**
  14680. * Manage the mouse inputs to control the movement of a free camera.
  14681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14682. * @param touchEnabled Defines if touch is enabled or not
  14683. */
  14684. function FreeCameraMouseInput(
  14685. /**
  14686. * Define if touch is enabled in the mouse input
  14687. */
  14688. touchEnabled) {
  14689. if (touchEnabled === void 0) { touchEnabled = true; }
  14690. this.touchEnabled = touchEnabled;
  14691. /**
  14692. * Defines the buttons associated with the input to handle camera move.
  14693. */
  14694. this.buttons = [0, 1, 2];
  14695. /**
  14696. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14697. */
  14698. this.angularSensibility = 2000.0;
  14699. this.previousPosition = null;
  14700. }
  14701. /**
  14702. * Attach the input controls to a specific dom element to get the input from.
  14703. * @param element Defines the element the controls should be listened from
  14704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14705. */
  14706. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14707. var _this = this;
  14708. var engine = this.camera.getEngine();
  14709. if (!this._pointerInput) {
  14710. this._pointerInput = function (p) {
  14711. var evt = p.event;
  14712. if (engine.isInVRExclusivePointerMode) {
  14713. return;
  14714. }
  14715. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14716. return;
  14717. }
  14718. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14719. return;
  14720. }
  14721. var srcElement = (evt.srcElement || evt.target);
  14722. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14723. try {
  14724. srcElement.setPointerCapture(evt.pointerId);
  14725. }
  14726. catch (e) {
  14727. //Nothing to do with the error. Execution will continue.
  14728. }
  14729. _this.previousPosition = {
  14730. x: evt.clientX,
  14731. y: evt.clientY
  14732. };
  14733. if (!noPreventDefault) {
  14734. evt.preventDefault();
  14735. element.focus();
  14736. }
  14737. }
  14738. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14739. try {
  14740. srcElement.releasePointerCapture(evt.pointerId);
  14741. }
  14742. catch (e) {
  14743. //Nothing to do with the error.
  14744. }
  14745. _this.previousPosition = null;
  14746. if (!noPreventDefault) {
  14747. evt.preventDefault();
  14748. }
  14749. }
  14750. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14751. if (!_this.previousPosition || engine.isPointerLock) {
  14752. return;
  14753. }
  14754. var offsetX = evt.clientX - _this.previousPosition.x;
  14755. if (_this.camera.getScene().useRightHandedSystem) {
  14756. offsetX *= -1;
  14757. }
  14758. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14759. offsetX *= -1;
  14760. }
  14761. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14762. var offsetY = evt.clientY - _this.previousPosition.y;
  14763. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14764. _this.previousPosition = {
  14765. x: evt.clientX,
  14766. y: evt.clientY
  14767. };
  14768. if (!noPreventDefault) {
  14769. evt.preventDefault();
  14770. }
  14771. }
  14772. };
  14773. }
  14774. this._onMouseMove = function (evt) {
  14775. if (!engine.isPointerLock) {
  14776. return;
  14777. }
  14778. if (engine.isInVRExclusivePointerMode) {
  14779. return;
  14780. }
  14781. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14782. if (_this.camera.getScene().useRightHandedSystem) {
  14783. offsetX *= -1;
  14784. }
  14785. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14786. offsetX *= -1;
  14787. }
  14788. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14789. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14790. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14791. _this.previousPosition = null;
  14792. if (!noPreventDefault) {
  14793. evt.preventDefault();
  14794. }
  14795. };
  14796. 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);
  14797. element.addEventListener("mousemove", this._onMouseMove, false);
  14798. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  14799. };
  14800. /**
  14801. * Called on JS contextmenu event.
  14802. * Override this method to provide functionality.
  14803. */
  14804. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  14805. evt.preventDefault();
  14806. };
  14807. /**
  14808. * Detach the current controls from the specified dom element.
  14809. * @param element Defines the element to stop listening the inputs from
  14810. */
  14811. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14812. if (this._observer && element) {
  14813. this.camera.getScene().onPointerObservable.remove(this._observer);
  14814. if (this._onMouseMove) {
  14815. element.removeEventListener("mousemove", this._onMouseMove);
  14816. }
  14817. if (this.onContextMenu) {
  14818. element.removeEventListener("contextmenu", this.onContextMenu);
  14819. }
  14820. this._observer = null;
  14821. this._onMouseMove = null;
  14822. this.previousPosition = null;
  14823. }
  14824. };
  14825. /**
  14826. * Gets the class name of the current intput.
  14827. * @returns the class name
  14828. */
  14829. FreeCameraMouseInput.prototype.getClassName = function () {
  14830. return "FreeCameraMouseInput";
  14831. };
  14832. /**
  14833. * Get the friendly name associated with the input class.
  14834. * @returns the input friendly name
  14835. */
  14836. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14837. return "mouse";
  14838. };
  14839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14841. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14844. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14845. return FreeCameraMouseInput;
  14846. }());
  14847. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14848. /***/ }),
  14849. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14850. /*!************************************************!*\
  14851. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14852. \************************************************/
  14853. /*! exports provided: FreeCameraTouchInput */
  14854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14855. "use strict";
  14856. __webpack_require__.r(__webpack_exports__);
  14857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14858. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14859. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14860. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14861. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14862. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14863. /**
  14864. * Manage the touch inputs to control the movement of a free camera.
  14865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14866. */
  14867. var FreeCameraTouchInput = /** @class */ (function () {
  14868. function FreeCameraTouchInput() {
  14869. /**
  14870. * Defines the touch sensibility for rotation.
  14871. * The higher the faster.
  14872. */
  14873. this.touchAngularSensibility = 200000.0;
  14874. /**
  14875. * Defines the touch sensibility for move.
  14876. * The higher the faster.
  14877. */
  14878. this.touchMoveSensibility = 250.0;
  14879. this._offsetX = null;
  14880. this._offsetY = null;
  14881. this._pointerPressed = new Array();
  14882. }
  14883. /**
  14884. * Attach the input controls to a specific dom element to get the input from.
  14885. * @param element Defines the element the controls should be listened from
  14886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14887. */
  14888. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14889. var _this = this;
  14890. var previousPosition = null;
  14891. if (this._pointerInput === undefined) {
  14892. this._onLostFocus = function () {
  14893. _this._offsetX = null;
  14894. _this._offsetY = null;
  14895. };
  14896. this._pointerInput = function (p) {
  14897. var evt = p.event;
  14898. if (evt.pointerType === "mouse") {
  14899. return;
  14900. }
  14901. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14902. if (!noPreventDefault) {
  14903. evt.preventDefault();
  14904. }
  14905. _this._pointerPressed.push(evt.pointerId);
  14906. if (_this._pointerPressed.length !== 1) {
  14907. return;
  14908. }
  14909. previousPosition = {
  14910. x: evt.clientX,
  14911. y: evt.clientY
  14912. };
  14913. }
  14914. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14915. if (!noPreventDefault) {
  14916. evt.preventDefault();
  14917. }
  14918. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14919. if (index === -1) {
  14920. return;
  14921. }
  14922. _this._pointerPressed.splice(index, 1);
  14923. if (index != 0) {
  14924. return;
  14925. }
  14926. previousPosition = null;
  14927. _this._offsetX = null;
  14928. _this._offsetY = null;
  14929. }
  14930. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14931. if (!noPreventDefault) {
  14932. evt.preventDefault();
  14933. }
  14934. if (!previousPosition) {
  14935. return;
  14936. }
  14937. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14938. if (index != 0) {
  14939. return;
  14940. }
  14941. _this._offsetX = evt.clientX - previousPosition.x;
  14942. _this._offsetY = -(evt.clientY - previousPosition.y);
  14943. }
  14944. };
  14945. }
  14946. 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);
  14947. if (this._onLostFocus) {
  14948. element.addEventListener("blur", this._onLostFocus);
  14949. }
  14950. };
  14951. /**
  14952. * Detach the current controls from the specified dom element.
  14953. * @param element Defines the element to stop listening the inputs from
  14954. */
  14955. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14956. if (this._pointerInput && element) {
  14957. if (this._observer) {
  14958. this.camera.getScene().onPointerObservable.remove(this._observer);
  14959. this._observer = null;
  14960. }
  14961. if (this._onLostFocus) {
  14962. element.removeEventListener("blur", this._onLostFocus);
  14963. this._onLostFocus = null;
  14964. }
  14965. this._pointerPressed = [];
  14966. this._offsetX = null;
  14967. this._offsetY = null;
  14968. }
  14969. };
  14970. /**
  14971. * Update the current camera state depending on the inputs that have been used this frame.
  14972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14973. */
  14974. FreeCameraTouchInput.prototype.checkInputs = function () {
  14975. if (this._offsetX && this._offsetY) {
  14976. var camera = this.camera;
  14977. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14978. if (this._pointerPressed.length > 1) {
  14979. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14980. }
  14981. else {
  14982. var speed = camera._computeLocalCameraSpeed();
  14983. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14984. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14985. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14986. }
  14987. }
  14988. };
  14989. /**
  14990. * Gets the class name of the current intput.
  14991. * @returns the class name
  14992. */
  14993. FreeCameraTouchInput.prototype.getClassName = function () {
  14994. return "FreeCameraTouchInput";
  14995. };
  14996. /**
  14997. * Get the friendly name associated with the input class.
  14998. * @returns the input friendly name
  14999. */
  15000. FreeCameraTouchInput.prototype.getSimpleName = function () {
  15001. return "touch";
  15002. };
  15003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15005. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  15006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15008. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  15009. return FreeCameraTouchInput;
  15010. }());
  15011. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  15012. /***/ }),
  15013. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  15014. /*!**********************************************************!*\
  15015. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  15016. \**********************************************************/
  15017. /*! exports provided: FreeCameraVirtualJoystickInput */
  15018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15019. "use strict";
  15020. __webpack_require__.r(__webpack_exports__);
  15021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  15022. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  15023. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15024. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15025. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  15026. /**
  15027. * Add virtual joystick input support to the input manager.
  15028. * @returns the current input manager
  15029. */
  15030. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15031. this.add(new FreeCameraVirtualJoystickInput());
  15032. return this;
  15033. };
  15034. /**
  15035. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15037. */
  15038. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15039. function FreeCameraVirtualJoystickInput() {
  15040. }
  15041. /**
  15042. * Gets the left stick of the virtual joystick.
  15043. * @returns The virtual Joystick
  15044. */
  15045. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15046. return this._leftjoystick;
  15047. };
  15048. /**
  15049. * Gets the right stick of the virtual joystick.
  15050. * @returns The virtual Joystick
  15051. */
  15052. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15053. return this._rightjoystick;
  15054. };
  15055. /**
  15056. * Update the current camera state depending on the inputs that have been used this frame.
  15057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15058. */
  15059. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15060. if (this._leftjoystick) {
  15061. var camera = this.camera;
  15062. var speed = camera._computeLocalCameraSpeed() * 50;
  15063. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15064. 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);
  15065. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15066. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15067. if (!this._leftjoystick.pressed) {
  15068. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15069. }
  15070. if (!this._rightjoystick.pressed) {
  15071. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15072. }
  15073. }
  15074. };
  15075. /**
  15076. * Attach the input controls to a specific dom element to get the input from.
  15077. * @param element Defines the element the controls should be listened from
  15078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15079. */
  15080. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15081. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15082. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15083. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15084. this._leftjoystick.setJoystickSensibility(0.15);
  15085. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15086. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15087. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15088. this._rightjoystick.reverseUpDown = true;
  15089. this._rightjoystick.setJoystickSensibility(0.05);
  15090. this._rightjoystick.setJoystickColor("yellow");
  15091. };
  15092. /**
  15093. * Detach the current controls from the specified dom element.
  15094. * @param element Defines the element to stop listening the inputs from
  15095. */
  15096. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15097. this._leftjoystick.releaseCanvas();
  15098. this._rightjoystick.releaseCanvas();
  15099. };
  15100. /**
  15101. * Gets the class name of the current intput.
  15102. * @returns the class name
  15103. */
  15104. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15105. return "FreeCameraVirtualJoystickInput";
  15106. };
  15107. /**
  15108. * Get the friendly name associated with the input class.
  15109. * @returns the input friendly name
  15110. */
  15111. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15112. return "virtualJoystick";
  15113. };
  15114. return FreeCameraVirtualJoystickInput;
  15115. }());
  15116. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15117. /***/ }),
  15118. /***/ "./Cameras/Inputs/index.ts":
  15119. /*!*********************************!*\
  15120. !*** ./Cameras/Inputs/index.ts ***!
  15121. \*********************************/
  15122. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15124. "use strict";
  15125. __webpack_require__.r(__webpack_exports__);
  15126. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15128. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15130. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15132. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15134. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15136. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15138. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15140. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15142. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15144. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15146. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15148. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15150. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15152. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15154. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15156. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15158. /***/ }),
  15159. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15160. /*!*********************************************************!*\
  15161. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15162. \*********************************************************/
  15163. /*! no exports provided */
  15164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15165. "use strict";
  15166. __webpack_require__.r(__webpack_exports__);
  15167. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15168. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15169. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15170. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15171. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15172. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15173. };
  15174. /***/ }),
  15175. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15176. /*!*************************************************!*\
  15177. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15178. \*************************************************/
  15179. /*! no exports provided */
  15180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15181. "use strict";
  15182. __webpack_require__.r(__webpack_exports__);
  15183. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15184. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15185. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15186. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15187. 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;
  15188. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15189. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15190. };
  15191. /***/ }),
  15192. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15193. /*!***************************************!*\
  15194. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15195. \***************************************/
  15196. /*! no exports provided */
  15197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15198. "use strict";
  15199. __webpack_require__.r(__webpack_exports__);
  15200. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15201. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15202. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15203. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15204. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15205. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  15206. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15207. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15208. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15209. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15210. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15211. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15212. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15213. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15214. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15215. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15216. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15217. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15218. if (metrics.compensateDistortion) {
  15219. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15220. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15221. }
  15222. };
  15223. /***/ }),
  15224. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15225. /*!******************************************!*\
  15226. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15227. \******************************************/
  15228. /*! no exports provided */
  15229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15230. "use strict";
  15231. __webpack_require__.r(__webpack_exports__);
  15232. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15233. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15234. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15235. if (rigParams.vrDisplay) {
  15236. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15237. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15238. //Left eye
  15239. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15240. camera._rigCameras[0].setCameraRigParameter("left", true);
  15241. //leaving this for future reference
  15242. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15243. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15244. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15245. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15246. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15247. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15248. camera._rigCameras[0].parent = camera;
  15249. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15250. //Right eye
  15251. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15252. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15253. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15254. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15255. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15256. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15257. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15258. camera._rigCameras[1].parent = camera;
  15259. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15260. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  15261. camera._rigCameras[1]._skipRendering = true;
  15262. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  15263. }
  15264. }
  15265. };
  15266. /***/ }),
  15267. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15268. /*!*********************************************************!*\
  15269. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15270. \*********************************************************/
  15271. /*! exports provided: AnaglyphArcRotateCamera */
  15272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15273. "use strict";
  15274. __webpack_require__.r(__webpack_exports__);
  15275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15276. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15277. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15278. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15279. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15280. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15281. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15282. // Side effect import to define the stereoscopic mode.
  15283. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15284. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15285. });
  15286. /**
  15287. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15288. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15289. */
  15290. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15291. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15292. /**
  15293. * Creates a new AnaglyphArcRotateCamera
  15294. * @param name defines camera name
  15295. * @param alpha defines alpha angle (in radians)
  15296. * @param beta defines beta angle (in radians)
  15297. * @param radius defines radius
  15298. * @param target defines camera target
  15299. * @param interaxialDistance defines distance between each color axis
  15300. * @param scene defines the hosting scene
  15301. */
  15302. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15303. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15304. _this.interaxialDistance = interaxialDistance;
  15305. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15306. return _this;
  15307. }
  15308. /**
  15309. * Gets camera class name
  15310. * @returns AnaglyphArcRotateCamera
  15311. */
  15312. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15313. return "AnaglyphArcRotateCamera";
  15314. };
  15315. return AnaglyphArcRotateCamera;
  15316. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15317. /***/ }),
  15318. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15319. /*!****************************************************!*\
  15320. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15321. \****************************************************/
  15322. /*! exports provided: AnaglyphFreeCamera */
  15323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15324. "use strict";
  15325. __webpack_require__.r(__webpack_exports__);
  15326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15327. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15328. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15329. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15330. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15331. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15332. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15333. // Side effect import to define the stereoscopic mode.
  15334. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15335. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15336. });
  15337. /**
  15338. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15340. */
  15341. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15342. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15343. /**
  15344. * Creates a new AnaglyphFreeCamera
  15345. * @param name defines camera name
  15346. * @param position defines initial position
  15347. * @param interaxialDistance defines distance between each color axis
  15348. * @param scene defines the hosting scene
  15349. */
  15350. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15351. var _this = _super.call(this, name, position, scene) || this;
  15352. _this.interaxialDistance = interaxialDistance;
  15353. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15354. return _this;
  15355. }
  15356. /**
  15357. * Gets camera class name
  15358. * @returns AnaglyphFreeCamera
  15359. */
  15360. AnaglyphFreeCamera.prototype.getClassName = function () {
  15361. return "AnaglyphFreeCamera";
  15362. };
  15363. return AnaglyphFreeCamera;
  15364. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15365. /***/ }),
  15366. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15367. /*!*******************************************************!*\
  15368. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15369. \*******************************************************/
  15370. /*! exports provided: AnaglyphGamepadCamera */
  15371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15372. "use strict";
  15373. __webpack_require__.r(__webpack_exports__);
  15374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15375. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15376. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15377. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15379. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15380. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15381. // Side effect import to define the stereoscopic mode.
  15382. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15383. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15384. });
  15385. /**
  15386. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15387. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15388. */
  15389. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15390. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15391. /**
  15392. * Creates a new AnaglyphGamepadCamera
  15393. * @param name defines camera name
  15394. * @param position defines initial position
  15395. * @param interaxialDistance defines distance between each color axis
  15396. * @param scene defines the hosting scene
  15397. */
  15398. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15399. var _this = _super.call(this, name, position, scene) || this;
  15400. _this.interaxialDistance = interaxialDistance;
  15401. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15402. return _this;
  15403. }
  15404. /**
  15405. * Gets camera class name
  15406. * @returns AnaglyphGamepadCamera
  15407. */
  15408. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15409. return "AnaglyphGamepadCamera";
  15410. };
  15411. return AnaglyphGamepadCamera;
  15412. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15413. /***/ }),
  15414. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15415. /*!*********************************************************!*\
  15416. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15417. \*********************************************************/
  15418. /*! exports provided: AnaglyphUniversalCamera */
  15419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15420. "use strict";
  15421. __webpack_require__.r(__webpack_exports__);
  15422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15423. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15424. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15425. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15426. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15427. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15428. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15429. // Side effect import to define the stereoscopic mode.
  15430. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15431. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15432. });
  15433. /**
  15434. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15435. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15436. */
  15437. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15438. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15439. /**
  15440. * Creates a new AnaglyphUniversalCamera
  15441. * @param name defines camera name
  15442. * @param position defines initial position
  15443. * @param interaxialDistance defines distance between each color axis
  15444. * @param scene defines the hosting scene
  15445. */
  15446. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15447. var _this = _super.call(this, name, position, scene) || this;
  15448. _this.interaxialDistance = interaxialDistance;
  15449. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15450. return _this;
  15451. }
  15452. /**
  15453. * Gets camera class name
  15454. * @returns AnaglyphUniversalCamera
  15455. */
  15456. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15457. return "AnaglyphUniversalCamera";
  15458. };
  15459. return AnaglyphUniversalCamera;
  15460. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15461. /***/ }),
  15462. /***/ "./Cameras/Stereoscopic/index.ts":
  15463. /*!***************************************!*\
  15464. !*** ./Cameras/Stereoscopic/index.ts ***!
  15465. \***************************************/
  15466. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15468. "use strict";
  15469. __webpack_require__.r(__webpack_exports__);
  15470. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15472. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15474. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15476. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15478. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15480. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15482. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15484. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15486. /***/ }),
  15487. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15488. /*!*************************************************************!*\
  15489. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15490. \*************************************************************/
  15491. /*! exports provided: StereoscopicArcRotateCamera */
  15492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15493. "use strict";
  15494. __webpack_require__.r(__webpack_exports__);
  15495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15496. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15497. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15498. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15499. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15500. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15501. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15502. // Side effect import to define the stereoscopic mode.
  15503. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15504. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15505. });
  15506. /**
  15507. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15508. * @see http://doc.babylonjs.com/features/cameras
  15509. */
  15510. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15511. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15512. /**
  15513. * Creates a new StereoscopicArcRotateCamera
  15514. * @param name defines camera name
  15515. * @param alpha defines alpha angle (in radians)
  15516. * @param beta defines beta angle (in radians)
  15517. * @param radius defines radius
  15518. * @param target defines camera target
  15519. * @param interaxialDistance defines distance between each color axis
  15520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15521. * @param scene defines the hosting scene
  15522. */
  15523. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15524. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15525. _this.interaxialDistance = interaxialDistance;
  15526. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15527. _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 });
  15528. return _this;
  15529. }
  15530. /**
  15531. * Gets camera class name
  15532. * @returns StereoscopicArcRotateCamera
  15533. */
  15534. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15535. return "StereoscopicArcRotateCamera";
  15536. };
  15537. return StereoscopicArcRotateCamera;
  15538. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15539. /***/ }),
  15540. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15541. /*!********************************************************!*\
  15542. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15543. \********************************************************/
  15544. /*! exports provided: StereoscopicFreeCamera */
  15545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15546. "use strict";
  15547. __webpack_require__.r(__webpack_exports__);
  15548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15550. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15551. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15552. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15553. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15554. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15555. // Side effect import to define the stereoscopic mode.
  15556. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15557. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15558. });
  15559. /**
  15560. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15561. * @see http://doc.babylonjs.com/features/cameras
  15562. */
  15563. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15564. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15565. /**
  15566. * Creates a new StereoscopicFreeCamera
  15567. * @param name defines camera name
  15568. * @param position defines initial position
  15569. * @param interaxialDistance defines distance between each color axis
  15570. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15571. * @param scene defines the hosting scene
  15572. */
  15573. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15574. var _this = _super.call(this, name, position, scene) || this;
  15575. _this.interaxialDistance = interaxialDistance;
  15576. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15577. _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 });
  15578. return _this;
  15579. }
  15580. /**
  15581. * Gets camera class name
  15582. * @returns StereoscopicFreeCamera
  15583. */
  15584. StereoscopicFreeCamera.prototype.getClassName = function () {
  15585. return "StereoscopicFreeCamera";
  15586. };
  15587. return StereoscopicFreeCamera;
  15588. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15589. /***/ }),
  15590. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15591. /*!***********************************************************!*\
  15592. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15593. \***********************************************************/
  15594. /*! exports provided: StereoscopicGamepadCamera */
  15595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15596. "use strict";
  15597. __webpack_require__.r(__webpack_exports__);
  15598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15599. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15600. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15601. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15602. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15603. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15604. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15605. // Side effect import to define the stereoscopic mode.
  15606. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15607. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15608. });
  15609. /**
  15610. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15611. * @see http://doc.babylonjs.com/features/cameras
  15612. */
  15613. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15614. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15615. /**
  15616. * Creates a new StereoscopicGamepadCamera
  15617. * @param name defines camera name
  15618. * @param position defines initial position
  15619. * @param interaxialDistance defines distance between each color axis
  15620. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15621. * @param scene defines the hosting scene
  15622. */
  15623. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15624. var _this = _super.call(this, name, position, scene) || this;
  15625. _this.interaxialDistance = interaxialDistance;
  15626. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15627. _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 });
  15628. return _this;
  15629. }
  15630. /**
  15631. * Gets camera class name
  15632. * @returns StereoscopicGamepadCamera
  15633. */
  15634. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15635. return "StereoscopicGamepadCamera";
  15636. };
  15637. return StereoscopicGamepadCamera;
  15638. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15639. /***/ }),
  15640. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15641. /*!*************************************************************!*\
  15642. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15643. \*************************************************************/
  15644. /*! exports provided: StereoscopicUniversalCamera */
  15645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15646. "use strict";
  15647. __webpack_require__.r(__webpack_exports__);
  15648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15649. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15650. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15651. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15652. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15653. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15654. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15655. // Side effect import to define the stereoscopic mode.
  15656. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15657. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15658. });
  15659. /**
  15660. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15661. * @see http://doc.babylonjs.com/features/cameras
  15662. */
  15663. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15664. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15665. /**
  15666. * Creates a new StereoscopicUniversalCamera
  15667. * @param name defines camera name
  15668. * @param position defines initial position
  15669. * @param interaxialDistance defines distance between each color axis
  15670. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15671. * @param scene defines the hosting scene
  15672. */
  15673. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15674. var _this = _super.call(this, name, position, scene) || this;
  15675. _this.interaxialDistance = interaxialDistance;
  15676. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15677. _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 });
  15678. return _this;
  15679. }
  15680. /**
  15681. * Gets camera class name
  15682. * @returns StereoscopicUniversalCamera
  15683. */
  15684. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15685. return "StereoscopicUniversalCamera";
  15686. };
  15687. return StereoscopicUniversalCamera;
  15688. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15689. /***/ }),
  15690. /***/ "./Cameras/VR/index.ts":
  15691. /*!*****************************!*\
  15692. !*** ./Cameras/VR/index.ts ***!
  15693. \*****************************/
  15694. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15696. "use strict";
  15697. __webpack_require__.r(__webpack_exports__);
  15698. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15700. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15702. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15704. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15706. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15709. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15711. /***/ }),
  15712. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15713. /*!***************************************!*\
  15714. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15715. \***************************************/
  15716. /*! exports provided: VRCameraMetrics */
  15717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15718. "use strict";
  15719. __webpack_require__.r(__webpack_exports__);
  15720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15721. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15722. /**
  15723. * This represents all the required metrics to create a VR camera.
  15724. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15725. */
  15726. var VRCameraMetrics = /** @class */ (function () {
  15727. function VRCameraMetrics() {
  15728. /**
  15729. * Define if the current vr camera should compensate the distortion of the lense or not.
  15730. */
  15731. this.compensateDistortion = true;
  15732. }
  15733. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15734. /**
  15735. * Gets the rendering aspect ratio based on the provided resolutions.
  15736. */
  15737. get: function () {
  15738. return this.hResolution / (2 * this.vResolution);
  15739. },
  15740. enumerable: true,
  15741. configurable: true
  15742. });
  15743. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15744. /**
  15745. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15746. */
  15747. get: function () {
  15748. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15749. },
  15750. enumerable: true,
  15751. configurable: true
  15752. });
  15753. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15754. /**
  15755. * @hidden
  15756. */
  15757. get: function () {
  15758. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15759. var h = (4 * meters) / this.hScreenSize;
  15760. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15761. },
  15762. enumerable: true,
  15763. configurable: true
  15764. });
  15765. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15766. /**
  15767. * @hidden
  15768. */
  15769. get: function () {
  15770. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15771. var h = (4 * meters) / this.hScreenSize;
  15772. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15773. },
  15774. enumerable: true,
  15775. configurable: true
  15776. });
  15777. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15778. /**
  15779. * @hidden
  15780. */
  15781. get: function () {
  15782. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15783. },
  15784. enumerable: true,
  15785. configurable: true
  15786. });
  15787. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15788. /**
  15789. * @hidden
  15790. */
  15791. get: function () {
  15792. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15793. },
  15794. enumerable: true,
  15795. configurable: true
  15796. });
  15797. /**
  15798. * Get the default VRMetrics based on the most generic setup.
  15799. * @returns the default vr metrics
  15800. */
  15801. VRCameraMetrics.GetDefault = function () {
  15802. var result = new VRCameraMetrics();
  15803. result.hResolution = 1280;
  15804. result.vResolution = 800;
  15805. result.hScreenSize = 0.149759993;
  15806. result.vScreenSize = 0.0935999975;
  15807. result.vScreenCenter = 0.0467999987;
  15808. result.eyeToScreenDistance = 0.0410000011;
  15809. result.lensSeparationDistance = 0.0635000020;
  15810. result.interpupillaryDistance = 0.0640000030;
  15811. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15812. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15813. result.postProcessScaleFactor = 1.714605507808412;
  15814. result.lensCenterOffset = 0.151976421;
  15815. return result;
  15816. };
  15817. return VRCameraMetrics;
  15818. }());
  15819. /***/ }),
  15820. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15821. /*!**********************************************************!*\
  15822. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15823. \**********************************************************/
  15824. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15826. "use strict";
  15827. __webpack_require__.r(__webpack_exports__);
  15828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15829. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15830. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15831. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15832. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15833. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15834. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15835. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15836. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15837. // Side effect import to define the stereoscopic mode.
  15838. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15839. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15840. });
  15841. /**
  15842. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15843. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15844. */
  15845. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15846. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15847. /**
  15848. * Creates a new VRDeviceOrientationArcRotateCamera
  15849. * @param name defines camera name
  15850. * @param alpha defines the camera rotation along the logitudinal axis
  15851. * @param beta defines the camera rotation along the latitudinal axis
  15852. * @param radius defines the camera distance from its target
  15853. * @param target defines the camera target
  15854. * @param scene defines the scene the camera belongs to
  15855. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15856. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15857. */
  15858. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15859. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15860. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15861. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15862. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15863. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15864. _this.inputs.addVRDeviceOrientation();
  15865. return _this;
  15866. }
  15867. /**
  15868. * Gets camera class name
  15869. * @returns VRDeviceOrientationArcRotateCamera
  15870. */
  15871. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15872. return "VRDeviceOrientationArcRotateCamera";
  15873. };
  15874. return VRDeviceOrientationArcRotateCamera;
  15875. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15876. /***/ }),
  15877. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15878. /*!*****************************************************!*\
  15879. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15880. \*****************************************************/
  15881. /*! exports provided: VRDeviceOrientationFreeCamera */
  15882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15883. "use strict";
  15884. __webpack_require__.r(__webpack_exports__);
  15885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15886. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15887. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15888. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15889. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15890. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15891. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15892. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15893. // Side effect import to define the stereoscopic mode.
  15894. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15895. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15896. });
  15897. /**
  15898. * Camera used to simulate VR rendering (based on FreeCamera)
  15899. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15900. */
  15901. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15902. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15903. /**
  15904. * Creates a new VRDeviceOrientationFreeCamera
  15905. * @param name defines camera name
  15906. * @param position defines the start position of the camera
  15907. * @param scene defines the scene the camera belongs to
  15908. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15909. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15910. */
  15911. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15912. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15913. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15914. var _this = _super.call(this, name, position, scene) || this;
  15915. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15916. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15917. return _this;
  15918. }
  15919. /**
  15920. * Gets camera class name
  15921. * @returns VRDeviceOrientationFreeCamera
  15922. */
  15923. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15924. return "VRDeviceOrientationFreeCamera";
  15925. };
  15926. return VRDeviceOrientationFreeCamera;
  15927. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15928. /***/ }),
  15929. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15930. /*!********************************************************!*\
  15931. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15932. \********************************************************/
  15933. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15935. "use strict";
  15936. __webpack_require__.r(__webpack_exports__);
  15937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15938. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15939. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15940. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15941. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15942. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15943. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15944. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15945. });
  15946. /**
  15947. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15948. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15949. */
  15950. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15951. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15952. /**
  15953. * Creates a new VRDeviceOrientationGamepadCamera
  15954. * @param name defines camera name
  15955. * @param position defines the start position of the camera
  15956. * @param scene defines the scene the camera belongs to
  15957. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15958. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15959. */
  15960. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15961. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15962. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15963. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15964. _this.inputs.addGamepad();
  15965. return _this;
  15966. }
  15967. /**
  15968. * Gets camera class name
  15969. * @returns VRDeviceOrientationGamepadCamera
  15970. */
  15971. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15972. return "VRDeviceOrientationGamepadCamera";
  15973. };
  15974. return VRDeviceOrientationGamepadCamera;
  15975. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15976. /***/ }),
  15977. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15978. /*!******************************************!*\
  15979. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15980. \******************************************/
  15981. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  15982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15983. "use strict";
  15984. __webpack_require__.r(__webpack_exports__);
  15985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  15986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15987. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15988. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15989. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15990. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15991. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15992. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15993. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15994. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15995. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15996. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15997. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15998. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15999. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  16000. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  16001. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  16002. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  16003. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  16004. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  16005. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  16006. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  16007. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  16008. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  16009. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  16010. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  16011. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  16012. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16013. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  16014. var VRExperienceHelperGazer = /** @class */ (function () {
  16015. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  16016. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  16017. this.scene = scene;
  16018. /** @hidden */
  16019. this._pointerDownOnMeshAsked = false;
  16020. /** @hidden */
  16021. this._isActionableMesh = false;
  16022. /** @hidden */
  16023. this._teleportationRequestInitiated = false;
  16024. /** @hidden */
  16025. this._teleportationBackRequestInitiated = false;
  16026. /** @hidden */
  16027. this._rotationRightAsked = false;
  16028. /** @hidden */
  16029. this._rotationLeftAsked = false;
  16030. /** @hidden */
  16031. this._dpadPressed = true;
  16032. /** @hidden */
  16033. this._activePointer = false;
  16034. this._id = VRExperienceHelperGazer._idCounter++;
  16035. // Gaze tracker
  16036. if (!gazeTrackerToClone) {
  16037. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16038. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16039. this._gazeTracker.isPickable = false;
  16040. this._gazeTracker.isVisible = false;
  16041. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16042. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16043. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16044. targetMat.backFaceCulling = false;
  16045. this._gazeTracker.material = targetMat;
  16046. }
  16047. else {
  16048. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16049. }
  16050. }
  16051. /** @hidden */
  16052. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16053. 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));
  16054. };
  16055. /** @hidden */
  16056. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16057. this._pointerDownOnMeshAsked = true;
  16058. if (this._currentHit) {
  16059. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16060. }
  16061. };
  16062. /** @hidden */
  16063. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16064. if (this._currentHit) {
  16065. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16066. }
  16067. this._pointerDownOnMeshAsked = false;
  16068. };
  16069. /** @hidden */
  16070. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16071. this._activePointer = true;
  16072. };
  16073. /** @hidden */
  16074. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16075. this._activePointer = false;
  16076. };
  16077. /** @hidden */
  16078. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16079. if (distance === void 0) { distance = 100; }
  16080. };
  16081. VRExperienceHelperGazer.prototype.dispose = function () {
  16082. this._interactionsEnabled = false;
  16083. this._teleportationEnabled = false;
  16084. if (this._gazeTracker) {
  16085. this._gazeTracker.dispose();
  16086. }
  16087. };
  16088. VRExperienceHelperGazer._idCounter = 0;
  16089. return VRExperienceHelperGazer;
  16090. }());
  16091. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16092. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16093. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16094. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16095. _this.webVRController = webVRController;
  16096. // Laser pointer
  16097. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16098. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16099. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16100. laserPointerMaterial.alpha = 0.6;
  16101. _this._laserPointer.material = laserPointerMaterial;
  16102. _this._laserPointer.rotation.x = Math.PI / 2;
  16103. _this._laserPointer.position.z = -0.5;
  16104. _this._laserPointer.isVisible = false;
  16105. _this._laserPointer.isPickable = false;
  16106. if (!webVRController.mesh) {
  16107. // Create an empty mesh that is used prior to loading the high quality model
  16108. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16109. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16110. preloadPointerPose.rotation.x = -0.7;
  16111. preloadMesh.addChild(preloadPointerPose);
  16112. webVRController.attachToMesh(preloadMesh);
  16113. }
  16114. _this._setLaserPointerParent(webVRController.mesh);
  16115. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16116. _this._setLaserPointerParent(mesh);
  16117. });
  16118. return _this;
  16119. }
  16120. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16121. return this.webVRController.getForwardRay(length);
  16122. };
  16123. /** @hidden */
  16124. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16125. _super.prototype._activatePointer.call(this);
  16126. this._laserPointer.isVisible = true;
  16127. };
  16128. /** @hidden */
  16129. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16130. _super.prototype._deactivatePointer.call(this);
  16131. this._laserPointer.isVisible = false;
  16132. };
  16133. /** @hidden */
  16134. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16135. this._laserPointer.material.emissiveColor = color;
  16136. };
  16137. /** @hidden */
  16138. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16139. var makeNotPick = function (root) {
  16140. root.isPickable = false;
  16141. root.getChildMeshes().forEach(function (c) {
  16142. makeNotPick(c);
  16143. });
  16144. };
  16145. makeNotPick(mesh);
  16146. var meshChildren = mesh.getChildren(undefined, false);
  16147. var laserParent = mesh;
  16148. this.webVRController._pointingPoseNode = null;
  16149. for (var i = 0; i < meshChildren.length; i++) {
  16150. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16151. laserParent = meshChildren[i];
  16152. this.webVRController._pointingPoseNode = laserParent;
  16153. break;
  16154. }
  16155. }
  16156. this._laserPointer.parent = laserParent;
  16157. };
  16158. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16159. if (distance === void 0) { distance = 100; }
  16160. this._laserPointer.scaling.y = distance;
  16161. this._laserPointer.position.z = -distance / 2;
  16162. };
  16163. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16164. _super.prototype.dispose.call(this);
  16165. this._laserPointer.dispose();
  16166. if (this._meshAttachedObserver) {
  16167. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16168. }
  16169. };
  16170. return VRExperienceHelperControllerGazer;
  16171. }(VRExperienceHelperGazer));
  16172. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16173. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16174. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16175. var _this = _super.call(this, scene) || this;
  16176. _this.getCamera = getCamera;
  16177. return _this;
  16178. }
  16179. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16180. var camera = this.getCamera();
  16181. if (camera) {
  16182. return camera.getForwardRay(length);
  16183. }
  16184. else {
  16185. 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());
  16186. }
  16187. };
  16188. return VRExperienceHelperCameraGazer;
  16189. }(VRExperienceHelperGazer));
  16190. /**
  16191. * Event containing information after VR has been entered
  16192. */
  16193. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16194. function OnAfterEnteringVRObservableEvent() {
  16195. }
  16196. return OnAfterEnteringVRObservableEvent;
  16197. }());
  16198. /**
  16199. * Helps to quickly add VR support to an existing scene.
  16200. * See http://doc.babylonjs.com/how_to/webvr_helper
  16201. */
  16202. var VRExperienceHelper = /** @class */ (function () {
  16203. /**
  16204. * Instantiates a VRExperienceHelper.
  16205. * Helps to quickly add VR support to an existing scene.
  16206. * @param scene The scene the VRExperienceHelper belongs to.
  16207. * @param webVROptions Options to modify the vr experience helper's behavior.
  16208. */
  16209. function VRExperienceHelper(scene,
  16210. /** Options to modify the vr experience helper's behavior. */
  16211. webVROptions) {
  16212. if (webVROptions === void 0) { webVROptions = {}; }
  16213. var _this = this;
  16214. this.webVROptions = webVROptions;
  16215. // Can the system support WebVR, even if a headset isn't plugged in?
  16216. this._webVRsupported = false;
  16217. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16218. this._webVRready = false;
  16219. // Are we waiting for the requestPresent callback to complete?
  16220. this._webVRrequesting = false;
  16221. // Are we presenting to the headset right now? (this is the vrDevice state)
  16222. this._webVRpresenting = false;
  16223. // Are we presenting in the fullscreen fallback?
  16224. this._fullscreenVRpresenting = false;
  16225. /**
  16226. * Observable raised right before entering VR.
  16227. */
  16228. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16229. /**
  16230. * Observable raised when entering VR has completed.
  16231. */
  16232. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16233. /**
  16234. * Observable raised when exiting VR.
  16235. */
  16236. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16237. /**
  16238. * Observable raised when controller mesh is loaded.
  16239. */
  16240. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16241. this._useCustomVRButton = false;
  16242. this._teleportationRequested = false;
  16243. this._teleportActive = false;
  16244. this._floorMeshesCollection = [];
  16245. this._rotationAllowed = true;
  16246. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16247. this._isDefaultTeleportationTarget = true;
  16248. this._teleportationFillColor = "#444444";
  16249. this._teleportationBorderColor = "#FFFFFF";
  16250. this._rotationAngle = 0;
  16251. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16252. this._padSensibilityUp = 0.65;
  16253. this._padSensibilityDown = 0.35;
  16254. this._leftController = null;
  16255. this._rightController = null;
  16256. /**
  16257. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16258. */
  16259. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16260. /**
  16261. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16262. */
  16263. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16264. /**
  16265. * Observable raised before camera teleportation
  16266. */
  16267. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16268. /**
  16269. * Observable raised after camera teleportation
  16270. */
  16271. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16272. /**
  16273. * Observable raised when current selected mesh gets unselected
  16274. */
  16275. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16276. /**
  16277. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16278. */
  16279. this.teleportationEnabled = true;
  16280. this._teleportationInitialized = false;
  16281. this._interactionsEnabled = false;
  16282. this._interactionsRequested = false;
  16283. this._displayGaze = true;
  16284. this._displayLaserPointer = true;
  16285. /**
  16286. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16287. */
  16288. this.updateGazeTrackerScale = true;
  16289. /**
  16290. * If the gaze trackers color should be updated when selecting meshes
  16291. */
  16292. this.updateGazeTrackerColor = true;
  16293. /**
  16294. * Defines wether or not Pointer lock should be requested when switching to
  16295. * full screen.
  16296. */
  16297. this.requestPointerLockOnFullScreen = true;
  16298. this._onResize = function () {
  16299. _this.moveButtonToBottomRight();
  16300. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16301. _this.exitVR();
  16302. }
  16303. };
  16304. this._onFullscreenChange = function () {
  16305. var anyDoc = document;
  16306. if (anyDoc.fullscreen !== undefined) {
  16307. _this._fullscreenVRpresenting = document.fullscreen;
  16308. }
  16309. else if (anyDoc.mozFullScreen !== undefined) {
  16310. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16311. }
  16312. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16313. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16314. }
  16315. else if (anyDoc.msIsFullScreen !== undefined) {
  16316. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16317. }
  16318. else if (document.msFullscreenElement !== undefined) {
  16319. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16320. }
  16321. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16322. _this.exitVR();
  16323. if (!_this._useCustomVRButton) {
  16324. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16325. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16326. }
  16327. }
  16328. };
  16329. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16330. this.beforeRender = function () {
  16331. if (_this._leftController && _this._leftController._activePointer) {
  16332. _this._castRayAndSelectObject(_this._leftController);
  16333. }
  16334. if (_this._rightController && _this._rightController._activePointer) {
  16335. _this._castRayAndSelectObject(_this._rightController);
  16336. }
  16337. if (_this._noControllerIsActive) {
  16338. _this._castRayAndSelectObject(_this._cameraGazer);
  16339. }
  16340. else {
  16341. _this._cameraGazer._gazeTracker.isVisible = false;
  16342. }
  16343. };
  16344. this._onNewGamepadConnected = function (gamepad) {
  16345. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16346. if (gamepad.leftStick) {
  16347. gamepad.onleftstickchanged(function (stickValues) {
  16348. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16349. // Listening to classic/xbox gamepad only if no VR controller is active
  16350. if ((!_this._leftController && !_this._rightController) ||
  16351. ((_this._leftController && !_this._leftController._activePointer) &&
  16352. (_this._rightController && !_this._rightController._activePointer))) {
  16353. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16354. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16355. }
  16356. }
  16357. });
  16358. }
  16359. if (gamepad.rightStick) {
  16360. gamepad.onrightstickchanged(function (stickValues) {
  16361. if (_this._teleportationInitialized) {
  16362. _this._checkRotate(stickValues, _this._cameraGazer);
  16363. }
  16364. });
  16365. }
  16366. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16367. gamepad.onbuttondown(function (buttonPressed) {
  16368. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16369. _this._cameraGazer._selectionPointerDown();
  16370. }
  16371. });
  16372. gamepad.onbuttonup(function (buttonPressed) {
  16373. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16374. _this._cameraGazer._selectionPointerUp();
  16375. }
  16376. });
  16377. }
  16378. }
  16379. else {
  16380. var webVRController = gamepad;
  16381. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16382. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16383. _this._rightController = controller;
  16384. }
  16385. else {
  16386. _this._leftController = controller;
  16387. }
  16388. _this._tryEnableInteractionOnController(controller);
  16389. }
  16390. };
  16391. // 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
  16392. this._tryEnableInteractionOnController = function (controller) {
  16393. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16394. _this._enableInteractionOnController(controller);
  16395. }
  16396. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16397. _this._enableTeleportationOnController(controller);
  16398. }
  16399. };
  16400. this._onNewGamepadDisconnected = function (gamepad) {
  16401. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16402. if (gamepad.hand === "left" && _this._leftController != null) {
  16403. _this._leftController.dispose();
  16404. _this._leftController = null;
  16405. }
  16406. if (gamepad.hand === "right" && _this._rightController != null) {
  16407. _this._rightController.dispose();
  16408. _this._rightController = null;
  16409. }
  16410. }
  16411. };
  16412. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16413. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16414. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16415. this._scene = scene;
  16416. this._canvas = scene.getEngine().getRenderingCanvas();
  16417. // Parse options
  16418. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16419. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16420. }
  16421. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16422. webVROptions.createDeviceOrientationCamera = true;
  16423. }
  16424. if (webVROptions.laserToggle === undefined) {
  16425. webVROptions.laserToggle = true;
  16426. }
  16427. if (webVROptions.defaultHeight === undefined) {
  16428. webVROptions.defaultHeight = 1.7;
  16429. }
  16430. if (webVROptions.useCustomVRButton) {
  16431. this._useCustomVRButton = true;
  16432. if (webVROptions.customVRButton) {
  16433. this._btnVR = webVROptions.customVRButton;
  16434. }
  16435. }
  16436. if (webVROptions.rayLength) {
  16437. this._rayLength = webVROptions.rayLength;
  16438. }
  16439. this._defaultHeight = webVROptions.defaultHeight;
  16440. if (webVROptions.positionScale) {
  16441. this._rayLength *= webVROptions.positionScale;
  16442. this._defaultHeight *= webVROptions.positionScale;
  16443. }
  16444. this._hasEnteredVR = false;
  16445. // Set position
  16446. if (this._scene.activeCamera) {
  16447. this._position = this._scene.activeCamera.position.clone();
  16448. }
  16449. else {
  16450. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16451. }
  16452. // Set non-vr camera
  16453. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16454. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16455. // Copy data from existing camera
  16456. if (this._scene.activeCamera) {
  16457. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16458. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16459. // Set rotation from previous camera
  16460. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16461. var targetCamera = this._scene.activeCamera;
  16462. if (targetCamera.rotationQuaternion) {
  16463. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16464. }
  16465. else {
  16466. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16467. }
  16468. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16469. }
  16470. }
  16471. this._scene.activeCamera = this._deviceOrientationCamera;
  16472. if (this._canvas) {
  16473. this._scene.activeCamera.attachControl(this._canvas);
  16474. }
  16475. }
  16476. else {
  16477. this._existingCamera = this._scene.activeCamera;
  16478. }
  16479. // Create VR cameras
  16480. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16481. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16482. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16483. }
  16484. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16485. this._webVRCamera.useStandingMatrix();
  16486. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16487. // Create default button
  16488. if (!this._useCustomVRButton) {
  16489. this._btnVR = document.createElement("BUTTON");
  16490. this._btnVR.className = "babylonVRicon";
  16491. this._btnVR.id = "babylonVRiconbtn";
  16492. this._btnVR.title = "Click to switch to VR";
  16493. 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) }";
  16494. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16495. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16496. // css += ".babylonVRicon.vrdisplaysupported { }";
  16497. // css += ".babylonVRicon.vrdisplayready { }";
  16498. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16499. var style = document.createElement('style');
  16500. style.appendChild(document.createTextNode(css));
  16501. document.getElementsByTagName('head')[0].appendChild(style);
  16502. this.moveButtonToBottomRight();
  16503. }
  16504. // VR button click event
  16505. if (this._btnVR) {
  16506. this._btnVR.addEventListener("click", function () {
  16507. if (!_this.isInVRMode) {
  16508. _this.enterVR();
  16509. }
  16510. else {
  16511. _this.exitVR();
  16512. }
  16513. });
  16514. }
  16515. // Window events
  16516. window.addEventListener("resize", this._onResize);
  16517. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16518. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16519. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16520. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16521. document.onmsfullscreenchange = this._onFullscreenChange;
  16522. // Display vr button when headset is connected
  16523. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16524. this.displayVRButton();
  16525. }
  16526. else {
  16527. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16528. if (e.vrDisplay) {
  16529. _this.displayVRButton();
  16530. }
  16531. });
  16532. }
  16533. // Exiting VR mode using 'ESC' key on desktop
  16534. this._onKeyDown = function (event) {
  16535. if (event.keyCode === 27 && _this.isInVRMode) {
  16536. _this.exitVR();
  16537. }
  16538. };
  16539. document.addEventListener("keydown", this._onKeyDown);
  16540. // Exiting VR mode double tapping the touch screen
  16541. this._scene.onPrePointerObservable.add(function () {
  16542. if (_this.isInVRMode) {
  16543. _this.exitVR();
  16544. if (_this._fullscreenVRpresenting) {
  16545. _this._scene.getEngine().exitFullscreen();
  16546. }
  16547. }
  16548. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16549. // Listen for WebVR display changes
  16550. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16551. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16552. this._onVRRequestPresentStart = function () {
  16553. _this._webVRrequesting = true;
  16554. _this.updateButtonVisibility();
  16555. };
  16556. this._onVRRequestPresentComplete = function () {
  16557. _this._webVRrequesting = false;
  16558. _this.updateButtonVisibility();
  16559. };
  16560. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16561. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16562. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16563. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16564. scene.onDisposeObservable.add(function () {
  16565. _this.dispose();
  16566. });
  16567. // Gamepad connection events
  16568. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16569. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16570. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16571. this.updateButtonVisibility();
  16572. //create easing functions
  16573. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16574. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16575. if (this.webVROptions.floorMeshes) {
  16576. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16577. }
  16578. }
  16579. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16580. /** Return this.onEnteringVRObservable
  16581. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16582. */
  16583. get: function () {
  16584. return this.onEnteringVRObservable;
  16585. },
  16586. enumerable: true,
  16587. configurable: true
  16588. });
  16589. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16590. /** Return this.onExitingVRObservable
  16591. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16592. */
  16593. get: function () {
  16594. return this.onExitingVRObservable;
  16595. },
  16596. enumerable: true,
  16597. configurable: true
  16598. });
  16599. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16600. /** Return this.onControllerMeshLoadedObservable
  16601. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16602. */
  16603. get: function () {
  16604. return this.onControllerMeshLoadedObservable;
  16605. },
  16606. enumerable: true,
  16607. configurable: true
  16608. });
  16609. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16610. /**
  16611. * The mesh used to display where the user is going to teleport.
  16612. */
  16613. get: function () {
  16614. return this._teleportationTarget;
  16615. },
  16616. /**
  16617. * Sets the mesh to be used to display where the user is going to teleport.
  16618. */
  16619. set: function (value) {
  16620. if (value) {
  16621. value.name = "teleportationTarget";
  16622. this._isDefaultTeleportationTarget = false;
  16623. this._teleportationTarget = value;
  16624. }
  16625. },
  16626. enumerable: true,
  16627. configurable: true
  16628. });
  16629. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16630. /**
  16631. * 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
  16632. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16633. * See http://doc.babylonjs.com/resources/baking_transformations
  16634. */
  16635. get: function () {
  16636. return this._cameraGazer._gazeTracker;
  16637. },
  16638. set: function (value) {
  16639. if (value) {
  16640. // Dispose of existing meshes
  16641. if (this._cameraGazer._gazeTracker) {
  16642. this._cameraGazer._gazeTracker.dispose();
  16643. }
  16644. if (this._leftController && this._leftController._gazeTracker) {
  16645. this._leftController._gazeTracker.dispose();
  16646. }
  16647. if (this._rightController && this._rightController._gazeTracker) {
  16648. this._rightController._gazeTracker.dispose();
  16649. }
  16650. // Set and create gaze trackers on head and controllers
  16651. this._cameraGazer._gazeTracker = value;
  16652. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16653. this._cameraGazer._gazeTracker.isPickable = false;
  16654. this._cameraGazer._gazeTracker.isVisible = false;
  16655. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16656. if (this._leftController) {
  16657. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16658. }
  16659. if (this._rightController) {
  16660. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16661. }
  16662. }
  16663. },
  16664. enumerable: true,
  16665. configurable: true
  16666. });
  16667. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16668. /**
  16669. * The gaze tracking mesh corresponding to the left controller
  16670. */
  16671. get: function () {
  16672. if (this._leftController) {
  16673. return this._leftController._gazeTracker;
  16674. }
  16675. return null;
  16676. },
  16677. enumerable: true,
  16678. configurable: true
  16679. });
  16680. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16681. /**
  16682. * The gaze tracking mesh corresponding to the right controller
  16683. */
  16684. get: function () {
  16685. if (this._rightController) {
  16686. return this._rightController._gazeTracker;
  16687. }
  16688. return null;
  16689. },
  16690. enumerable: true,
  16691. configurable: true
  16692. });
  16693. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16694. /**
  16695. * If the ray of the gaze should be displayed.
  16696. */
  16697. get: function () {
  16698. return this._displayGaze;
  16699. },
  16700. /**
  16701. * Sets if the ray of the gaze should be displayed.
  16702. */
  16703. set: function (value) {
  16704. this._displayGaze = value;
  16705. if (!value) {
  16706. this._cameraGazer._gazeTracker.isVisible = false;
  16707. if (this._leftController) {
  16708. this._leftController._gazeTracker.isVisible = false;
  16709. }
  16710. if (this._rightController) {
  16711. this._rightController._gazeTracker.isVisible = false;
  16712. }
  16713. }
  16714. },
  16715. enumerable: true,
  16716. configurable: true
  16717. });
  16718. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16719. /**
  16720. * If the ray of the LaserPointer should be displayed.
  16721. */
  16722. get: function () {
  16723. return this._displayLaserPointer;
  16724. },
  16725. /**
  16726. * Sets if the ray of the LaserPointer should be displayed.
  16727. */
  16728. set: function (value) {
  16729. this._displayLaserPointer = value;
  16730. if (!value) {
  16731. if (this._rightController) {
  16732. this._rightController._deactivatePointer();
  16733. this._rightController._gazeTracker.isVisible = false;
  16734. }
  16735. if (this._leftController) {
  16736. this._leftController._deactivatePointer();
  16737. this._leftController._gazeTracker.isVisible = false;
  16738. }
  16739. }
  16740. else {
  16741. if (this._rightController) {
  16742. this._rightController._activatePointer();
  16743. }
  16744. if (this._leftController) {
  16745. this._leftController._activatePointer();
  16746. }
  16747. }
  16748. },
  16749. enumerable: true,
  16750. configurable: true
  16751. });
  16752. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16753. /**
  16754. * The deviceOrientationCamera used as the camera when not in VR.
  16755. */
  16756. get: function () {
  16757. return this._deviceOrientationCamera;
  16758. },
  16759. enumerable: true,
  16760. configurable: true
  16761. });
  16762. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16763. /**
  16764. * Based on the current WebVR support, returns the current VR camera used.
  16765. */
  16766. get: function () {
  16767. if (this._webVRready) {
  16768. return this._webVRCamera;
  16769. }
  16770. else {
  16771. return this._scene.activeCamera;
  16772. }
  16773. },
  16774. enumerable: true,
  16775. configurable: true
  16776. });
  16777. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16778. /**
  16779. * The webVRCamera which is used when in VR.
  16780. */
  16781. get: function () {
  16782. return this._webVRCamera;
  16783. },
  16784. enumerable: true,
  16785. configurable: true
  16786. });
  16787. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16788. /**
  16789. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16790. */
  16791. get: function () {
  16792. return this._vrDeviceOrientationCamera;
  16793. },
  16794. enumerable: true,
  16795. configurable: true
  16796. });
  16797. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16798. get: function () {
  16799. var result = this._cameraGazer._teleportationRequestInitiated
  16800. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16801. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16802. return result;
  16803. },
  16804. enumerable: true,
  16805. configurable: true
  16806. });
  16807. // Raised when one of the controller has loaded successfully its associated default mesh
  16808. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16809. if (this._leftController && this._leftController.webVRController == webVRController) {
  16810. if (webVRController.mesh) {
  16811. this._leftController._setLaserPointerParent(webVRController.mesh);
  16812. }
  16813. }
  16814. if (this._rightController && this._rightController.webVRController == webVRController) {
  16815. if (webVRController.mesh) {
  16816. this._rightController._setLaserPointerParent(webVRController.mesh);
  16817. }
  16818. }
  16819. try {
  16820. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16821. }
  16822. catch (err) {
  16823. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16824. }
  16825. };
  16826. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16827. /**
  16828. * Gets a value indicating if we are currently in VR mode.
  16829. */
  16830. get: function () {
  16831. return this._webVRpresenting || this._fullscreenVRpresenting;
  16832. },
  16833. enumerable: true,
  16834. configurable: true
  16835. });
  16836. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16837. var vrDisplay = this._scene.getEngine().getVRDevice();
  16838. if (vrDisplay) {
  16839. var wasPresenting = this._webVRpresenting;
  16840. this._webVRpresenting = vrDisplay.isPresenting;
  16841. if (wasPresenting && !this._webVRpresenting) {
  16842. this.exitVR();
  16843. }
  16844. }
  16845. else {
  16846. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16847. }
  16848. this.updateButtonVisibility();
  16849. };
  16850. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16851. this._webVRsupported = eventArgs.vrSupported;
  16852. this._webVRready = !!eventArgs.vrDisplay;
  16853. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16854. this.updateButtonVisibility();
  16855. };
  16856. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16857. if (this._canvas && !this._useCustomVRButton) {
  16858. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16859. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16860. }
  16861. };
  16862. VRExperienceHelper.prototype.displayVRButton = function () {
  16863. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16864. document.body.appendChild(this._btnVR);
  16865. this._btnVRDisplayed = true;
  16866. }
  16867. };
  16868. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16869. if (!this._btnVR || this._useCustomVRButton) {
  16870. return;
  16871. }
  16872. this._btnVR.className = "babylonVRicon";
  16873. if (this.isInVRMode) {
  16874. this._btnVR.className += " vrdisplaypresenting";
  16875. }
  16876. else {
  16877. if (this._webVRready) {
  16878. this._btnVR.className += " vrdisplayready";
  16879. }
  16880. if (this._webVRsupported) {
  16881. this._btnVR.className += " vrdisplaysupported";
  16882. }
  16883. if (this._webVRrequesting) {
  16884. this._btnVR.className += " vrdisplayrequesting";
  16885. }
  16886. }
  16887. };
  16888. /**
  16889. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16890. * Otherwise, will use the fullscreen API.
  16891. */
  16892. VRExperienceHelper.prototype.enterVR = function () {
  16893. var _this = this;
  16894. if (this.onEnteringVRObservable) {
  16895. try {
  16896. this.onEnteringVRObservable.notifyObservers(this);
  16897. }
  16898. catch (err) {
  16899. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16900. }
  16901. }
  16902. if (this._scene.activeCamera) {
  16903. this._position = this._scene.activeCamera.position.clone();
  16904. if (this.vrDeviceOrientationCamera) {
  16905. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16906. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16907. }
  16908. if (this.webVRCamera) {
  16909. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16910. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16911. var delta = desiredYRotation - currentYRotation;
  16912. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16913. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16914. }
  16915. // make sure that we return to the last active camera
  16916. this._existingCamera = this._scene.activeCamera;
  16917. // Remove and cache angular sensability to avoid camera rotation when in VR
  16918. if (this._existingCamera.angularSensibilityX) {
  16919. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16920. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16921. }
  16922. if (this._existingCamera.angularSensibilityY) {
  16923. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16924. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16925. }
  16926. if (this._existingCamera.angularSensibility) {
  16927. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16928. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16929. }
  16930. }
  16931. if (this._webVRrequesting) {
  16932. return;
  16933. }
  16934. // If WebVR is supported and a headset is connected
  16935. if (this._webVRready) {
  16936. if (!this._webVRpresenting) {
  16937. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  16938. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  16939. });
  16940. this._webVRCamera.position = this._position;
  16941. this._scene.activeCamera = this._webVRCamera;
  16942. }
  16943. }
  16944. else if (this._vrDeviceOrientationCamera) {
  16945. this._vrDeviceOrientationCamera.position = this._position;
  16946. if (this._scene.activeCamera) {
  16947. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16948. }
  16949. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16950. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  16951. this.updateButtonVisibility();
  16952. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  16953. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  16954. });
  16955. }
  16956. if (this._scene.activeCamera && this._canvas) {
  16957. this._scene.activeCamera.attachControl(this._canvas);
  16958. }
  16959. if (this._interactionsEnabled) {
  16960. this._scene.registerBeforeRender(this.beforeRender);
  16961. }
  16962. if (this._displayLaserPointer) {
  16963. [this._leftController, this._rightController].forEach(function (controller) {
  16964. if (controller) {
  16965. controller._activatePointer();
  16966. }
  16967. });
  16968. }
  16969. this._hasEnteredVR = true;
  16970. };
  16971. /**
  16972. * Attempt to exit VR, or fullscreen.
  16973. */
  16974. VRExperienceHelper.prototype.exitVR = function () {
  16975. if (this._hasEnteredVR) {
  16976. if (this.onExitingVRObservable) {
  16977. try {
  16978. this.onExitingVRObservable.notifyObservers(this);
  16979. }
  16980. catch (err) {
  16981. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16982. }
  16983. }
  16984. if (this._webVRpresenting) {
  16985. this._scene.getEngine().disableVR();
  16986. }
  16987. if (this._scene.activeCamera) {
  16988. this._position = this._scene.activeCamera.position.clone();
  16989. }
  16990. if (this.vrDeviceOrientationCamera) {
  16991. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16992. }
  16993. if (this._deviceOrientationCamera) {
  16994. this._deviceOrientationCamera.position = this._position;
  16995. this._scene.activeCamera = this._deviceOrientationCamera;
  16996. if (this._canvas) {
  16997. this._scene.activeCamera.attachControl(this._canvas);
  16998. }
  16999. // Restore angular sensibility
  17000. if (this._cachedAngularSensibility.angularSensibilityX) {
  17001. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17002. this._cachedAngularSensibility.angularSensibilityX = null;
  17003. }
  17004. if (this._cachedAngularSensibility.angularSensibilityY) {
  17005. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17006. this._cachedAngularSensibility.angularSensibilityY = null;
  17007. }
  17008. if (this._cachedAngularSensibility.angularSensibility) {
  17009. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17010. this._cachedAngularSensibility.angularSensibility = null;
  17011. }
  17012. }
  17013. else if (this._existingCamera) {
  17014. this._existingCamera.position = this._position;
  17015. this._scene.activeCamera = this._existingCamera;
  17016. // Restore angular sensibility
  17017. if (this._cachedAngularSensibility.angularSensibilityX) {
  17018. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17019. this._cachedAngularSensibility.angularSensibilityX = null;
  17020. }
  17021. if (this._cachedAngularSensibility.angularSensibilityY) {
  17022. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17023. this._cachedAngularSensibility.angularSensibilityY = null;
  17024. }
  17025. if (this._cachedAngularSensibility.angularSensibility) {
  17026. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17027. this._cachedAngularSensibility.angularSensibility = null;
  17028. }
  17029. }
  17030. this.updateButtonVisibility();
  17031. if (this._interactionsEnabled) {
  17032. this._scene.unregisterBeforeRender(this.beforeRender);
  17033. this._cameraGazer._gazeTracker.isVisible = false;
  17034. if (this._leftController) {
  17035. this._leftController._gazeTracker.isVisible = false;
  17036. }
  17037. if (this._rightController) {
  17038. this._rightController._gazeTracker.isVisible = false;
  17039. }
  17040. }
  17041. // resize to update width and height when exiting vr exits fullscreen
  17042. this._scene.getEngine().resize();
  17043. [this._leftController, this._rightController].forEach(function (controller) {
  17044. if (controller) {
  17045. controller._deactivatePointer();
  17046. }
  17047. });
  17048. this._hasEnteredVR = false;
  17049. }
  17050. };
  17051. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17052. /**
  17053. * The position of the vr experience helper.
  17054. */
  17055. get: function () {
  17056. return this._position;
  17057. },
  17058. /**
  17059. * Sets the position of the vr experience helper.
  17060. */
  17061. set: function (value) {
  17062. this._position = value;
  17063. if (this._scene.activeCamera) {
  17064. this._scene.activeCamera.position = value;
  17065. }
  17066. },
  17067. enumerable: true,
  17068. configurable: true
  17069. });
  17070. /**
  17071. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17072. */
  17073. VRExperienceHelper.prototype.enableInteractions = function () {
  17074. var _this = this;
  17075. if (!this._interactionsEnabled) {
  17076. this._interactionsRequested = true;
  17077. if (this._leftController) {
  17078. this._enableInteractionOnController(this._leftController);
  17079. }
  17080. if (this._rightController) {
  17081. this._enableInteractionOnController(this._rightController);
  17082. }
  17083. this.raySelectionPredicate = function (mesh) {
  17084. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17085. };
  17086. this.meshSelectionPredicate = function () {
  17087. return true;
  17088. };
  17089. this._raySelectionPredicate = function (mesh) {
  17090. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17091. && mesh.name.indexOf("teleportationTarget") === -1
  17092. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17093. return _this.raySelectionPredicate(mesh);
  17094. }
  17095. return false;
  17096. };
  17097. this._interactionsEnabled = true;
  17098. }
  17099. };
  17100. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17101. get: function () {
  17102. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17103. },
  17104. enumerable: true,
  17105. configurable: true
  17106. });
  17107. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17108. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17109. if (this._floorMeshesCollection[i].id === mesh.id) {
  17110. return true;
  17111. }
  17112. }
  17113. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17114. return true;
  17115. }
  17116. return false;
  17117. };
  17118. /**
  17119. * Adds a floor mesh to be used for teleportation.
  17120. * @param floorMesh the mesh to be used for teleportation.
  17121. */
  17122. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17123. if (!this._floorMeshesCollection) {
  17124. return;
  17125. }
  17126. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17127. return;
  17128. }
  17129. this._floorMeshesCollection.push(floorMesh);
  17130. };
  17131. /**
  17132. * Removes a floor mesh from being used for teleportation.
  17133. * @param floorMesh the mesh to be removed.
  17134. */
  17135. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17136. if (!this._floorMeshesCollection) {
  17137. return;
  17138. }
  17139. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17140. if (meshIndex !== -1) {
  17141. this._floorMeshesCollection.splice(meshIndex, 1);
  17142. }
  17143. };
  17144. /**
  17145. * Enables interactions and teleportation using the VR controllers and gaze.
  17146. * @param vrTeleportationOptions options to modify teleportation behavior.
  17147. */
  17148. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17149. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17150. if (!this._teleportationInitialized) {
  17151. this._teleportationRequested = true;
  17152. this.enableInteractions();
  17153. if (vrTeleportationOptions.floorMeshName) {
  17154. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17155. }
  17156. if (vrTeleportationOptions.floorMeshes) {
  17157. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17158. }
  17159. if (this._leftController != null) {
  17160. this._enableTeleportationOnController(this._leftController);
  17161. }
  17162. if (this._rightController != null) {
  17163. this._enableTeleportationOnController(this._rightController);
  17164. }
  17165. // Creates an image processing post process for the vignette not relying
  17166. // on the main scene configuration for image processing to reduce setup and spaces
  17167. // (gamma/linear) conflicts.
  17168. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17169. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17170. imageProcessingConfiguration.vignetteEnabled = true;
  17171. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17172. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17173. this._teleportationInitialized = true;
  17174. if (this._isDefaultTeleportationTarget) {
  17175. this._createTeleportationCircles();
  17176. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17177. }
  17178. }
  17179. };
  17180. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17181. var _this = this;
  17182. var controllerMesh = controller.webVRController.mesh;
  17183. if (controllerMesh) {
  17184. controller._interactionsEnabled = true;
  17185. if (this.isInVRMode && this._displayLaserPointer) {
  17186. controller._activatePointer();
  17187. }
  17188. if (this.webVROptions.laserToggle) {
  17189. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17190. // Enabling / disabling laserPointer
  17191. if (_this._displayLaserPointer && stateObject.value === 1) {
  17192. if (controller._activePointer) {
  17193. controller._deactivatePointer();
  17194. }
  17195. else {
  17196. controller._activatePointer();
  17197. }
  17198. if (_this.displayGaze) {
  17199. controller._gazeTracker.isVisible = controller._activePointer;
  17200. }
  17201. }
  17202. });
  17203. }
  17204. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17205. var gazer = controller;
  17206. if (_this._noControllerIsActive) {
  17207. gazer = _this._cameraGazer;
  17208. }
  17209. if (!gazer._pointerDownOnMeshAsked) {
  17210. if (stateObject.value > _this._padSensibilityUp) {
  17211. gazer._selectionPointerDown();
  17212. }
  17213. }
  17214. else if (stateObject.value < _this._padSensibilityDown) {
  17215. gazer._selectionPointerUp();
  17216. }
  17217. });
  17218. }
  17219. };
  17220. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17221. // Dont teleport if another gaze already requested teleportation
  17222. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17223. return;
  17224. }
  17225. if (!gazer._teleportationRequestInitiated) {
  17226. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17227. gazer._activatePointer();
  17228. gazer._teleportationRequestInitiated = true;
  17229. }
  17230. }
  17231. else {
  17232. // Listening to the proper controller values changes to confirm teleportation
  17233. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17234. if (this._teleportActive) {
  17235. this.teleportCamera(this._haloCenter);
  17236. }
  17237. gazer._teleportationRequestInitiated = false;
  17238. }
  17239. }
  17240. };
  17241. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17242. // Only rotate when user is not currently selecting a teleportation location
  17243. if (gazer._teleportationRequestInitiated) {
  17244. return;
  17245. }
  17246. if (!gazer._rotationLeftAsked) {
  17247. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17248. gazer._rotationLeftAsked = true;
  17249. if (this._rotationAllowed) {
  17250. this._rotateCamera(false);
  17251. }
  17252. }
  17253. }
  17254. else {
  17255. if (stateObject.x > -this._padSensibilityDown) {
  17256. gazer._rotationLeftAsked = false;
  17257. }
  17258. }
  17259. if (!gazer._rotationRightAsked) {
  17260. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17261. gazer._rotationRightAsked = true;
  17262. if (this._rotationAllowed) {
  17263. this._rotateCamera(true);
  17264. }
  17265. }
  17266. }
  17267. else {
  17268. if (stateObject.x < this._padSensibilityDown) {
  17269. gazer._rotationRightAsked = false;
  17270. }
  17271. }
  17272. };
  17273. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17274. // Only teleport backwards when user is not currently selecting a teleportation location
  17275. if (gazer._teleportationRequestInitiated) {
  17276. return;
  17277. }
  17278. // Teleport backwards
  17279. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17280. if (!gazer._teleportationBackRequestInitiated) {
  17281. if (!this.currentVRCamera) {
  17282. return;
  17283. }
  17284. // Get rotation and position of the current camera
  17285. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17286. var position = this.currentVRCamera.position;
  17287. // If the camera has device position, use that instead
  17288. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17289. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17290. position = this.currentVRCamera.devicePosition;
  17291. }
  17292. // Get matrix with only the y rotation of the device rotation
  17293. rotation.toEulerAnglesToRef(this._workingVector);
  17294. this._workingVector.z = 0;
  17295. this._workingVector.x = 0;
  17296. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17297. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17298. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17299. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17300. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17301. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17302. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17303. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17304. this.teleportCamera(hit.pickedPoint);
  17305. }
  17306. gazer._teleportationBackRequestInitiated = true;
  17307. }
  17308. }
  17309. else {
  17310. gazer._teleportationBackRequestInitiated = false;
  17311. }
  17312. };
  17313. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17314. var _this = this;
  17315. var controllerMesh = controller.webVRController.mesh;
  17316. if (controllerMesh) {
  17317. if (!controller._interactionsEnabled) {
  17318. this._enableInteractionOnController(controller);
  17319. }
  17320. controller._interactionsEnabled = true;
  17321. controller._teleportationEnabled = true;
  17322. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17323. controller._dpadPressed = false;
  17324. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17325. controller._dpadPressed = stateObject.pressed;
  17326. if (!controller._dpadPressed) {
  17327. controller._rotationLeftAsked = false;
  17328. controller._rotationRightAsked = false;
  17329. controller._teleportationBackRequestInitiated = false;
  17330. }
  17331. });
  17332. }
  17333. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17334. if (_this.teleportationEnabled) {
  17335. _this._checkTeleportBackwards(stateObject, controller);
  17336. _this._checkTeleportWithRay(stateObject, controller);
  17337. }
  17338. _this._checkRotate(stateObject, controller);
  17339. });
  17340. }
  17341. };
  17342. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17343. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17344. this._teleportationTarget.isPickable = false;
  17345. var length = 512;
  17346. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17347. dynamicTexture.hasAlpha = true;
  17348. var context = dynamicTexture.getContext();
  17349. var centerX = length / 2;
  17350. var centerY = length / 2;
  17351. var radius = 200;
  17352. context.beginPath();
  17353. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17354. context.fillStyle = this._teleportationFillColor;
  17355. context.fill();
  17356. context.lineWidth = 10;
  17357. context.strokeStyle = this._teleportationBorderColor;
  17358. context.stroke();
  17359. context.closePath();
  17360. dynamicTexture.update();
  17361. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17362. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17363. this._teleportationTarget.material = teleportationCircleMaterial;
  17364. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17365. torus.isPickable = false;
  17366. torus.parent = this._teleportationTarget;
  17367. 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);
  17368. var keys = [];
  17369. keys.push({
  17370. frame: 0,
  17371. value: 0
  17372. });
  17373. keys.push({
  17374. frame: 30,
  17375. value: 0.4
  17376. });
  17377. keys.push({
  17378. frame: 60,
  17379. value: 0
  17380. });
  17381. animationInnerCircle.setKeys(keys);
  17382. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17383. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17384. animationInnerCircle.setEasingFunction(easingFunction);
  17385. torus.animations = [];
  17386. torus.animations.push(animationInnerCircle);
  17387. this._scene.beginAnimation(torus, 0, 60, true);
  17388. this._hideTeleportationTarget();
  17389. };
  17390. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17391. this._teleportActive = true;
  17392. if (this._teleportationInitialized) {
  17393. this._teleportationTarget.isVisible = true;
  17394. if (this._isDefaultTeleportationTarget) {
  17395. this._teleportationTarget.getChildren()[0].isVisible = true;
  17396. }
  17397. }
  17398. };
  17399. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17400. this._teleportActive = false;
  17401. if (this._teleportationInitialized) {
  17402. this._teleportationTarget.isVisible = false;
  17403. if (this._isDefaultTeleportationTarget) {
  17404. this._teleportationTarget.getChildren()[0].isVisible = false;
  17405. }
  17406. }
  17407. };
  17408. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17409. var _this = this;
  17410. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17411. return;
  17412. }
  17413. if (right) {
  17414. this._rotationAngle++;
  17415. }
  17416. else {
  17417. this._rotationAngle--;
  17418. }
  17419. this.currentVRCamera.animations = [];
  17420. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17421. 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);
  17422. var animationRotationKeys = [];
  17423. animationRotationKeys.push({
  17424. frame: 0,
  17425. value: this.currentVRCamera.rotationQuaternion
  17426. });
  17427. animationRotationKeys.push({
  17428. frame: 6,
  17429. value: target
  17430. });
  17431. animationRotation.setKeys(animationRotationKeys);
  17432. animationRotation.setEasingFunction(this._circleEase);
  17433. this.currentVRCamera.animations.push(animationRotation);
  17434. this._postProcessMove.animations = [];
  17435. 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);
  17436. var vignetteWeightKeys = [];
  17437. vignetteWeightKeys.push({
  17438. frame: 0,
  17439. value: 0
  17440. });
  17441. vignetteWeightKeys.push({
  17442. frame: 3,
  17443. value: 4
  17444. });
  17445. vignetteWeightKeys.push({
  17446. frame: 6,
  17447. value: 0
  17448. });
  17449. animationPP.setKeys(vignetteWeightKeys);
  17450. animationPP.setEasingFunction(this._circleEase);
  17451. this._postProcessMove.animations.push(animationPP);
  17452. 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);
  17453. var vignetteStretchKeys = [];
  17454. vignetteStretchKeys.push({
  17455. frame: 0,
  17456. value: 0
  17457. });
  17458. vignetteStretchKeys.push({
  17459. frame: 3,
  17460. value: 10
  17461. });
  17462. vignetteStretchKeys.push({
  17463. frame: 6,
  17464. value: 0
  17465. });
  17466. animationPP2.setKeys(vignetteStretchKeys);
  17467. animationPP2.setEasingFunction(this._circleEase);
  17468. this._postProcessMove.animations.push(animationPP2);
  17469. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17470. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17471. this._postProcessMove.samples = 4;
  17472. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17473. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17474. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17475. });
  17476. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17477. };
  17478. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17479. if (hit.pickedPoint) {
  17480. if (gazer._teleportationRequestInitiated) {
  17481. this._displayTeleportationTarget();
  17482. this._haloCenter.copyFrom(hit.pickedPoint);
  17483. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17484. }
  17485. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17486. if (pickNormal) {
  17487. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17488. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17489. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17490. }
  17491. this._teleportationTarget.position.y += 0.1;
  17492. }
  17493. };
  17494. /**
  17495. * Teleports the users feet to the desired location
  17496. * @param location The location where the user's feet should be placed
  17497. */
  17498. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17499. var _this = this;
  17500. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17501. return;
  17502. }
  17503. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17504. // offset of the headset from the anchor.
  17505. if (this.webVRCamera.leftCamera) {
  17506. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17507. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17508. location.subtractToRef(this._workingVector, this._workingVector);
  17509. }
  17510. else {
  17511. this._workingVector.copyFrom(location);
  17512. }
  17513. // Add height to account for user's height offset
  17514. if (this.isInVRMode) {
  17515. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17516. }
  17517. else {
  17518. this._workingVector.y += this._defaultHeight;
  17519. }
  17520. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17521. // Create animation from the camera's position to the new location
  17522. this.currentVRCamera.animations = [];
  17523. 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);
  17524. var animationCameraTeleportationKeys = [{
  17525. frame: 0,
  17526. value: this.currentVRCamera.position
  17527. },
  17528. {
  17529. frame: 11,
  17530. value: this._workingVector
  17531. }
  17532. ];
  17533. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17534. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17535. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17536. this._postProcessMove.animations = [];
  17537. 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);
  17538. var vignetteWeightKeys = [];
  17539. vignetteWeightKeys.push({
  17540. frame: 0,
  17541. value: 0
  17542. });
  17543. vignetteWeightKeys.push({
  17544. frame: 5,
  17545. value: 8
  17546. });
  17547. vignetteWeightKeys.push({
  17548. frame: 11,
  17549. value: 0
  17550. });
  17551. animationPP.setKeys(vignetteWeightKeys);
  17552. this._postProcessMove.animations.push(animationPP);
  17553. var animationPP2 = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP2", "vignetteStretch", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17554. var vignetteStretchKeys = [];
  17555. vignetteStretchKeys.push({
  17556. frame: 0,
  17557. value: 0
  17558. });
  17559. vignetteStretchKeys.push({
  17560. frame: 5,
  17561. value: 10
  17562. });
  17563. vignetteStretchKeys.push({
  17564. frame: 11,
  17565. value: 0
  17566. });
  17567. animationPP2.setKeys(vignetteStretchKeys);
  17568. this._postProcessMove.animations.push(animationPP2);
  17569. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17570. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17571. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17572. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17573. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17574. });
  17575. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17576. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17577. });
  17578. this._hideTeleportationTarget();
  17579. };
  17580. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17581. if (normal) {
  17582. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17583. if (angle < Math.PI / 2) {
  17584. normal.scaleInPlace(-1);
  17585. }
  17586. }
  17587. return normal;
  17588. };
  17589. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17590. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17591. return;
  17592. }
  17593. var ray = gazer._getForwardRay(this._rayLength);
  17594. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17595. if (hit) {
  17596. // Populate the contrllers mesh that can be used for drag/drop
  17597. if (gazer._laserPointer) {
  17598. hit.originMesh = gazer._laserPointer.parent;
  17599. }
  17600. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17601. }
  17602. gazer._currentHit = hit;
  17603. // Moving the gazeTracker on the mesh face targetted
  17604. if (hit && hit.pickedPoint) {
  17605. if (this._displayGaze) {
  17606. var multiplier = 1;
  17607. gazer._gazeTracker.isVisible = true;
  17608. if (gazer._isActionableMesh) {
  17609. multiplier = 3;
  17610. }
  17611. if (this.updateGazeTrackerScale) {
  17612. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17613. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17614. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17615. }
  17616. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17617. // To avoid z-fighting
  17618. var deltaFighting = 0.002;
  17619. if (pickNormal) {
  17620. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17621. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17622. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17623. }
  17624. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17625. if (gazer._gazeTracker.position.x < 0) {
  17626. gazer._gazeTracker.position.x += deltaFighting;
  17627. }
  17628. else {
  17629. gazer._gazeTracker.position.x -= deltaFighting;
  17630. }
  17631. if (gazer._gazeTracker.position.y < 0) {
  17632. gazer._gazeTracker.position.y += deltaFighting;
  17633. }
  17634. else {
  17635. gazer._gazeTracker.position.y -= deltaFighting;
  17636. }
  17637. if (gazer._gazeTracker.position.z < 0) {
  17638. gazer._gazeTracker.position.z += deltaFighting;
  17639. }
  17640. else {
  17641. gazer._gazeTracker.position.z -= deltaFighting;
  17642. }
  17643. }
  17644. // Changing the size of the laser pointer based on the distance from the targetted point
  17645. gazer._updatePointerDistance(hit.distance);
  17646. }
  17647. else {
  17648. gazer._updatePointerDistance();
  17649. gazer._gazeTracker.isVisible = false;
  17650. }
  17651. if (hit && hit.pickedMesh) {
  17652. // The object selected is the floor, we're in a teleportation scenario
  17653. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17654. // Moving the teleportation area to this targetted point
  17655. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17656. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17657. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17658. }
  17659. gazer._currentMeshSelected = null;
  17660. if (gazer._teleportationRequestInitiated) {
  17661. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17662. }
  17663. return;
  17664. }
  17665. // If not, we're in a selection scenario
  17666. //this._teleportationAllowed = false;
  17667. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17668. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17669. this.onNewMeshPicked.notifyObservers(hit);
  17670. gazer._currentMeshSelected = hit.pickedMesh;
  17671. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17672. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17673. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17674. gazer._isActionableMesh = true;
  17675. }
  17676. else {
  17677. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17678. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17679. gazer._isActionableMesh = false;
  17680. }
  17681. try {
  17682. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17683. }
  17684. catch (err) {
  17685. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17686. }
  17687. }
  17688. else {
  17689. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17690. gazer._currentMeshSelected = null;
  17691. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17692. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17693. }
  17694. }
  17695. }
  17696. else {
  17697. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17698. gazer._currentMeshSelected = null;
  17699. //this._teleportationAllowed = false;
  17700. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17701. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17702. }
  17703. };
  17704. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17705. if (mesh) {
  17706. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17707. }
  17708. };
  17709. /**
  17710. * Sets the color of the laser ray from the vr controllers.
  17711. * @param color new color for the ray.
  17712. */
  17713. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17714. if (this._leftController) {
  17715. this._leftController._setLaserPointerColor(color);
  17716. }
  17717. if (this._rightController) {
  17718. this._rightController._setLaserPointerColor(color);
  17719. }
  17720. };
  17721. /**
  17722. * Sets the color of the ray from the vr headsets gaze.
  17723. * @param color new color for the ray.
  17724. */
  17725. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17726. if (!this.updateGazeTrackerColor) {
  17727. return;
  17728. }
  17729. if (!this._cameraGazer._gazeTracker.material) {
  17730. return;
  17731. }
  17732. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17733. if (this._leftController) {
  17734. this._leftController._gazeTracker.material.emissiveColor = color;
  17735. }
  17736. if (this._rightController) {
  17737. this._rightController._gazeTracker.material.emissiveColor = color;
  17738. }
  17739. };
  17740. /**
  17741. * Exits VR and disposes of the vr experience helper
  17742. */
  17743. VRExperienceHelper.prototype.dispose = function () {
  17744. if (this.isInVRMode) {
  17745. this.exitVR();
  17746. }
  17747. if (this._postProcessMove) {
  17748. this._postProcessMove.dispose();
  17749. }
  17750. if (this._webVRCamera) {
  17751. this._webVRCamera.dispose();
  17752. }
  17753. if (this._vrDeviceOrientationCamera) {
  17754. this._vrDeviceOrientationCamera.dispose();
  17755. }
  17756. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17757. document.body.removeChild(this._btnVR);
  17758. }
  17759. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17760. this._deviceOrientationCamera.dispose();
  17761. }
  17762. if (this._cameraGazer) {
  17763. this._cameraGazer.dispose();
  17764. }
  17765. if (this._leftController) {
  17766. this._leftController.dispose();
  17767. }
  17768. if (this._rightController) {
  17769. this._rightController.dispose();
  17770. }
  17771. if (this._teleportationTarget) {
  17772. this._teleportationTarget.dispose();
  17773. }
  17774. this._floorMeshesCollection = [];
  17775. document.removeEventListener("keydown", this._onKeyDown);
  17776. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17777. window.removeEventListener("resize", this._onResize);
  17778. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17779. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17780. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17781. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17782. document.onmsfullscreenchange = null;
  17783. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17784. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17785. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17786. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17787. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17788. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17789. this._scene.unregisterBeforeRender(this.beforeRender);
  17790. };
  17791. /**
  17792. * Gets the name of the VRExperienceHelper class
  17793. * @returns "VRExperienceHelper"
  17794. */
  17795. VRExperienceHelper.prototype.getClassName = function () {
  17796. return "VRExperienceHelper";
  17797. };
  17798. return VRExperienceHelper;
  17799. }());
  17800. /***/ }),
  17801. /***/ "./Cameras/VR/webVRCamera.ts":
  17802. /*!***********************************!*\
  17803. !*** ./Cameras/VR/webVRCamera.ts ***!
  17804. \***********************************/
  17805. /*! exports provided: WebVRFreeCamera */
  17806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17807. "use strict";
  17808. __webpack_require__.r(__webpack_exports__);
  17809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17810. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17811. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17812. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17813. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17814. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17815. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17816. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17817. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17818. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17819. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17820. // Side effect import to define the stereoscopic mode.
  17821. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17822. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17823. });
  17824. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17825. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17826. });
  17827. /**
  17828. * This represents a WebVR camera.
  17829. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17830. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17831. */
  17832. var WebVRFreeCamera = /** @class */ (function (_super) {
  17833. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17834. /**
  17835. * Instantiates a WebVRFreeCamera.
  17836. * @param name The name of the WebVRFreeCamera
  17837. * @param position The starting anchor position for the camera
  17838. * @param scene The scene the camera belongs to
  17839. * @param webVROptions a set of customizable options for the webVRCamera
  17840. */
  17841. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17842. if (webVROptions === void 0) { webVROptions = {}; }
  17843. var _this = _super.call(this, name, position, scene) || this;
  17844. _this.webVROptions = webVROptions;
  17845. /**
  17846. * @hidden
  17847. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17848. */
  17849. _this._vrDevice = null;
  17850. /**
  17851. * The rawPose of the vrDevice.
  17852. */
  17853. _this.rawPose = null;
  17854. _this._specsVersion = "1.1";
  17855. _this._attached = false;
  17856. _this._descendants = [];
  17857. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17858. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17859. /** @hidden */
  17860. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17861. _this._standingMatrix = null;
  17862. /**
  17863. * Represents device position in babylon space.
  17864. */
  17865. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17866. /**
  17867. * Represents device rotation in babylon space.
  17868. */
  17869. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17870. /**
  17871. * The scale of the device to be used when translating from device space to babylon space.
  17872. */
  17873. _this.deviceScaleFactor = 1;
  17874. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17875. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17876. /**
  17877. * References to the webVR controllers for the vrDevice.
  17878. */
  17879. _this.controllers = [];
  17880. /**
  17881. * Emits an event when a controller is attached.
  17882. */
  17883. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17884. /**
  17885. * Emits an event when a controller's mesh has been loaded;
  17886. */
  17887. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17888. /**
  17889. * Emits an event when the HMD's pose has been updated.
  17890. */
  17891. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17892. _this._poseSet = false;
  17893. /**
  17894. * If the rig cameras be used as parent instead of this camera.
  17895. */
  17896. _this.rigParenting = true;
  17897. _this._defaultHeight = undefined;
  17898. _this._htmlElementAttached = null;
  17899. _this._detachIfAttached = function () {
  17900. var vrDisplay = _this.getEngine().getVRDevice();
  17901. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17902. _this.detachControl(_this._htmlElementAttached);
  17903. }
  17904. };
  17905. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17906. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17907. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17908. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17909. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17910. if (webVROptions.defaultHeight) {
  17911. _this._defaultHeight = webVROptions.defaultHeight;
  17912. _this.position.y = _this._defaultHeight;
  17913. }
  17914. _this.minZ = 0.1;
  17915. //legacy support - the compensation boolean was removed.
  17916. if (arguments.length === 5) {
  17917. _this.webVROptions = arguments[4];
  17918. }
  17919. // default webVR options
  17920. if (_this.webVROptions.trackPosition == undefined) {
  17921. _this.webVROptions.trackPosition = true;
  17922. }
  17923. if (_this.webVROptions.controllerMeshes == undefined) {
  17924. _this.webVROptions.controllerMeshes = true;
  17925. }
  17926. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17927. _this.webVROptions.defaultLightingOnControllers = true;
  17928. }
  17929. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17930. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17931. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17932. }
  17933. //enable VR
  17934. var engine = _this.getEngine();
  17935. _this._onVREnabled = function (success) { if (success) {
  17936. _this.initControllers();
  17937. } };
  17938. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17939. engine.initWebVR().add(function (event) {
  17940. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17941. return;
  17942. }
  17943. _this._vrDevice = event.vrDisplay;
  17944. //reset the rig parameters.
  17945. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17946. if (_this._attached) {
  17947. _this.getEngine().enableVR();
  17948. }
  17949. });
  17950. if (typeof (VRFrameData) !== "undefined") {
  17951. _this._frameData = new VRFrameData();
  17952. }
  17953. /**
  17954. * The idea behind the following lines:
  17955. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17956. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17957. * the second will not show it correctly.
  17958. *
  17959. * To solve this - each object that has the camera as parent will be added to a protected array.
  17960. * When the rig camera renders, it will take this array and set all of those to be its children.
  17961. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17962. * Amazing!
  17963. */
  17964. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17965. if (camera.parent === _this && _this.rigParenting) {
  17966. _this._descendants = _this.getDescendants(true, function (n) {
  17967. // don't take the cameras or the controllers!
  17968. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17969. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17970. return !isController && !isRigCamera;
  17971. });
  17972. _this._descendants.forEach(function (node) {
  17973. node.parent = camera;
  17974. });
  17975. }
  17976. });
  17977. scene.onAfterCameraRenderObservable.add(function (camera) {
  17978. if (camera.parent === _this && _this.rigParenting) {
  17979. _this._descendants.forEach(function (node) {
  17980. node.parent = _this;
  17981. });
  17982. }
  17983. });
  17984. return _this;
  17985. }
  17986. /**
  17987. * Gets the device distance from the ground in meters.
  17988. * @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.
  17989. */
  17990. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17991. if (this._standingMatrix) {
  17992. // Add standing matrix offset to get real offset from ground in room
  17993. this._standingMatrix.getTranslationToRef(this._workingVector);
  17994. return this._deviceRoomPosition.y + this._workingVector.y;
  17995. }
  17996. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17997. return this._defaultHeight || 0;
  17998. };
  17999. /**
  18000. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18001. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18002. */
  18003. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  18004. var _this = this;
  18005. if (callback === void 0) { callback = function (bool) { }; }
  18006. // Use standing matrix if available
  18007. this.getEngine().initWebVRAsync().then(function (result) {
  18008. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  18009. callback(false);
  18010. }
  18011. else {
  18012. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18013. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  18014. if (!_this.getScene().useRightHandedSystem) {
  18015. if (_this._standingMatrix) {
  18016. _this._standingMatrix.toggleModelMatrixHandInPlace();
  18017. }
  18018. }
  18019. callback(true);
  18020. }
  18021. });
  18022. };
  18023. /**
  18024. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18025. * @returns A promise with a boolean set to if the standing matrix is supported.
  18026. */
  18027. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18028. var _this = this;
  18029. return new Promise(function (res) {
  18030. _this.useStandingMatrix(function (supported) {
  18031. res(supported);
  18032. });
  18033. });
  18034. };
  18035. /**
  18036. * Disposes the camera
  18037. */
  18038. WebVRFreeCamera.prototype.dispose = function () {
  18039. this._detachIfAttached();
  18040. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18041. if (this._updateCacheWhenTrackingDisabledObserver) {
  18042. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18043. }
  18044. _super.prototype.dispose.call(this);
  18045. };
  18046. /**
  18047. * Gets a vrController by name.
  18048. * @param name The name of the controller to retreive
  18049. * @returns the controller matching the name specified or null if not found
  18050. */
  18051. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18052. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18053. var gp = _a[_i];
  18054. if (gp.hand === name) {
  18055. return gp;
  18056. }
  18057. }
  18058. return null;
  18059. };
  18060. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18061. /**
  18062. * The controller corrisponding to the users left hand.
  18063. */
  18064. get: function () {
  18065. if (!this._leftController) {
  18066. this._leftController = this.getControllerByName("left");
  18067. }
  18068. return this._leftController;
  18069. },
  18070. enumerable: true,
  18071. configurable: true
  18072. });
  18073. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18074. /**
  18075. * The controller corrisponding to the users right hand.
  18076. */
  18077. get: function () {
  18078. if (!this._rightController) {
  18079. this._rightController = this.getControllerByName("right");
  18080. }
  18081. return this._rightController;
  18082. },
  18083. enumerable: true,
  18084. configurable: true
  18085. });
  18086. /**
  18087. * Casts a ray forward from the vrCamera's gaze.
  18088. * @param length Length of the ray (default: 100)
  18089. * @returns the ray corrisponding to the gaze
  18090. */
  18091. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18092. if (length === void 0) { length = 100; }
  18093. if (this.leftCamera) {
  18094. // Use left eye to avoid computation to compute center on every call
  18095. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18096. }
  18097. else {
  18098. return _super.prototype.getForwardRay.call(this, length);
  18099. }
  18100. };
  18101. /**
  18102. * @hidden
  18103. * Updates the camera based on device's frame data
  18104. */
  18105. WebVRFreeCamera.prototype._checkInputs = function () {
  18106. if (this._vrDevice && this._vrDevice.isPresenting) {
  18107. this._vrDevice.getFrameData(this._frameData);
  18108. this.updateFromDevice(this._frameData.pose);
  18109. }
  18110. _super.prototype._checkInputs.call(this);
  18111. };
  18112. /**
  18113. * Updates the poseControlled values based on the input device pose.
  18114. * @param poseData Pose coming from the device
  18115. */
  18116. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18117. if (poseData && poseData.orientation) {
  18118. this.rawPose = poseData;
  18119. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18120. if (this.getScene().useRightHandedSystem) {
  18121. this._deviceRoomRotationQuaternion.z *= -1;
  18122. this._deviceRoomRotationQuaternion.w *= -1;
  18123. }
  18124. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18125. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18126. if (this.getScene().useRightHandedSystem) {
  18127. this._deviceRoomPosition.z *= -1;
  18128. }
  18129. }
  18130. this._poseSet = true;
  18131. }
  18132. };
  18133. /**
  18134. * WebVR's attach control will start broadcasting frames to the device.
  18135. * Note that in certain browsers (chrome for example) this function must be called
  18136. * within a user-interaction callback. Example:
  18137. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18138. *
  18139. * @param element html element to attach the vrDevice to
  18140. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18141. */
  18142. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18143. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18144. this._attached = true;
  18145. this._htmlElementAttached = element;
  18146. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18147. if (this._vrDevice) {
  18148. this.getEngine().enableVR();
  18149. }
  18150. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18151. };
  18152. /**
  18153. * Detaches the camera from the html element and disables VR
  18154. *
  18155. * @param element html element to detach from
  18156. */
  18157. WebVRFreeCamera.prototype.detachControl = function (element) {
  18158. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18159. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18160. _super.prototype.detachControl.call(this, element);
  18161. this._attached = false;
  18162. this.getEngine().disableVR();
  18163. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18164. };
  18165. /**
  18166. * @returns the name of this class
  18167. */
  18168. WebVRFreeCamera.prototype.getClassName = function () {
  18169. return "WebVRFreeCamera";
  18170. };
  18171. /**
  18172. * Calls resetPose on the vrDisplay
  18173. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18174. */
  18175. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18176. //uses the vrDisplay's "resetPose()".
  18177. //pitch and roll won't be affected.
  18178. this._vrDevice.resetPose();
  18179. };
  18180. /**
  18181. * @hidden
  18182. * Updates the rig cameras (left and right eye)
  18183. */
  18184. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18185. var camLeft = this._rigCameras[0];
  18186. var camRight = this._rigCameras[1];
  18187. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18188. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18189. camLeft.position.copyFrom(this._deviceRoomPosition);
  18190. camRight.position.copyFrom(this._deviceRoomPosition);
  18191. };
  18192. // Remove translation from 6dof headset if trackposition is set to false
  18193. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18194. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18195. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18196. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18197. if (!isViewMatrix) {
  18198. this._tmpMatrix.invert();
  18199. }
  18200. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18201. }
  18202. };
  18203. /**
  18204. * @hidden
  18205. * Updates the cached values of the camera
  18206. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18207. */
  18208. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18209. var _this = this;
  18210. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18211. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18212. if (!this.updateCacheCalled) {
  18213. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18214. this.updateCacheCalled = true;
  18215. this.update();
  18216. }
  18217. // Set working vector to the device position in room space rotated by the new rotation
  18218. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18219. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18220. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18221. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18222. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18223. // Add translation from anchor position
  18224. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18225. this._workingVector.addInPlace(this.position);
  18226. this._workingVector.subtractInPlace(this._cache.position);
  18227. this._deviceToWorld.setTranslation(this._workingVector);
  18228. // Set an inverted matrix to be used when updating the camera
  18229. this._deviceToWorld.invertToRef(this._worldToDevice);
  18230. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18231. this.controllers.forEach(function (controller) {
  18232. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18233. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18234. controller.update();
  18235. });
  18236. }
  18237. if (!ignoreParentClass) {
  18238. _super.prototype._updateCache.call(this);
  18239. }
  18240. this.updateCacheCalled = false;
  18241. };
  18242. /**
  18243. * @hidden
  18244. * Get current device position in babylon world
  18245. */
  18246. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18247. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18248. };
  18249. /**
  18250. * Updates the current device position and rotation in the babylon world
  18251. */
  18252. WebVRFreeCamera.prototype.update = function () {
  18253. this._computeDevicePosition();
  18254. // Get current device rotation in babylon world
  18255. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18256. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18257. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18258. if (this._poseSet) {
  18259. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18260. }
  18261. _super.prototype.update.call(this);
  18262. };
  18263. /**
  18264. * @hidden
  18265. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18266. * @returns an identity matrix
  18267. */
  18268. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18269. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18270. };
  18271. /**
  18272. * This function is called by the two RIG cameras.
  18273. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18274. * @hidden
  18275. */
  18276. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18277. // Update the parent camera prior to using a child camera to avoid desynchronization
  18278. var parentCamera = this._cameraRigParams["parentCamera"];
  18279. parentCamera._updateCache();
  18280. //WebVR 1.1
  18281. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18282. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18283. if (!this.getScene().useRightHandedSystem) {
  18284. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18285. }
  18286. // update the camera rotation matrix
  18287. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18288. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18289. // Computing target and final matrix
  18290. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18291. // should the view matrix be updated with scale and position offset?
  18292. if (parentCamera.deviceScaleFactor !== 1) {
  18293. this._webvrViewMatrix.invert();
  18294. // scale the position, if set
  18295. if (parentCamera.deviceScaleFactor) {
  18296. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18297. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18298. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18299. }
  18300. this._webvrViewMatrix.invert();
  18301. }
  18302. // Remove translation from 6dof headset if trackposition is set to false
  18303. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18304. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18305. // Compute global position
  18306. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18307. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18308. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18309. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18310. this._markSyncedWithParent();
  18311. return this._webvrViewMatrix;
  18312. };
  18313. /** @hidden */
  18314. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18315. var parentCamera = this.parent;
  18316. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18317. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18318. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18319. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18320. //babylon compatible matrix
  18321. if (!this.getScene().useRightHandedSystem) {
  18322. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18323. }
  18324. return this._projectionMatrix;
  18325. };
  18326. /**
  18327. * Initializes the controllers and their meshes
  18328. */
  18329. WebVRFreeCamera.prototype.initControllers = function () {
  18330. var _this = this;
  18331. this.controllers = [];
  18332. var manager = this.getScene().gamepadManager;
  18333. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18334. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18335. var webVrController = gamepad;
  18336. if (webVrController.defaultModel) {
  18337. webVrController.defaultModel.setEnabled(false);
  18338. }
  18339. if (webVrController.hand === "right") {
  18340. _this._rightController = null;
  18341. }
  18342. if (webVrController.hand === "left") {
  18343. _this._leftController = null;
  18344. }
  18345. var controllerIndex = _this.controllers.indexOf(webVrController);
  18346. if (controllerIndex !== -1) {
  18347. _this.controllers.splice(controllerIndex, 1);
  18348. }
  18349. }
  18350. });
  18351. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18352. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18353. var webVrController_1 = gamepad;
  18354. if (!_this.webVROptions.trackPosition) {
  18355. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18356. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18357. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18358. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18359. _this._updateCache();
  18360. });
  18361. }
  18362. }
  18363. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18364. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18365. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18366. if (_this.webVROptions.controllerMeshes) {
  18367. if (webVrController_1.defaultModel) {
  18368. webVrController_1.defaultModel.setEnabled(true);
  18369. }
  18370. else {
  18371. // Load the meshes
  18372. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18373. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18374. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18375. if (_this.webVROptions.defaultLightingOnControllers) {
  18376. if (!_this._lightOnControllers) {
  18377. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18378. }
  18379. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18380. var children = mesh.getChildren();
  18381. if (children && children.length !== 0) {
  18382. children.forEach(function (mesh) {
  18383. light.includedOnlyMeshes.push(mesh);
  18384. activateLightOnSubMeshes_1(mesh, light);
  18385. });
  18386. }
  18387. };
  18388. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18389. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18390. }
  18391. });
  18392. }
  18393. }
  18394. webVrController_1.attachToPoseControlledCamera(_this);
  18395. // since this is async - sanity check. Is the controller already stored?
  18396. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18397. //add to the controllers array
  18398. _this.controllers.push(webVrController_1);
  18399. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18400. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18401. // So we're overriding setting left & right manually to be sure
  18402. var firstViveWandDetected = false;
  18403. for (var i = 0; i < _this.controllers.length; i++) {
  18404. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18405. if (!firstViveWandDetected) {
  18406. firstViveWandDetected = true;
  18407. _this.controllers[i].hand = "left";
  18408. }
  18409. else {
  18410. _this.controllers[i].hand = "right";
  18411. }
  18412. }
  18413. }
  18414. //did we find enough controllers? Great! let the developer know.
  18415. if (_this.controllers.length >= 2) {
  18416. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18417. }
  18418. }
  18419. }
  18420. });
  18421. };
  18422. return WebVRFreeCamera;
  18423. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18424. /***/ }),
  18425. /***/ "./Cameras/XR/index.ts":
  18426. /*!*****************************!*\
  18427. !*** ./Cameras/XR/index.ts ***!
  18428. \*****************************/
  18429. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18431. "use strict";
  18432. __webpack_require__.r(__webpack_exports__);
  18433. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18435. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18439. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18442. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18445. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18447. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18449. /***/ }),
  18450. /***/ "./Cameras/XR/webXRCamera.ts":
  18451. /*!***********************************!*\
  18452. !*** ./Cameras/XR/webXRCamera.ts ***!
  18453. \***********************************/
  18454. /*! exports provided: WebXRCamera */
  18455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18456. "use strict";
  18457. __webpack_require__.r(__webpack_exports__);
  18458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18459. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18460. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18461. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18462. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18463. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18464. /**
  18465. * WebXR Camera which holds the views for the xrSession
  18466. * @see https://doc.babylonjs.com/how_to/webxr
  18467. */
  18468. var WebXRCamera = /** @class */ (function (_super) {
  18469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18470. /**
  18471. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18472. * @param name the name of the camera
  18473. * @param scene the scene to add the camera to
  18474. */
  18475. function WebXRCamera(name, scene) {
  18476. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18477. // Initial camera configuration
  18478. _this.minZ = 0;
  18479. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18480. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18481. _this.updateUpVectorFromRotation = true;
  18482. _this._updateNumberOfRigCameras(1);
  18483. return _this;
  18484. }
  18485. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18486. if (viewCount === void 0) { viewCount = 1; }
  18487. while (this.rigCameras.length < viewCount) {
  18488. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18489. newCamera.minZ = 0;
  18490. newCamera.parent = this;
  18491. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18492. newCamera.updateUpVectorFromRotation = true;
  18493. this.rigCameras.push(newCamera);
  18494. }
  18495. while (this.rigCameras.length > viewCount) {
  18496. var removedCamera = this.rigCameras.pop();
  18497. if (removedCamera) {
  18498. removedCamera.dispose();
  18499. }
  18500. }
  18501. };
  18502. /** @hidden */
  18503. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18504. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18505. // Create initial camera rigs
  18506. this._updateNumberOfRigCameras(2);
  18507. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18508. this.rigCameras[0].position.x = -pupilDistance / 2;
  18509. this.rigCameras[0].outputRenderTarget = null;
  18510. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18511. this.rigCameras[1].position.x = pupilDistance / 2;
  18512. this.rigCameras[1].outputRenderTarget = null;
  18513. };
  18514. /**
  18515. * Updates the cameras position from the current pose information of the XR session
  18516. * @param xrSessionManager the session containing pose information
  18517. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18518. */
  18519. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18520. var _this = this;
  18521. // Ensure all frame data is available
  18522. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18523. return false;
  18524. }
  18525. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18526. if (!pose || !pose.poseModelMatrix) {
  18527. return false;
  18528. }
  18529. // Update the parent cameras matrix
  18530. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18531. if (!this._scene.useRightHandedSystem) {
  18532. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18533. }
  18534. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18535. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18536. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18537. this.computeWorldMatrix();
  18538. // Update camera rigs
  18539. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18540. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18541. // Update view/projection matrix
  18542. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18543. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18544. if (!_this._scene.useRightHandedSystem) {
  18545. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18546. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18547. }
  18548. // Update viewport
  18549. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18550. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18551. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18552. _this.rigCameras[i].viewport.width = viewport.width / width;
  18553. _this.rigCameras[i].viewport.height = viewport.height / height;
  18554. _this.rigCameras[i].viewport.x = viewport.x / width;
  18555. _this.rigCameras[i].viewport.y = viewport.y / height;
  18556. // Set cameras to render to the session's render target
  18557. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18558. });
  18559. return true;
  18560. };
  18561. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18562. return WebXRCamera;
  18563. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18564. /***/ }),
  18565. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18566. /*!****************************************!*\
  18567. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18568. \****************************************/
  18569. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18571. "use strict";
  18572. __webpack_require__.r(__webpack_exports__);
  18573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18576. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18577. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18578. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18579. /**
  18580. * Button which can be used to enter a different mode of XR
  18581. */
  18582. var WebXREnterExitUIButton = /** @class */ (function () {
  18583. /**
  18584. * Creates a WebXREnterExitUIButton
  18585. * @param element button element
  18586. * @param initializationOptions XR initialization options for the button
  18587. */
  18588. function WebXREnterExitUIButton(
  18589. /** button element */
  18590. element,
  18591. /** XR initialization options for the button */
  18592. initializationOptions) {
  18593. this.element = element;
  18594. this.initializationOptions = initializationOptions;
  18595. }
  18596. /**
  18597. * Overwritable function which can be used to update the button's visuals when the state changes
  18598. * @param activeButton the current active button in the UI
  18599. */
  18600. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18601. };
  18602. return WebXREnterExitUIButton;
  18603. }());
  18604. /**
  18605. * Options to create the webXR UI
  18606. */
  18607. var WebXREnterExitUIOptions = /** @class */ (function () {
  18608. function WebXREnterExitUIOptions() {
  18609. }
  18610. return WebXREnterExitUIOptions;
  18611. }());
  18612. /**
  18613. * UI to allow the user to enter/exit XR mode
  18614. */
  18615. var WebXREnterExitUI = /** @class */ (function () {
  18616. function WebXREnterExitUI(scene, options) {
  18617. var _this = this;
  18618. this.scene = scene;
  18619. this._buttons = [];
  18620. this._activeButton = null;
  18621. /**
  18622. * Fired every time the active button is changed.
  18623. *
  18624. * When xr is entered via a button that launches xr that button will be the callback parameter
  18625. *
  18626. * When exiting xr the callback parameter will be null)
  18627. */
  18628. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18629. this._overlay = document.createElement("div");
  18630. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18631. if (options.customButtons) {
  18632. this._buttons = options.customButtons;
  18633. }
  18634. else {
  18635. var hmdBtn = document.createElement("button");
  18636. 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;";
  18637. hmdBtn.innerText = "HMD";
  18638. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18639. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18640. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18641. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18642. };
  18643. var windowBtn = document.createElement("button");
  18644. windowBtn.style.cssText = hmdBtn.style.cssText;
  18645. windowBtn.innerText = "Window";
  18646. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18647. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18648. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18649. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18650. };
  18651. this._updateButtons(null);
  18652. }
  18653. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18654. if (renderCanvas && renderCanvas.parentNode) {
  18655. renderCanvas.parentNode.appendChild(this._overlay);
  18656. scene.onDisposeObservable.addOnce(function () {
  18657. _this.dispose();
  18658. });
  18659. }
  18660. }
  18661. /**
  18662. * Creates UI to allow the user to enter/exit XR mode
  18663. * @param scene the scene to add the ui to
  18664. * @param helper the xr experience helper to enter/exit xr with
  18665. * @param options options to configure the UI
  18666. * @returns the created ui
  18667. */
  18668. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18669. var _this = this;
  18670. var ui = new WebXREnterExitUI(scene, options);
  18671. var supportedPromises = ui._buttons.map(function (btn) {
  18672. return helper.supportsSessionAsync(btn.initializationOptions);
  18673. });
  18674. helper.onStateChangedObservable.add(function (state) {
  18675. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18676. ui._updateButtons(null);
  18677. }
  18678. });
  18679. return Promise.all(supportedPromises).then(function (results) {
  18680. results.forEach(function (supported, i) {
  18681. if (supported) {
  18682. ui._overlay.appendChild(ui._buttons[i].element);
  18683. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18684. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18685. switch (_a.label) {
  18686. case 0:
  18687. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18688. ui._updateButtons(null);
  18689. return [4 /*yield*/, helper.exitXRAsync()];
  18690. case 1:
  18691. _a.sent();
  18692. return [2 /*return*/];
  18693. case 2:
  18694. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18695. ui._updateButtons(ui._buttons[i]);
  18696. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18697. case 3:
  18698. _a.sent();
  18699. _a.label = 4;
  18700. case 4: return [2 /*return*/];
  18701. }
  18702. });
  18703. }); };
  18704. }
  18705. });
  18706. return ui;
  18707. });
  18708. };
  18709. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18710. var _this = this;
  18711. this._activeButton = activeButton;
  18712. this._buttons.forEach(function (b) {
  18713. b.update(_this._activeButton);
  18714. });
  18715. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18716. };
  18717. /**
  18718. * Disposes of the object
  18719. */
  18720. WebXREnterExitUI.prototype.dispose = function () {
  18721. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18722. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18723. renderCanvas.parentNode.removeChild(this._overlay);
  18724. }
  18725. this.activeButtonChangedObservable.clear();
  18726. };
  18727. return WebXREnterExitUI;
  18728. }());
  18729. /***/ }),
  18730. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18731. /*!*********************************************!*\
  18732. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18733. \*********************************************/
  18734. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18736. "use strict";
  18737. __webpack_require__.r(__webpack_exports__);
  18738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18740. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18741. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18742. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18743. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18744. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18745. /**
  18746. * States of the webXR experience
  18747. */
  18748. var WebXRState;
  18749. (function (WebXRState) {
  18750. /**
  18751. * Transitioning to being in XR mode
  18752. */
  18753. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18754. /**
  18755. * Transitioning to non XR mode
  18756. */
  18757. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18758. /**
  18759. * In XR mode and presenting
  18760. */
  18761. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18762. /**
  18763. * Not entered XR mode
  18764. */
  18765. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18766. })(WebXRState || (WebXRState = {}));
  18767. /**
  18768. * Helper class used to enable XR
  18769. * @see https://doc.babylonjs.com/how_to/webxr
  18770. */
  18771. var WebXRExperienceHelper = /** @class */ (function () {
  18772. /**
  18773. * Creates a WebXRExperienceHelper
  18774. * @param scene The scene the helper should be created in
  18775. */
  18776. function WebXRExperienceHelper(scene) {
  18777. this.scene = scene;
  18778. /**
  18779. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18780. */
  18781. this.state = WebXRState.NOT_IN_XR;
  18782. /**
  18783. * Fires when the state of the experience helper has changed
  18784. */
  18785. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18786. this._nonVRCamera = null;
  18787. this._originalSceneAutoClear = true;
  18788. this._supported = false;
  18789. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18790. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18791. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18792. this.camera.parent = this.container;
  18793. }
  18794. WebXRExperienceHelper.prototype._setState = function (val) {
  18795. this.state = val;
  18796. this.onStateChangedObservable.notifyObservers(this.state);
  18797. };
  18798. /**
  18799. * Creates the experience helper
  18800. * @param scene the scene to attach the experience helper to
  18801. * @returns a promise for the experience helper
  18802. */
  18803. WebXRExperienceHelper.CreateAsync = function (scene) {
  18804. var helper = new WebXRExperienceHelper(scene);
  18805. return helper._sessionManager.initializeAsync().then(function () {
  18806. helper._supported = true;
  18807. return helper;
  18808. }).catch(function () {
  18809. return helper;
  18810. });
  18811. };
  18812. /**
  18813. * Exits XR mode and returns the scene to its original state
  18814. * @returns promise that resolves after xr mode has exited
  18815. */
  18816. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18817. this._setState(WebXRState.EXITING_XR);
  18818. return this._sessionManager.exitXRAsync();
  18819. };
  18820. /**
  18821. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18822. * @param sessionCreationOptions options for the XR session
  18823. * @param frameOfReference frame of reference of the XR session
  18824. * @returns promise that resolves after xr mode has entered
  18825. */
  18826. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18827. var _this = this;
  18828. if (!this._supported) {
  18829. throw "XR session not supported by this browser";
  18830. }
  18831. this._setState(WebXRState.ENTERING_XR);
  18832. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18833. // Cache pre xr scene settings
  18834. _this._originalSceneAutoClear = _this.scene.autoClear;
  18835. _this._nonVRCamera = _this.scene.activeCamera;
  18836. // Overwrite current scene settings
  18837. _this.scene.autoClear = false;
  18838. _this.scene.activeCamera = _this.camera;
  18839. _this._sessionManager.onXRFrameObservable.add(function () {
  18840. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18841. });
  18842. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18843. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18844. _this.camera.rigCameras.forEach(function (c) {
  18845. c.outputRenderTarget = null;
  18846. });
  18847. // Restore scene settings
  18848. _this.scene.autoClear = _this._originalSceneAutoClear;
  18849. _this.scene.activeCamera = _this._nonVRCamera;
  18850. _this._sessionManager.onXRFrameObservable.clear();
  18851. _this._setState(WebXRState.NOT_IN_XR);
  18852. });
  18853. _this._setState(WebXRState.IN_XR);
  18854. });
  18855. };
  18856. /**
  18857. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18858. * @param ray ray to cast into the environment
  18859. * @returns Promise which resolves with a collision point in the environment if it exists
  18860. */
  18861. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18862. return this._sessionManager.environmentPointHitTestAsync(ray);
  18863. };
  18864. /**
  18865. * Updates the global position of the camera by moving the camera's container
  18866. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18867. * @param position The desired global position of the camera
  18868. */
  18869. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18870. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18871. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18872. };
  18873. /**
  18874. * Rotates the xr camera by rotating the camera's container around the camera's position
  18875. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18876. * @param rotation the desired quaternion rotation to apply to the camera
  18877. */
  18878. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18879. if (!this.container.rotationQuaternion) {
  18880. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18881. }
  18882. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18883. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18884. };
  18885. /**
  18886. * Checks if the creation options are supported by the xr session
  18887. * @param options creation options
  18888. * @returns true if supported
  18889. */
  18890. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18891. if (!this._supported) {
  18892. return Promise.resolve(false);
  18893. }
  18894. return this._sessionManager.supportsSessionAsync(options);
  18895. };
  18896. /**
  18897. * Disposes of the experience helper
  18898. */
  18899. WebXRExperienceHelper.prototype.dispose = function () {
  18900. this.camera.dispose();
  18901. this.container.dispose();
  18902. this.onStateChangedObservable.clear();
  18903. this._sessionManager.dispose();
  18904. };
  18905. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18906. return WebXRExperienceHelper;
  18907. }());
  18908. /***/ }),
  18909. /***/ "./Cameras/XR/webXRInput.ts":
  18910. /*!**********************************!*\
  18911. !*** ./Cameras/XR/webXRInput.ts ***!
  18912. \**********************************/
  18913. /*! exports provided: WebXRController, WebXRInput */
  18914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18915. "use strict";
  18916. __webpack_require__.r(__webpack_exports__);
  18917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18919. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18920. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18921. /**
  18922. * Represents an XR input
  18923. */
  18924. var WebXRController = /** @class */ (function () {
  18925. /**
  18926. * Creates the controller
  18927. * @see https://doc.babylonjs.com/how_to/webxr
  18928. * @param scene the scene which the controller should be associated to
  18929. */
  18930. function WebXRController(scene) {
  18931. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18932. }
  18933. /**
  18934. * Disposes of the object
  18935. */
  18936. WebXRController.prototype.dispose = function () {
  18937. if (this.grip) {
  18938. this.grip.dispose();
  18939. }
  18940. this.pointer.dispose();
  18941. };
  18942. return WebXRController;
  18943. }());
  18944. /**
  18945. * XR input used to track XR inputs such as controllers/rays
  18946. */
  18947. var WebXRInput = /** @class */ (function () {
  18948. /**
  18949. * Initializes the WebXRInput
  18950. * @param helper experience helper which the input should be created for
  18951. */
  18952. function WebXRInput(helper) {
  18953. var _this = this;
  18954. this.helper = helper;
  18955. /**
  18956. * XR controllers being tracked
  18957. */
  18958. this.controllers = [];
  18959. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18960. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18961. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18962. return;
  18963. }
  18964. var xrFrame = helper._sessionManager._currentXRFrame;
  18965. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18966. inputSources.forEach(function (input, i) {
  18967. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18968. if (inputPose) {
  18969. if (_this.controllers.length <= i) {
  18970. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18971. }
  18972. var controller = _this.controllers[i];
  18973. // Manage the grip if it exists
  18974. if (inputPose.gripMatrix) {
  18975. if (!controller.grip) {
  18976. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18977. }
  18978. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18979. if (!controller.grip.getScene().useRightHandedSystem) {
  18980. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18981. }
  18982. if (!controller.grip.rotationQuaternion) {
  18983. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18984. }
  18985. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18986. }
  18987. // Manager pointer of controller
  18988. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18989. if (!controller.pointer.getScene().useRightHandedSystem) {
  18990. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18991. }
  18992. if (!controller.pointer.rotationQuaternion) {
  18993. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18994. }
  18995. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18996. }
  18997. });
  18998. });
  18999. }
  19000. /**
  19001. * Disposes of the object
  19002. */
  19003. WebXRInput.prototype.dispose = function () {
  19004. this.controllers.forEach(function (c) {
  19005. c.dispose();
  19006. });
  19007. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  19008. };
  19009. return WebXRInput;
  19010. }());
  19011. /***/ }),
  19012. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  19013. /*!************************************************!*\
  19014. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  19015. \************************************************/
  19016. /*! exports provided: WebXRManagedOutputCanvas */
  19017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19018. "use strict";
  19019. __webpack_require__.r(__webpack_exports__);
  19020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  19021. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19022. /**
  19023. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  19024. */
  19025. var WebXRManagedOutputCanvas = /** @class */ (function () {
  19026. /**
  19027. * Initializes the canvas to be added/removed upon entering/exiting xr
  19028. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19029. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19030. */
  19031. function WebXRManagedOutputCanvas(helper, canvas) {
  19032. var _this = this;
  19033. this._canvas = null;
  19034. /**
  19035. * xrpresent context of the canvas which can be used to display/mirror xr content
  19036. */
  19037. this.canvasContext = null;
  19038. if (!canvas) {
  19039. canvas = document.createElement('canvas');
  19040. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19041. }
  19042. this._setManagedOutputCanvas(canvas);
  19043. helper.onStateChangedObservable.add(function (stateInfo) {
  19044. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19045. // 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
  19046. _this._addCanvas();
  19047. }
  19048. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19049. _this._removeCanvas();
  19050. }
  19051. });
  19052. }
  19053. /**
  19054. * Disposes of the object
  19055. */
  19056. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19057. this._removeCanvas();
  19058. this._setManagedOutputCanvas(null);
  19059. };
  19060. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19061. this._removeCanvas();
  19062. if (!canvas) {
  19063. this._canvas = null;
  19064. this.canvasContext = null;
  19065. }
  19066. else {
  19067. this._canvas = canvas;
  19068. this.canvasContext = this._canvas.getContext('xrpresent');
  19069. }
  19070. };
  19071. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19072. if (this._canvas) {
  19073. document.body.appendChild(this._canvas);
  19074. }
  19075. };
  19076. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19077. if (this._canvas && document.body.contains(this._canvas)) {
  19078. document.body.removeChild(this._canvas);
  19079. }
  19080. };
  19081. return WebXRManagedOutputCanvas;
  19082. }());
  19083. /***/ }),
  19084. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19085. /*!*******************************************!*\
  19086. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19087. \*******************************************/
  19088. /*! exports provided: WebXRSessionManager */
  19089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19090. "use strict";
  19091. __webpack_require__.r(__webpack_exports__);
  19092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19093. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19094. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19095. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19096. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19097. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19098. /**
  19099. * Manages an XRSession
  19100. * @see https://doc.babylonjs.com/how_to/webxr
  19101. */
  19102. var WebXRSessionManager = /** @class */ (function () {
  19103. /**
  19104. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19105. * @param scene The scene which the session should be created for
  19106. */
  19107. function WebXRSessionManager(scene) {
  19108. this.scene = scene;
  19109. /**
  19110. * Fires every time a new xrFrame arrives which can be used to update the camera
  19111. */
  19112. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19113. /**
  19114. * Fires when the xr session is ended either by the device or manually done
  19115. */
  19116. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19117. /** @hidden */
  19118. this._sessionRenderTargetTexture = null;
  19119. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19120. }
  19121. /**
  19122. * Initializes the manager
  19123. * After initialization enterXR can be called to start an XR session
  19124. * @returns Promise which resolves after it is initialized
  19125. */
  19126. WebXRSessionManager.prototype.initializeAsync = function () {
  19127. var _this = this;
  19128. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19129. // Check if the browser supports webXR
  19130. this._xrNavigator = navigator;
  19131. if (!this._xrNavigator.xr) {
  19132. return Promise.reject("webXR not supported by this browser");
  19133. }
  19134. // Request the webXR device
  19135. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19136. _this._xrDevice = device;
  19137. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19138. });
  19139. };
  19140. /**
  19141. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19142. * @param sessionCreationOptions xr options to create the session with
  19143. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19144. * @returns Promise which resolves after it enters XR
  19145. */
  19146. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19147. var _this = this;
  19148. // initialize session
  19149. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19150. _this._xrSession = session;
  19151. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19152. _this._xrSession.addEventListener("end", function () {
  19153. // Remove render target texture and notify frame obervers
  19154. _this._sessionRenderTargetTexture = null;
  19155. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19156. _this.scene.getEngine().restoreDefaultFramebuffer();
  19157. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19158. _this.scene.getEngine().customAnimationFrameRequester = null;
  19159. _this.onXRSessionEnded.notifyObservers(null);
  19160. _this.scene.getEngine()._renderLoop();
  19161. }, { once: true });
  19162. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19163. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19164. }).then(function (frameOfRef) {
  19165. _this._frameOfReference = frameOfRef;
  19166. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19167. _this.scene.getEngine().customAnimationFrameRequester = {
  19168. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19169. renderFunction: function (timestamp, xrFrame) {
  19170. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19171. _this._currentXRFrame = xrFrame;
  19172. _this.onXRFrameObservable.notifyObservers(null);
  19173. _this.scene.getEngine()._renderLoop();
  19174. }
  19175. };
  19176. // Create render target texture from xr's webgl render target
  19177. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19178. // Stop window's animation frame and trigger sessions animation frame
  19179. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19180. _this.scene.getEngine()._renderLoop();
  19181. });
  19182. };
  19183. /**
  19184. * Stops the xrSession and restores the renderloop
  19185. * @returns Promise which resolves after it exits XR
  19186. */
  19187. WebXRSessionManager.prototype.exitXRAsync = function () {
  19188. return this._xrSession.end();
  19189. };
  19190. /**
  19191. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19192. * @param ray ray to cast into the environment
  19193. * @returns Promise which resolves with a collision point in the environment if it exists
  19194. */
  19195. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19196. var _this = this;
  19197. return new Promise(function (res) {
  19198. // Compute left handed inputs to request hit test
  19199. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19200. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19201. if (!_this.scene.useRightHandedSystem) {
  19202. origin[2] *= -1;
  19203. direction[2] *= -1;
  19204. }
  19205. // Fire hittest
  19206. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19207. .then(function (hits) {
  19208. if (hits.length > 0) {
  19209. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19210. var hitPoint = _this._tmpMatrix.getTranslation();
  19211. if (!_this.scene.useRightHandedSystem) {
  19212. hitPoint.z *= -1;
  19213. }
  19214. res(hitPoint);
  19215. }
  19216. else {
  19217. res(null);
  19218. }
  19219. }).catch(function () {
  19220. res(null);
  19221. });
  19222. });
  19223. };
  19224. /**
  19225. * Checks if a session would be supported for the creation options specified
  19226. * @param options creation options to check if they are supported
  19227. * @returns true if supported
  19228. */
  19229. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19230. return this._xrDevice.supportsSession(options).then(function () {
  19231. return true;
  19232. }).catch(function () {
  19233. return false;
  19234. });
  19235. };
  19236. /**
  19237. * @hidden
  19238. * Converts the render layer of xrSession to a render target
  19239. * @param session session to create render target for
  19240. * @param scene scene the new render target should be created for
  19241. */
  19242. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19243. // Create internal texture
  19244. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19245. internalTexture.width = session.baseLayer.framebufferWidth;
  19246. internalTexture.height = session.baseLayer.framebufferHeight;
  19247. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19248. // Create render target texture from the internal texture
  19249. 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);
  19250. renderTargetTexture._texture = internalTexture;
  19251. return renderTargetTexture;
  19252. };
  19253. /**
  19254. * Disposes of the session manager
  19255. */
  19256. WebXRSessionManager.prototype.dispose = function () {
  19257. this.onXRFrameObservable.clear();
  19258. this.onXRSessionEnded.clear();
  19259. };
  19260. return WebXRSessionManager;
  19261. }());
  19262. /***/ }),
  19263. /***/ "./Cameras/arcRotateCamera.ts":
  19264. /*!************************************!*\
  19265. !*** ./Cameras/arcRotateCamera.ts ***!
  19266. \************************************/
  19267. /*! exports provided: ArcRotateCamera */
  19268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19269. "use strict";
  19270. __webpack_require__.r(__webpack_exports__);
  19271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19272. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19273. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19274. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19275. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19276. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19277. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19278. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19279. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19280. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19281. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19282. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19283. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19284. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19285. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19286. });
  19287. /**
  19288. * This represents an orbital type of camera.
  19289. *
  19290. * 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.
  19291. * 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.
  19292. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19293. */
  19294. var ArcRotateCamera = /** @class */ (function (_super) {
  19295. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19296. /**
  19297. * Instantiates a new ArcRotateCamera in a given scene
  19298. * @param name Defines the name of the camera
  19299. * @param alpha Defines the camera rotation along the logitudinal axis
  19300. * @param beta Defines the camera rotation along the latitudinal axis
  19301. * @param radius Defines the camera distance from its target
  19302. * @param target Defines the camera target
  19303. * @param scene Defines the scene the camera belongs to
  19304. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19305. */
  19306. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19307. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19308. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19309. /**
  19310. * Current inertia value on the longitudinal axis.
  19311. * The bigger this number the longer it will take for the camera to stop.
  19312. */
  19313. _this.inertialAlphaOffset = 0;
  19314. /**
  19315. * Current inertia value on the latitudinal axis.
  19316. * The bigger this number the longer it will take for the camera to stop.
  19317. */
  19318. _this.inertialBetaOffset = 0;
  19319. /**
  19320. * Current inertia value on the radius axis.
  19321. * The bigger this number the longer it will take for the camera to stop.
  19322. */
  19323. _this.inertialRadiusOffset = 0;
  19324. /**
  19325. * Minimum allowed angle on the longitudinal axis.
  19326. * This can help limiting how the Camera is able to move in the scene.
  19327. */
  19328. _this.lowerAlphaLimit = null;
  19329. /**
  19330. * Maximum allowed angle on the longitudinal axis.
  19331. * This can help limiting how the Camera is able to move in the scene.
  19332. */
  19333. _this.upperAlphaLimit = null;
  19334. /**
  19335. * Minimum allowed angle on the latitudinal axis.
  19336. * This can help limiting how the Camera is able to move in the scene.
  19337. */
  19338. _this.lowerBetaLimit = 0.01;
  19339. /**
  19340. * Maximum allowed angle on the latitudinal axis.
  19341. * This can help limiting how the Camera is able to move in the scene.
  19342. */
  19343. _this.upperBetaLimit = Math.PI - 0.01;
  19344. /**
  19345. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19346. * This can help limiting how the Camera is able to move in the scene.
  19347. */
  19348. _this.lowerRadiusLimit = null;
  19349. /**
  19350. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19351. * This can help limiting how the Camera is able to move in the scene.
  19352. */
  19353. _this.upperRadiusLimit = null;
  19354. /**
  19355. * Defines the current inertia value used during panning of the camera along the X axis.
  19356. */
  19357. _this.inertialPanningX = 0;
  19358. /**
  19359. * Defines the current inertia value used during panning of the camera along the Y axis.
  19360. */
  19361. _this.inertialPanningY = 0;
  19362. /**
  19363. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19364. * Basically if your fingers moves away from more than this distance you will be considered
  19365. * in pinch mode.
  19366. */
  19367. _this.pinchToPanMaxDistance = 20;
  19368. /**
  19369. * Defines the maximum distance the camera can pan.
  19370. * This could help keeping the cammera always in your scene.
  19371. */
  19372. _this.panningDistanceLimit = null;
  19373. /**
  19374. * Defines the target of the camera before paning.
  19375. */
  19376. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19377. /**
  19378. * Defines the value of the inertia used during panning.
  19379. * 0 would mean stop inertia and one would mean no decelleration at all.
  19380. */
  19381. _this.panningInertia = 0.9;
  19382. //-- end properties for backward compatibility for inputs
  19383. /**
  19384. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19385. */
  19386. _this.zoomOnFactor = 1;
  19387. /**
  19388. * Defines a screen offset for the camera position.
  19389. */
  19390. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19391. /**
  19392. * Allows the camera to be completely reversed.
  19393. * If false the camera can not arrive upside down.
  19394. */
  19395. _this.allowUpsideDown = true;
  19396. /**
  19397. * Define if double tap/click is used to restore the previously saved state of the camera.
  19398. */
  19399. _this.useInputToRestoreState = true;
  19400. /** @hidden */
  19401. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19402. /**
  19403. * Defines the allowed panning axis.
  19404. */
  19405. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19406. /**
  19407. * Observable triggered when the mesh target has been changed on the camera.
  19408. */
  19409. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19410. /**
  19411. * Defines whether the camera should check collision with the objects oh the scene.
  19412. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19413. */
  19414. _this.checkCollisions = false;
  19415. /**
  19416. * Defines the collision radius of the camera.
  19417. * This simulates a sphere around the camera.
  19418. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19419. */
  19420. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19421. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19422. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19423. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19424. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19425. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19426. if (collidedMesh === void 0) { collidedMesh = null; }
  19427. if (!collidedMesh) {
  19428. _this._previousPosition.copyFrom(_this._position);
  19429. }
  19430. else {
  19431. _this.setPosition(newPosition);
  19432. if (_this.onCollide) {
  19433. _this.onCollide(collidedMesh);
  19434. }
  19435. }
  19436. // Recompute because of constraints
  19437. var cosa = Math.cos(_this.alpha);
  19438. var sina = Math.sin(_this.alpha);
  19439. var cosb = Math.cos(_this.beta);
  19440. var sinb = Math.sin(_this.beta);
  19441. if (sinb === 0) {
  19442. sinb = 0.0001;
  19443. }
  19444. var target = _this._getTargetPosition();
  19445. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19446. target.addToRef(_this._computationVector, _this._newPosition);
  19447. _this._position.copyFrom(_this._newPosition);
  19448. var up = _this.upVector;
  19449. if (_this.allowUpsideDown && _this.beta < 0) {
  19450. up = up.clone();
  19451. up = up.negate();
  19452. }
  19453. _this._computeViewMatrix(_this._position, target, up);
  19454. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19455. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19456. _this._collisionTriggered = false;
  19457. };
  19458. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19459. if (target) {
  19460. _this.setTarget(target);
  19461. }
  19462. _this.alpha = alpha;
  19463. _this.beta = beta;
  19464. _this.radius = radius;
  19465. _this.getViewMatrix();
  19466. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19467. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19468. return _this;
  19469. }
  19470. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19471. /**
  19472. * Defines the target point of the camera.
  19473. * The camera looks towards it form the radius distance.
  19474. */
  19475. get: function () {
  19476. return this._target;
  19477. },
  19478. set: function (value) {
  19479. this.setTarget(value);
  19480. },
  19481. enumerable: true,
  19482. configurable: true
  19483. });
  19484. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19485. /**
  19486. * Define the current local position of the camera in the scene
  19487. */
  19488. get: function () {
  19489. return this._position;
  19490. },
  19491. set: function (newPosition) {
  19492. this.setPosition(newPosition);
  19493. },
  19494. enumerable: true,
  19495. configurable: true
  19496. });
  19497. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19498. //-- begin properties for backward compatibility for inputs
  19499. /**
  19500. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19501. */
  19502. get: function () {
  19503. var pointers = this.inputs.attached["pointers"];
  19504. if (pointers) {
  19505. return pointers.angularSensibilityX;
  19506. }
  19507. return 0;
  19508. },
  19509. set: function (value) {
  19510. var pointers = this.inputs.attached["pointers"];
  19511. if (pointers) {
  19512. pointers.angularSensibilityX = value;
  19513. }
  19514. },
  19515. enumerable: true,
  19516. configurable: true
  19517. });
  19518. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19519. /**
  19520. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19521. */
  19522. get: function () {
  19523. var pointers = this.inputs.attached["pointers"];
  19524. if (pointers) {
  19525. return pointers.angularSensibilityY;
  19526. }
  19527. return 0;
  19528. },
  19529. set: function (value) {
  19530. var pointers = this.inputs.attached["pointers"];
  19531. if (pointers) {
  19532. pointers.angularSensibilityY = value;
  19533. }
  19534. },
  19535. enumerable: true,
  19536. configurable: true
  19537. });
  19538. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19539. /**
  19540. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19541. */
  19542. get: function () {
  19543. var pointers = this.inputs.attached["pointers"];
  19544. if (pointers) {
  19545. return pointers.pinchPrecision;
  19546. }
  19547. return 0;
  19548. },
  19549. set: function (value) {
  19550. var pointers = this.inputs.attached["pointers"];
  19551. if (pointers) {
  19552. pointers.pinchPrecision = value;
  19553. }
  19554. },
  19555. enumerable: true,
  19556. configurable: true
  19557. });
  19558. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19559. /**
  19560. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19561. * It will be used instead of pinchDeltaPrecision if different from 0.
  19562. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19563. */
  19564. get: function () {
  19565. var pointers = this.inputs.attached["pointers"];
  19566. if (pointers) {
  19567. return pointers.pinchDeltaPercentage;
  19568. }
  19569. return 0;
  19570. },
  19571. set: function (value) {
  19572. var pointers = this.inputs.attached["pointers"];
  19573. if (pointers) {
  19574. pointers.pinchDeltaPercentage = value;
  19575. }
  19576. },
  19577. enumerable: true,
  19578. configurable: true
  19579. });
  19580. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19581. /**
  19582. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19583. */
  19584. get: function () {
  19585. var pointers = this.inputs.attached["pointers"];
  19586. if (pointers) {
  19587. return pointers.panningSensibility;
  19588. }
  19589. return 0;
  19590. },
  19591. set: function (value) {
  19592. var pointers = this.inputs.attached["pointers"];
  19593. if (pointers) {
  19594. pointers.panningSensibility = value;
  19595. }
  19596. },
  19597. enumerable: true,
  19598. configurable: true
  19599. });
  19600. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19601. /**
  19602. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19603. */
  19604. get: function () {
  19605. var keyboard = this.inputs.attached["keyboard"];
  19606. if (keyboard) {
  19607. return keyboard.keysUp;
  19608. }
  19609. return [];
  19610. },
  19611. set: function (value) {
  19612. var keyboard = this.inputs.attached["keyboard"];
  19613. if (keyboard) {
  19614. keyboard.keysUp = value;
  19615. }
  19616. },
  19617. enumerable: true,
  19618. configurable: true
  19619. });
  19620. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19621. /**
  19622. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19623. */
  19624. get: function () {
  19625. var keyboard = this.inputs.attached["keyboard"];
  19626. if (keyboard) {
  19627. return keyboard.keysDown;
  19628. }
  19629. return [];
  19630. },
  19631. set: function (value) {
  19632. var keyboard = this.inputs.attached["keyboard"];
  19633. if (keyboard) {
  19634. keyboard.keysDown = value;
  19635. }
  19636. },
  19637. enumerable: true,
  19638. configurable: true
  19639. });
  19640. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19641. /**
  19642. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19643. */
  19644. get: function () {
  19645. var keyboard = this.inputs.attached["keyboard"];
  19646. if (keyboard) {
  19647. return keyboard.keysLeft;
  19648. }
  19649. return [];
  19650. },
  19651. set: function (value) {
  19652. var keyboard = this.inputs.attached["keyboard"];
  19653. if (keyboard) {
  19654. keyboard.keysLeft = value;
  19655. }
  19656. },
  19657. enumerable: true,
  19658. configurable: true
  19659. });
  19660. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19661. /**
  19662. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19663. */
  19664. get: function () {
  19665. var keyboard = this.inputs.attached["keyboard"];
  19666. if (keyboard) {
  19667. return keyboard.keysRight;
  19668. }
  19669. return [];
  19670. },
  19671. set: function (value) {
  19672. var keyboard = this.inputs.attached["keyboard"];
  19673. if (keyboard) {
  19674. keyboard.keysRight = value;
  19675. }
  19676. },
  19677. enumerable: true,
  19678. configurable: true
  19679. });
  19680. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19681. /**
  19682. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19683. */
  19684. get: function () {
  19685. var mousewheel = this.inputs.attached["mousewheel"];
  19686. if (mousewheel) {
  19687. return mousewheel.wheelPrecision;
  19688. }
  19689. return 0;
  19690. },
  19691. set: function (value) {
  19692. var mousewheel = this.inputs.attached["mousewheel"];
  19693. if (mousewheel) {
  19694. mousewheel.wheelPrecision = value;
  19695. }
  19696. },
  19697. enumerable: true,
  19698. configurable: true
  19699. });
  19700. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19701. /**
  19702. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19703. * It will be used instead of pinchDeltaPrecision if different from 0.
  19704. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19705. */
  19706. get: function () {
  19707. var mousewheel = this.inputs.attached["mousewheel"];
  19708. if (mousewheel) {
  19709. return mousewheel.wheelDeltaPercentage;
  19710. }
  19711. return 0;
  19712. },
  19713. set: function (value) {
  19714. var mousewheel = this.inputs.attached["mousewheel"];
  19715. if (mousewheel) {
  19716. mousewheel.wheelDeltaPercentage = value;
  19717. }
  19718. },
  19719. enumerable: true,
  19720. configurable: true
  19721. });
  19722. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19723. /**
  19724. * Gets the bouncing behavior of the camera if it has been enabled.
  19725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19726. */
  19727. get: function () {
  19728. return this._bouncingBehavior;
  19729. },
  19730. enumerable: true,
  19731. configurable: true
  19732. });
  19733. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19734. /**
  19735. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19737. */
  19738. get: function () {
  19739. return this._bouncingBehavior != null;
  19740. },
  19741. set: function (value) {
  19742. if (value === this.useBouncingBehavior) {
  19743. return;
  19744. }
  19745. if (value) {
  19746. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19747. this.addBehavior(this._bouncingBehavior);
  19748. }
  19749. else if (this._bouncingBehavior) {
  19750. this.removeBehavior(this._bouncingBehavior);
  19751. this._bouncingBehavior = null;
  19752. }
  19753. },
  19754. enumerable: true,
  19755. configurable: true
  19756. });
  19757. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19758. /**
  19759. * Gets the framing behavior of the camera if it has been enabled.
  19760. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19761. */
  19762. get: function () {
  19763. return this._framingBehavior;
  19764. },
  19765. enumerable: true,
  19766. configurable: true
  19767. });
  19768. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19769. /**
  19770. * Defines if the framing behavior of the camera is enabled on the camera.
  19771. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19772. */
  19773. get: function () {
  19774. return this._framingBehavior != null;
  19775. },
  19776. set: function (value) {
  19777. if (value === this.useFramingBehavior) {
  19778. return;
  19779. }
  19780. if (value) {
  19781. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19782. this.addBehavior(this._framingBehavior);
  19783. }
  19784. else if (this._framingBehavior) {
  19785. this.removeBehavior(this._framingBehavior);
  19786. this._framingBehavior = null;
  19787. }
  19788. },
  19789. enumerable: true,
  19790. configurable: true
  19791. });
  19792. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19793. /**
  19794. * Gets the auto rotation behavior of the camera if it has been enabled.
  19795. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19796. */
  19797. get: function () {
  19798. return this._autoRotationBehavior;
  19799. },
  19800. enumerable: true,
  19801. configurable: true
  19802. });
  19803. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19804. /**
  19805. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19806. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19807. */
  19808. get: function () {
  19809. return this._autoRotationBehavior != null;
  19810. },
  19811. set: function (value) {
  19812. if (value === this.useAutoRotationBehavior) {
  19813. return;
  19814. }
  19815. if (value) {
  19816. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19817. this.addBehavior(this._autoRotationBehavior);
  19818. }
  19819. else if (this._autoRotationBehavior) {
  19820. this.removeBehavior(this._autoRotationBehavior);
  19821. this._autoRotationBehavior = null;
  19822. }
  19823. },
  19824. enumerable: true,
  19825. configurable: true
  19826. });
  19827. // Cache
  19828. /** @hidden */
  19829. ArcRotateCamera.prototype._initCache = function () {
  19830. _super.prototype._initCache.call(this);
  19831. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19832. this._cache.alpha = undefined;
  19833. this._cache.beta = undefined;
  19834. this._cache.radius = undefined;
  19835. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19836. };
  19837. /** @hidden */
  19838. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19839. if (!ignoreParentClass) {
  19840. _super.prototype._updateCache.call(this);
  19841. }
  19842. this._cache._target.copyFrom(this._getTargetPosition());
  19843. this._cache.alpha = this.alpha;
  19844. this._cache.beta = this.beta;
  19845. this._cache.radius = this.radius;
  19846. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19847. };
  19848. ArcRotateCamera.prototype._getTargetPosition = function () {
  19849. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19850. var pos = this._targetHost.absolutePosition;
  19851. if (this._targetBoundingCenter) {
  19852. pos.addToRef(this._targetBoundingCenter, this._target);
  19853. }
  19854. else {
  19855. this._target.copyFrom(pos);
  19856. }
  19857. }
  19858. var lockedTargetPosition = this._getLockedTargetPosition();
  19859. if (lockedTargetPosition) {
  19860. return lockedTargetPosition;
  19861. }
  19862. return this._target;
  19863. };
  19864. /**
  19865. * Stores the current state of the camera (alpha, beta, radius and target)
  19866. * @returns the camera itself
  19867. */
  19868. ArcRotateCamera.prototype.storeState = function () {
  19869. this._storedAlpha = this.alpha;
  19870. this._storedBeta = this.beta;
  19871. this._storedRadius = this.radius;
  19872. this._storedTarget = this._getTargetPosition().clone();
  19873. return _super.prototype.storeState.call(this);
  19874. };
  19875. /**
  19876. * @hidden
  19877. * Restored camera state. You must call storeState() first
  19878. */
  19879. ArcRotateCamera.prototype._restoreStateValues = function () {
  19880. if (!_super.prototype._restoreStateValues.call(this)) {
  19881. return false;
  19882. }
  19883. this.alpha = this._storedAlpha;
  19884. this.beta = this._storedBeta;
  19885. this.radius = this._storedRadius;
  19886. this.setTarget(this._storedTarget.clone());
  19887. this.inertialAlphaOffset = 0;
  19888. this.inertialBetaOffset = 0;
  19889. this.inertialRadiusOffset = 0;
  19890. this.inertialPanningX = 0;
  19891. this.inertialPanningY = 0;
  19892. return true;
  19893. };
  19894. // Synchronized
  19895. /** @hidden */
  19896. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19897. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19898. return false;
  19899. }
  19900. return this._cache._target.equals(this._getTargetPosition())
  19901. && this._cache.alpha === this.alpha
  19902. && this._cache.beta === this.beta
  19903. && this._cache.radius === this.radius
  19904. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19905. };
  19906. /**
  19907. * Attached controls to the current camera.
  19908. * @param element Defines the element the controls should be listened from
  19909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19910. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19911. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19912. */
  19913. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19914. var _this = this;
  19915. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19916. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19917. this._useCtrlForPanning = useCtrlForPanning;
  19918. this._panningMouseButton = panningMouseButton;
  19919. this.inputs.attachElement(element, noPreventDefault);
  19920. this._reset = function () {
  19921. _this.inertialAlphaOffset = 0;
  19922. _this.inertialBetaOffset = 0;
  19923. _this.inertialRadiusOffset = 0;
  19924. _this.inertialPanningX = 0;
  19925. _this.inertialPanningY = 0;
  19926. };
  19927. };
  19928. /**
  19929. * Detach the current controls from the camera.
  19930. * The camera will stop reacting to inputs.
  19931. * @param element Defines the element to stop listening the inputs from
  19932. */
  19933. ArcRotateCamera.prototype.detachControl = function (element) {
  19934. this.inputs.detachElement(element);
  19935. if (this._reset) {
  19936. this._reset();
  19937. }
  19938. };
  19939. /** @hidden */
  19940. ArcRotateCamera.prototype._checkInputs = function () {
  19941. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19942. if (this._collisionTriggered) {
  19943. return;
  19944. }
  19945. this.inputs.checkInputs();
  19946. // Inertia
  19947. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19948. var inertialAlphaOffset = this.inertialAlphaOffset;
  19949. if (this.beta <= 0) {
  19950. inertialAlphaOffset *= -1;
  19951. }
  19952. if (this.getScene().useRightHandedSystem) {
  19953. inertialAlphaOffset *= -1;
  19954. }
  19955. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19956. inertialAlphaOffset *= -1;
  19957. }
  19958. this.alpha += inertialAlphaOffset;
  19959. this.beta += this.inertialBetaOffset;
  19960. this.radius -= this.inertialRadiusOffset;
  19961. this.inertialAlphaOffset *= this.inertia;
  19962. this.inertialBetaOffset *= this.inertia;
  19963. this.inertialRadiusOffset *= this.inertia;
  19964. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19965. this.inertialAlphaOffset = 0;
  19966. }
  19967. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19968. this.inertialBetaOffset = 0;
  19969. }
  19970. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19971. this.inertialRadiusOffset = 0;
  19972. }
  19973. }
  19974. // Panning inertia
  19975. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19976. if (!this._localDirection) {
  19977. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19978. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19979. }
  19980. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19981. this._localDirection.multiplyInPlace(this.panningAxis);
  19982. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19983. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19984. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19985. if (!this.panningAxis.y) {
  19986. this._transformedDirection.y = 0;
  19987. }
  19988. if (!this._targetHost) {
  19989. if (this.panningDistanceLimit) {
  19990. this._transformedDirection.addInPlace(this._target);
  19991. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19992. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19993. this._target.copyFrom(this._transformedDirection);
  19994. }
  19995. }
  19996. else {
  19997. this._target.addInPlace(this._transformedDirection);
  19998. }
  19999. }
  20000. this.inertialPanningX *= this.panningInertia;
  20001. this.inertialPanningY *= this.panningInertia;
  20002. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20003. this.inertialPanningX = 0;
  20004. }
  20005. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20006. this.inertialPanningY = 0;
  20007. }
  20008. }
  20009. // Limits
  20010. this._checkLimits();
  20011. _super.prototype._checkInputs.call(this);
  20012. };
  20013. ArcRotateCamera.prototype._checkLimits = function () {
  20014. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  20015. if (this.allowUpsideDown && this.beta > Math.PI) {
  20016. this.beta = this.beta - (2 * Math.PI);
  20017. }
  20018. }
  20019. else {
  20020. if (this.beta < this.lowerBetaLimit) {
  20021. this.beta = this.lowerBetaLimit;
  20022. }
  20023. }
  20024. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  20025. if (this.allowUpsideDown && this.beta < -Math.PI) {
  20026. this.beta = this.beta + (2 * Math.PI);
  20027. }
  20028. }
  20029. else {
  20030. if (this.beta > this.upperBetaLimit) {
  20031. this.beta = this.upperBetaLimit;
  20032. }
  20033. }
  20034. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  20035. this.alpha = this.lowerAlphaLimit;
  20036. }
  20037. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  20038. this.alpha = this.upperAlphaLimit;
  20039. }
  20040. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20041. this.radius = this.lowerRadiusLimit;
  20042. this.inertialRadiusOffset = 0;
  20043. }
  20044. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20045. this.radius = this.upperRadiusLimit;
  20046. this.inertialRadiusOffset = 0;
  20047. }
  20048. };
  20049. /**
  20050. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20051. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  20052. */
  20053. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function (updateView) {
  20054. if (updateView === void 0) { updateView = true; }
  20055. if (updateView) {
  20056. this.getViewMatrix(); // Force position update
  20057. }
  20058. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20059. this.radius = this._computationVector.length();
  20060. if (this.radius === 0) {
  20061. this.radius = 0.0001; // Just to avoid division by zero
  20062. }
  20063. // Alpha
  20064. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20065. if (this._computationVector.z < 0) {
  20066. this.alpha = 2 * Math.PI - this.alpha;
  20067. }
  20068. // Beta
  20069. this.beta = Math.acos(this._computationVector.y / this.radius);
  20070. this._checkLimits();
  20071. };
  20072. /**
  20073. * Use a position to define the current camera related information like aplha, beta and radius
  20074. * @param position Defines the position to set the camera at
  20075. */
  20076. ArcRotateCamera.prototype.setPosition = function (position) {
  20077. if (this._position.equals(position)) {
  20078. return;
  20079. }
  20080. this._position.copyFrom(position);
  20081. this.rebuildAnglesAndRadius(false);
  20082. };
  20083. /**
  20084. * Defines the target the camera should look at.
  20085. * This will automatically adapt alpha beta and radius to fit within the new target.
  20086. * @param target Defines the new target as a Vector or a mesh
  20087. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20088. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20089. */
  20090. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20091. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20092. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20093. if (target.getBoundingInfo) {
  20094. if (toBoundingCenter) {
  20095. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20096. }
  20097. else {
  20098. this._targetBoundingCenter = null;
  20099. }
  20100. target.computeWorldMatrix();
  20101. this._targetHost = target;
  20102. this._target = this._getTargetPosition();
  20103. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20104. }
  20105. else {
  20106. var newTarget = target;
  20107. var currentTarget = this._getTargetPosition();
  20108. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20109. return;
  20110. }
  20111. this._targetHost = null;
  20112. this._target = newTarget;
  20113. this._targetBoundingCenter = null;
  20114. this.onMeshTargetChangedObservable.notifyObservers(null);
  20115. }
  20116. this.rebuildAnglesAndRadius();
  20117. };
  20118. /** @hidden */
  20119. ArcRotateCamera.prototype._getViewMatrix = function () {
  20120. // Compute
  20121. var cosa = Math.cos(this.alpha);
  20122. var sina = Math.sin(this.alpha);
  20123. var cosb = Math.cos(this.beta);
  20124. var sinb = Math.sin(this.beta);
  20125. if (sinb === 0) {
  20126. sinb = 0.0001;
  20127. }
  20128. var target = this._getTargetPosition();
  20129. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20130. // Rotate according to up vector
  20131. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  20132. if (!this._tempAxisVector) {
  20133. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  20134. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  20135. }
  20136. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  20137. this._tempAxisVector.normalize();
  20138. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  20139. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  20140. this._tempAxisVector.copyFrom(this._computationVector);
  20141. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  20142. }
  20143. target.addToRef(this._computationVector, this._newPosition);
  20144. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20145. var coordinator = this.getScene().collisionCoordinator;
  20146. if (!this._collider) {
  20147. this._collider = coordinator.createCollider();
  20148. }
  20149. this._collider._radius = this.collisionRadius;
  20150. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20151. this._collisionTriggered = true;
  20152. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20153. }
  20154. else {
  20155. this._position.copyFrom(this._newPosition);
  20156. var up = this.upVector;
  20157. if (this.allowUpsideDown && sinb < 0) {
  20158. up = up.clone();
  20159. up = up.negate();
  20160. }
  20161. this._computeViewMatrix(this._position, target, up);
  20162. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20163. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20164. }
  20165. this._currentTarget = target;
  20166. return this._viewMatrix;
  20167. };
  20168. /**
  20169. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20170. * @param meshes Defines the mesh to zoom on
  20171. * @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)
  20172. */
  20173. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20174. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20175. meshes = meshes || this.getScene().meshes;
  20176. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20177. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20178. this.radius = distance * this.zoomOnFactor;
  20179. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20180. };
  20181. /**
  20182. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20183. * The target will be changed but the radius
  20184. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20185. * @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)
  20186. */
  20187. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20188. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20189. var meshesOrMinMaxVector;
  20190. var distance;
  20191. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20192. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20193. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20194. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20195. }
  20196. else { //minMaxVector and distance
  20197. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20198. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20199. distance = minMaxVectorAndDistance.distance;
  20200. }
  20201. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20202. if (!doNotUpdateMaxZ) {
  20203. this.maxZ = distance * 2;
  20204. }
  20205. };
  20206. /**
  20207. * @override
  20208. * Override Camera.createRigCamera
  20209. */
  20210. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20211. var alphaShift = 0;
  20212. switch (this.cameraRigMode) {
  20213. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20214. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20215. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20216. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20217. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20218. break;
  20219. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20220. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20221. break;
  20222. }
  20223. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20224. rigCam._cameraRigParams = {};
  20225. return rigCam;
  20226. };
  20227. /**
  20228. * @hidden
  20229. * @override
  20230. * Override Camera._updateRigCameras
  20231. */
  20232. ArcRotateCamera.prototype._updateRigCameras = function () {
  20233. var camLeft = this._rigCameras[0];
  20234. var camRight = this._rigCameras[1];
  20235. camLeft.beta = camRight.beta = this.beta;
  20236. switch (this.cameraRigMode) {
  20237. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20238. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20239. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20240. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20241. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20242. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20243. break;
  20244. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20245. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20246. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20247. break;
  20248. }
  20249. _super.prototype._updateRigCameras.call(this);
  20250. };
  20251. /**
  20252. * Destroy the camera and release the current resources hold by it.
  20253. */
  20254. ArcRotateCamera.prototype.dispose = function () {
  20255. this.inputs.clear();
  20256. _super.prototype.dispose.call(this);
  20257. };
  20258. /**
  20259. * Gets the current object class name.
  20260. * @return the class name
  20261. */
  20262. ArcRotateCamera.prototype.getClassName = function () {
  20263. return "ArcRotateCamera";
  20264. };
  20265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20267. ], ArcRotateCamera.prototype, "alpha", void 0);
  20268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20270. ], ArcRotateCamera.prototype, "beta", void 0);
  20271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20273. ], ArcRotateCamera.prototype, "radius", void 0);
  20274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20276. ], ArcRotateCamera.prototype, "_target", void 0);
  20277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20279. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20282. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20285. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20288. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20291. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20294. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20297. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20300. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20303. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20306. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20309. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20312. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20315. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20318. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20321. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20324. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20327. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20330. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20333. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20334. return ArcRotateCamera;
  20335. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20336. /***/ }),
  20337. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20338. /*!*************************************************!*\
  20339. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20340. \*************************************************/
  20341. /*! exports provided: ArcRotateCameraInputsManager */
  20342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20343. "use strict";
  20344. __webpack_require__.r(__webpack_exports__);
  20345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20346. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20347. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20348. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20349. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20350. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20351. /**
  20352. * Default Inputs manager for the ArcRotateCamera.
  20353. * It groups all the default supported inputs for ease of use.
  20354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20355. */
  20356. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20357. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20358. /**
  20359. * Instantiates a new ArcRotateCameraInputsManager.
  20360. * @param camera Defines the camera the inputs belong to
  20361. */
  20362. function ArcRotateCameraInputsManager(camera) {
  20363. return _super.call(this, camera) || this;
  20364. }
  20365. /**
  20366. * Add mouse wheel input support to the input manager.
  20367. * @returns the current input manager
  20368. */
  20369. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20370. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20371. return this;
  20372. };
  20373. /**
  20374. * Add pointers input support to the input manager.
  20375. * @returns the current input manager
  20376. */
  20377. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20378. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20379. return this;
  20380. };
  20381. /**
  20382. * Add keyboard input support to the input manager.
  20383. * @returns the current input manager
  20384. */
  20385. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20386. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20387. return this;
  20388. };
  20389. return ArcRotateCameraInputsManager;
  20390. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20391. /***/ }),
  20392. /***/ "./Cameras/camera.ts":
  20393. /*!***************************!*\
  20394. !*** ./Cameras/camera.ts ***!
  20395. \***************************/
  20396. /*! exports provided: Camera */
  20397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20398. "use strict";
  20399. __webpack_require__.r(__webpack_exports__);
  20400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20401. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20402. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20403. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20404. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20405. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20406. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20407. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20408. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20409. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20410. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20411. /**
  20412. * This is the base class of all the camera used in the application.
  20413. * @see http://doc.babylonjs.com/features/cameras
  20414. */
  20415. var Camera = /** @class */ (function (_super) {
  20416. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20417. /**
  20418. * Instantiates a new camera object.
  20419. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20420. * @see http://doc.babylonjs.com/features/cameras
  20421. * @param name Defines the name of the camera in the scene
  20422. * @param position Defines the position of the camera
  20423. * @param scene Defines the scene the camera belongs too
  20424. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20425. */
  20426. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20427. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20428. var _this = _super.call(this, name, scene) || this;
  20429. /** @hidden */
  20430. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20431. /**
  20432. * The vector the camera should consider as up.
  20433. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20434. */
  20435. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20436. /**
  20437. * Define the current limit on the left side for an orthographic camera
  20438. * In scene unit
  20439. */
  20440. _this.orthoLeft = null;
  20441. /**
  20442. * Define the current limit on the right side for an orthographic camera
  20443. * In scene unit
  20444. */
  20445. _this.orthoRight = null;
  20446. /**
  20447. * Define the current limit on the bottom side for an orthographic camera
  20448. * In scene unit
  20449. */
  20450. _this.orthoBottom = null;
  20451. /**
  20452. * Define the current limit on the top side for an orthographic camera
  20453. * In scene unit
  20454. */
  20455. _this.orthoTop = null;
  20456. /**
  20457. * Field Of View is set in Radians. (default is 0.8)
  20458. */
  20459. _this.fov = 0.8;
  20460. /**
  20461. * Define the minimum distance the camera can see from.
  20462. * This is important to note that the depth buffer are not infinite and the closer it starts
  20463. * the more your scene might encounter depth fighting issue.
  20464. */
  20465. _this.minZ = 1;
  20466. /**
  20467. * Define the maximum distance the camera can see to.
  20468. * This is important to note that the depth buffer are not infinite and the further it end
  20469. * the more your scene might encounter depth fighting issue.
  20470. */
  20471. _this.maxZ = 10000.0;
  20472. /**
  20473. * Define the default inertia of the camera.
  20474. * This helps giving a smooth feeling to the camera movement.
  20475. */
  20476. _this.inertia = 0.9;
  20477. /**
  20478. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20479. */
  20480. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20481. /**
  20482. * Define wether the camera is intermediate.
  20483. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20484. */
  20485. _this.isIntermediate = false;
  20486. /**
  20487. * Define the viewport of the camera.
  20488. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20489. */
  20490. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20491. /**
  20492. * Restricts the camera to viewing objects with the same layerMask.
  20493. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20494. */
  20495. _this.layerMask = 0x0FFFFFFF;
  20496. /**
  20497. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20498. */
  20499. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20500. /**
  20501. * Rig mode of the camera.
  20502. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20503. * This is normally controlled byt the camera themselves as internal use.
  20504. */
  20505. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20506. /**
  20507. * 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
  20508. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20509. * else in the scene.
  20510. */
  20511. _this.customRenderTargets = new Array();
  20512. /**
  20513. * When set, the camera will render to this render target instead of the default canvas
  20514. */
  20515. _this.outputRenderTarget = null;
  20516. /**
  20517. * Observable triggered when the camera view matrix has changed.
  20518. */
  20519. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20520. /**
  20521. * Observable triggered when the camera Projection matrix has changed.
  20522. */
  20523. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20524. /**
  20525. * Observable triggered when the inputs have been processed.
  20526. */
  20527. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20528. /**
  20529. * Observable triggered when reset has been called and applied to the camera.
  20530. */
  20531. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20532. /** @hidden */
  20533. _this._rigCameras = new Array();
  20534. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20535. /** @hidden */
  20536. _this._skipRendering = false;
  20537. /** @hidden */
  20538. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20539. /** @hidden */
  20540. _this._postProcesses = new Array();
  20541. /** @hidden */
  20542. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20543. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20544. /** hidden */
  20545. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20546. _this._doNotComputeProjectionMatrix = false;
  20547. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20548. _this._refreshFrustumPlanes = true;
  20549. /** @hidden */
  20550. _this._isCamera = true;
  20551. /** @hidden */
  20552. _this._isLeftCamera = false;
  20553. /** @hidden */
  20554. _this._isRightCamera = true;
  20555. _this.getScene().addCamera(_this);
  20556. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20557. _this.getScene().activeCamera = _this;
  20558. }
  20559. _this.position = position;
  20560. return _this;
  20561. }
  20562. Object.defineProperty(Camera.prototype, "position", {
  20563. /**
  20564. * Define the current local position of the camera in the scene
  20565. */
  20566. get: function () {
  20567. return this._position;
  20568. },
  20569. set: function (newPosition) {
  20570. this._position = newPosition;
  20571. },
  20572. enumerable: true,
  20573. configurable: true
  20574. });
  20575. /**
  20576. * Store current camera state (fov, position, etc..)
  20577. * @returns the camera
  20578. */
  20579. Camera.prototype.storeState = function () {
  20580. this._stateStored = true;
  20581. this._storedFov = this.fov;
  20582. return this;
  20583. };
  20584. /**
  20585. * Restores the camera state values if it has been stored. You must call storeState() first
  20586. */
  20587. Camera.prototype._restoreStateValues = function () {
  20588. if (!this._stateStored) {
  20589. return false;
  20590. }
  20591. this.fov = this._storedFov;
  20592. return true;
  20593. };
  20594. /**
  20595. * Restored camera state. You must call storeState() first.
  20596. * @returns true if restored and false otherwise
  20597. */
  20598. Camera.prototype.restoreState = function () {
  20599. if (this._restoreStateValues()) {
  20600. this.onRestoreStateObservable.notifyObservers(this);
  20601. return true;
  20602. }
  20603. return false;
  20604. };
  20605. /**
  20606. * Gets the class name of the camera.
  20607. * @returns the class name
  20608. */
  20609. Camera.prototype.getClassName = function () {
  20610. return "Camera";
  20611. };
  20612. /**
  20613. * Gets a string representation of the camera useful for debug purpose.
  20614. * @param fullDetails Defines that a more verboe level of logging is required
  20615. * @returns the string representation
  20616. */
  20617. Camera.prototype.toString = function (fullDetails) {
  20618. var ret = "Name: " + this.name;
  20619. ret += ", type: " + this.getClassName();
  20620. if (this.animations) {
  20621. for (var i = 0; i < this.animations.length; i++) {
  20622. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20623. }
  20624. }
  20625. if (fullDetails) {
  20626. }
  20627. return ret;
  20628. };
  20629. Object.defineProperty(Camera.prototype, "globalPosition", {
  20630. /**
  20631. * Gets the current world space position of the camera.
  20632. */
  20633. get: function () {
  20634. return this._globalPosition;
  20635. },
  20636. enumerable: true,
  20637. configurable: true
  20638. });
  20639. /**
  20640. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20641. * @returns the active meshe list
  20642. */
  20643. Camera.prototype.getActiveMeshes = function () {
  20644. return this._activeMeshes;
  20645. };
  20646. /**
  20647. * Check wether a mesh is part of the current active mesh list of the camera
  20648. * @param mesh Defines the mesh to check
  20649. * @returns true if active, false otherwise
  20650. */
  20651. Camera.prototype.isActiveMesh = function (mesh) {
  20652. return (this._activeMeshes.indexOf(mesh) !== -1);
  20653. };
  20654. /**
  20655. * Is this camera ready to be used/rendered
  20656. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20657. * @return true if the camera is ready
  20658. */
  20659. Camera.prototype.isReady = function (completeCheck) {
  20660. if (completeCheck === void 0) { completeCheck = false; }
  20661. if (completeCheck) {
  20662. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20663. var pp = _a[_i];
  20664. if (pp && !pp.isReady()) {
  20665. return false;
  20666. }
  20667. }
  20668. }
  20669. return _super.prototype.isReady.call(this, completeCheck);
  20670. };
  20671. /** @hidden */
  20672. Camera.prototype._initCache = function () {
  20673. _super.prototype._initCache.call(this);
  20674. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20675. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20676. this._cache.mode = undefined;
  20677. this._cache.minZ = undefined;
  20678. this._cache.maxZ = undefined;
  20679. this._cache.fov = undefined;
  20680. this._cache.fovMode = undefined;
  20681. this._cache.aspectRatio = undefined;
  20682. this._cache.orthoLeft = undefined;
  20683. this._cache.orthoRight = undefined;
  20684. this._cache.orthoBottom = undefined;
  20685. this._cache.orthoTop = undefined;
  20686. this._cache.renderWidth = undefined;
  20687. this._cache.renderHeight = undefined;
  20688. };
  20689. /** @hidden */
  20690. Camera.prototype._updateCache = function (ignoreParentClass) {
  20691. if (!ignoreParentClass) {
  20692. _super.prototype._updateCache.call(this);
  20693. }
  20694. this._cache.position.copyFrom(this.position);
  20695. this._cache.upVector.copyFrom(this.upVector);
  20696. };
  20697. /** @hidden */
  20698. Camera.prototype._isSynchronized = function () {
  20699. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20700. };
  20701. /** @hidden */
  20702. Camera.prototype._isSynchronizedViewMatrix = function () {
  20703. if (!_super.prototype._isSynchronized.call(this)) {
  20704. return false;
  20705. }
  20706. return this._cache.position.equals(this.position)
  20707. && this._cache.upVector.equals(this.upVector)
  20708. && this.isSynchronizedWithParent();
  20709. };
  20710. /** @hidden */
  20711. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20712. var check = this._cache.mode === this.mode
  20713. && this._cache.minZ === this.minZ
  20714. && this._cache.maxZ === this.maxZ;
  20715. if (!check) {
  20716. return false;
  20717. }
  20718. var engine = this.getEngine();
  20719. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20720. check = this._cache.fov === this.fov
  20721. && this._cache.fovMode === this.fovMode
  20722. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20723. }
  20724. else {
  20725. check = this._cache.orthoLeft === this.orthoLeft
  20726. && this._cache.orthoRight === this.orthoRight
  20727. && this._cache.orthoBottom === this.orthoBottom
  20728. && this._cache.orthoTop === this.orthoTop
  20729. && this._cache.renderWidth === engine.getRenderWidth()
  20730. && this._cache.renderHeight === engine.getRenderHeight();
  20731. }
  20732. return check;
  20733. };
  20734. /**
  20735. * Attach the input controls to a specific dom element to get the input from.
  20736. * @param element Defines the element the controls should be listened from
  20737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20738. */
  20739. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20740. };
  20741. /**
  20742. * Detach the current controls from the specified dom element.
  20743. * @param element Defines the element to stop listening the inputs from
  20744. */
  20745. Camera.prototype.detachControl = function (element) {
  20746. };
  20747. /**
  20748. * Update the camera state according to the different inputs gathered during the frame.
  20749. */
  20750. Camera.prototype.update = function () {
  20751. this._checkInputs();
  20752. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20753. this._updateRigCameras();
  20754. }
  20755. };
  20756. /** @hidden */
  20757. Camera.prototype._checkInputs = function () {
  20758. this.onAfterCheckInputsObservable.notifyObservers(this);
  20759. };
  20760. Object.defineProperty(Camera.prototype, "rigCameras", {
  20761. /** @hidden */
  20762. get: function () {
  20763. return this._rigCameras;
  20764. },
  20765. enumerable: true,
  20766. configurable: true
  20767. });
  20768. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20769. /**
  20770. * Gets the post process used by the rig cameras
  20771. */
  20772. get: function () {
  20773. return this._rigPostProcess;
  20774. },
  20775. enumerable: true,
  20776. configurable: true
  20777. });
  20778. /**
  20779. * Internal, gets the first post proces.
  20780. * @returns the first post process to be run on this camera.
  20781. */
  20782. Camera.prototype._getFirstPostProcess = function () {
  20783. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20784. if (this._postProcesses[ppIndex] !== null) {
  20785. return this._postProcesses[ppIndex];
  20786. }
  20787. }
  20788. return null;
  20789. };
  20790. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20791. // invalidate framebuffer
  20792. var firstPostProcess = this._getFirstPostProcess();
  20793. if (firstPostProcess) {
  20794. firstPostProcess.markTextureDirty();
  20795. }
  20796. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20797. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20798. var cam = this._rigCameras[i];
  20799. var rigPostProcess = cam._rigPostProcess;
  20800. // for VR rig, there does not have to be a post process
  20801. if (rigPostProcess) {
  20802. var isPass = rigPostProcess.getEffectName() === "pass";
  20803. if (isPass) {
  20804. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20805. cam.isIntermediate = this._postProcesses.length === 0;
  20806. }
  20807. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20808. rigPostProcess.markTextureDirty();
  20809. }
  20810. else {
  20811. cam._postProcesses = this._postProcesses.slice(0);
  20812. }
  20813. }
  20814. };
  20815. /**
  20816. * Attach a post process to the camera.
  20817. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20818. * @param postProcess The post process to attach to the camera
  20819. * @param insertAt The position of the post process in case several of them are in use in the scene
  20820. * @returns the position the post process has been inserted at
  20821. */
  20822. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20823. if (insertAt === void 0) { insertAt = null; }
  20824. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20825. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20826. return 0;
  20827. }
  20828. if (insertAt == null || insertAt < 0) {
  20829. this._postProcesses.push(postProcess);
  20830. }
  20831. else if (this._postProcesses[insertAt] === null) {
  20832. this._postProcesses[insertAt] = postProcess;
  20833. }
  20834. else {
  20835. this._postProcesses.splice(insertAt, 0, postProcess);
  20836. }
  20837. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20838. return this._postProcesses.indexOf(postProcess);
  20839. };
  20840. /**
  20841. * Detach a post process to the camera.
  20842. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20843. * @param postProcess The post process to detach from the camera
  20844. */
  20845. Camera.prototype.detachPostProcess = function (postProcess) {
  20846. var idx = this._postProcesses.indexOf(postProcess);
  20847. if (idx !== -1) {
  20848. this._postProcesses[idx] = null;
  20849. }
  20850. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20851. };
  20852. /**
  20853. * Gets the current world matrix of the camera
  20854. */
  20855. Camera.prototype.getWorldMatrix = function () {
  20856. if (this._isSynchronizedViewMatrix()) {
  20857. return this._worldMatrix;
  20858. }
  20859. // Getting the the view matrix will also compute the world matrix.
  20860. this.getViewMatrix();
  20861. return this._worldMatrix;
  20862. };
  20863. /** @hidden */
  20864. Camera.prototype._getViewMatrix = function () {
  20865. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20866. };
  20867. /**
  20868. * Gets the current view matrix of the camera.
  20869. * @param force forces the camera to recompute the matrix without looking at the cached state
  20870. * @returns the view matrix
  20871. */
  20872. Camera.prototype.getViewMatrix = function (force) {
  20873. if (!force && this._isSynchronizedViewMatrix()) {
  20874. return this._computedViewMatrix;
  20875. }
  20876. this.updateCache();
  20877. this._computedViewMatrix = this._getViewMatrix();
  20878. this._currentRenderId = this.getScene().getRenderId();
  20879. this._childRenderId = this._currentRenderId;
  20880. this._refreshFrustumPlanes = true;
  20881. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20882. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20883. }
  20884. this.onViewMatrixChangedObservable.notifyObservers(this);
  20885. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20886. return this._computedViewMatrix;
  20887. };
  20888. /**
  20889. * Freeze the projection matrix.
  20890. * It will prevent the cache check of the camera projection compute and can speed up perf
  20891. * if no parameter of the camera are meant to change
  20892. * @param projection Defines manually a projection if necessary
  20893. */
  20894. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20895. this._doNotComputeProjectionMatrix = true;
  20896. if (projection !== undefined) {
  20897. this._projectionMatrix = projection;
  20898. }
  20899. };
  20900. /**
  20901. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20902. */
  20903. Camera.prototype.unfreezeProjectionMatrix = function () {
  20904. this._doNotComputeProjectionMatrix = false;
  20905. };
  20906. /**
  20907. * Gets the current projection matrix of the camera.
  20908. * @param force forces the camera to recompute the matrix without looking at the cached state
  20909. * @returns the projection matrix
  20910. */
  20911. Camera.prototype.getProjectionMatrix = function (force) {
  20912. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20913. return this._projectionMatrix;
  20914. }
  20915. // Cache
  20916. this._cache.mode = this.mode;
  20917. this._cache.minZ = this.minZ;
  20918. this._cache.maxZ = this.maxZ;
  20919. // Matrix
  20920. this._refreshFrustumPlanes = true;
  20921. var engine = this.getEngine();
  20922. var scene = this.getScene();
  20923. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20924. this._cache.fov = this.fov;
  20925. this._cache.fovMode = this.fovMode;
  20926. this._cache.aspectRatio = engine.getAspectRatio(this);
  20927. if (this.minZ <= 0) {
  20928. this.minZ = 0.1;
  20929. }
  20930. if (scene.useRightHandedSystem) {
  20931. _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);
  20932. }
  20933. else {
  20934. _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);
  20935. }
  20936. }
  20937. else {
  20938. var halfWidth = engine.getRenderWidth() / 2.0;
  20939. var halfHeight = engine.getRenderHeight() / 2.0;
  20940. if (scene.useRightHandedSystem) {
  20941. _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);
  20942. }
  20943. else {
  20944. _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);
  20945. }
  20946. this._cache.orthoLeft = this.orthoLeft;
  20947. this._cache.orthoRight = this.orthoRight;
  20948. this._cache.orthoBottom = this.orthoBottom;
  20949. this._cache.orthoTop = this.orthoTop;
  20950. this._cache.renderWidth = engine.getRenderWidth();
  20951. this._cache.renderHeight = engine.getRenderHeight();
  20952. }
  20953. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20954. return this._projectionMatrix;
  20955. };
  20956. /**
  20957. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20958. * @returns a Matrix
  20959. */
  20960. Camera.prototype.getTransformationMatrix = function () {
  20961. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20962. return this._transformMatrix;
  20963. };
  20964. Camera.prototype._updateFrustumPlanes = function () {
  20965. if (!this._refreshFrustumPlanes) {
  20966. return;
  20967. }
  20968. this.getTransformationMatrix();
  20969. if (!this._frustumPlanes) {
  20970. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20971. }
  20972. else {
  20973. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20974. }
  20975. this._refreshFrustumPlanes = false;
  20976. };
  20977. /**
  20978. * Checks if a cullable object (mesh...) is in the camera frustum
  20979. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20980. * @param target The object to check
  20981. * @returns true if the object is in frustum otherwise false
  20982. */
  20983. Camera.prototype.isInFrustum = function (target) {
  20984. this._updateFrustumPlanes();
  20985. return target.isInFrustum(this._frustumPlanes);
  20986. };
  20987. /**
  20988. * Checks if a cullable object (mesh...) is in the camera frustum
  20989. * Unlike isInFrustum this cheks the full bounding box
  20990. * @param target The object to check
  20991. * @returns true if the object is in frustum otherwise false
  20992. */
  20993. Camera.prototype.isCompletelyInFrustum = function (target) {
  20994. this._updateFrustumPlanes();
  20995. return target.isCompletelyInFrustum(this._frustumPlanes);
  20996. };
  20997. /**
  20998. * Gets a ray in the forward direction from the camera.
  20999. * @param length Defines the length of the ray to create
  21000. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  21001. * @param origin Defines the start point of the ray which defaults to the camera position
  21002. * @returns the forward ray
  21003. */
  21004. Camera.prototype.getForwardRay = function (length, transform, origin) {
  21005. if (length === void 0) { length = 100; }
  21006. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  21007. };
  21008. /**
  21009. * Releases resources associated with this node.
  21010. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21011. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21012. */
  21013. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  21014. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  21015. // Observables
  21016. this.onViewMatrixChangedObservable.clear();
  21017. this.onProjectionMatrixChangedObservable.clear();
  21018. this.onAfterCheckInputsObservable.clear();
  21019. this.onRestoreStateObservable.clear();
  21020. // Inputs
  21021. if (this.inputs) {
  21022. this.inputs.clear();
  21023. }
  21024. // Animations
  21025. this.getScene().stopAnimation(this);
  21026. // Remove from scene
  21027. this.getScene().removeCamera(this);
  21028. while (this._rigCameras.length > 0) {
  21029. var camera = this._rigCameras.pop();
  21030. if (camera) {
  21031. camera.dispose();
  21032. }
  21033. }
  21034. // Postprocesses
  21035. if (this._rigPostProcess) {
  21036. this._rigPostProcess.dispose(this);
  21037. this._rigPostProcess = null;
  21038. this._postProcesses = [];
  21039. }
  21040. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21041. this._rigPostProcess = null;
  21042. this._postProcesses = [];
  21043. }
  21044. else {
  21045. var i = this._postProcesses.length;
  21046. while (--i >= 0) {
  21047. var postProcess = this._postProcesses[i];
  21048. if (postProcess) {
  21049. postProcess.dispose(this);
  21050. }
  21051. }
  21052. }
  21053. // Render targets
  21054. var i = this.customRenderTargets.length;
  21055. while (--i >= 0) {
  21056. this.customRenderTargets[i].dispose();
  21057. }
  21058. this.customRenderTargets = [];
  21059. // Active Meshes
  21060. this._activeMeshes.dispose();
  21061. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21062. };
  21063. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21064. /**
  21065. * Gets the left camera of a rig setup in case of Rigged Camera
  21066. */
  21067. get: function () {
  21068. return this._isLeftCamera;
  21069. },
  21070. enumerable: true,
  21071. configurable: true
  21072. });
  21073. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21074. /**
  21075. * Gets the right camera of a rig setup in case of Rigged Camera
  21076. */
  21077. get: function () {
  21078. return this._isRightCamera;
  21079. },
  21080. enumerable: true,
  21081. configurable: true
  21082. });
  21083. Object.defineProperty(Camera.prototype, "leftCamera", {
  21084. /**
  21085. * Gets the left camera of a rig setup in case of Rigged Camera
  21086. */
  21087. get: function () {
  21088. if (this._rigCameras.length < 1) {
  21089. return null;
  21090. }
  21091. return this._rigCameras[0];
  21092. },
  21093. enumerable: true,
  21094. configurable: true
  21095. });
  21096. Object.defineProperty(Camera.prototype, "rightCamera", {
  21097. /**
  21098. * Gets the right camera of a rig setup in case of Rigged Camera
  21099. */
  21100. get: function () {
  21101. if (this._rigCameras.length < 2) {
  21102. return null;
  21103. }
  21104. return this._rigCameras[1];
  21105. },
  21106. enumerable: true,
  21107. configurable: true
  21108. });
  21109. /**
  21110. * Gets the left camera target of a rig setup in case of Rigged Camera
  21111. * @returns the target position
  21112. */
  21113. Camera.prototype.getLeftTarget = function () {
  21114. if (this._rigCameras.length < 1) {
  21115. return null;
  21116. }
  21117. return this._rigCameras[0].getTarget();
  21118. };
  21119. /**
  21120. * Gets the right camera target of a rig setup in case of Rigged Camera
  21121. * @returns the target position
  21122. */
  21123. Camera.prototype.getRightTarget = function () {
  21124. if (this._rigCameras.length < 2) {
  21125. return null;
  21126. }
  21127. return this._rigCameras[1].getTarget();
  21128. };
  21129. /**
  21130. * @hidden
  21131. */
  21132. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21133. if (this.cameraRigMode === mode) {
  21134. return;
  21135. }
  21136. while (this._rigCameras.length > 0) {
  21137. var camera = this._rigCameras.pop();
  21138. if (camera) {
  21139. camera.dispose();
  21140. }
  21141. }
  21142. this.cameraRigMode = mode;
  21143. this._cameraRigParams = {};
  21144. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21145. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21146. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21147. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21148. // create the rig cameras, unless none
  21149. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21150. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21151. if (leftCamera) {
  21152. leftCamera._isLeftCamera = true;
  21153. }
  21154. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21155. if (rightCamera) {
  21156. rightCamera._isRightCamera = true;
  21157. }
  21158. if (leftCamera && rightCamera) {
  21159. this._rigCameras.push(leftCamera);
  21160. this._rigCameras.push(rightCamera);
  21161. }
  21162. }
  21163. switch (this.cameraRigMode) {
  21164. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21165. Camera._setStereoscopicAnaglyphRigMode(this);
  21166. break;
  21167. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21168. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21169. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21170. Camera._setStereoscopicRigMode(this);
  21171. break;
  21172. case Camera.RIG_MODE_VR:
  21173. Camera._setVRRigMode(this, rigParams);
  21174. break;
  21175. case Camera.RIG_MODE_WEBVR:
  21176. Camera._setWebVRRigMode(this, rigParams);
  21177. break;
  21178. }
  21179. this._cascadePostProcessesToRigCams();
  21180. this.update();
  21181. };
  21182. /** @hidden */
  21183. Camera._setStereoscopicRigMode = function (camera) {
  21184. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21185. };
  21186. /** @hidden */
  21187. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21188. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21189. };
  21190. /** @hidden */
  21191. Camera._setVRRigMode = function (camera, rigParams) {
  21192. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21193. };
  21194. /** @hidden */
  21195. Camera._setWebVRRigMode = function (camera, rigParams) {
  21196. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21197. };
  21198. /** @hidden */
  21199. Camera.prototype._getVRProjectionMatrix = function () {
  21200. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21201. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21202. return this._projectionMatrix;
  21203. };
  21204. Camera.prototype._updateCameraRotationMatrix = function () {
  21205. //Here for WebVR
  21206. };
  21207. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21208. //Here for WebVR
  21209. };
  21210. /**
  21211. * This function MUST be overwritten by the different WebVR cameras available.
  21212. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21213. * @hidden
  21214. */
  21215. Camera.prototype._getWebVRProjectionMatrix = function () {
  21216. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21217. };
  21218. /**
  21219. * This function MUST be overwritten by the different WebVR cameras available.
  21220. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21221. * @hidden
  21222. */
  21223. Camera.prototype._getWebVRViewMatrix = function () {
  21224. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21225. };
  21226. /** @hidden */
  21227. Camera.prototype.setCameraRigParameter = function (name, value) {
  21228. if (!this._cameraRigParams) {
  21229. this._cameraRigParams = {};
  21230. }
  21231. this._cameraRigParams[name] = value;
  21232. //provisionnally:
  21233. if (name === "interaxialDistance") {
  21234. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21235. }
  21236. };
  21237. /**
  21238. * needs to be overridden by children so sub has required properties to be copied
  21239. * @hidden
  21240. */
  21241. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21242. return null;
  21243. };
  21244. /**
  21245. * May need to be overridden by children
  21246. * @hidden
  21247. */
  21248. Camera.prototype._updateRigCameras = function () {
  21249. for (var i = 0; i < this._rigCameras.length; i++) {
  21250. this._rigCameras[i].minZ = this.minZ;
  21251. this._rigCameras[i].maxZ = this.maxZ;
  21252. this._rigCameras[i].fov = this.fov;
  21253. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21254. }
  21255. // only update viewport when ANAGLYPH
  21256. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21257. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21258. }
  21259. };
  21260. /** @hidden */
  21261. Camera.prototype._setupInputs = function () {
  21262. };
  21263. /**
  21264. * Serialiaze the camera setup to a json represention
  21265. * @returns the JSON representation
  21266. */
  21267. Camera.prototype.serialize = function () {
  21268. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21269. // Type
  21270. serializationObject.type = this.getClassName();
  21271. // Parent
  21272. if (this.parent) {
  21273. serializationObject.parentId = this.parent.id;
  21274. }
  21275. if (this.inputs) {
  21276. this.inputs.serialize(serializationObject);
  21277. }
  21278. // Animations
  21279. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21280. serializationObject.ranges = this.serializeAnimationRanges();
  21281. return serializationObject;
  21282. };
  21283. /**
  21284. * Clones the current camera.
  21285. * @param name The cloned camera name
  21286. * @returns the cloned camera
  21287. */
  21288. Camera.prototype.clone = function (name) {
  21289. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21290. };
  21291. /**
  21292. * Gets the direction of the camera relative to a given local axis.
  21293. * @param localAxis Defines the reference axis to provide a relative direction.
  21294. * @return the direction
  21295. */
  21296. Camera.prototype.getDirection = function (localAxis) {
  21297. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21298. this.getDirectionToRef(localAxis, result);
  21299. return result;
  21300. };
  21301. /**
  21302. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21303. * @param localAxis Defines the reference axis to provide a relative direction.
  21304. * @param result Defines the vector to store the result in
  21305. */
  21306. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21307. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21308. };
  21309. /**
  21310. * Gets a camera constructor for a given camera type
  21311. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21312. * @param name The name of the camera the result will be able to instantiate
  21313. * @param scene The scene the result will construct the camera in
  21314. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21315. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21316. * @returns a factory method to construc the camera
  21317. */
  21318. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21319. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21320. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21321. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21322. interaxial_distance: interaxial_distance,
  21323. isStereoscopicSideBySide: isStereoscopicSideBySide
  21324. });
  21325. if (constructorFunc) {
  21326. return constructorFunc;
  21327. }
  21328. // Default to universal camera
  21329. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21330. };
  21331. /**
  21332. * Compute the world matrix of the camera.
  21333. * @returns the camera workd matrix
  21334. */
  21335. Camera.prototype.computeWorldMatrix = function () {
  21336. return this.getWorldMatrix();
  21337. };
  21338. /**
  21339. * Parse a JSON and creates the camera from the parsed information
  21340. * @param parsedCamera The JSON to parse
  21341. * @param scene The scene to instantiate the camera in
  21342. * @returns the newly constructed camera
  21343. */
  21344. Camera.Parse = function (parsedCamera, scene) {
  21345. var type = parsedCamera.type;
  21346. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21347. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21348. // Parent
  21349. if (parsedCamera.parentId) {
  21350. camera._waitingParentId = parsedCamera.parentId;
  21351. }
  21352. //If camera has an input manager, let it parse inputs settings
  21353. if (camera.inputs) {
  21354. camera.inputs.parse(parsedCamera);
  21355. camera._setupInputs();
  21356. }
  21357. if (camera.setPosition) { // need to force position
  21358. camera.position.copyFromFloats(0, 0, 0);
  21359. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21360. }
  21361. // Target
  21362. if (parsedCamera.target) {
  21363. if (camera.setTarget) {
  21364. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21365. }
  21366. }
  21367. // Apply 3d rig, when found
  21368. if (parsedCamera.cameraRigMode) {
  21369. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21370. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21371. }
  21372. // Animations
  21373. if (parsedCamera.animations) {
  21374. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21375. var parsedAnimation = parsedCamera.animations[animationIndex];
  21376. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21377. if (internalClass) {
  21378. camera.animations.push(internalClass.Parse(parsedAnimation));
  21379. }
  21380. }
  21381. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21382. }
  21383. if (parsedCamera.autoAnimate) {
  21384. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21385. }
  21386. return camera;
  21387. };
  21388. /** @hidden */
  21389. Camera._createDefaultParsedCamera = function (name, scene) {
  21390. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21391. };
  21392. /**
  21393. * This is the default projection mode used by the cameras.
  21394. * It helps recreating a feeling of perspective and better appreciate depth.
  21395. * This is the best way to simulate real life cameras.
  21396. */
  21397. Camera.PERSPECTIVE_CAMERA = 0;
  21398. /**
  21399. * This helps creating camera with an orthographic mode.
  21400. * 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.
  21401. */
  21402. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21403. /**
  21404. * This is the default FOV mode for perspective cameras.
  21405. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21406. */
  21407. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21408. /**
  21409. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21410. */
  21411. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21412. /**
  21413. * This specifies ther is no need for a camera rig.
  21414. * Basically only one eye is rendered corresponding to the camera.
  21415. */
  21416. Camera.RIG_MODE_NONE = 0;
  21417. /**
  21418. * Simulates a camera Rig with one blue eye and one red eye.
  21419. * This can be use with 3d blue and red glasses.
  21420. */
  21421. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21422. /**
  21423. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21424. */
  21425. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21426. /**
  21427. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21428. */
  21429. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21430. /**
  21431. * Defines that both eyes of the camera will be rendered over under each other.
  21432. */
  21433. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21434. /**
  21435. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21436. */
  21437. Camera.RIG_MODE_VR = 20;
  21438. /**
  21439. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21440. */
  21441. Camera.RIG_MODE_WEBVR = 21;
  21442. /**
  21443. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21444. */
  21445. Camera.RIG_MODE_CUSTOM = 22;
  21446. /**
  21447. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21448. */
  21449. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21450. /**
  21451. * @hidden
  21452. * Might be removed once multiview will be a thing
  21453. */
  21454. Camera.UseAlternateWebVRRendering = false;
  21455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21457. ], Camera.prototype, "_position", void 0);
  21458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21460. ], Camera.prototype, "upVector", void 0);
  21461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21463. ], Camera.prototype, "orthoLeft", void 0);
  21464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21466. ], Camera.prototype, "orthoRight", void 0);
  21467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21469. ], Camera.prototype, "orthoBottom", void 0);
  21470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21472. ], Camera.prototype, "orthoTop", void 0);
  21473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21475. ], Camera.prototype, "fov", void 0);
  21476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21478. ], Camera.prototype, "minZ", void 0);
  21479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21481. ], Camera.prototype, "maxZ", void 0);
  21482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21484. ], Camera.prototype, "inertia", void 0);
  21485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21487. ], Camera.prototype, "mode", void 0);
  21488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21490. ], Camera.prototype, "layerMask", void 0);
  21491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21493. ], Camera.prototype, "fovMode", void 0);
  21494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21496. ], Camera.prototype, "cameraRigMode", void 0);
  21497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21499. ], Camera.prototype, "interaxialDistance", void 0);
  21500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21502. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21503. return Camera;
  21504. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21505. /***/ }),
  21506. /***/ "./Cameras/cameraInputsManager.ts":
  21507. /*!****************************************!*\
  21508. !*** ./Cameras/cameraInputsManager.ts ***!
  21509. \****************************************/
  21510. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21512. "use strict";
  21513. __webpack_require__.r(__webpack_exports__);
  21514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21516. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21517. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21518. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21519. /**
  21520. * @ignore
  21521. * This is a list of all the different input types that are available in the application.
  21522. * Fo instance: ArcRotateCameraGamepadInput...
  21523. */
  21524. var CameraInputTypes = {};
  21525. /**
  21526. * This represents the input manager used within a camera.
  21527. * It helps dealing with all the different kind of input attached to a camera.
  21528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21529. */
  21530. var CameraInputsManager = /** @class */ (function () {
  21531. /**
  21532. * Instantiate a new Camera Input Manager.
  21533. * @param camera Defines the camera the input manager blongs to
  21534. */
  21535. function CameraInputsManager(camera) {
  21536. this.attached = {};
  21537. this.camera = camera;
  21538. this.checkInputs = function () { };
  21539. }
  21540. /**
  21541. * Add an input method to a camera
  21542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21543. * @param input camera input method
  21544. */
  21545. CameraInputsManager.prototype.add = function (input) {
  21546. var type = input.getSimpleName();
  21547. if (this.attached[type]) {
  21548. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21549. return;
  21550. }
  21551. this.attached[type] = input;
  21552. input.camera = this.camera;
  21553. //for checkInputs, we are dynamically creating a function
  21554. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21555. if (input.checkInputs) {
  21556. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21557. }
  21558. if (this.attachedElement) {
  21559. input.attachControl(this.attachedElement);
  21560. }
  21561. };
  21562. /**
  21563. * Remove a specific input method from a camera
  21564. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21565. * @param inputToRemove camera input method
  21566. */
  21567. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21568. for (var cam in this.attached) {
  21569. var input = this.attached[cam];
  21570. if (input === inputToRemove) {
  21571. input.detachControl(this.attachedElement);
  21572. input.camera = null;
  21573. delete this.attached[cam];
  21574. this.rebuildInputCheck();
  21575. }
  21576. }
  21577. };
  21578. /**
  21579. * Remove a specific input type from a camera
  21580. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21581. * @param inputType the type of the input to remove
  21582. */
  21583. CameraInputsManager.prototype.removeByType = function (inputType) {
  21584. for (var cam in this.attached) {
  21585. var input = this.attached[cam];
  21586. if (input.getClassName() === inputType) {
  21587. input.detachControl(this.attachedElement);
  21588. input.camera = null;
  21589. delete this.attached[cam];
  21590. this.rebuildInputCheck();
  21591. }
  21592. }
  21593. };
  21594. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21595. var current = this.checkInputs;
  21596. return function () {
  21597. current();
  21598. fn();
  21599. };
  21600. };
  21601. /**
  21602. * Attach the input controls to the currently attached dom element to listen the events from.
  21603. * @param input Defines the input to attach
  21604. */
  21605. CameraInputsManager.prototype.attachInput = function (input) {
  21606. if (this.attachedElement) {
  21607. input.attachControl(this.attachedElement, this.noPreventDefault);
  21608. }
  21609. };
  21610. /**
  21611. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21612. * @param element Defines the dom element to collect the events from
  21613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21614. */
  21615. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21616. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21617. if (this.attachedElement) {
  21618. return;
  21619. }
  21620. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21621. this.attachedElement = element;
  21622. this.noPreventDefault = noPreventDefault;
  21623. for (var cam in this.attached) {
  21624. this.attached[cam].attachControl(element, noPreventDefault);
  21625. }
  21626. };
  21627. /**
  21628. * Detach the current manager inputs controls from a specific dom element.
  21629. * @param element Defines the dom element to collect the events from
  21630. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21631. */
  21632. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21633. if (disconnect === void 0) { disconnect = false; }
  21634. if (this.attachedElement !== element) {
  21635. return;
  21636. }
  21637. for (var cam in this.attached) {
  21638. this.attached[cam].detachControl(element);
  21639. if (disconnect) {
  21640. this.attached[cam].camera = null;
  21641. }
  21642. }
  21643. this.attachedElement = null;
  21644. };
  21645. /**
  21646. * Rebuild the dynamic inputCheck function from the current list of
  21647. * defined inputs in the manager.
  21648. */
  21649. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21650. this.checkInputs = function () { };
  21651. for (var cam in this.attached) {
  21652. var input = this.attached[cam];
  21653. if (input.checkInputs) {
  21654. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21655. }
  21656. }
  21657. };
  21658. /**
  21659. * Remove all attached input methods from a camera
  21660. */
  21661. CameraInputsManager.prototype.clear = function () {
  21662. if (this.attachedElement) {
  21663. this.detachElement(this.attachedElement, true);
  21664. }
  21665. this.attached = {};
  21666. this.attachedElement = null;
  21667. this.checkInputs = function () { };
  21668. };
  21669. /**
  21670. * Serialize the current input manager attached to a camera.
  21671. * This ensures than once parsed,
  21672. * the input associated to the camera will be identical to the current ones
  21673. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21674. */
  21675. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21676. var inputs = {};
  21677. for (var cam in this.attached) {
  21678. var input = this.attached[cam];
  21679. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21680. inputs[input.getClassName()] = res;
  21681. }
  21682. serializedCamera.inputsmgr = inputs;
  21683. };
  21684. /**
  21685. * Parses an input manager serialized JSON to restore the previous list of inputs
  21686. * and states associated to a camera.
  21687. * @param parsedCamera Defines the JSON to parse
  21688. */
  21689. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21690. var parsedInputs = parsedCamera.inputsmgr;
  21691. if (parsedInputs) {
  21692. this.clear();
  21693. for (var n in parsedInputs) {
  21694. var construct = CameraInputTypes[n];
  21695. if (construct) {
  21696. var parsedinput = parsedInputs[n];
  21697. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21698. this.add(input);
  21699. }
  21700. }
  21701. }
  21702. else {
  21703. //2016-03-08 this part is for managing backward compatibility
  21704. for (var n in this.attached) {
  21705. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21706. if (construct) {
  21707. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21708. this.remove(this.attached[n]);
  21709. this.add(input);
  21710. }
  21711. }
  21712. }
  21713. };
  21714. return CameraInputsManager;
  21715. }());
  21716. /***/ }),
  21717. /***/ "./Cameras/deviceOrientationCamera.ts":
  21718. /*!********************************************!*\
  21719. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21720. \********************************************/
  21721. /*! exports provided: DeviceOrientationCamera */
  21722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21723. "use strict";
  21724. __webpack_require__.r(__webpack_exports__);
  21725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21726. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21727. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21728. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21729. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21730. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21731. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21732. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21733. });
  21734. // We're mainly based on the logic defined into the FreeCamera code
  21735. /**
  21736. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21737. * being tilted forward or back and left or right.
  21738. */
  21739. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21740. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21741. /**
  21742. * Creates a new device orientation camera
  21743. * @param name The name of the camera
  21744. * @param position The start position camera
  21745. * @param scene The scene the camera belongs to
  21746. */
  21747. function DeviceOrientationCamera(name, position, scene) {
  21748. var _this = _super.call(this, name, position, scene) || this;
  21749. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21750. _this.inputs.addDeviceOrientation();
  21751. return _this;
  21752. }
  21753. /**
  21754. * Gets the current instance class name ("DeviceOrientationCamera").
  21755. * This helps avoiding instanceof at run time.
  21756. * @returns the class name
  21757. */
  21758. DeviceOrientationCamera.prototype.getClassName = function () {
  21759. return "DeviceOrientationCamera";
  21760. };
  21761. /**
  21762. * @hidden
  21763. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21764. */
  21765. DeviceOrientationCamera.prototype._checkInputs = function () {
  21766. _super.prototype._checkInputs.call(this);
  21767. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21768. if (this._initialQuaternion) {
  21769. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21770. }
  21771. };
  21772. /**
  21773. * Reset the camera to its default orientation on the specified axis only.
  21774. * @param axis The axis to reset
  21775. */
  21776. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21777. var _this = this;
  21778. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21779. //can only work if this camera has a rotation quaternion already.
  21780. if (!this.rotationQuaternion) {
  21781. return;
  21782. }
  21783. if (!this._initialQuaternion) {
  21784. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21785. }
  21786. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21787. ['x', 'y', 'z'].forEach(function (axisName) {
  21788. if (!axis[axisName]) {
  21789. _this._initialQuaternion[axisName] = 0;
  21790. }
  21791. else {
  21792. _this._initialQuaternion[axisName] *= -1;
  21793. }
  21794. });
  21795. this._initialQuaternion.normalize();
  21796. //force rotation update
  21797. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21798. };
  21799. return DeviceOrientationCamera;
  21800. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21801. /***/ }),
  21802. /***/ "./Cameras/flyCamera.ts":
  21803. /*!******************************!*\
  21804. !*** ./Cameras/flyCamera.ts ***!
  21805. \******************************/
  21806. /*! exports provided: FlyCamera */
  21807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21808. "use strict";
  21809. __webpack_require__.r(__webpack_exports__);
  21810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21811. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21812. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21813. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21814. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21815. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21816. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21817. /**
  21818. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21819. * such as in a 3D Space Shooter or a Flight Simulator.
  21820. */
  21821. var FlyCamera = /** @class */ (function (_super) {
  21822. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21823. /**
  21824. * Instantiates a FlyCamera.
  21825. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21826. * such as in a 3D Space Shooter or a Flight Simulator.
  21827. * @param name Define the name of the camera in the scene.
  21828. * @param position Define the starting position of the camera in the scene.
  21829. * @param scene Define the scene the camera belongs to.
  21830. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21831. */
  21832. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21833. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21834. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21835. /**
  21836. * Define the collision ellipsoid of the camera.
  21837. * This is helpful for simulating a camera body, like a player's body.
  21838. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21839. */
  21840. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21841. /**
  21842. * Define an offset for the position of the ellipsoid around the camera.
  21843. * This can be helpful if the camera is attached away from the player's body center,
  21844. * such as at its head.
  21845. */
  21846. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21847. /**
  21848. * Enable or disable collisions of the camera with the rest of the scene objects.
  21849. */
  21850. _this.checkCollisions = false;
  21851. /**
  21852. * Enable or disable gravity on the camera.
  21853. */
  21854. _this.applyGravity = false;
  21855. /**
  21856. * Define the current direction the camera is moving to.
  21857. */
  21858. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21859. /**
  21860. * Track Roll to maintain the wanted Rolling when looking around.
  21861. */
  21862. _this._trackRoll = 0;
  21863. /**
  21864. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21865. */
  21866. _this.rollCorrect = 100;
  21867. /**
  21868. * Mimic a banked turn, Rolling the camera when Yawing.
  21869. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21870. */
  21871. _this.bankedTurn = false;
  21872. /**
  21873. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21874. */
  21875. _this.bankedTurnLimit = Math.PI / 2;
  21876. /**
  21877. * Value of 0 disables the banked Roll.
  21878. * Value of 1 is equal to the Yaw angle in radians.
  21879. */
  21880. _this.bankedTurnMultiplier = 1;
  21881. _this._needMoveForGravity = false;
  21882. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21883. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21884. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21885. // Collisions.
  21886. _this._collisionMask = -1;
  21887. /** @hidden */
  21888. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21889. if (collidedMesh === void 0) { collidedMesh = null; }
  21890. var updatePosition = function (newPos) {
  21891. _this._newPosition.copyFrom(newPos);
  21892. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21893. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21894. _this.position.addInPlace(_this._diffPosition);
  21895. if (_this.onCollide && collidedMesh) {
  21896. _this.onCollide(collidedMesh);
  21897. }
  21898. }
  21899. };
  21900. updatePosition(newPosition);
  21901. };
  21902. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21903. _this.inputs.addKeyboard().addMouse();
  21904. return _this;
  21905. }
  21906. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21907. /**
  21908. * Gets the input sensibility for mouse input.
  21909. * Higher values reduce sensitivity.
  21910. */
  21911. get: function () {
  21912. var mouse = this.inputs.attached["mouse"];
  21913. if (mouse) {
  21914. return mouse.angularSensibility;
  21915. }
  21916. return 0;
  21917. },
  21918. /**
  21919. * Sets the input sensibility for a mouse input.
  21920. * Higher values reduce sensitivity.
  21921. */
  21922. set: function (value) {
  21923. var mouse = this.inputs.attached["mouse"];
  21924. if (mouse) {
  21925. mouse.angularSensibility = value;
  21926. }
  21927. },
  21928. enumerable: true,
  21929. configurable: true
  21930. });
  21931. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21932. /**
  21933. * Get the keys for camera movement forward.
  21934. */
  21935. get: function () {
  21936. var keyboard = this.inputs.attached["keyboard"];
  21937. if (keyboard) {
  21938. return keyboard.keysForward;
  21939. }
  21940. return [];
  21941. },
  21942. /**
  21943. * Set the keys for camera movement forward.
  21944. */
  21945. set: function (value) {
  21946. var keyboard = this.inputs.attached["keyboard"];
  21947. if (keyboard) {
  21948. keyboard.keysForward = value;
  21949. }
  21950. },
  21951. enumerable: true,
  21952. configurable: true
  21953. });
  21954. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21955. /**
  21956. * Get the keys for camera movement backward.
  21957. */
  21958. get: function () {
  21959. var keyboard = this.inputs.attached["keyboard"];
  21960. if (keyboard) {
  21961. return keyboard.keysBackward;
  21962. }
  21963. return [];
  21964. },
  21965. set: function (value) {
  21966. var keyboard = this.inputs.attached["keyboard"];
  21967. if (keyboard) {
  21968. keyboard.keysBackward = value;
  21969. }
  21970. },
  21971. enumerable: true,
  21972. configurable: true
  21973. });
  21974. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21975. /**
  21976. * Get the keys for camera movement up.
  21977. */
  21978. get: function () {
  21979. var keyboard = this.inputs.attached["keyboard"];
  21980. if (keyboard) {
  21981. return keyboard.keysUp;
  21982. }
  21983. return [];
  21984. },
  21985. /**
  21986. * Set the keys for camera movement up.
  21987. */
  21988. set: function (value) {
  21989. var keyboard = this.inputs.attached["keyboard"];
  21990. if (keyboard) {
  21991. keyboard.keysUp = value;
  21992. }
  21993. },
  21994. enumerable: true,
  21995. configurable: true
  21996. });
  21997. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21998. /**
  21999. * Get the keys for camera movement down.
  22000. */
  22001. get: function () {
  22002. var keyboard = this.inputs.attached["keyboard"];
  22003. if (keyboard) {
  22004. return keyboard.keysDown;
  22005. }
  22006. return [];
  22007. },
  22008. /**
  22009. * Set the keys for camera movement down.
  22010. */
  22011. set: function (value) {
  22012. var keyboard = this.inputs.attached["keyboard"];
  22013. if (keyboard) {
  22014. keyboard.keysDown = value;
  22015. }
  22016. },
  22017. enumerable: true,
  22018. configurable: true
  22019. });
  22020. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  22021. /**
  22022. * Get the keys for camera movement left.
  22023. */
  22024. get: function () {
  22025. var keyboard = this.inputs.attached["keyboard"];
  22026. if (keyboard) {
  22027. return keyboard.keysLeft;
  22028. }
  22029. return [];
  22030. },
  22031. /**
  22032. * Set the keys for camera movement left.
  22033. */
  22034. set: function (value) {
  22035. var keyboard = this.inputs.attached["keyboard"];
  22036. if (keyboard) {
  22037. keyboard.keysLeft = value;
  22038. }
  22039. },
  22040. enumerable: true,
  22041. configurable: true
  22042. });
  22043. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22044. /**
  22045. * Set the keys for camera movement right.
  22046. */
  22047. get: function () {
  22048. var keyboard = this.inputs.attached["keyboard"];
  22049. if (keyboard) {
  22050. return keyboard.keysRight;
  22051. }
  22052. return [];
  22053. },
  22054. /**
  22055. * Set the keys for camera movement right.
  22056. */
  22057. set: function (value) {
  22058. var keyboard = this.inputs.attached["keyboard"];
  22059. if (keyboard) {
  22060. keyboard.keysRight = value;
  22061. }
  22062. },
  22063. enumerable: true,
  22064. configurable: true
  22065. });
  22066. /**
  22067. * Attach a control to the HTML DOM element.
  22068. * @param element Defines the element that listens to the input events.
  22069. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22070. */
  22071. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22072. this.inputs.attachElement(element, noPreventDefault);
  22073. };
  22074. /**
  22075. * Detach a control from the HTML DOM element.
  22076. * The camera will stop reacting to that input.
  22077. * @param element Defines the element that listens to the input events.
  22078. */
  22079. FlyCamera.prototype.detachControl = function (element) {
  22080. this.inputs.detachElement(element);
  22081. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22082. };
  22083. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22084. /**
  22085. * Get the mask that the camera ignores in collision events.
  22086. */
  22087. get: function () {
  22088. return this._collisionMask;
  22089. },
  22090. /**
  22091. * Set the mask that the camera ignores in collision events.
  22092. */
  22093. set: function (mask) {
  22094. this._collisionMask = !isNaN(mask) ? mask : -1;
  22095. },
  22096. enumerable: true,
  22097. configurable: true
  22098. });
  22099. /** @hidden */
  22100. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22101. var globalPosition;
  22102. if (this.parent) {
  22103. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22104. }
  22105. else {
  22106. globalPosition = this.position;
  22107. }
  22108. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22109. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22110. var coordinator = this.getScene().collisionCoordinator;
  22111. if (!this._collider) {
  22112. this._collider = coordinator.createCollider();
  22113. }
  22114. this._collider._radius = this.ellipsoid;
  22115. this._collider.collisionMask = this._collisionMask;
  22116. // No need for clone, as long as gravity is not on.
  22117. var actualDisplacement = displacement;
  22118. // Add gravity to direction to prevent dual-collision checking.
  22119. if (this.applyGravity) {
  22120. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22121. actualDisplacement = displacement.add(this.getScene().gravity);
  22122. }
  22123. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22124. };
  22125. /** @hidden */
  22126. FlyCamera.prototype._checkInputs = function () {
  22127. if (!this._localDirection) {
  22128. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22129. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22130. }
  22131. this.inputs.checkInputs();
  22132. _super.prototype._checkInputs.call(this);
  22133. };
  22134. /** @hidden */
  22135. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22136. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22137. };
  22138. /** @hidden */
  22139. FlyCamera.prototype._updatePosition = function () {
  22140. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22141. this._collideWithWorld(this.cameraDirection);
  22142. }
  22143. else {
  22144. _super.prototype._updatePosition.call(this);
  22145. }
  22146. };
  22147. /**
  22148. * Restore the Roll to its target value at the rate specified.
  22149. * @param rate - Higher means slower restoring.
  22150. * @hidden
  22151. */
  22152. FlyCamera.prototype.restoreRoll = function (rate) {
  22153. var limit = this._trackRoll; // Target Roll.
  22154. var z = this.rotation.z; // Current Roll.
  22155. var delta = limit - z; // Difference in Roll.
  22156. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22157. // If the difference is noticable, restore the Roll.
  22158. if (Math.abs(delta) >= minRad) {
  22159. // Change Z rotation towards the target Roll.
  22160. this.rotation.z += delta / rate;
  22161. // Match when near enough.
  22162. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22163. this.rotation.z = limit;
  22164. }
  22165. }
  22166. };
  22167. /**
  22168. * Destroy the camera and release the current resources held by it.
  22169. */
  22170. FlyCamera.prototype.dispose = function () {
  22171. this.inputs.clear();
  22172. _super.prototype.dispose.call(this);
  22173. };
  22174. /**
  22175. * Get the current object class name.
  22176. * @returns the class name.
  22177. */
  22178. FlyCamera.prototype.getClassName = function () {
  22179. return "FlyCamera";
  22180. };
  22181. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22182. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22183. ], FlyCamera.prototype, "ellipsoid", void 0);
  22184. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22185. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22186. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22187. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22188. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22189. ], FlyCamera.prototype, "checkCollisions", void 0);
  22190. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22191. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22192. ], FlyCamera.prototype, "applyGravity", void 0);
  22193. return FlyCamera;
  22194. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22195. /***/ }),
  22196. /***/ "./Cameras/flyCameraInputsManager.ts":
  22197. /*!*******************************************!*\
  22198. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22199. \*******************************************/
  22200. /*! exports provided: FlyCameraInputsManager */
  22201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22202. "use strict";
  22203. __webpack_require__.r(__webpack_exports__);
  22204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22205. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22206. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22207. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22208. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22209. /**
  22210. * Default Inputs manager for the FlyCamera.
  22211. * It groups all the default supported inputs for ease of use.
  22212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22213. */
  22214. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22215. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22216. /**
  22217. * Instantiates a new FlyCameraInputsManager.
  22218. * @param camera Defines the camera the inputs belong to.
  22219. */
  22220. function FlyCameraInputsManager(camera) {
  22221. return _super.call(this, camera) || this;
  22222. }
  22223. /**
  22224. * Add keyboard input support to the input manager.
  22225. * @returns the new FlyCameraKeyboardMoveInput().
  22226. */
  22227. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22228. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22229. return this;
  22230. };
  22231. /**
  22232. * Add mouse input support to the input manager.
  22233. * @param touchEnabled Enable touch screen support.
  22234. * @returns the new FlyCameraMouseInput().
  22235. */
  22236. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22237. if (touchEnabled === void 0) { touchEnabled = true; }
  22238. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22239. return this;
  22240. };
  22241. return FlyCameraInputsManager;
  22242. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22243. /***/ }),
  22244. /***/ "./Cameras/followCamera.ts":
  22245. /*!*********************************!*\
  22246. !*** ./Cameras/followCamera.ts ***!
  22247. \*********************************/
  22248. /*! exports provided: FollowCamera, ArcFollowCamera */
  22249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22250. "use strict";
  22251. __webpack_require__.r(__webpack_exports__);
  22252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22254. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22255. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22256. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22257. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22258. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22259. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22260. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22261. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22262. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22263. });
  22264. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22265. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22266. });
  22267. /**
  22268. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22269. * an arc rotate version arcFollowCamera are available.
  22270. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22271. */
  22272. var FollowCamera = /** @class */ (function (_super) {
  22273. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22274. /**
  22275. * Instantiates the follow camera.
  22276. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22277. * @param name Define the name of the camera in the scene
  22278. * @param position Define the position of the camera
  22279. * @param scene Define the scene the camera belong to
  22280. * @param lockedTarget Define the target of the camera
  22281. */
  22282. function FollowCamera(name, position, scene, lockedTarget) {
  22283. if (lockedTarget === void 0) { lockedTarget = null; }
  22284. var _this = _super.call(this, name, position, scene) || this;
  22285. /**
  22286. * Distance the follow camera should follow an object at
  22287. */
  22288. _this.radius = 12;
  22289. /**
  22290. * Minimum allowed distance of the camera to the axis of rotation
  22291. * (The camera can not get closer).
  22292. * This can help limiting how the Camera is able to move in the scene.
  22293. */
  22294. _this.lowerRadiusLimit = null;
  22295. /**
  22296. * Maximum allowed distance of the camera to the axis of rotation
  22297. * (The camera can not get further).
  22298. * This can help limiting how the Camera is able to move in the scene.
  22299. */
  22300. _this.upperRadiusLimit = null;
  22301. /**
  22302. * Define a rotation offset between the camera and the object it follows
  22303. */
  22304. _this.rotationOffset = 0;
  22305. /**
  22306. * Minimum allowed angle to camera position relative to target object.
  22307. * This can help limiting how the Camera is able to move in the scene.
  22308. */
  22309. _this.lowerRotationOffsetLimit = null;
  22310. /**
  22311. * Maximum allowed angle to camera position relative to target object.
  22312. * This can help limiting how the Camera is able to move in the scene.
  22313. */
  22314. _this.upperRotationOffsetLimit = null;
  22315. /**
  22316. * Define a height offset between the camera and the object it follows.
  22317. * It can help following an object from the top (like a car chaing a plane)
  22318. */
  22319. _this.heightOffset = 4;
  22320. /**
  22321. * Minimum allowed height of camera position relative to target object.
  22322. * This can help limiting how the Camera is able to move in the scene.
  22323. */
  22324. _this.lowerHeightOffsetLimit = null;
  22325. /**
  22326. * Maximum allowed height of camera position relative to target object.
  22327. * This can help limiting how the Camera is able to move in the scene.
  22328. */
  22329. _this.upperHeightOffsetLimit = null;
  22330. /**
  22331. * Define how fast the camera can accelerate to follow it s target.
  22332. */
  22333. _this.cameraAcceleration = 0.05;
  22334. /**
  22335. * Define the speed limit of the camera following an object.
  22336. */
  22337. _this.maxCameraSpeed = 20;
  22338. _this.lockedTarget = lockedTarget;
  22339. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22340. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22341. return _this;
  22342. // Uncomment the following line when the relevant handlers have been implemented.
  22343. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22344. }
  22345. FollowCamera.prototype._follow = function (cameraTarget) {
  22346. if (!cameraTarget) {
  22347. return;
  22348. }
  22349. var yRotation;
  22350. if (cameraTarget.rotationQuaternion) {
  22351. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22352. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22353. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22354. }
  22355. else {
  22356. yRotation = cameraTarget.rotation.y;
  22357. }
  22358. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22359. var targetPosition = cameraTarget.getAbsolutePosition();
  22360. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22361. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22362. var dx = targetX - this.position.x;
  22363. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22364. var dz = (targetZ) - this.position.z;
  22365. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22366. var vy = dy * this.cameraAcceleration;
  22367. var vz = dz * this.cameraAcceleration * 2;
  22368. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22369. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22370. }
  22371. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22372. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22373. }
  22374. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22375. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22376. }
  22377. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22378. this.setTarget(targetPosition);
  22379. };
  22380. /**
  22381. * Attached controls to the current camera.
  22382. * @param element Defines the element the controls should be listened from
  22383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22384. */
  22385. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22386. this.inputs.attachElement(element, noPreventDefault);
  22387. this._reset = function () {
  22388. };
  22389. };
  22390. /**
  22391. * Detach the current controls from the camera.
  22392. * The camera will stop reacting to inputs.
  22393. * @param element Defines the element to stop listening the inputs from
  22394. */
  22395. FollowCamera.prototype.detachControl = function (element) {
  22396. this.inputs.detachElement(element);
  22397. if (this._reset) {
  22398. this._reset();
  22399. }
  22400. };
  22401. /** @hidden */
  22402. FollowCamera.prototype._checkInputs = function () {
  22403. this.inputs.checkInputs();
  22404. this._checkLimits();
  22405. _super.prototype._checkInputs.call(this);
  22406. if (this.lockedTarget) {
  22407. this._follow(this.lockedTarget);
  22408. }
  22409. };
  22410. FollowCamera.prototype._checkLimits = function () {
  22411. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22412. this.radius = this.lowerRadiusLimit;
  22413. }
  22414. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22415. this.radius = this.upperRadiusLimit;
  22416. }
  22417. if (this.lowerHeightOffsetLimit !== null &&
  22418. this.heightOffset < this.lowerHeightOffsetLimit) {
  22419. this.heightOffset = this.lowerHeightOffsetLimit;
  22420. }
  22421. if (this.upperHeightOffsetLimit !== null &&
  22422. this.heightOffset > this.upperHeightOffsetLimit) {
  22423. this.heightOffset = this.upperHeightOffsetLimit;
  22424. }
  22425. if (this.lowerRotationOffsetLimit !== null &&
  22426. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22427. this.rotationOffset = this.lowerRotationOffsetLimit;
  22428. }
  22429. if (this.upperRotationOffsetLimit !== null &&
  22430. this.rotationOffset > this.upperRotationOffsetLimit) {
  22431. this.rotationOffset = this.upperRotationOffsetLimit;
  22432. }
  22433. };
  22434. /**
  22435. * Gets the camera class name.
  22436. * @returns the class name
  22437. */
  22438. FollowCamera.prototype.getClassName = function () {
  22439. return "FollowCamera";
  22440. };
  22441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22443. ], FollowCamera.prototype, "radius", void 0);
  22444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22446. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22449. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22452. ], FollowCamera.prototype, "rotationOffset", void 0);
  22453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22455. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22458. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22461. ], FollowCamera.prototype, "heightOffset", void 0);
  22462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22464. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22467. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22470. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22473. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22476. ], FollowCamera.prototype, "lockedTarget", void 0);
  22477. return FollowCamera;
  22478. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22479. /**
  22480. * Arc Rotate version of the follow camera.
  22481. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22482. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22483. */
  22484. var ArcFollowCamera = /** @class */ (function (_super) {
  22485. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22486. /**
  22487. * Instantiates a new ArcFollowCamera
  22488. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22489. * @param name Define the name of the camera
  22490. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22491. * @param beta Define the rotation angle of the camera around the elevation axis
  22492. * @param radius Define the radius of the camera from its target point
  22493. * @param target Define the target of the camera
  22494. * @param scene Define the scene the camera belongs to
  22495. */
  22496. function ArcFollowCamera(name,
  22497. /** The longitudinal angle of the camera */
  22498. alpha,
  22499. /** The latitudinal angle of the camera */
  22500. beta,
  22501. /** The radius of the camera from its target */
  22502. radius,
  22503. /** Define the camera target (the messh it should follow) */
  22504. target, scene) {
  22505. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22506. _this.alpha = alpha;
  22507. _this.beta = beta;
  22508. _this.radius = radius;
  22509. _this.target = target;
  22510. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22511. _this._follow();
  22512. return _this;
  22513. }
  22514. ArcFollowCamera.prototype._follow = function () {
  22515. if (!this.target) {
  22516. return;
  22517. }
  22518. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22519. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22520. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22521. var targetPosition = this.target.getAbsolutePosition();
  22522. this.position = targetPosition.add(this._cartesianCoordinates);
  22523. this.setTarget(targetPosition);
  22524. };
  22525. /** @hidden */
  22526. ArcFollowCamera.prototype._checkInputs = function () {
  22527. _super.prototype._checkInputs.call(this);
  22528. this._follow();
  22529. };
  22530. /**
  22531. * Returns the class name of the object.
  22532. * It is mostly used internally for serialization purposes.
  22533. */
  22534. ArcFollowCamera.prototype.getClassName = function () {
  22535. return "ArcFollowCamera";
  22536. };
  22537. return ArcFollowCamera;
  22538. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22539. /***/ }),
  22540. /***/ "./Cameras/followCameraInputsManager.ts":
  22541. /*!**********************************************!*\
  22542. !*** ./Cameras/followCameraInputsManager.ts ***!
  22543. \**********************************************/
  22544. /*! exports provided: FollowCameraInputsManager */
  22545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22546. "use strict";
  22547. __webpack_require__.r(__webpack_exports__);
  22548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22550. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22551. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22552. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22553. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22554. /**
  22555. * Default Inputs manager for the FollowCamera.
  22556. * It groups all the default supported inputs for ease of use.
  22557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22558. */
  22559. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22561. /**
  22562. * Instantiates a new FollowCameraInputsManager.
  22563. * @param camera Defines the camera the inputs belong to
  22564. */
  22565. function FollowCameraInputsManager(camera) {
  22566. return _super.call(this, camera) || this;
  22567. }
  22568. /**
  22569. * Add keyboard input support to the input manager.
  22570. * @returns the current input manager
  22571. */
  22572. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22573. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22574. return this;
  22575. };
  22576. /**
  22577. * Add mouse wheel input support to the input manager.
  22578. * @returns the current input manager
  22579. */
  22580. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22581. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22582. return this;
  22583. };
  22584. /**
  22585. * Add pointers input support to the input manager.
  22586. * @returns the current input manager
  22587. */
  22588. FollowCameraInputsManager.prototype.addPointers = function () {
  22589. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22590. return this;
  22591. };
  22592. /**
  22593. * Add orientation input support to the input manager.
  22594. * @returns the current input manager
  22595. */
  22596. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22597. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22598. return this;
  22599. };
  22600. return FollowCameraInputsManager;
  22601. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22602. /***/ }),
  22603. /***/ "./Cameras/freeCamera.ts":
  22604. /*!*******************************!*\
  22605. !*** ./Cameras/freeCamera.ts ***!
  22606. \*******************************/
  22607. /*! exports provided: FreeCamera */
  22608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22609. "use strict";
  22610. __webpack_require__.r(__webpack_exports__);
  22611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22612. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22613. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22614. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22615. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22616. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22617. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22618. /**
  22619. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22620. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22621. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22622. */
  22623. var FreeCamera = /** @class */ (function (_super) {
  22624. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22625. /**
  22626. * Instantiates a Free Camera.
  22627. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22628. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22629. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22630. * @param name Define the name of the camera in the scene
  22631. * @param position Define the start position of the camera in the scene
  22632. * @param scene Define the scene the camera belongs to
  22633. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22634. */
  22635. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22636. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22637. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22638. /**
  22639. * Define the collision ellipsoid of the camera.
  22640. * This is helpful to simulate a camera body like the player body around the camera
  22641. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22642. */
  22643. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22644. /**
  22645. * Define an offset for the position of the ellipsoid around the camera.
  22646. * This can be helpful to determine the center of the body near the gravity center of the body
  22647. * instead of its head.
  22648. */
  22649. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22650. /**
  22651. * Enable or disable collisions of the camera with the rest of the scene objects.
  22652. */
  22653. _this.checkCollisions = false;
  22654. /**
  22655. * Enable or disable gravity on the camera.
  22656. */
  22657. _this.applyGravity = false;
  22658. _this._needMoveForGravity = false;
  22659. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22660. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22661. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22662. // Collisions
  22663. _this._collisionMask = -1;
  22664. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22665. if (collidedMesh === void 0) { collidedMesh = null; }
  22666. var updatePosition = function (newPos) {
  22667. _this._newPosition.copyFrom(newPos);
  22668. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22669. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22670. _this.position.addInPlace(_this._diffPosition);
  22671. if (_this.onCollide && collidedMesh) {
  22672. _this.onCollide(collidedMesh);
  22673. }
  22674. }
  22675. };
  22676. updatePosition(newPosition);
  22677. };
  22678. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22679. _this.inputs.addKeyboard().addMouse();
  22680. return _this;
  22681. }
  22682. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22683. /**
  22684. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22685. * Higher values reduce sensitivity.
  22686. */
  22687. get: function () {
  22688. var mouse = this.inputs.attached["mouse"];
  22689. if (mouse) {
  22690. return mouse.angularSensibility;
  22691. }
  22692. return 0;
  22693. },
  22694. /**
  22695. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22696. * Higher values reduce sensitivity.
  22697. */
  22698. set: function (value) {
  22699. var mouse = this.inputs.attached["mouse"];
  22700. if (mouse) {
  22701. mouse.angularSensibility = value;
  22702. }
  22703. },
  22704. enumerable: true,
  22705. configurable: true
  22706. });
  22707. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22708. /**
  22709. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22710. */
  22711. get: function () {
  22712. var keyboard = this.inputs.attached["keyboard"];
  22713. if (keyboard) {
  22714. return keyboard.keysUp;
  22715. }
  22716. return [];
  22717. },
  22718. set: function (value) {
  22719. var keyboard = this.inputs.attached["keyboard"];
  22720. if (keyboard) {
  22721. keyboard.keysUp = value;
  22722. }
  22723. },
  22724. enumerable: true,
  22725. configurable: true
  22726. });
  22727. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22728. /**
  22729. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22730. */
  22731. get: function () {
  22732. var keyboard = this.inputs.attached["keyboard"];
  22733. if (keyboard) {
  22734. return keyboard.keysDown;
  22735. }
  22736. return [];
  22737. },
  22738. set: function (value) {
  22739. var keyboard = this.inputs.attached["keyboard"];
  22740. if (keyboard) {
  22741. keyboard.keysDown = value;
  22742. }
  22743. },
  22744. enumerable: true,
  22745. configurable: true
  22746. });
  22747. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22748. /**
  22749. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22750. */
  22751. get: function () {
  22752. var keyboard = this.inputs.attached["keyboard"];
  22753. if (keyboard) {
  22754. return keyboard.keysLeft;
  22755. }
  22756. return [];
  22757. },
  22758. set: function (value) {
  22759. var keyboard = this.inputs.attached["keyboard"];
  22760. if (keyboard) {
  22761. keyboard.keysLeft = value;
  22762. }
  22763. },
  22764. enumerable: true,
  22765. configurable: true
  22766. });
  22767. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22768. /**
  22769. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22770. */
  22771. get: function () {
  22772. var keyboard = this.inputs.attached["keyboard"];
  22773. if (keyboard) {
  22774. return keyboard.keysRight;
  22775. }
  22776. return [];
  22777. },
  22778. set: function (value) {
  22779. var keyboard = this.inputs.attached["keyboard"];
  22780. if (keyboard) {
  22781. keyboard.keysRight = value;
  22782. }
  22783. },
  22784. enumerable: true,
  22785. configurable: true
  22786. });
  22787. /**
  22788. * Attached controls to the current camera.
  22789. * @param element Defines the element the controls should be listened from
  22790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22791. */
  22792. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22793. this.inputs.attachElement(element, noPreventDefault);
  22794. };
  22795. /**
  22796. * Detach the current controls from the camera.
  22797. * The camera will stop reacting to inputs.
  22798. * @param element Defines the element to stop listening the inputs from
  22799. */
  22800. FreeCamera.prototype.detachControl = function (element) {
  22801. this.inputs.detachElement(element);
  22802. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22803. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22804. };
  22805. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22806. /**
  22807. * Define a collision mask to limit the list of object the camera can collide with
  22808. */
  22809. get: function () {
  22810. return this._collisionMask;
  22811. },
  22812. set: function (mask) {
  22813. this._collisionMask = !isNaN(mask) ? mask : -1;
  22814. },
  22815. enumerable: true,
  22816. configurable: true
  22817. });
  22818. /** @hidden */
  22819. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22820. var globalPosition;
  22821. if (this.parent) {
  22822. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22823. }
  22824. else {
  22825. globalPosition = this.position;
  22826. }
  22827. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22828. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22829. var coordinator = this.getScene().collisionCoordinator;
  22830. if (!this._collider) {
  22831. this._collider = coordinator.createCollider();
  22832. }
  22833. this._collider._radius = this.ellipsoid;
  22834. this._collider.collisionMask = this._collisionMask;
  22835. //no need for clone, as long as gravity is not on.
  22836. var actualDisplacement = displacement;
  22837. //add gravity to the direction to prevent the dual-collision checking
  22838. if (this.applyGravity) {
  22839. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22840. actualDisplacement = displacement.add(this.getScene().gravity);
  22841. }
  22842. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22843. };
  22844. /** @hidden */
  22845. FreeCamera.prototype._checkInputs = function () {
  22846. if (!this._localDirection) {
  22847. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22848. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22849. }
  22850. this.inputs.checkInputs();
  22851. _super.prototype._checkInputs.call(this);
  22852. };
  22853. /** @hidden */
  22854. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22855. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22856. };
  22857. /** @hidden */
  22858. FreeCamera.prototype._updatePosition = function () {
  22859. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22860. this._collideWithWorld(this.cameraDirection);
  22861. }
  22862. else {
  22863. _super.prototype._updatePosition.call(this);
  22864. }
  22865. };
  22866. /**
  22867. * Destroy the camera and release the current resources hold by it.
  22868. */
  22869. FreeCamera.prototype.dispose = function () {
  22870. this.inputs.clear();
  22871. _super.prototype.dispose.call(this);
  22872. };
  22873. /**
  22874. * Gets the current object class name.
  22875. * @return the class name
  22876. */
  22877. FreeCamera.prototype.getClassName = function () {
  22878. return "FreeCamera";
  22879. };
  22880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22882. ], FreeCamera.prototype, "ellipsoid", void 0);
  22883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22885. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22888. ], FreeCamera.prototype, "checkCollisions", void 0);
  22889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22891. ], FreeCamera.prototype, "applyGravity", void 0);
  22892. return FreeCamera;
  22893. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22894. /***/ }),
  22895. /***/ "./Cameras/freeCameraInputsManager.ts":
  22896. /*!********************************************!*\
  22897. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22898. \********************************************/
  22899. /*! exports provided: FreeCameraInputsManager */
  22900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22901. "use strict";
  22902. __webpack_require__.r(__webpack_exports__);
  22903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22904. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22905. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22906. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22907. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22908. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22909. /**
  22910. * Default Inputs manager for the FreeCamera.
  22911. * It groups all the default supported inputs for ease of use.
  22912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22913. */
  22914. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22915. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22916. /**
  22917. * Instantiates a new FreeCameraInputsManager.
  22918. * @param camera Defines the camera the inputs belong to
  22919. */
  22920. function FreeCameraInputsManager(camera) {
  22921. return _super.call(this, camera) || this;
  22922. }
  22923. /**
  22924. * Add keyboard input support to the input manager.
  22925. * @returns the current input manager
  22926. */
  22927. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22928. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22929. return this;
  22930. };
  22931. /**
  22932. * Add mouse input support to the input manager.
  22933. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22934. * @returns the current input manager
  22935. */
  22936. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22937. if (touchEnabled === void 0) { touchEnabled = true; }
  22938. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22939. return this;
  22940. };
  22941. /**
  22942. * Add touch input support to the input manager.
  22943. * @returns the current input manager
  22944. */
  22945. FreeCameraInputsManager.prototype.addTouch = function () {
  22946. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22947. return this;
  22948. };
  22949. return FreeCameraInputsManager;
  22950. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22951. /***/ }),
  22952. /***/ "./Cameras/gamepadCamera.ts":
  22953. /*!**********************************!*\
  22954. !*** ./Cameras/gamepadCamera.ts ***!
  22955. \**********************************/
  22956. /*! exports provided: GamepadCamera */
  22957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22958. "use strict";
  22959. __webpack_require__.r(__webpack_exports__);
  22960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22961. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22962. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22963. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22964. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22965. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22966. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22967. });
  22968. /**
  22969. * This represents a FPS type of camera. This is only here for back compat purpose.
  22970. * Please use the UniversalCamera instead as both are identical.
  22971. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22972. */
  22973. var GamepadCamera = /** @class */ (function (_super) {
  22974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22975. /**
  22976. * Instantiates a new Gamepad Camera
  22977. * This represents a FPS type of camera. This is only here for back compat purpose.
  22978. * Please use the UniversalCamera instead as both are identical.
  22979. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22980. * @param name Define the name of the camera in the scene
  22981. * @param position Define the start position of the camera in the scene
  22982. * @param scene Define the scene the camera belongs to
  22983. */
  22984. function GamepadCamera(name, position, scene) {
  22985. return _super.call(this, name, position, scene) || this;
  22986. }
  22987. /**
  22988. * Gets the current object class name.
  22989. * @return the class name
  22990. */
  22991. GamepadCamera.prototype.getClassName = function () {
  22992. return "GamepadCamera";
  22993. };
  22994. return GamepadCamera;
  22995. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22996. /***/ }),
  22997. /***/ "./Cameras/index.ts":
  22998. /*!**************************!*\
  22999. !*** ./Cameras/index.ts ***!
  23000. \**************************/
  23001. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  23002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23003. "use strict";
  23004. __webpack_require__.r(__webpack_exports__);
  23005. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  23006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  23007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  23008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  23009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  23010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  23011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  23012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  23013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  23014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  23015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  23016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  23017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  23018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  23019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  23020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  23021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  23022. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  23024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  23025. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  23027. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  23029. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  23031. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  23033. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  23035. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  23036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  23037. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  23038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  23039. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23041. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23043. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23045. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23048. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23050. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23059. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23061. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23063. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23071. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23082. /***/ }),
  23083. /***/ "./Cameras/targetCamera.ts":
  23084. /*!*********************************!*\
  23085. !*** ./Cameras/targetCamera.ts ***!
  23086. \*********************************/
  23087. /*! exports provided: TargetCamera */
  23088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23089. "use strict";
  23090. __webpack_require__.r(__webpack_exports__);
  23091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23092. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23093. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23094. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23095. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23096. /**
  23097. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23098. * This is the base of the follow, arc rotate cameras and Free camera
  23099. * @see http://doc.babylonjs.com/features/cameras
  23100. */
  23101. var TargetCamera = /** @class */ (function (_super) {
  23102. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23103. /**
  23104. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23105. * This is the base of the follow, arc rotate cameras and Free camera
  23106. * @see http://doc.babylonjs.com/features/cameras
  23107. * @param name Defines the name of the camera in the scene
  23108. * @param position Defines the start position of the camera in the scene
  23109. * @param scene Defines the scene the camera belongs to
  23110. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23111. */
  23112. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23113. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23114. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23115. /**
  23116. * Define the current direction the camera is moving to
  23117. */
  23118. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23119. /**
  23120. * Define the current rotation the camera is rotating to
  23121. */
  23122. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23123. /**
  23124. * When set, the up vector of the camera will be updated by the rotation of the camera
  23125. */
  23126. _this.updateUpVectorFromRotation = false;
  23127. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23128. /**
  23129. * Define the current rotation of the camera
  23130. */
  23131. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23132. /**
  23133. * Define the current speed of the camera
  23134. */
  23135. _this.speed = 2.0;
  23136. /**
  23137. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23138. * around all axis.
  23139. */
  23140. _this.noRotationConstraint = false;
  23141. /**
  23142. * Define the current target of the camera as an object or a position.
  23143. */
  23144. _this.lockedTarget = null;
  23145. /** @hidden */
  23146. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23147. /** @hidden */
  23148. _this._initialFocalDistance = 1;
  23149. /** @hidden */
  23150. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23151. /** @hidden */
  23152. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23153. /** @hidden */
  23154. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23155. /** @hidden */
  23156. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23157. /** @hidden */
  23158. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23159. /** @hidden */
  23160. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23161. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23162. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23163. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23164. _this._cachedRotationZ = 0;
  23165. _this._cachedQuaternionRotationZ = 0;
  23166. return _this;
  23167. }
  23168. /**
  23169. * Gets the position in front of the camera at a given distance.
  23170. * @param distance The distance from the camera we want the position to be
  23171. * @returns the position
  23172. */
  23173. TargetCamera.prototype.getFrontPosition = function (distance) {
  23174. this.getWorldMatrix();
  23175. var direction = this.getTarget().subtract(this.position);
  23176. direction.normalize();
  23177. direction.scaleInPlace(distance);
  23178. return this.globalPosition.add(direction);
  23179. };
  23180. /** @hidden */
  23181. TargetCamera.prototype._getLockedTargetPosition = function () {
  23182. if (!this.lockedTarget) {
  23183. return null;
  23184. }
  23185. if (this.lockedTarget.absolutePosition) {
  23186. this.lockedTarget.computeWorldMatrix();
  23187. }
  23188. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23189. };
  23190. /**
  23191. * Store current camera state of the camera (fov, position, rotation, etc..)
  23192. * @returns the camera
  23193. */
  23194. TargetCamera.prototype.storeState = function () {
  23195. this._storedPosition = this.position.clone();
  23196. this._storedRotation = this.rotation.clone();
  23197. if (this.rotationQuaternion) {
  23198. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23199. }
  23200. return _super.prototype.storeState.call(this);
  23201. };
  23202. /**
  23203. * Restored camera state. You must call storeState() first
  23204. * @returns whether it was successful or not
  23205. * @hidden
  23206. */
  23207. TargetCamera.prototype._restoreStateValues = function () {
  23208. if (!_super.prototype._restoreStateValues.call(this)) {
  23209. return false;
  23210. }
  23211. this.position = this._storedPosition.clone();
  23212. this.rotation = this._storedRotation.clone();
  23213. if (this.rotationQuaternion) {
  23214. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23215. }
  23216. this.cameraDirection.copyFromFloats(0, 0, 0);
  23217. this.cameraRotation.copyFromFloats(0, 0);
  23218. return true;
  23219. };
  23220. /** @hidden */
  23221. TargetCamera.prototype._initCache = function () {
  23222. _super.prototype._initCache.call(this);
  23223. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23224. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23225. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23226. };
  23227. /** @hidden */
  23228. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23229. if (!ignoreParentClass) {
  23230. _super.prototype._updateCache.call(this);
  23231. }
  23232. var lockedTargetPosition = this._getLockedTargetPosition();
  23233. if (!lockedTargetPosition) {
  23234. this._cache.lockedTarget = null;
  23235. }
  23236. else {
  23237. if (!this._cache.lockedTarget) {
  23238. this._cache.lockedTarget = lockedTargetPosition.clone();
  23239. }
  23240. else {
  23241. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23242. }
  23243. }
  23244. this._cache.rotation.copyFrom(this.rotation);
  23245. if (this.rotationQuaternion) {
  23246. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23247. }
  23248. };
  23249. // Synchronized
  23250. /** @hidden */
  23251. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23252. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23253. return false;
  23254. }
  23255. var lockedTargetPosition = this._getLockedTargetPosition();
  23256. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23257. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23258. };
  23259. // Methods
  23260. /** @hidden */
  23261. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23262. var engine = this.getEngine();
  23263. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23264. };
  23265. // Target
  23266. /**
  23267. * Defines the target the camera should look at.
  23268. * This will automatically adapt alpha beta and radius to fit within the new target.
  23269. * @param target Defines the new target as a Vector or a mesh
  23270. */
  23271. TargetCamera.prototype.setTarget = function (target) {
  23272. this.upVector.normalize();
  23273. this._initialFocalDistance = target.subtract(this.position).length();
  23274. if (this.position.z === target.z) {
  23275. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23276. }
  23277. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23278. this._camMatrix.invert();
  23279. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23280. var vDir = target.subtract(this.position);
  23281. if (vDir.x >= 0.0) {
  23282. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23283. }
  23284. else {
  23285. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23286. }
  23287. this.rotation.z = 0;
  23288. if (isNaN(this.rotation.x)) {
  23289. this.rotation.x = 0;
  23290. }
  23291. if (isNaN(this.rotation.y)) {
  23292. this.rotation.y = 0;
  23293. }
  23294. if (isNaN(this.rotation.z)) {
  23295. this.rotation.z = 0;
  23296. }
  23297. if (this.rotationQuaternion) {
  23298. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23299. }
  23300. };
  23301. /**
  23302. * Return the current target position of the camera. This value is expressed in local space.
  23303. * @returns the target position
  23304. */
  23305. TargetCamera.prototype.getTarget = function () {
  23306. return this._currentTarget;
  23307. };
  23308. /** @hidden */
  23309. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23310. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23311. };
  23312. /** @hidden */
  23313. TargetCamera.prototype._updatePosition = function () {
  23314. if (this.parent) {
  23315. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23316. _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]);
  23317. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23318. return;
  23319. }
  23320. this.position.addInPlace(this.cameraDirection);
  23321. };
  23322. /** @hidden */
  23323. TargetCamera.prototype._checkInputs = function () {
  23324. var needToMove = this._decideIfNeedsToMove();
  23325. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23326. // Move
  23327. if (needToMove) {
  23328. this._updatePosition();
  23329. }
  23330. // Rotate
  23331. if (needToRotate) {
  23332. this.rotation.x += this.cameraRotation.x;
  23333. this.rotation.y += this.cameraRotation.y;
  23334. //rotate, if quaternion is set and rotation was used
  23335. if (this.rotationQuaternion) {
  23336. var len = this.rotation.lengthSquared();
  23337. if (len) {
  23338. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23339. }
  23340. }
  23341. if (!this.noRotationConstraint) {
  23342. var limit = (Math.PI / 2) * 0.95;
  23343. if (this.rotation.x > limit) {
  23344. this.rotation.x = limit;
  23345. }
  23346. if (this.rotation.x < -limit) {
  23347. this.rotation.x = -limit;
  23348. }
  23349. }
  23350. }
  23351. // Inertia
  23352. if (needToMove) {
  23353. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23354. this.cameraDirection.x = 0;
  23355. }
  23356. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23357. this.cameraDirection.y = 0;
  23358. }
  23359. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23360. this.cameraDirection.z = 0;
  23361. }
  23362. this.cameraDirection.scaleInPlace(this.inertia);
  23363. }
  23364. if (needToRotate) {
  23365. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23366. this.cameraRotation.x = 0;
  23367. }
  23368. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23369. this.cameraRotation.y = 0;
  23370. }
  23371. this.cameraRotation.scaleInPlace(this.inertia);
  23372. }
  23373. _super.prototype._checkInputs.call(this);
  23374. };
  23375. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23376. if (this.rotationQuaternion) {
  23377. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23378. }
  23379. else {
  23380. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23381. }
  23382. };
  23383. /**
  23384. * 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)
  23385. * @returns the current camera
  23386. */
  23387. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23388. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23389. return this;
  23390. };
  23391. /** @hidden */
  23392. TargetCamera.prototype._getViewMatrix = function () {
  23393. if (this.lockedTarget) {
  23394. this.setTarget(this._getLockedTargetPosition());
  23395. }
  23396. // Compute
  23397. this._updateCameraRotationMatrix();
  23398. // Apply the changed rotation to the upVector
  23399. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23400. this._rotateUpVectorWithCameraRotationMatrix();
  23401. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23402. }
  23403. else if (this._cachedRotationZ != this.rotation.z) {
  23404. this._rotateUpVectorWithCameraRotationMatrix();
  23405. this._cachedRotationZ = this.rotation.z;
  23406. }
  23407. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23408. // Computing target and final matrix
  23409. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23410. if (this.updateUpVectorFromRotation) {
  23411. if (this.rotationQuaternion) {
  23412. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23413. }
  23414. else {
  23415. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23416. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23417. }
  23418. }
  23419. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23420. return this._viewMatrix;
  23421. };
  23422. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23423. if (this.parent) {
  23424. var parentWorldMatrix = this.parent.getWorldMatrix();
  23425. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23426. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23427. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23428. this._markSyncedWithParent();
  23429. }
  23430. else {
  23431. this._globalPosition.copyFrom(position);
  23432. this._globalCurrentTarget.copyFrom(target);
  23433. this._globalCurrentUpVector.copyFrom(up);
  23434. }
  23435. if (this.getScene().useRightHandedSystem) {
  23436. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23437. }
  23438. else {
  23439. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23440. }
  23441. };
  23442. /**
  23443. * @hidden
  23444. */
  23445. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23446. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23447. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23448. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23449. if (!this.rotationQuaternion) {
  23450. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23451. }
  23452. rigCamera._cameraRigParams = {};
  23453. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23454. }
  23455. return rigCamera;
  23456. }
  23457. return null;
  23458. };
  23459. /**
  23460. * @hidden
  23461. */
  23462. TargetCamera.prototype._updateRigCameras = function () {
  23463. var camLeft = this._rigCameras[0];
  23464. var camRight = this._rigCameras[1];
  23465. this.computeWorldMatrix();
  23466. switch (this.cameraRigMode) {
  23467. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23468. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23469. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23470. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23471. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23472. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23473. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23474. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23475. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23476. break;
  23477. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23478. if (camLeft.rotationQuaternion) {
  23479. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23480. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23481. }
  23482. else {
  23483. camLeft.rotation.copyFrom(this.rotation);
  23484. camRight.rotation.copyFrom(this.rotation);
  23485. }
  23486. camLeft.position.copyFrom(this.position);
  23487. camRight.position.copyFrom(this.position);
  23488. break;
  23489. }
  23490. _super.prototype._updateRigCameras.call(this);
  23491. };
  23492. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23493. var target = this.getTarget();
  23494. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23495. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23496. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23497. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23498. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23499. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23500. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23501. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23502. rigCamera.setTarget(newFocalTarget);
  23503. };
  23504. /**
  23505. * Gets the current object class name.
  23506. * @return the class name
  23507. */
  23508. TargetCamera.prototype.getClassName = function () {
  23509. return "TargetCamera";
  23510. };
  23511. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23512. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23513. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23514. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23515. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23516. ], TargetCamera.prototype, "rotation", void 0);
  23517. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23518. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23519. ], TargetCamera.prototype, "speed", void 0);
  23520. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23521. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23522. ], TargetCamera.prototype, "lockedTarget", void 0);
  23523. return TargetCamera;
  23524. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23525. /***/ }),
  23526. /***/ "./Cameras/touchCamera.ts":
  23527. /*!********************************!*\
  23528. !*** ./Cameras/touchCamera.ts ***!
  23529. \********************************/
  23530. /*! exports provided: TouchCamera */
  23531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23532. "use strict";
  23533. __webpack_require__.r(__webpack_exports__);
  23534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23536. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23537. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23538. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23539. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23540. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23541. });
  23542. /**
  23543. * This represents a FPS type of camera controlled by touch.
  23544. * This is like a universal camera minus the Gamepad controls.
  23545. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23546. */
  23547. var TouchCamera = /** @class */ (function (_super) {
  23548. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23549. /**
  23550. * Instantiates a new touch camera.
  23551. * This represents a FPS type of camera controlled by touch.
  23552. * This is like a universal camera minus the Gamepad controls.
  23553. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23554. * @param name Define the name of the camera in the scene
  23555. * @param position Define the start position of the camera in the scene
  23556. * @param scene Define the scene the camera belongs to
  23557. */
  23558. function TouchCamera(name, position, scene) {
  23559. var _this = _super.call(this, name, position, scene) || this;
  23560. _this.inputs.addTouch();
  23561. _this._setupInputs();
  23562. return _this;
  23563. }
  23564. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23565. /**
  23566. * Defines the touch sensibility for rotation.
  23567. * The higher the faster.
  23568. */
  23569. get: function () {
  23570. var touch = this.inputs.attached["touch"];
  23571. if (touch) {
  23572. return touch.touchAngularSensibility;
  23573. }
  23574. return 0;
  23575. },
  23576. set: function (value) {
  23577. var touch = this.inputs.attached["touch"];
  23578. if (touch) {
  23579. touch.touchAngularSensibility = value;
  23580. }
  23581. },
  23582. enumerable: true,
  23583. configurable: true
  23584. });
  23585. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23586. /**
  23587. * Defines the touch sensibility for move.
  23588. * The higher the faster.
  23589. */
  23590. get: function () {
  23591. var touch = this.inputs.attached["touch"];
  23592. if (touch) {
  23593. return touch.touchMoveSensibility;
  23594. }
  23595. return 0;
  23596. },
  23597. set: function (value) {
  23598. var touch = this.inputs.attached["touch"];
  23599. if (touch) {
  23600. touch.touchMoveSensibility = value;
  23601. }
  23602. },
  23603. enumerable: true,
  23604. configurable: true
  23605. });
  23606. /**
  23607. * Gets the current object class name.
  23608. * @return the class name
  23609. */
  23610. TouchCamera.prototype.getClassName = function () {
  23611. return "TouchCamera";
  23612. };
  23613. /** @hidden */
  23614. TouchCamera.prototype._setupInputs = function () {
  23615. var mouse = this.inputs.attached["mouse"];
  23616. if (mouse) {
  23617. mouse.touchEnabled = false;
  23618. }
  23619. };
  23620. return TouchCamera;
  23621. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23622. /***/ }),
  23623. /***/ "./Cameras/universalCamera.ts":
  23624. /*!************************************!*\
  23625. !*** ./Cameras/universalCamera.ts ***!
  23626. \************************************/
  23627. /*! exports provided: UniversalCamera */
  23628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23629. "use strict";
  23630. __webpack_require__.r(__webpack_exports__);
  23631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23632. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23633. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23634. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23635. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23636. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23637. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23638. // Forcing to use the Universal camera
  23639. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23640. });
  23641. /**
  23642. * 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,
  23643. * which still works and will still be found in many Playgrounds.
  23644. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23645. */
  23646. var UniversalCamera = /** @class */ (function (_super) {
  23647. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23648. /**
  23649. * 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,
  23650. * which still works and will still be found in many Playgrounds.
  23651. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23652. * @param name Define the name of the camera in the scene
  23653. * @param position Define the start position of the camera in the scene
  23654. * @param scene Define the scene the camera belongs to
  23655. */
  23656. function UniversalCamera(name, position, scene) {
  23657. var _this = _super.call(this, name, position, scene) || this;
  23658. _this.inputs.addGamepad();
  23659. return _this;
  23660. }
  23661. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23662. /**
  23663. * Defines the gamepad rotation sensiblity.
  23664. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23665. */
  23666. get: function () {
  23667. var gamepad = this.inputs.attached["gamepad"];
  23668. if (gamepad) {
  23669. return gamepad.gamepadAngularSensibility;
  23670. }
  23671. return 0;
  23672. },
  23673. set: function (value) {
  23674. var gamepad = this.inputs.attached["gamepad"];
  23675. if (gamepad) {
  23676. gamepad.gamepadAngularSensibility = value;
  23677. }
  23678. },
  23679. enumerable: true,
  23680. configurable: true
  23681. });
  23682. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23683. /**
  23684. * Defines the gamepad move sensiblity.
  23685. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23686. */
  23687. get: function () {
  23688. var gamepad = this.inputs.attached["gamepad"];
  23689. if (gamepad) {
  23690. return gamepad.gamepadMoveSensibility;
  23691. }
  23692. return 0;
  23693. },
  23694. set: function (value) {
  23695. var gamepad = this.inputs.attached["gamepad"];
  23696. if (gamepad) {
  23697. gamepad.gamepadMoveSensibility = value;
  23698. }
  23699. },
  23700. enumerable: true,
  23701. configurable: true
  23702. });
  23703. /**
  23704. * Gets the current object class name.
  23705. * @return the class name
  23706. */
  23707. UniversalCamera.prototype.getClassName = function () {
  23708. return "UniversalCamera";
  23709. };
  23710. return UniversalCamera;
  23711. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23712. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23713. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23714. };
  23715. /***/ }),
  23716. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23717. /*!*******************************************!*\
  23718. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23719. \*******************************************/
  23720. /*! exports provided: VirtualJoysticksCamera */
  23721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23722. "use strict";
  23723. __webpack_require__.r(__webpack_exports__);
  23724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23725. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23726. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23727. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23728. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23729. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23730. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23731. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23732. });
  23733. /**
  23734. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23735. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23736. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23737. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23738. */
  23739. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23740. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23741. /**
  23742. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23743. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23744. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23745. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23746. * @param name Define the name of the camera in the scene
  23747. * @param position Define the start position of the camera in the scene
  23748. * @param scene Define the scene the camera belongs to
  23749. */
  23750. function VirtualJoysticksCamera(name, position, scene) {
  23751. var _this = _super.call(this, name, position, scene) || this;
  23752. _this.inputs.addVirtualJoystick();
  23753. return _this;
  23754. }
  23755. /**
  23756. * Gets the current object class name.
  23757. * @return the class name
  23758. */
  23759. VirtualJoysticksCamera.prototype.getClassName = function () {
  23760. return "VirtualJoysticksCamera";
  23761. };
  23762. return VirtualJoysticksCamera;
  23763. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23764. /***/ }),
  23765. /***/ "./Collisions/collider.ts":
  23766. /*!********************************!*\
  23767. !*** ./Collisions/collider.ts ***!
  23768. \********************************/
  23769. /*! exports provided: Collider */
  23770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23771. "use strict";
  23772. __webpack_require__.r(__webpack_exports__);
  23773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23774. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23775. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23776. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23777. return false;
  23778. }
  23779. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23780. return false;
  23781. }
  23782. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23783. return false;
  23784. }
  23785. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23786. return false;
  23787. }
  23788. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23789. return false;
  23790. }
  23791. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23792. return false;
  23793. }
  23794. return true;
  23795. };
  23796. var getLowestRoot = (function () {
  23797. var result = { root: 0, found: false };
  23798. return function (a, b, c, maxR) {
  23799. result.root = 0;
  23800. result.found = false;
  23801. var determinant = b * b - 4.0 * a * c;
  23802. if (determinant < 0) {
  23803. return result;
  23804. }
  23805. var sqrtD = Math.sqrt(determinant);
  23806. var r1 = (-b - sqrtD) / (2.0 * a);
  23807. var r2 = (-b + sqrtD) / (2.0 * a);
  23808. if (r1 > r2) {
  23809. var temp = r2;
  23810. r2 = r1;
  23811. r1 = temp;
  23812. }
  23813. if (r1 > 0 && r1 < maxR) {
  23814. result.root = r1;
  23815. result.found = true;
  23816. return result;
  23817. }
  23818. if (r2 > 0 && r2 < maxR) {
  23819. result.root = r2;
  23820. result.found = true;
  23821. return result;
  23822. }
  23823. return result;
  23824. };
  23825. })();
  23826. /** @hidden */
  23827. var Collider = /** @class */ (function () {
  23828. function Collider() {
  23829. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23830. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23831. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23832. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23833. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23834. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23835. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23836. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23837. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23838. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23839. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23840. /** @hidden */
  23841. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23842. /** @hidden */
  23843. this._retry = 0;
  23844. /** @hidden */
  23845. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23846. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23847. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23848. this._collisionMask = -1;
  23849. }
  23850. Object.defineProperty(Collider.prototype, "collisionMask", {
  23851. get: function () {
  23852. return this._collisionMask;
  23853. },
  23854. set: function (mask) {
  23855. this._collisionMask = !isNaN(mask) ? mask : -1;
  23856. },
  23857. enumerable: true,
  23858. configurable: true
  23859. });
  23860. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23861. /**
  23862. * Gets the plane normal used to compute the sliding response (in local space)
  23863. */
  23864. get: function () {
  23865. return this._slidePlaneNormal;
  23866. },
  23867. enumerable: true,
  23868. configurable: true
  23869. });
  23870. // Methods
  23871. /** @hidden */
  23872. Collider.prototype._initialize = function (source, dir, e) {
  23873. this._velocity = dir;
  23874. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23875. this._basePoint = source;
  23876. source.multiplyToRef(this._radius, this._basePointWorld);
  23877. dir.multiplyToRef(this._radius, this._velocityWorld);
  23878. this._velocityWorldLength = this._velocityWorld.length();
  23879. this._epsilon = e;
  23880. this.collisionFound = false;
  23881. };
  23882. /** @hidden */
  23883. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23884. pa.subtractToRef(point, this._tempVector);
  23885. pb.subtractToRef(point, this._tempVector2);
  23886. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23887. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23888. if (d < 0) {
  23889. return false;
  23890. }
  23891. pc.subtractToRef(point, this._tempVector3);
  23892. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23893. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23894. if (d < 0) {
  23895. return false;
  23896. }
  23897. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23898. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23899. return d >= 0;
  23900. };
  23901. /** @hidden */
  23902. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23903. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23904. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23905. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23906. return false;
  23907. }
  23908. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23909. return false;
  23910. }
  23911. return true;
  23912. };
  23913. /** @hidden */
  23914. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23915. var t0;
  23916. var embeddedInPlane = false;
  23917. //defensive programming, actually not needed.
  23918. if (!trianglePlaneArray) {
  23919. trianglePlaneArray = [];
  23920. }
  23921. if (!trianglePlaneArray[faceIndex]) {
  23922. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23923. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23924. }
  23925. var trianglePlane = trianglePlaneArray[faceIndex];
  23926. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23927. return;
  23928. }
  23929. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23930. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23931. if (normalDotVelocity == 0) {
  23932. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23933. return;
  23934. }
  23935. embeddedInPlane = true;
  23936. t0 = 0;
  23937. }
  23938. else {
  23939. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23940. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23941. if (t0 > t1) {
  23942. var temp = t1;
  23943. t1 = t0;
  23944. t0 = temp;
  23945. }
  23946. if (t0 > 1.0 || t1 < 0.0) {
  23947. return;
  23948. }
  23949. if (t0 < 0) {
  23950. t0 = 0;
  23951. }
  23952. if (t0 > 1.0) {
  23953. t0 = 1.0;
  23954. }
  23955. }
  23956. this._collisionPoint.copyFromFloats(0, 0, 0);
  23957. var found = false;
  23958. var t = 1.0;
  23959. if (!embeddedInPlane) {
  23960. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23961. this._velocity.scaleToRef(t0, this._tempVector);
  23962. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23963. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23964. found = true;
  23965. t = t0;
  23966. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23967. }
  23968. }
  23969. if (!found) {
  23970. var velocitySquaredLength = this._velocity.lengthSquared();
  23971. var a = velocitySquaredLength;
  23972. this._basePoint.subtractToRef(p1, this._tempVector);
  23973. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23974. var c = this._tempVector.lengthSquared() - 1.0;
  23975. var lowestRoot = getLowestRoot(a, b, c, t);
  23976. if (lowestRoot.found) {
  23977. t = lowestRoot.root;
  23978. found = true;
  23979. this._collisionPoint.copyFrom(p1);
  23980. }
  23981. this._basePoint.subtractToRef(p2, this._tempVector);
  23982. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23983. c = this._tempVector.lengthSquared() - 1.0;
  23984. lowestRoot = getLowestRoot(a, b, c, t);
  23985. if (lowestRoot.found) {
  23986. t = lowestRoot.root;
  23987. found = true;
  23988. this._collisionPoint.copyFrom(p2);
  23989. }
  23990. this._basePoint.subtractToRef(p3, this._tempVector);
  23991. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23992. c = this._tempVector.lengthSquared() - 1.0;
  23993. lowestRoot = getLowestRoot(a, b, c, t);
  23994. if (lowestRoot.found) {
  23995. t = lowestRoot.root;
  23996. found = true;
  23997. this._collisionPoint.copyFrom(p3);
  23998. }
  23999. p2.subtractToRef(p1, this._edge);
  24000. p1.subtractToRef(this._basePoint, this._baseToVertex);
  24001. var edgeSquaredLength = this._edge.lengthSquared();
  24002. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24003. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24004. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24005. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24006. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24007. lowestRoot = getLowestRoot(a, b, c, t);
  24008. if (lowestRoot.found) {
  24009. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24010. if (f >= 0.0 && f <= 1.0) {
  24011. t = lowestRoot.root;
  24012. found = true;
  24013. this._edge.scaleInPlace(f);
  24014. p1.addToRef(this._edge, this._collisionPoint);
  24015. }
  24016. }
  24017. p3.subtractToRef(p2, this._edge);
  24018. p2.subtractToRef(this._basePoint, this._baseToVertex);
  24019. edgeSquaredLength = this._edge.lengthSquared();
  24020. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24021. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24022. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24023. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24024. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24025. lowestRoot = getLowestRoot(a, b, c, t);
  24026. if (lowestRoot.found) {
  24027. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24028. if (f >= 0.0 && f <= 1.0) {
  24029. t = lowestRoot.root;
  24030. found = true;
  24031. this._edge.scaleInPlace(f);
  24032. p2.addToRef(this._edge, this._collisionPoint);
  24033. }
  24034. }
  24035. p1.subtractToRef(p3, this._edge);
  24036. p3.subtractToRef(this._basePoint, this._baseToVertex);
  24037. edgeSquaredLength = this._edge.lengthSquared();
  24038. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24039. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24040. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24041. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24042. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24043. lowestRoot = getLowestRoot(a, b, c, t);
  24044. if (lowestRoot.found) {
  24045. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24046. if (f >= 0.0 && f <= 1.0) {
  24047. t = lowestRoot.root;
  24048. found = true;
  24049. this._edge.scaleInPlace(f);
  24050. p3.addToRef(this._edge, this._collisionPoint);
  24051. }
  24052. }
  24053. }
  24054. if (found) {
  24055. var distToCollision = t * this._velocity.length();
  24056. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24057. if (!this.intersectionPoint) {
  24058. this.intersectionPoint = this._collisionPoint.clone();
  24059. }
  24060. else {
  24061. this.intersectionPoint.copyFrom(this._collisionPoint);
  24062. }
  24063. this._nearestDistance = distToCollision;
  24064. this.collisionFound = true;
  24065. }
  24066. }
  24067. };
  24068. /** @hidden */
  24069. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24070. for (var i = indexStart; i < indexEnd; i += 3) {
  24071. var p1 = pts[indices[i] - decal];
  24072. var p2 = pts[indices[i + 1] - decal];
  24073. var p3 = pts[indices[i + 2] - decal];
  24074. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24075. }
  24076. };
  24077. /** @hidden */
  24078. Collider.prototype._getResponse = function (pos, vel) {
  24079. pos.addToRef(vel, this._destinationPoint);
  24080. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24081. this._basePoint.addToRef(vel, pos);
  24082. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24083. this._slidePlaneNormal.normalize();
  24084. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24085. pos.addInPlace(this._displacementVector);
  24086. this.intersectionPoint.addInPlace(this._displacementVector);
  24087. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24088. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24089. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24090. };
  24091. return Collider;
  24092. }());
  24093. /***/ }),
  24094. /***/ "./Collisions/collisionCoordinator.ts":
  24095. /*!********************************************!*\
  24096. !*** ./Collisions/collisionCoordinator.ts ***!
  24097. \********************************************/
  24098. /*! exports provided: DefaultCollisionCoordinator */
  24099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24100. "use strict";
  24101. __webpack_require__.r(__webpack_exports__);
  24102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24103. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24104. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24105. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24106. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24107. /** @hidden */
  24108. var DefaultCollisionCoordinator = /** @class */ (function () {
  24109. function DefaultCollisionCoordinator() {
  24110. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24111. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24112. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24113. }
  24114. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24115. position.divideToRef(collider._radius, this._scaledPosition);
  24116. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24117. collider.collidedMesh = null;
  24118. collider._retry = 0;
  24119. collider._initialVelocity = this._scaledVelocity;
  24120. collider._initialPosition = this._scaledPosition;
  24121. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24122. this._finalPosition.multiplyInPlace(collider._radius);
  24123. //run the callback
  24124. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24125. };
  24126. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24127. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24128. };
  24129. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24130. this._scene = scene;
  24131. };
  24132. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24133. if (excludedMesh === void 0) { excludedMesh = null; }
  24134. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24135. if (collider._retry >= maximumRetry) {
  24136. finalPosition.copyFrom(position);
  24137. return;
  24138. }
  24139. // Check if this is a mesh else camera or -1
  24140. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24141. collider._initialize(position, velocity, closeDistance);
  24142. // Check all meshes
  24143. for (var index = 0; index < this._scene.meshes.length; index++) {
  24144. var mesh = this._scene.meshes[index];
  24145. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24146. mesh._checkCollision(collider);
  24147. }
  24148. }
  24149. if (!collider.collisionFound) {
  24150. position.addToRef(velocity, finalPosition);
  24151. return;
  24152. }
  24153. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24154. collider._getResponse(position, velocity);
  24155. }
  24156. if (velocity.length() <= closeDistance) {
  24157. finalPosition.copyFrom(position);
  24158. return;
  24159. }
  24160. collider._retry++;
  24161. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24162. };
  24163. return DefaultCollisionCoordinator;
  24164. }());
  24165. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24166. return new DefaultCollisionCoordinator();
  24167. };
  24168. /***/ }),
  24169. /***/ "./Collisions/index.ts":
  24170. /*!*****************************!*\
  24171. !*** ./Collisions/index.ts ***!
  24172. \*****************************/
  24173. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  24174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24175. "use strict";
  24176. __webpack_require__.r(__webpack_exports__);
  24177. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24179. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24181. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24183. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24185. /***/ }),
  24186. /***/ "./Collisions/intersectionInfo.ts":
  24187. /*!****************************************!*\
  24188. !*** ./Collisions/intersectionInfo.ts ***!
  24189. \****************************************/
  24190. /*! exports provided: IntersectionInfo */
  24191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24192. "use strict";
  24193. __webpack_require__.r(__webpack_exports__);
  24194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24195. /**
  24196. * @hidden
  24197. */
  24198. var IntersectionInfo = /** @class */ (function () {
  24199. function IntersectionInfo(bu, bv, distance) {
  24200. this.bu = bu;
  24201. this.bv = bv;
  24202. this.distance = distance;
  24203. this.faceId = 0;
  24204. this.subMeshId = 0;
  24205. }
  24206. return IntersectionInfo;
  24207. }());
  24208. /***/ }),
  24209. /***/ "./Collisions/pickingInfo.ts":
  24210. /*!***********************************!*\
  24211. !*** ./Collisions/pickingInfo.ts ***!
  24212. \***********************************/
  24213. /*! exports provided: PickingInfo */
  24214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24215. "use strict";
  24216. __webpack_require__.r(__webpack_exports__);
  24217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24218. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24219. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24220. /**
  24221. * Information about the result of picking within a scene
  24222. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24223. */
  24224. var PickingInfo = /** @class */ (function () {
  24225. function PickingInfo() {
  24226. /** @hidden */
  24227. this._pickingUnavailable = false;
  24228. /**
  24229. * If the pick collided with an object
  24230. */
  24231. this.hit = false;
  24232. /**
  24233. * Distance away where the pick collided
  24234. */
  24235. this.distance = 0;
  24236. /**
  24237. * The location of pick collision
  24238. */
  24239. this.pickedPoint = null;
  24240. /**
  24241. * The mesh corresponding the the pick collision
  24242. */
  24243. this.pickedMesh = null;
  24244. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24245. this.bu = 0;
  24246. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24247. this.bv = 0;
  24248. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24249. this.faceId = -1;
  24250. /** Id of the the submesh that was picked */
  24251. this.subMeshId = 0;
  24252. /** If a sprite was picked, this will be the sprite the pick collided with */
  24253. this.pickedSprite = null;
  24254. /**
  24255. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24256. */
  24257. this.originMesh = null;
  24258. /**
  24259. * The ray that was used to perform the picking.
  24260. */
  24261. this.ray = null;
  24262. }
  24263. /**
  24264. * Gets the normal correspodning to the face the pick collided with
  24265. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24266. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24267. * @returns The normal correspodning to the face the pick collided with
  24268. */
  24269. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24270. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24271. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24272. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24273. return null;
  24274. }
  24275. var indices = this.pickedMesh.getIndices();
  24276. if (!indices) {
  24277. return null;
  24278. }
  24279. var result;
  24280. if (useVerticesNormals) {
  24281. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24282. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24283. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24284. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24285. normal0 = normal0.scale(this.bu);
  24286. normal1 = normal1.scale(this.bv);
  24287. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24288. 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);
  24289. }
  24290. else {
  24291. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24292. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24293. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24294. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24295. var p1p2 = vertex1.subtract(vertex2);
  24296. var p3p2 = vertex3.subtract(vertex2);
  24297. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24298. }
  24299. if (useWorldCoordinates) {
  24300. var wm = this.pickedMesh.getWorldMatrix();
  24301. if (this.pickedMesh.nonUniformScaling) {
  24302. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24303. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24304. wm.setTranslationFromFloats(0, 0, 0);
  24305. wm.invert();
  24306. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24307. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24308. }
  24309. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24310. }
  24311. result.normalize();
  24312. return result;
  24313. };
  24314. /**
  24315. * Gets the texture coordinates of where the pick occured
  24316. * @returns the vector containing the coordnates of the texture
  24317. */
  24318. PickingInfo.prototype.getTextureCoordinates = function () {
  24319. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24320. return null;
  24321. }
  24322. var indices = this.pickedMesh.getIndices();
  24323. if (!indices) {
  24324. return null;
  24325. }
  24326. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24327. if (!uvs) {
  24328. return null;
  24329. }
  24330. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24331. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24332. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24333. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24334. uv1 = uv1.scale(this.bu);
  24335. uv2 = uv2.scale(this.bv);
  24336. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24337. };
  24338. return PickingInfo;
  24339. }());
  24340. /***/ }),
  24341. /***/ "./Culling/Octrees/index.ts":
  24342. /*!**********************************!*\
  24343. !*** ./Culling/Octrees/index.ts ***!
  24344. \**********************************/
  24345. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24347. "use strict";
  24348. __webpack_require__.r(__webpack_exports__);
  24349. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24351. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24353. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24355. /***/ }),
  24356. /***/ "./Culling/Octrees/octree.ts":
  24357. /*!***********************************!*\
  24358. !*** ./Culling/Octrees/octree.ts ***!
  24359. \***********************************/
  24360. /*! exports provided: Octree */
  24361. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24362. "use strict";
  24363. __webpack_require__.r(__webpack_exports__);
  24364. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24365. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24366. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24367. /**
  24368. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24369. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24370. */
  24371. var Octree = /** @class */ (function () {
  24372. /**
  24373. * Creates a octree
  24374. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24375. * @param creationFunc function to be used to instatiate the octree
  24376. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24377. * @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.)
  24378. */
  24379. function Octree(creationFunc, maxBlockCapacity,
  24380. /** 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.) */
  24381. maxDepth) {
  24382. if (maxDepth === void 0) { maxDepth = 2; }
  24383. this.maxDepth = maxDepth;
  24384. /**
  24385. * Content stored in the octree
  24386. */
  24387. this.dynamicContent = new Array();
  24388. this._maxBlockCapacity = maxBlockCapacity || 64;
  24389. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24390. this._creationFunc = creationFunc;
  24391. }
  24392. // Methods
  24393. /**
  24394. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24395. * @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);
  24396. * @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);
  24397. * @param entries meshes to be added to the octree blocks
  24398. */
  24399. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24400. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24401. };
  24402. /**
  24403. * Adds a mesh to the octree
  24404. * @param entry Mesh to add to the octree
  24405. */
  24406. Octree.prototype.addMesh = function (entry) {
  24407. for (var index = 0; index < this.blocks.length; index++) {
  24408. var block = this.blocks[index];
  24409. block.addEntry(entry);
  24410. }
  24411. };
  24412. /**
  24413. * Remove an element from the octree
  24414. * @param entry defines the element to remove
  24415. */
  24416. Octree.prototype.removeMesh = function (entry) {
  24417. for (var index = 0; index < this.blocks.length; index++) {
  24418. var block = this.blocks[index];
  24419. block.removeEntry(entry);
  24420. }
  24421. };
  24422. /**
  24423. * Selects an array of meshes within the frustum
  24424. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24425. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24426. * @returns array of meshes within the frustum
  24427. */
  24428. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24429. this._selectionContent.reset();
  24430. for (var index = 0; index < this.blocks.length; index++) {
  24431. var block = this.blocks[index];
  24432. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24433. }
  24434. if (allowDuplicate) {
  24435. this._selectionContent.concat(this.dynamicContent);
  24436. }
  24437. else {
  24438. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24439. }
  24440. return this._selectionContent;
  24441. };
  24442. /**
  24443. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24444. * @param sphereCenter defines the bounding sphere center
  24445. * @param sphereRadius defines the bounding sphere radius
  24446. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24447. * @returns an array of objects that intersect the sphere
  24448. */
  24449. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24450. this._selectionContent.reset();
  24451. for (var index = 0; index < this.blocks.length; index++) {
  24452. var block = this.blocks[index];
  24453. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24454. }
  24455. if (allowDuplicate) {
  24456. this._selectionContent.concat(this.dynamicContent);
  24457. }
  24458. else {
  24459. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24460. }
  24461. return this._selectionContent;
  24462. };
  24463. /**
  24464. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24465. * @param ray defines the ray to test with
  24466. * @returns array of intersected objects
  24467. */
  24468. Octree.prototype.intersectsRay = function (ray) {
  24469. this._selectionContent.reset();
  24470. for (var index = 0; index < this.blocks.length; index++) {
  24471. var block = this.blocks[index];
  24472. block.intersectsRay(ray, this._selectionContent);
  24473. }
  24474. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24475. return this._selectionContent;
  24476. };
  24477. /**
  24478. * Adds a mesh into the octree block if it intersects the block
  24479. */
  24480. Octree.CreationFuncForMeshes = function (entry, block) {
  24481. var boundingInfo = entry.getBoundingInfo();
  24482. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24483. block.entries.push(entry);
  24484. }
  24485. };
  24486. /**
  24487. * Adds a submesh into the octree block if it intersects the block
  24488. */
  24489. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24490. var boundingInfo = entry.getBoundingInfo();
  24491. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24492. block.entries.push(entry);
  24493. }
  24494. };
  24495. return Octree;
  24496. }());
  24497. /***/ }),
  24498. /***/ "./Culling/Octrees/octreeBlock.ts":
  24499. /*!****************************************!*\
  24500. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24501. \****************************************/
  24502. /*! exports provided: OctreeBlock */
  24503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24504. "use strict";
  24505. __webpack_require__.r(__webpack_exports__);
  24506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24507. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24508. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24509. /**
  24510. * Class used to store a cell in an octree
  24511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24512. */
  24513. var OctreeBlock = /** @class */ (function () {
  24514. /**
  24515. * Creates a new block
  24516. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24517. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24518. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24519. * @param depth defines the current depth of this block in the octree
  24520. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24521. * @param creationFunc defines a callback to call when an element is added to the block
  24522. */
  24523. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24524. /**
  24525. * Gets the content of the current block
  24526. */
  24527. this.entries = new Array();
  24528. this._boundingVectors = new Array();
  24529. this._capacity = capacity;
  24530. this._depth = depth;
  24531. this._maxDepth = maxDepth;
  24532. this._creationFunc = creationFunc;
  24533. this._minPoint = minPoint;
  24534. this._maxPoint = maxPoint;
  24535. this._boundingVectors.push(minPoint.clone());
  24536. this._boundingVectors.push(maxPoint.clone());
  24537. this._boundingVectors.push(minPoint.clone());
  24538. this._boundingVectors[2].x = maxPoint.x;
  24539. this._boundingVectors.push(minPoint.clone());
  24540. this._boundingVectors[3].y = maxPoint.y;
  24541. this._boundingVectors.push(minPoint.clone());
  24542. this._boundingVectors[4].z = maxPoint.z;
  24543. this._boundingVectors.push(maxPoint.clone());
  24544. this._boundingVectors[5].z = minPoint.z;
  24545. this._boundingVectors.push(maxPoint.clone());
  24546. this._boundingVectors[6].x = minPoint.x;
  24547. this._boundingVectors.push(maxPoint.clone());
  24548. this._boundingVectors[7].y = minPoint.y;
  24549. }
  24550. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24551. // Property
  24552. /**
  24553. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24554. */
  24555. get: function () {
  24556. return this._capacity;
  24557. },
  24558. enumerable: true,
  24559. configurable: true
  24560. });
  24561. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24562. /**
  24563. * Gets the minimum vector (in world space) of the block's bounding box
  24564. */
  24565. get: function () {
  24566. return this._minPoint;
  24567. },
  24568. enumerable: true,
  24569. configurable: true
  24570. });
  24571. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24572. /**
  24573. * Gets the maximum vector (in world space) of the block's bounding box
  24574. */
  24575. get: function () {
  24576. return this._maxPoint;
  24577. },
  24578. enumerable: true,
  24579. configurable: true
  24580. });
  24581. // Methods
  24582. /**
  24583. * Add a new element to this block
  24584. * @param entry defines the element to add
  24585. */
  24586. OctreeBlock.prototype.addEntry = function (entry) {
  24587. if (this.blocks) {
  24588. for (var index = 0; index < this.blocks.length; index++) {
  24589. var block = this.blocks[index];
  24590. block.addEntry(entry);
  24591. }
  24592. return;
  24593. }
  24594. this._creationFunc(entry, this);
  24595. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24596. this.createInnerBlocks();
  24597. }
  24598. };
  24599. /**
  24600. * Remove an element from this block
  24601. * @param entry defines the element to remove
  24602. */
  24603. OctreeBlock.prototype.removeEntry = function (entry) {
  24604. if (this.blocks) {
  24605. for (var index = 0; index < this.blocks.length; index++) {
  24606. var block = this.blocks[index];
  24607. block.removeEntry(entry);
  24608. }
  24609. return;
  24610. }
  24611. var entryIndex = this.entries.indexOf(entry);
  24612. if (entryIndex > -1) {
  24613. this.entries.splice(entryIndex, 1);
  24614. }
  24615. };
  24616. /**
  24617. * Add an array of elements to this block
  24618. * @param entries defines the array of elements to add
  24619. */
  24620. OctreeBlock.prototype.addEntries = function (entries) {
  24621. for (var index = 0; index < entries.length; index++) {
  24622. var mesh = entries[index];
  24623. this.addEntry(mesh);
  24624. }
  24625. };
  24626. /**
  24627. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24628. * @param frustumPlanes defines the frustum planes to test
  24629. * @param selection defines the array to store current content if selection is positive
  24630. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24631. */
  24632. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24633. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24634. if (this.blocks) {
  24635. for (var index = 0; index < this.blocks.length; index++) {
  24636. var block = this.blocks[index];
  24637. block.select(frustumPlanes, selection, allowDuplicate);
  24638. }
  24639. return;
  24640. }
  24641. if (allowDuplicate) {
  24642. selection.concat(this.entries);
  24643. }
  24644. else {
  24645. selection.concatWithNoDuplicate(this.entries);
  24646. }
  24647. }
  24648. };
  24649. /**
  24650. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24651. * @param sphereCenter defines the bounding sphere center
  24652. * @param sphereRadius defines the bounding sphere radius
  24653. * @param selection defines the array to store current content if selection is positive
  24654. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24655. */
  24656. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24657. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24658. if (this.blocks) {
  24659. for (var index = 0; index < this.blocks.length; index++) {
  24660. var block = this.blocks[index];
  24661. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24662. }
  24663. return;
  24664. }
  24665. if (allowDuplicate) {
  24666. selection.concat(this.entries);
  24667. }
  24668. else {
  24669. selection.concatWithNoDuplicate(this.entries);
  24670. }
  24671. }
  24672. };
  24673. /**
  24674. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24675. * @param ray defines the ray to test with
  24676. * @param selection defines the array to store current content if selection is positive
  24677. */
  24678. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24679. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24680. if (this.blocks) {
  24681. for (var index = 0; index < this.blocks.length; index++) {
  24682. var block = this.blocks[index];
  24683. block.intersectsRay(ray, selection);
  24684. }
  24685. return;
  24686. }
  24687. selection.concatWithNoDuplicate(this.entries);
  24688. }
  24689. };
  24690. /**
  24691. * Subdivide the content into child blocks (this block will then be empty)
  24692. */
  24693. OctreeBlock.prototype.createInnerBlocks = function () {
  24694. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24695. };
  24696. /**
  24697. * @hidden
  24698. */
  24699. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24700. target.blocks = new Array();
  24701. 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);
  24702. // Segmenting space
  24703. for (var x = 0; x < 2; x++) {
  24704. for (var y = 0; y < 2; y++) {
  24705. for (var z = 0; z < 2; z++) {
  24706. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24707. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24708. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24709. block.addEntries(entries);
  24710. target.blocks.push(block);
  24711. }
  24712. }
  24713. }
  24714. };
  24715. return OctreeBlock;
  24716. }());
  24717. /***/ }),
  24718. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24719. /*!*************************************************!*\
  24720. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24721. \*************************************************/
  24722. /*! exports provided: OctreeSceneComponent */
  24723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24724. "use strict";
  24725. __webpack_require__.r(__webpack_exports__);
  24726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24727. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24728. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24729. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24730. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24731. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24732. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24733. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24734. if (maxCapacity === void 0) { maxCapacity = 64; }
  24735. if (maxDepth === void 0) { maxDepth = 2; }
  24736. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24737. if (!component) {
  24738. component = new OctreeSceneComponent(this);
  24739. this._addComponent(component);
  24740. }
  24741. if (!this._selectionOctree) {
  24742. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24743. }
  24744. var worldExtends = this.getWorldExtends();
  24745. // Update octree
  24746. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24747. return this._selectionOctree;
  24748. };
  24749. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24750. get: function () {
  24751. return this._selectionOctree;
  24752. },
  24753. enumerable: true,
  24754. configurable: true
  24755. });
  24756. /**
  24757. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24758. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24759. * @param maxCapacity defines the maximum size of each block (64 by default)
  24760. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24761. * @returns the new octree
  24762. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24763. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24764. */
  24765. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24766. if (maxCapacity === void 0) { maxCapacity = 64; }
  24767. if (maxDepth === void 0) { maxDepth = 2; }
  24768. var scene = this.getScene();
  24769. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24770. if (!component) {
  24771. component = new OctreeSceneComponent(scene);
  24772. scene._addComponent(component);
  24773. }
  24774. if (!this._submeshesOctree) {
  24775. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24776. }
  24777. this.computeWorldMatrix(true);
  24778. var boundingInfo = this.getBoundingInfo();
  24779. // Update octree
  24780. var bbox = boundingInfo.boundingBox;
  24781. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24782. return this._submeshesOctree;
  24783. };
  24784. /**
  24785. * Defines the octree scene component responsible to manage any octrees
  24786. * in a given scene.
  24787. */
  24788. var OctreeSceneComponent = /** @class */ (function () {
  24789. /**
  24790. * Creates a new instance of the component for the given scene
  24791. * @param scene Defines the scene to register the component in
  24792. */
  24793. function OctreeSceneComponent(scene) {
  24794. /**
  24795. * The component name helpfull to identify the component in the list of scene components.
  24796. */
  24797. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24798. /**
  24799. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24800. */
  24801. this.checksIsEnabled = true;
  24802. 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));
  24803. this.scene = scene;
  24804. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24805. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24806. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24807. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24808. }
  24809. /**
  24810. * Registers the component in a given scene
  24811. */
  24812. OctreeSceneComponent.prototype.register = function () {
  24813. var _this = this;
  24814. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24815. var sceneOctree = _this.scene.selectionOctree;
  24816. if (sceneOctree !== undefined && sceneOctree !== null) {
  24817. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24818. if (index !== -1) {
  24819. sceneOctree.dynamicContent.splice(index, 1);
  24820. }
  24821. }
  24822. });
  24823. this.scene.onMeshImportedObservable.add(function (mesh) {
  24824. var sceneOctree = _this.scene.selectionOctree;
  24825. if (sceneOctree !== undefined && sceneOctree !== null) {
  24826. sceneOctree.addMesh(mesh);
  24827. }
  24828. });
  24829. };
  24830. /**
  24831. * Return the list of active meshes
  24832. * @returns the list of active meshes
  24833. */
  24834. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24835. if (this.scene._selectionOctree) {
  24836. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24837. return selection;
  24838. }
  24839. return this.scene._getDefaultMeshCandidates();
  24840. };
  24841. /**
  24842. * Return the list of active sub meshes
  24843. * @param mesh The mesh to get the candidates sub meshes from
  24844. * @returns the list of active sub meshes
  24845. */
  24846. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24847. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24848. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24849. return intersections;
  24850. }
  24851. return this.scene._getDefaultSubMeshCandidates(mesh);
  24852. };
  24853. /**
  24854. * Return the list of sub meshes intersecting with a given local ray
  24855. * @param mesh defines the mesh to find the submesh for
  24856. * @param localRay defines the ray in local space
  24857. * @returns the list of intersecting sub meshes
  24858. */
  24859. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24860. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24861. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24862. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24863. return intersections;
  24864. }
  24865. return this.scene._getDefaultSubMeshCandidates(mesh);
  24866. };
  24867. /**
  24868. * Return the list of sub meshes colliding with a collider
  24869. * @param mesh defines the mesh to find the submesh for
  24870. * @param collider defines the collider to evaluate the collision against
  24871. * @returns the list of colliding sub meshes
  24872. */
  24873. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24874. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24875. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24876. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24877. return intersections;
  24878. }
  24879. return this.scene._getDefaultSubMeshCandidates(mesh);
  24880. };
  24881. /**
  24882. * Rebuilds the elements related to this component in case of
  24883. * context lost for instance.
  24884. */
  24885. OctreeSceneComponent.prototype.rebuild = function () {
  24886. // Nothing to do here.
  24887. };
  24888. /**
  24889. * Disposes the component and the associated ressources.
  24890. */
  24891. OctreeSceneComponent.prototype.dispose = function () {
  24892. // Nothing to do here.
  24893. };
  24894. return OctreeSceneComponent;
  24895. }());
  24896. /***/ }),
  24897. /***/ "./Culling/boundingBox.ts":
  24898. /*!********************************!*\
  24899. !*** ./Culling/boundingBox.ts ***!
  24900. \********************************/
  24901. /*! exports provided: BoundingBox */
  24902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24903. "use strict";
  24904. __webpack_require__.r(__webpack_exports__);
  24905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24906. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24907. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24908. /**
  24909. * Class used to store bounding box information
  24910. */
  24911. var BoundingBox = /** @class */ (function () {
  24912. /**
  24913. * Creates a new bounding box
  24914. * @param min defines the minimum vector (in local space)
  24915. * @param max defines the maximum vector (in local space)
  24916. * @param worldMatrix defines the new world matrix
  24917. */
  24918. function BoundingBox(min, max, worldMatrix) {
  24919. /**
  24920. * Gets the 8 vectors representing the bounding box in local space
  24921. */
  24922. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24923. /**
  24924. * Gets the center of the bounding box in local space
  24925. */
  24926. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24927. /**
  24928. * Gets the center of the bounding box in world space
  24929. */
  24930. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24931. /**
  24932. * Gets the extend size in local space
  24933. */
  24934. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24935. /**
  24936. * Gets the extend size in world space
  24937. */
  24938. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24939. /**
  24940. * Gets the OBB (object bounding box) directions
  24941. */
  24942. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24943. /**
  24944. * Gets the 8 vectors representing the bounding box in world space
  24945. */
  24946. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24947. /**
  24948. * Gets the minimum vector in world space
  24949. */
  24950. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24951. /**
  24952. * Gets the maximum vector in world space
  24953. */
  24954. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24955. /**
  24956. * Gets the minimum vector in local space
  24957. */
  24958. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24959. /**
  24960. * Gets the maximum vector in local space
  24961. */
  24962. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24963. this.reConstruct(min, max, worldMatrix);
  24964. }
  24965. // Methods
  24966. /**
  24967. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24968. * @param min defines the new minimum vector (in local space)
  24969. * @param max defines the new maximum vector (in local space)
  24970. * @param worldMatrix defines the new world matrix
  24971. */
  24972. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24973. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24974. var vectors = this.vectors;
  24975. this.minimum.copyFromFloats(minX, minY, minZ);
  24976. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24977. vectors[0].copyFromFloats(minX, minY, minZ);
  24978. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24979. vectors[2].copyFromFloats(maxX, minY, minZ);
  24980. vectors[3].copyFromFloats(minX, maxY, minZ);
  24981. vectors[4].copyFromFloats(minX, minY, maxZ);
  24982. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24983. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24984. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24985. // OBB
  24986. max.addToRef(min, this.center).scaleInPlace(0.5);
  24987. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24988. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24989. };
  24990. /**
  24991. * Scale the current bounding box by applying a scale factor
  24992. * @param factor defines the scale factor to apply
  24993. * @returns the current bounding box
  24994. */
  24995. BoundingBox.prototype.scale = function (factor) {
  24996. var tmpVectors = BoundingBox.TmpVector3;
  24997. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24998. var len = diff.length();
  24999. diff.normalizeFromLength(len);
  25000. var distance = len * factor;
  25001. var newRadius = diff.scaleInPlace(distance * 0.5);
  25002. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  25003. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  25004. this.reConstruct(min, max, this._worldMatrix);
  25005. return this;
  25006. };
  25007. /**
  25008. * Gets the world matrix of the bounding box
  25009. * @returns a matrix
  25010. */
  25011. BoundingBox.prototype.getWorldMatrix = function () {
  25012. return this._worldMatrix;
  25013. };
  25014. /** @hidden */
  25015. BoundingBox.prototype._update = function (world) {
  25016. var minWorld = this.minimumWorld;
  25017. var maxWorld = this.maximumWorld;
  25018. var directions = this.directions;
  25019. var vectorsWorld = this.vectorsWorld;
  25020. var vectors = this.vectors;
  25021. if (!world.isIdentity()) {
  25022. minWorld.setAll(Number.MAX_VALUE);
  25023. maxWorld.setAll(-Number.MAX_VALUE);
  25024. for (var index = 0; index < 8; ++index) {
  25025. var v = vectorsWorld[index];
  25026. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  25027. minWorld.minimizeInPlace(v);
  25028. maxWorld.maximizeInPlace(v);
  25029. }
  25030. // Extend
  25031. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  25032. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  25033. }
  25034. else {
  25035. minWorld.copyFrom(this.minimum);
  25036. maxWorld.copyFrom(this.maximum);
  25037. for (var index = 0; index < 8; ++index) {
  25038. vectorsWorld[index].copyFrom(vectors[index]);
  25039. }
  25040. // Extend
  25041. this.extendSizeWorld.copyFrom(this.extendSize);
  25042. this.centerWorld.copyFrom(this.center);
  25043. }
  25044. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25045. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25046. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25047. this._worldMatrix = world;
  25048. };
  25049. /**
  25050. * Tests if the bounding box is intersecting the frustum planes
  25051. * @param frustumPlanes defines the frustum planes to test
  25052. * @returns true if there is an intersection
  25053. */
  25054. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25055. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25056. };
  25057. /**
  25058. * Tests if the bounding box is entirely inside the frustum planes
  25059. * @param frustumPlanes defines the frustum planes to test
  25060. * @returns true if there is an inclusion
  25061. */
  25062. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25063. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25064. };
  25065. /**
  25066. * Tests if a point is inside the bounding box
  25067. * @param point defines the point to test
  25068. * @returns true if the point is inside the bounding box
  25069. */
  25070. BoundingBox.prototype.intersectsPoint = function (point) {
  25071. var min = this.minimumWorld;
  25072. var max = this.maximumWorld;
  25073. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25074. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25075. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25076. if (maxX - pointX < delta || delta > pointX - minX) {
  25077. return false;
  25078. }
  25079. if (maxY - pointY < delta || delta > pointY - minY) {
  25080. return false;
  25081. }
  25082. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25083. return false;
  25084. }
  25085. return true;
  25086. };
  25087. /**
  25088. * Tests if the bounding box intersects with a bounding sphere
  25089. * @param sphere defines the sphere to test
  25090. * @returns true if there is an intersection
  25091. */
  25092. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25093. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25094. };
  25095. /**
  25096. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25097. * @param min defines the min vector to use
  25098. * @param max defines the max vector to use
  25099. * @returns true if there is an intersection
  25100. */
  25101. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25102. var myMin = this.minimumWorld;
  25103. var myMax = this.maximumWorld;
  25104. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25105. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25106. if (myMaxX < minX || myMinX > maxX) {
  25107. return false;
  25108. }
  25109. if (myMaxY < minY || myMinY > maxY) {
  25110. return false;
  25111. }
  25112. if (myMaxZ < minZ || myMinZ > maxZ) {
  25113. return false;
  25114. }
  25115. return true;
  25116. };
  25117. // Statics
  25118. /**
  25119. * Tests if two bounding boxes are intersections
  25120. * @param box0 defines the first box to test
  25121. * @param box1 defines the second box to test
  25122. * @returns true if there is an intersection
  25123. */
  25124. BoundingBox.Intersects = function (box0, box1) {
  25125. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25126. };
  25127. /**
  25128. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25129. * @param minPoint defines the minimum vector of the bounding box
  25130. * @param maxPoint defines the maximum vector of the bounding box
  25131. * @param sphereCenter defines the sphere center
  25132. * @param sphereRadius defines the sphere radius
  25133. * @returns true if there is an intersection
  25134. */
  25135. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25136. var vector = BoundingBox.TmpVector3[0];
  25137. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25138. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25139. return (num <= (sphereRadius * sphereRadius));
  25140. };
  25141. /**
  25142. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25143. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25144. * @param frustumPlanes defines the frustum planes to test
  25145. * @return true if there is an inclusion
  25146. */
  25147. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25148. for (var p = 0; p < 6; ++p) {
  25149. var frustumPlane = frustumPlanes[p];
  25150. for (var i = 0; i < 8; ++i) {
  25151. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25152. return false;
  25153. }
  25154. }
  25155. }
  25156. return true;
  25157. };
  25158. /**
  25159. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25160. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25161. * @param frustumPlanes defines the frustum planes to test
  25162. * @return true if there is an intersection
  25163. */
  25164. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25165. for (var p = 0; p < 6; ++p) {
  25166. var canReturnFalse = true;
  25167. var frustumPlane = frustumPlanes[p];
  25168. for (var i = 0; i < 8; ++i) {
  25169. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25170. canReturnFalse = false;
  25171. break;
  25172. }
  25173. }
  25174. if (canReturnFalse) {
  25175. return false;
  25176. }
  25177. }
  25178. return true;
  25179. };
  25180. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25181. return BoundingBox;
  25182. }());
  25183. /***/ }),
  25184. /***/ "./Culling/boundingInfo.ts":
  25185. /*!*********************************!*\
  25186. !*** ./Culling/boundingInfo.ts ***!
  25187. \*********************************/
  25188. /*! exports provided: BoundingInfo */
  25189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25190. "use strict";
  25191. __webpack_require__.r(__webpack_exports__);
  25192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25193. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25194. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25195. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25196. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25197. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25198. var _result0 = { min: 0, max: 0 };
  25199. var _result1 = { min: 0, max: 0 };
  25200. var computeBoxExtents = function (axis, box, result) {
  25201. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25202. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25203. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25204. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25205. var r = r0 + r1 + r2;
  25206. result.min = p - r;
  25207. result.max = p + r;
  25208. };
  25209. var axisOverlap = function (axis, box0, box1) {
  25210. computeBoxExtents(axis, box0, _result0);
  25211. computeBoxExtents(axis, box1, _result1);
  25212. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25213. };
  25214. /**
  25215. * Info for a bounding data of a mesh
  25216. */
  25217. var BoundingInfo = /** @class */ (function () {
  25218. /**
  25219. * Constructs bounding info
  25220. * @param minimum min vector of the bounding box/sphere
  25221. * @param maximum max vector of the bounding box/sphere
  25222. * @param worldMatrix defines the new world matrix
  25223. */
  25224. function BoundingInfo(minimum, maximum, worldMatrix) {
  25225. this._isLocked = false;
  25226. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25227. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25228. }
  25229. /**
  25230. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25231. * @param min defines the new minimum vector (in local space)
  25232. * @param max defines the new maximum vector (in local space)
  25233. * @param worldMatrix defines the new world matrix
  25234. */
  25235. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25236. this.boundingBox.reConstruct(min, max, worldMatrix);
  25237. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25238. };
  25239. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25240. /**
  25241. * min vector of the bounding box/sphere
  25242. */
  25243. get: function () {
  25244. return this.boundingBox.minimum;
  25245. },
  25246. enumerable: true,
  25247. configurable: true
  25248. });
  25249. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25250. /**
  25251. * max vector of the bounding box/sphere
  25252. */
  25253. get: function () {
  25254. return this.boundingBox.maximum;
  25255. },
  25256. enumerable: true,
  25257. configurable: true
  25258. });
  25259. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25260. /**
  25261. * If the info is locked and won't be updated to avoid perf overhead
  25262. */
  25263. get: function () {
  25264. return this._isLocked;
  25265. },
  25266. set: function (value) {
  25267. this._isLocked = value;
  25268. },
  25269. enumerable: true,
  25270. configurable: true
  25271. });
  25272. // Methods
  25273. /**
  25274. * Updates the bounding sphere and box
  25275. * @param world world matrix to be used to update
  25276. */
  25277. BoundingInfo.prototype.update = function (world) {
  25278. if (this._isLocked) {
  25279. return;
  25280. }
  25281. this.boundingBox._update(world);
  25282. this.boundingSphere._update(world);
  25283. };
  25284. /**
  25285. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25286. * @param center New center of the bounding info
  25287. * @param extend New extend of the bounding info
  25288. * @returns the current bounding info
  25289. */
  25290. BoundingInfo.prototype.centerOn = function (center, extend) {
  25291. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25292. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25293. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25294. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25295. return this;
  25296. };
  25297. /**
  25298. * Scale the current bounding info by applying a scale factor
  25299. * @param factor defines the scale factor to apply
  25300. * @returns the current bounding info
  25301. */
  25302. BoundingInfo.prototype.scale = function (factor) {
  25303. this.boundingBox.scale(factor);
  25304. this.boundingSphere.scale(factor);
  25305. return this;
  25306. };
  25307. /**
  25308. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25309. * @param frustumPlanes defines the frustum to test
  25310. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25311. * @returns true if the bounding info is in the frustum planes
  25312. */
  25313. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25314. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25315. 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);
  25316. if (inclusionTest) {
  25317. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25318. return true;
  25319. }
  25320. }
  25321. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25322. return false;
  25323. }
  25324. 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);
  25325. if (bSphereOnlyTest) {
  25326. return true;
  25327. }
  25328. return this.boundingBox.isInFrustum(frustumPlanes);
  25329. };
  25330. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25331. /**
  25332. * Gets the world distance between the min and max points of the bounding box
  25333. */
  25334. get: function () {
  25335. var boundingBox = this.boundingBox;
  25336. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25337. return diag.length();
  25338. },
  25339. enumerable: true,
  25340. configurable: true
  25341. });
  25342. /**
  25343. * Checks if a cullable object (mesh...) is in the camera frustum
  25344. * Unlike isInFrustum this cheks the full bounding box
  25345. * @param frustumPlanes Camera near/planes
  25346. * @returns true if the object is in frustum otherwise false
  25347. */
  25348. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25349. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25350. };
  25351. /** @hidden */
  25352. BoundingInfo.prototype._checkCollision = function (collider) {
  25353. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25354. };
  25355. /**
  25356. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25357. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25358. * @param point the point to check intersection with
  25359. * @returns if the point intersects
  25360. */
  25361. BoundingInfo.prototype.intersectsPoint = function (point) {
  25362. if (!this.boundingSphere.centerWorld) {
  25363. return false;
  25364. }
  25365. if (!this.boundingSphere.intersectsPoint(point)) {
  25366. return false;
  25367. }
  25368. if (!this.boundingBox.intersectsPoint(point)) {
  25369. return false;
  25370. }
  25371. return true;
  25372. };
  25373. /**
  25374. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25375. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25376. * @param boundingInfo the bounding info to check intersection with
  25377. * @param precise if the intersection should be done using OBB
  25378. * @returns if the bounding info intersects
  25379. */
  25380. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25381. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25382. return false;
  25383. }
  25384. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25385. return false;
  25386. }
  25387. if (!precise) {
  25388. return true;
  25389. }
  25390. var box0 = this.boundingBox;
  25391. var box1 = boundingInfo.boundingBox;
  25392. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25393. return false;
  25394. }
  25395. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25396. return false;
  25397. }
  25398. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25399. return false;
  25400. }
  25401. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25402. return false;
  25403. }
  25404. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25405. return false;
  25406. }
  25407. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25408. return false;
  25409. }
  25410. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25411. return false;
  25412. }
  25413. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25414. return false;
  25415. }
  25416. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25417. return false;
  25418. }
  25419. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25420. return false;
  25421. }
  25422. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25423. return false;
  25424. }
  25425. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25426. return false;
  25427. }
  25428. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25429. return false;
  25430. }
  25431. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25432. return false;
  25433. }
  25434. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25435. return false;
  25436. }
  25437. return true;
  25438. };
  25439. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25440. return BoundingInfo;
  25441. }());
  25442. /***/ }),
  25443. /***/ "./Culling/boundingSphere.ts":
  25444. /*!***********************************!*\
  25445. !*** ./Culling/boundingSphere.ts ***!
  25446. \***********************************/
  25447. /*! exports provided: BoundingSphere */
  25448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25449. "use strict";
  25450. __webpack_require__.r(__webpack_exports__);
  25451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  25452. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25453. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25454. /**
  25455. * Class used to store bounding sphere information
  25456. */
  25457. var BoundingSphere = /** @class */ (function () {
  25458. /**
  25459. * Creates a new bounding sphere
  25460. * @param min defines the minimum vector (in local space)
  25461. * @param max defines the maximum vector (in local space)
  25462. * @param worldMatrix defines the new world matrix
  25463. */
  25464. function BoundingSphere(min, max, worldMatrix) {
  25465. /**
  25466. * Gets the center of the bounding sphere in local space
  25467. */
  25468. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25469. /**
  25470. * Gets the center of the bounding sphere in world space
  25471. */
  25472. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25473. /**
  25474. * Gets the minimum vector in local space
  25475. */
  25476. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25477. /**
  25478. * Gets the maximum vector in local space
  25479. */
  25480. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25481. this.reConstruct(min, max, worldMatrix);
  25482. }
  25483. /**
  25484. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25485. * @param min defines the new minimum vector (in local space)
  25486. * @param max defines the new maximum vector (in local space)
  25487. * @param worldMatrix defines the new world matrix
  25488. */
  25489. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25490. this.minimum.copyFrom(min);
  25491. this.maximum.copyFrom(max);
  25492. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25493. max.addToRef(min, this.center).scaleInPlace(0.5);
  25494. this.radius = distance * 0.5;
  25495. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25496. };
  25497. /**
  25498. * Scale the current bounding sphere by applying a scale factor
  25499. * @param factor defines the scale factor to apply
  25500. * @returns the current bounding box
  25501. */
  25502. BoundingSphere.prototype.scale = function (factor) {
  25503. var newRadius = this.radius * factor;
  25504. var tmpVectors = BoundingSphere.TmpVector3;
  25505. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25506. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25507. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25508. this.reConstruct(min, max, this._worldMatrix);
  25509. return this;
  25510. };
  25511. /**
  25512. * Gets the world matrix of the bounding box
  25513. * @returns a matrix
  25514. */
  25515. BoundingSphere.prototype.getWorldMatrix = function () {
  25516. return this._worldMatrix;
  25517. };
  25518. // Methods
  25519. /** @hidden */
  25520. BoundingSphere.prototype._update = function (worldMatrix) {
  25521. if (!worldMatrix.isIdentity()) {
  25522. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25523. var tempVector = BoundingSphere.TmpVector3[0];
  25524. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25525. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25526. }
  25527. else {
  25528. this.centerWorld.copyFrom(this.center);
  25529. this.radiusWorld = this.radius;
  25530. }
  25531. };
  25532. /**
  25533. * Tests if the bounding sphere is intersecting the frustum planes
  25534. * @param frustumPlanes defines the frustum planes to test
  25535. * @returns true if there is an intersection
  25536. */
  25537. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25538. var center = this.centerWorld;
  25539. var radius = this.radiusWorld;
  25540. for (var i = 0; i < 6; i++) {
  25541. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25542. return false;
  25543. }
  25544. }
  25545. return true;
  25546. };
  25547. /**
  25548. * Tests if the bounding sphere center is in between the frustum planes.
  25549. * Used for optimistic fast inclusion.
  25550. * @param frustumPlanes defines the frustum planes to test
  25551. * @returns true if the sphere center is in between the frustum planes
  25552. */
  25553. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25554. var center = this.centerWorld;
  25555. for (var i = 0; i < 6; i++) {
  25556. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25557. return false;
  25558. }
  25559. }
  25560. return true;
  25561. };
  25562. /**
  25563. * Tests if a point is inside the bounding sphere
  25564. * @param point defines the point to test
  25565. * @returns true if the point is inside the bounding sphere
  25566. */
  25567. BoundingSphere.prototype.intersectsPoint = function (point) {
  25568. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25569. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25570. return false;
  25571. }
  25572. return true;
  25573. };
  25574. // Statics
  25575. /**
  25576. * Checks if two sphere intersct
  25577. * @param sphere0 sphere 0
  25578. * @param sphere1 sphere 1
  25579. * @returns true if the speres intersect
  25580. */
  25581. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25582. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25583. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25584. if (radiusSum * radiusSum < squareDistance) {
  25585. return false;
  25586. }
  25587. return true;
  25588. };
  25589. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25590. return BoundingSphere;
  25591. }());
  25592. /***/ }),
  25593. /***/ "./Culling/index.ts":
  25594. /*!**************************!*\
  25595. !*** ./Culling/index.ts ***!
  25596. \**************************/
  25597. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25599. "use strict";
  25600. __webpack_require__.r(__webpack_exports__);
  25601. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25603. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25605. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25607. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25611. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25613. /***/ }),
  25614. /***/ "./Culling/ray.ts":
  25615. /*!************************!*\
  25616. !*** ./Culling/ray.ts ***!
  25617. \************************/
  25618. /*! exports provided: Ray */
  25619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25620. "use strict";
  25621. __webpack_require__.r(__webpack_exports__);
  25622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25623. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25624. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25625. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25626. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25627. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25628. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25629. /**
  25630. * Class representing a ray with position and direction
  25631. */
  25632. var Ray = /** @class */ (function () {
  25633. /**
  25634. * Creates a new ray
  25635. * @param origin origin point
  25636. * @param direction direction
  25637. * @param length length of the ray
  25638. */
  25639. function Ray(
  25640. /** origin point */
  25641. origin,
  25642. /** direction */
  25643. direction,
  25644. /** length of the ray */
  25645. length) {
  25646. if (length === void 0) { length = Number.MAX_VALUE; }
  25647. this.origin = origin;
  25648. this.direction = direction;
  25649. this.length = length;
  25650. }
  25651. // Methods
  25652. /**
  25653. * Checks if the ray intersects a box
  25654. * @param minimum bound of the box
  25655. * @param maximum bound of the box
  25656. * @param intersectionTreshold extra extend to be added to the box in all direction
  25657. * @returns if the box was hit
  25658. */
  25659. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25660. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25661. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25662. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25663. var d = 0.0;
  25664. var maxValue = Number.MAX_VALUE;
  25665. var inv;
  25666. var min;
  25667. var max;
  25668. var temp;
  25669. if (Math.abs(this.direction.x) < 0.0000001) {
  25670. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25671. return false;
  25672. }
  25673. }
  25674. else {
  25675. inv = 1.0 / this.direction.x;
  25676. min = (newMinimum.x - this.origin.x) * inv;
  25677. max = (newMaximum.x - this.origin.x) * inv;
  25678. if (max === -Infinity) {
  25679. max = Infinity;
  25680. }
  25681. if (min > max) {
  25682. temp = min;
  25683. min = max;
  25684. max = temp;
  25685. }
  25686. d = Math.max(min, d);
  25687. maxValue = Math.min(max, maxValue);
  25688. if (d > maxValue) {
  25689. return false;
  25690. }
  25691. }
  25692. if (Math.abs(this.direction.y) < 0.0000001) {
  25693. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25694. return false;
  25695. }
  25696. }
  25697. else {
  25698. inv = 1.0 / this.direction.y;
  25699. min = (newMinimum.y - this.origin.y) * inv;
  25700. max = (newMaximum.y - this.origin.y) * inv;
  25701. if (max === -Infinity) {
  25702. max = Infinity;
  25703. }
  25704. if (min > max) {
  25705. temp = min;
  25706. min = max;
  25707. max = temp;
  25708. }
  25709. d = Math.max(min, d);
  25710. maxValue = Math.min(max, maxValue);
  25711. if (d > maxValue) {
  25712. return false;
  25713. }
  25714. }
  25715. if (Math.abs(this.direction.z) < 0.0000001) {
  25716. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25717. return false;
  25718. }
  25719. }
  25720. else {
  25721. inv = 1.0 / this.direction.z;
  25722. min = (newMinimum.z - this.origin.z) * inv;
  25723. max = (newMaximum.z - this.origin.z) * inv;
  25724. if (max === -Infinity) {
  25725. max = Infinity;
  25726. }
  25727. if (min > max) {
  25728. temp = min;
  25729. min = max;
  25730. max = temp;
  25731. }
  25732. d = Math.max(min, d);
  25733. maxValue = Math.min(max, maxValue);
  25734. if (d > maxValue) {
  25735. return false;
  25736. }
  25737. }
  25738. return true;
  25739. };
  25740. /**
  25741. * Checks if the ray intersects a box
  25742. * @param box the bounding box to check
  25743. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25744. * @returns if the box was hit
  25745. */
  25746. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25747. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25748. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25749. };
  25750. /**
  25751. * If the ray hits a sphere
  25752. * @param sphere the bounding sphere to check
  25753. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25754. * @returns true if it hits the sphere
  25755. */
  25756. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25757. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25758. var x = sphere.center.x - this.origin.x;
  25759. var y = sphere.center.y - this.origin.y;
  25760. var z = sphere.center.z - this.origin.z;
  25761. var pyth = (x * x) + (y * y) + (z * z);
  25762. var radius = sphere.radius + intersectionTreshold;
  25763. var rr = radius * radius;
  25764. if (pyth <= rr) {
  25765. return true;
  25766. }
  25767. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25768. if (dot < 0.0) {
  25769. return false;
  25770. }
  25771. var temp = pyth - (dot * dot);
  25772. return temp <= rr;
  25773. };
  25774. /**
  25775. * If the ray hits a triange
  25776. * @param vertex0 triangle vertex
  25777. * @param vertex1 triangle vertex
  25778. * @param vertex2 triangle vertex
  25779. * @returns intersection information if hit
  25780. */
  25781. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25782. var edge1 = Ray.TmpVector3[0];
  25783. var edge2 = Ray.TmpVector3[1];
  25784. var pvec = Ray.TmpVector3[2];
  25785. var tvec = Ray.TmpVector3[3];
  25786. var qvec = Ray.TmpVector3[4];
  25787. vertex1.subtractToRef(vertex0, edge1);
  25788. vertex2.subtractToRef(vertex0, edge2);
  25789. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25790. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25791. if (det === 0) {
  25792. return null;
  25793. }
  25794. var invdet = 1 / det;
  25795. this.origin.subtractToRef(vertex0, tvec);
  25796. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25797. if (bu < 0 || bu > 1.0) {
  25798. return null;
  25799. }
  25800. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25801. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25802. if (bv < 0 || bu + bv > 1.0) {
  25803. return null;
  25804. }
  25805. //check if the distance is longer than the predefined length.
  25806. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25807. if (distance > this.length) {
  25808. return null;
  25809. }
  25810. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25811. };
  25812. /**
  25813. * Checks if ray intersects a plane
  25814. * @param plane the plane to check
  25815. * @returns the distance away it was hit
  25816. */
  25817. Ray.prototype.intersectsPlane = function (plane) {
  25818. var distance;
  25819. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25820. if (Math.abs(result1) < 9.99999997475243E-07) {
  25821. return null;
  25822. }
  25823. else {
  25824. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25825. distance = (-plane.d - result2) / result1;
  25826. if (distance < 0.0) {
  25827. if (distance < -9.99999997475243E-07) {
  25828. return null;
  25829. }
  25830. else {
  25831. return 0;
  25832. }
  25833. }
  25834. return distance;
  25835. }
  25836. };
  25837. /**
  25838. * Checks if ray intersects a mesh
  25839. * @param mesh the mesh to check
  25840. * @param fastCheck if only the bounding box should checked
  25841. * @returns picking info of the intersecton
  25842. */
  25843. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25844. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25845. mesh.getWorldMatrix().invertToRef(tm);
  25846. if (this._tmpRay) {
  25847. Ray.TransformToRef(this, tm, this._tmpRay);
  25848. }
  25849. else {
  25850. this._tmpRay = Ray.Transform(this, tm);
  25851. }
  25852. return mesh.intersects(this._tmpRay, fastCheck);
  25853. };
  25854. /**
  25855. * Checks if ray intersects a mesh
  25856. * @param meshes the meshes to check
  25857. * @param fastCheck if only the bounding box should checked
  25858. * @param results array to store result in
  25859. * @returns Array of picking infos
  25860. */
  25861. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25862. if (results) {
  25863. results.length = 0;
  25864. }
  25865. else {
  25866. results = [];
  25867. }
  25868. for (var i = 0; i < meshes.length; i++) {
  25869. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25870. if (pickInfo.hit) {
  25871. results.push(pickInfo);
  25872. }
  25873. }
  25874. results.sort(this._comparePickingInfo);
  25875. return results;
  25876. };
  25877. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25878. if (pickingInfoA.distance < pickingInfoB.distance) {
  25879. return -1;
  25880. }
  25881. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25882. return 1;
  25883. }
  25884. else {
  25885. return 0;
  25886. }
  25887. };
  25888. /**
  25889. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25890. * @param sega the first point of the segment to test the intersection against
  25891. * @param segb the second point of the segment to test the intersection against
  25892. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25893. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25894. */
  25895. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25896. var o = this.origin;
  25897. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25898. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25899. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25900. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25901. segb.subtractToRef(sega, u);
  25902. this.direction.scaleToRef(Ray.rayl, v);
  25903. o.addToRef(v, rsegb);
  25904. sega.subtractToRef(o, w);
  25905. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25906. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25907. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25908. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25909. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25910. var D = a * c - b * b; // always >= 0
  25911. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25912. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25913. // compute the line parameters of the two closest points
  25914. if (D < Ray.smallnum) { // the lines are almost parallel
  25915. sN = 0.0; // force using point P0 on segment S1
  25916. sD = 1.0; // to prevent possible division by 0.0 later
  25917. tN = e;
  25918. tD = c;
  25919. }
  25920. else { // get the closest points on the infinite lines
  25921. sN = (b * e - c * d);
  25922. tN = (a * e - b * d);
  25923. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25924. sN = 0.0;
  25925. tN = e;
  25926. tD = c;
  25927. }
  25928. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25929. sN = sD;
  25930. tN = e + b;
  25931. tD = c;
  25932. }
  25933. }
  25934. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25935. tN = 0.0;
  25936. // recompute sc for this edge
  25937. if (-d < 0.0) {
  25938. sN = 0.0;
  25939. }
  25940. else if (-d > a) {
  25941. sN = sD;
  25942. }
  25943. else {
  25944. sN = -d;
  25945. sD = a;
  25946. }
  25947. }
  25948. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25949. tN = tD;
  25950. // recompute sc for this edge
  25951. if ((-d + b) < 0.0) {
  25952. sN = 0;
  25953. }
  25954. else if ((-d + b) > a) {
  25955. sN = sD;
  25956. }
  25957. else {
  25958. sN = (-d + b);
  25959. sD = a;
  25960. }
  25961. }
  25962. // finally do the division to get sc and tc
  25963. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25964. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25965. // get the difference of the two closest points
  25966. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25967. v.scaleToRef(tc, qtc);
  25968. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25969. u.scaleToRef(sc, qsc);
  25970. qsc.addInPlace(w);
  25971. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25972. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25973. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25974. if (isIntersected) {
  25975. return qsc.length();
  25976. }
  25977. return -1;
  25978. };
  25979. /**
  25980. * Update the ray from viewport position
  25981. * @param x position
  25982. * @param y y position
  25983. * @param viewportWidth viewport width
  25984. * @param viewportHeight viewport height
  25985. * @param world world matrix
  25986. * @param view view matrix
  25987. * @param projection projection matrix
  25988. * @returns this ray updated
  25989. */
  25990. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25991. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25992. return this;
  25993. };
  25994. // Statics
  25995. /**
  25996. * Creates a ray with origin and direction of 0,0,0
  25997. * @returns the new ray
  25998. */
  25999. Ray.Zero = function () {
  26000. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  26001. };
  26002. /**
  26003. * Creates a new ray from screen space and viewport
  26004. * @param x position
  26005. * @param y y position
  26006. * @param viewportWidth viewport width
  26007. * @param viewportHeight viewport height
  26008. * @param world world matrix
  26009. * @param view view matrix
  26010. * @param projection projection matrix
  26011. * @returns new ray
  26012. */
  26013. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26014. var result = Ray.Zero();
  26015. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  26016. };
  26017. /**
  26018. * 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
  26019. * transformed to the given world matrix.
  26020. * @param origin The origin point
  26021. * @param end The end point
  26022. * @param world a matrix to transform the ray to. Default is the identity matrix.
  26023. * @returns the new ray
  26024. */
  26025. Ray.CreateNewFromTo = function (origin, end, world) {
  26026. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  26027. var direction = end.subtract(origin);
  26028. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  26029. direction.normalize();
  26030. return Ray.Transform(new Ray(origin, direction, length), world);
  26031. };
  26032. /**
  26033. * Transforms a ray by a matrix
  26034. * @param ray ray to transform
  26035. * @param matrix matrix to apply
  26036. * @returns the resulting new ray
  26037. */
  26038. Ray.Transform = function (ray, matrix) {
  26039. 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));
  26040. Ray.TransformToRef(ray, matrix, result);
  26041. return result;
  26042. };
  26043. /**
  26044. * Transforms a ray by a matrix
  26045. * @param ray ray to transform
  26046. * @param matrix matrix to apply
  26047. * @param result ray to store result in
  26048. */
  26049. Ray.TransformToRef = function (ray, matrix, result) {
  26050. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26051. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26052. result.length = ray.length;
  26053. var dir = result.direction;
  26054. var len = dir.length();
  26055. if (!(len === 0 || len === 1)) {
  26056. var num = 1.0 / len;
  26057. dir.x *= num;
  26058. dir.y *= num;
  26059. dir.z *= num;
  26060. result.length *= len;
  26061. }
  26062. };
  26063. /**
  26064. * Unproject a ray from screen space to object space
  26065. * @param sourceX defines the screen space x coordinate to use
  26066. * @param sourceY defines the screen space y coordinate to use
  26067. * @param viewportWidth defines the current width of the viewport
  26068. * @param viewportHeight defines the current height of the viewport
  26069. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26070. * @param view defines the view matrix to use
  26071. * @param projection defines the projection matrix to use
  26072. */
  26073. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26074. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26075. world.multiplyToRef(view, matrix);
  26076. matrix.multiplyToRef(projection, matrix);
  26077. matrix.invert();
  26078. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26079. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26080. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26081. nearScreenSource.z = -1.0;
  26082. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26083. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26084. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26085. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26086. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26087. this.origin.copyFrom(nearVec3);
  26088. farVec3.subtractToRef(nearVec3, this.direction);
  26089. this.direction.normalize();
  26090. };
  26091. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26092. Ray.smallnum = 0.00000001;
  26093. Ray.rayl = 10e8;
  26094. return Ray;
  26095. }());
  26096. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26097. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26098. var result = Ray.Zero();
  26099. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26100. return result;
  26101. };
  26102. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26103. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26104. var engine = this.getEngine();
  26105. if (!camera) {
  26106. if (!this.activeCamera) {
  26107. throw new Error("Active camera not set");
  26108. }
  26109. camera = this.activeCamera;
  26110. }
  26111. var cameraViewport = camera.viewport;
  26112. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26113. // Moving coordinates to local viewport world
  26114. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26115. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26116. 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());
  26117. return this;
  26118. };
  26119. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26120. var result = Ray.Zero();
  26121. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26122. return result;
  26123. };
  26124. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26125. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26126. return this;
  26127. }
  26128. var engine = this.getEngine();
  26129. if (!camera) {
  26130. if (!this.activeCamera) {
  26131. throw new Error("Active camera not set");
  26132. }
  26133. camera = this.activeCamera;
  26134. }
  26135. var cameraViewport = camera.viewport;
  26136. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26137. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26138. // Moving coordinates to local viewport world
  26139. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26140. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26141. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26142. return this;
  26143. };
  26144. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26145. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26146. return null;
  26147. }
  26148. var pickingInfo = null;
  26149. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26150. var mesh = this.meshes[meshIndex];
  26151. if (predicate) {
  26152. if (!predicate(mesh)) {
  26153. continue;
  26154. }
  26155. }
  26156. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26157. continue;
  26158. }
  26159. var world = mesh.getWorldMatrix();
  26160. var ray = rayFunction(world);
  26161. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26162. if (!result || !result.hit) {
  26163. continue;
  26164. }
  26165. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26166. continue;
  26167. }
  26168. pickingInfo = result;
  26169. if (fastCheck) {
  26170. break;
  26171. }
  26172. }
  26173. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26174. };
  26175. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26176. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26177. return null;
  26178. }
  26179. var pickingInfos = new Array();
  26180. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26181. var mesh = this.meshes[meshIndex];
  26182. if (predicate) {
  26183. if (!predicate(mesh)) {
  26184. continue;
  26185. }
  26186. }
  26187. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26188. continue;
  26189. }
  26190. var world = mesh.getWorldMatrix();
  26191. var ray = rayFunction(world);
  26192. var result = mesh.intersects(ray, false, trianglePredicate);
  26193. if (!result || !result.hit) {
  26194. continue;
  26195. }
  26196. pickingInfos.push(result);
  26197. }
  26198. return pickingInfos;
  26199. };
  26200. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26201. var _this = this;
  26202. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26203. return null;
  26204. }
  26205. var result = this._internalPick(function (world) {
  26206. if (!_this._tempPickingRay) {
  26207. _this._tempPickingRay = Ray.Zero();
  26208. }
  26209. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26210. return _this._tempPickingRay;
  26211. }, predicate, fastCheck, trianglePredicate);
  26212. if (result) {
  26213. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26214. }
  26215. return result;
  26216. };
  26217. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26218. var _this = this;
  26219. var result = this._internalPick(function (world) {
  26220. if (!_this._pickWithRayInverseMatrix) {
  26221. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26222. }
  26223. world.invertToRef(_this._pickWithRayInverseMatrix);
  26224. if (!_this._cachedRayForTransform) {
  26225. _this._cachedRayForTransform = Ray.Zero();
  26226. }
  26227. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26228. return _this._cachedRayForTransform;
  26229. }, predicate, fastCheck, trianglePredicate);
  26230. if (result) {
  26231. result.ray = ray;
  26232. }
  26233. return result;
  26234. };
  26235. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26236. var _this = this;
  26237. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26238. };
  26239. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26240. var _this = this;
  26241. return this._internalMultiPick(function (world) {
  26242. if (!_this._pickWithRayInverseMatrix) {
  26243. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26244. }
  26245. world.invertToRef(_this._pickWithRayInverseMatrix);
  26246. if (!_this._cachedRayForTransform) {
  26247. _this._cachedRayForTransform = Ray.Zero();
  26248. }
  26249. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26250. return _this._cachedRayForTransform;
  26251. }, predicate, trianglePredicate);
  26252. };
  26253. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26254. if (length === void 0) { length = 100; }
  26255. if (!transform) {
  26256. transform = this.getWorldMatrix();
  26257. }
  26258. if (!origin) {
  26259. origin = this.position;
  26260. }
  26261. 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);
  26262. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26263. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26264. return new Ray(origin, direction, length);
  26265. };
  26266. /***/ }),
  26267. /***/ "./Debug/axesViewer.ts":
  26268. /*!*****************************!*\
  26269. !*** ./Debug/axesViewer.ts ***!
  26270. \*****************************/
  26271. /*! exports provided: AxesViewer */
  26272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26273. "use strict";
  26274. __webpack_require__.r(__webpack_exports__);
  26275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26276. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26277. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26278. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26279. /**
  26280. * The Axes viewer will show 3 axes in a specific point in space
  26281. */
  26282. var AxesViewer = /** @class */ (function () {
  26283. /**
  26284. * Creates a new AxesViewer
  26285. * @param scene defines the hosting scene
  26286. * @param scaleLines defines a number used to scale line length (1 by default)
  26287. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26288. * @param xAxis defines the node hierarchy used to render the x-axis
  26289. * @param yAxis defines the node hierarchy used to render the y-axis
  26290. * @param zAxis defines the node hierarchy used to render the z-axis
  26291. */
  26292. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26293. if (scaleLines === void 0) { scaleLines = 1; }
  26294. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26295. this._scaleLinesFactor = 4;
  26296. this._instanced = false;
  26297. /**
  26298. * Gets or sets a number used to scale line length
  26299. */
  26300. this.scaleLines = 1;
  26301. this.scaleLines = scaleLines;
  26302. if (!xAxis) {
  26303. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26304. redColoredMaterial.disableLighting = true;
  26305. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26306. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26307. }
  26308. if (!yAxis) {
  26309. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26310. greenColoredMaterial.disableLighting = true;
  26311. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26312. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26313. }
  26314. if (!zAxis) {
  26315. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26316. blueColoredMaterial.disableLighting = true;
  26317. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26318. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26319. }
  26320. this._xAxis = xAxis;
  26321. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26322. this._yAxis = yAxis;
  26323. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26324. this._zAxis = zAxis;
  26325. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26326. if (renderingGroupId != null) {
  26327. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26328. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26329. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26330. }
  26331. this.scene = scene;
  26332. 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());
  26333. }
  26334. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26335. /** Gets the node hierarchy used to render x-axis */
  26336. get: function () {
  26337. return this._xAxis;
  26338. },
  26339. enumerable: true,
  26340. configurable: true
  26341. });
  26342. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26343. /** Gets the node hierarchy used to render y-axis */
  26344. get: function () {
  26345. return this._yAxis;
  26346. },
  26347. enumerable: true,
  26348. configurable: true
  26349. });
  26350. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26351. /** Gets the node hierarchy used to render z-axis */
  26352. get: function () {
  26353. return this._zAxis;
  26354. },
  26355. enumerable: true,
  26356. configurable: true
  26357. });
  26358. /**
  26359. * Force the viewer to update
  26360. * @param position defines the position of the viewer
  26361. * @param xaxis defines the x axis of the viewer
  26362. * @param yaxis defines the y axis of the viewer
  26363. * @param zaxis defines the z axis of the viewer
  26364. */
  26365. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26366. this._xAxis.position.copyFrom(position);
  26367. this._xAxis.setDirection(xaxis);
  26368. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26369. this._yAxis.position.copyFrom(position);
  26370. this._yAxis.setDirection(yaxis);
  26371. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26372. this._zAxis.position.copyFrom(position);
  26373. this._zAxis.setDirection(zaxis);
  26374. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26375. };
  26376. /**
  26377. * Creates an instance of this axes viewer.
  26378. * @returns a new axes viewer with instanced meshes
  26379. */
  26380. AxesViewer.prototype.createInstance = function () {
  26381. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26382. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26383. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26384. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26385. axesViewer._instanced = true;
  26386. return axesViewer;
  26387. };
  26388. /** Releases resources */
  26389. AxesViewer.prototype.dispose = function () {
  26390. if (this._xAxis) {
  26391. this._xAxis.dispose(false, !this._instanced);
  26392. delete this._xAxis;
  26393. }
  26394. if (this._yAxis) {
  26395. this._yAxis.dispose(false, !this._instanced);
  26396. delete this._yAxis;
  26397. }
  26398. if (this._zAxis) {
  26399. this._zAxis.dispose(false, !this._instanced);
  26400. delete this._zAxis;
  26401. }
  26402. delete this.scene;
  26403. };
  26404. AxesViewer._SetRenderingGroupId = function (node, id) {
  26405. node.getChildMeshes().forEach(function (mesh) {
  26406. mesh.renderingGroupId = id;
  26407. });
  26408. };
  26409. return AxesViewer;
  26410. }());
  26411. /***/ }),
  26412. /***/ "./Debug/boneAxesViewer.ts":
  26413. /*!*********************************!*\
  26414. !*** ./Debug/boneAxesViewer.ts ***!
  26415. \*********************************/
  26416. /*! exports provided: BoneAxesViewer */
  26417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26418. "use strict";
  26419. __webpack_require__.r(__webpack_exports__);
  26420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26421. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26422. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26423. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26424. /**
  26425. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26426. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26427. */
  26428. var BoneAxesViewer = /** @class */ (function (_super) {
  26429. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26430. /**
  26431. * Creates a new BoneAxesViewer
  26432. * @param scene defines the hosting scene
  26433. * @param bone defines the target bone
  26434. * @param mesh defines the target mesh
  26435. * @param scaleLines defines a scaling factor for line length (1 by default)
  26436. */
  26437. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26438. if (scaleLines === void 0) { scaleLines = 1; }
  26439. var _this = _super.call(this, scene, scaleLines) || this;
  26440. /** Gets current position */
  26441. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26442. /** Gets direction of X axis */
  26443. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26444. /** Gets direction of Y axis */
  26445. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26446. /** Gets direction of Z axis */
  26447. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26448. _this.mesh = mesh;
  26449. _this.bone = bone;
  26450. return _this;
  26451. }
  26452. /**
  26453. * Force the viewer to update
  26454. */
  26455. BoneAxesViewer.prototype.update = function () {
  26456. if (!this.mesh || !this.bone) {
  26457. return;
  26458. }
  26459. var bone = this.bone;
  26460. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26461. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26462. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26463. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26464. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26465. };
  26466. /** Releases resources */
  26467. BoneAxesViewer.prototype.dispose = function () {
  26468. if (this.mesh) {
  26469. this.mesh = null;
  26470. this.bone = null;
  26471. _super.prototype.dispose.call(this);
  26472. }
  26473. };
  26474. return BoneAxesViewer;
  26475. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26476. /***/ }),
  26477. /***/ "./Debug/debugLayer.ts":
  26478. /*!*****************************!*\
  26479. !*** ./Debug/debugLayer.ts ***!
  26480. \*****************************/
  26481. /*! exports provided: DebugLayer */
  26482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26483. "use strict";
  26484. __webpack_require__.r(__webpack_exports__);
  26485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26486. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26487. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26488. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26489. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26490. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26491. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26492. get: function () {
  26493. if (!this._debugLayer) {
  26494. this._debugLayer = new DebugLayer(this);
  26495. }
  26496. return this._debugLayer;
  26497. },
  26498. enumerable: true,
  26499. configurable: true
  26500. });
  26501. /**
  26502. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26503. * what is happening in your scene
  26504. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26505. */
  26506. var DebugLayer = /** @class */ (function () {
  26507. /**
  26508. * Instantiates a new debug layer.
  26509. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26510. * what is happening in your scene
  26511. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26512. * @param scene Defines the scene to inspect
  26513. */
  26514. function DebugLayer(scene) {
  26515. var _this = this;
  26516. this.BJSINSPECTOR = this._getGlobalInspector();
  26517. /**
  26518. * Observable triggered when a property is changed through the inspector.
  26519. */
  26520. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26521. this._scene = scene;
  26522. this._scene.onDisposeObservable.add(function () {
  26523. // Debug layer
  26524. if (_this._scene._debugLayer) {
  26525. _this._scene._debugLayer.hide();
  26526. }
  26527. });
  26528. }
  26529. /** Creates the inspector window. */
  26530. DebugLayer.prototype._createInspector = function (config) {
  26531. if (this.isVisible()) {
  26532. return;
  26533. }
  26534. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26535. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26536. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26537. };
  26538. /**
  26539. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26540. * @param entity defines the entity to select
  26541. * @param lineContainerTitle defines the specific block to highlight
  26542. */
  26543. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26544. if (this.BJSINSPECTOR) {
  26545. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26546. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26547. }
  26548. };
  26549. /** Get the inspector from bundle or global */
  26550. DebugLayer.prototype._getGlobalInspector = function () {
  26551. // UMD Global name detection from Webpack Bundle UMD Name.
  26552. if (typeof INSPECTOR !== 'undefined') {
  26553. return INSPECTOR;
  26554. }
  26555. // In case of module let s check the global emitted from the Inspector entry point.
  26556. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26557. return BABYLON;
  26558. }
  26559. return undefined;
  26560. };
  26561. /**
  26562. * Get if the inspector is visible or not.
  26563. * @returns true if visible otherwise, false
  26564. */
  26565. DebugLayer.prototype.isVisible = function () {
  26566. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26567. };
  26568. /**
  26569. * Hide the inspector and close its window.
  26570. */
  26571. DebugLayer.prototype.hide = function () {
  26572. if (this.BJSINSPECTOR) {
  26573. this.BJSINSPECTOR.Inspector.Hide();
  26574. }
  26575. };
  26576. /**
  26577. * Launch the debugLayer.
  26578. * @param config Define the configuration of the inspector
  26579. * @return a promise fulfilled when the debug layer is visible
  26580. */
  26581. DebugLayer.prototype.show = function (config) {
  26582. var _this = this;
  26583. return new Promise(function (resolve, reject) {
  26584. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26585. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26586. // Load inspector and add it to the DOM
  26587. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26588. _this._createInspector(config);
  26589. resolve(_this);
  26590. });
  26591. }
  26592. else {
  26593. // Otherwise creates the inspector
  26594. _this._createInspector(config);
  26595. resolve(_this);
  26596. }
  26597. });
  26598. };
  26599. /**
  26600. * Define the url to get the inspector script from.
  26601. * By default it uses the babylonjs CDN.
  26602. * @ignoreNaming
  26603. */
  26604. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26605. return DebugLayer;
  26606. }());
  26607. /***/ }),
  26608. /***/ "./Debug/index.ts":
  26609. /*!************************!*\
  26610. !*** ./Debug/index.ts ***!
  26611. \************************/
  26612. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26614. "use strict";
  26615. __webpack_require__.r(__webpack_exports__);
  26616. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26618. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26620. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26622. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26624. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26626. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26628. /***/ }),
  26629. /***/ "./Debug/physicsViewer.ts":
  26630. /*!********************************!*\
  26631. !*** ./Debug/physicsViewer.ts ***!
  26632. \********************************/
  26633. /*! exports provided: PhysicsViewer */
  26634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26635. "use strict";
  26636. __webpack_require__.r(__webpack_exports__);
  26637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26638. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26639. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26640. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26641. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26642. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26643. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26644. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26645. /**
  26646. * Used to show the physics impostor around the specific mesh
  26647. */
  26648. var PhysicsViewer = /** @class */ (function () {
  26649. /**
  26650. * Creates a new PhysicsViewer
  26651. * @param scene defines the hosting scene
  26652. */
  26653. function PhysicsViewer(scene) {
  26654. /** @hidden */
  26655. this._impostors = [];
  26656. /** @hidden */
  26657. this._meshes = [];
  26658. /** @hidden */
  26659. this._numMeshes = 0;
  26660. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  26661. var physicEngine = this._scene.getPhysicsEngine();
  26662. if (physicEngine) {
  26663. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26664. }
  26665. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  26666. this._utilityLayer.pickUtilitySceneFirst = false;
  26667. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26668. }
  26669. /** @hidden */
  26670. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26671. var plugin = this._physicsEnginePlugin;
  26672. for (var i = 0; i < this._numMeshes; i++) {
  26673. var impostor = this._impostors[i];
  26674. if (!impostor) {
  26675. continue;
  26676. }
  26677. if (impostor.isDisposed) {
  26678. this.hideImpostor(this._impostors[i--]);
  26679. }
  26680. else {
  26681. var mesh = this._meshes[i];
  26682. if (mesh && plugin) {
  26683. plugin.syncMeshWithImpostor(mesh, impostor);
  26684. }
  26685. }
  26686. }
  26687. };
  26688. /**
  26689. * Renders a specified physic impostor
  26690. * @param impostor defines the impostor to render
  26691. * @returns the new debug mesh used to render the impostor
  26692. */
  26693. PhysicsViewer.prototype.showImpostor = function (impostor) {
  26694. if (!this._scene) {
  26695. return null;
  26696. }
  26697. for (var i = 0; i < this._numMeshes; i++) {
  26698. if (this._impostors[i] == impostor) {
  26699. return null;
  26700. }
  26701. }
  26702. var debugMesh = this._getDebugMesh(impostor);
  26703. if (debugMesh) {
  26704. this._impostors[this._numMeshes] = impostor;
  26705. this._meshes[this._numMeshes] = debugMesh;
  26706. if (this._numMeshes === 0) {
  26707. this._renderFunction = this._updateDebugMeshes.bind(this);
  26708. this._scene.registerBeforeRender(this._renderFunction);
  26709. }
  26710. this._numMeshes++;
  26711. }
  26712. return debugMesh;
  26713. };
  26714. /**
  26715. * Hides a specified physic impostor
  26716. * @param impostor defines the impostor to hide
  26717. */
  26718. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26719. if (!impostor || !this._scene || !this._utilityLayer) {
  26720. return;
  26721. }
  26722. var removed = false;
  26723. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26724. for (var i = 0; i < this._numMeshes; i++) {
  26725. if (this._impostors[i] == impostor) {
  26726. var mesh = this._meshes[i];
  26727. if (!mesh) {
  26728. continue;
  26729. }
  26730. utilityLayerScene.removeMesh(mesh);
  26731. mesh.dispose();
  26732. this._numMeshes--;
  26733. if (this._numMeshes > 0) {
  26734. this._meshes[i] = this._meshes[this._numMeshes];
  26735. this._impostors[i] = this._impostors[this._numMeshes];
  26736. this._meshes[this._numMeshes] = null;
  26737. this._impostors[this._numMeshes] = null;
  26738. }
  26739. else {
  26740. this._meshes[0] = null;
  26741. this._impostors[0] = null;
  26742. }
  26743. removed = true;
  26744. break;
  26745. }
  26746. }
  26747. if (removed && this._numMeshes === 0) {
  26748. this._scene.unregisterBeforeRender(this._renderFunction);
  26749. }
  26750. };
  26751. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26752. if (!this._debugMaterial) {
  26753. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26754. this._debugMaterial.wireframe = true;
  26755. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26756. this._debugMaterial.disableLighting = true;
  26757. }
  26758. return this._debugMaterial;
  26759. };
  26760. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26761. if (!this._debugBoxMesh) {
  26762. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26763. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26764. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26765. }
  26766. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26767. };
  26768. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26769. if (!this._debugSphereMesh) {
  26770. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26771. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26772. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26773. }
  26774. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26775. };
  26776. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26777. if (!this._utilityLayer) {
  26778. return null;
  26779. }
  26780. var mesh = null;
  26781. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26782. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26783. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26784. impostor.getBoxSizeToRef(mesh.scaling);
  26785. }
  26786. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26787. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26788. var radius = impostor.getRadius();
  26789. mesh.scaling.x = radius * 2;
  26790. mesh.scaling.y = radius * 2;
  26791. mesh.scaling.z = radius * 2;
  26792. }
  26793. return mesh;
  26794. };
  26795. /** Releases all resources */
  26796. PhysicsViewer.prototype.dispose = function () {
  26797. for (var i = 0; i < this._numMeshes; i++) {
  26798. this.hideImpostor(this._impostors[i]);
  26799. }
  26800. if (this._debugBoxMesh) {
  26801. this._debugBoxMesh.dispose();
  26802. }
  26803. if (this._debugSphereMesh) {
  26804. this._debugSphereMesh.dispose();
  26805. }
  26806. if (this._debugMaterial) {
  26807. this._debugMaterial.dispose();
  26808. }
  26809. this._impostors.length = 0;
  26810. this._scene = null;
  26811. this._physicsEnginePlugin = null;
  26812. if (this._utilityLayer) {
  26813. this._utilityLayer.dispose();
  26814. this._utilityLayer = null;
  26815. }
  26816. };
  26817. return PhysicsViewer;
  26818. }());
  26819. /***/ }),
  26820. /***/ "./Debug/rayHelper.ts":
  26821. /*!****************************!*\
  26822. !*** ./Debug/rayHelper.ts ***!
  26823. \****************************/
  26824. /*! exports provided: RayHelper */
  26825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26826. "use strict";
  26827. __webpack_require__.r(__webpack_exports__);
  26828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26829. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26830. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26831. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26832. /**
  26833. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26834. * in order to better appreciate the issue one might have.
  26835. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26836. */
  26837. var RayHelper = /** @class */ (function () {
  26838. /**
  26839. * Instantiate a new ray helper.
  26840. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26841. * in order to better appreciate the issue one might have.
  26842. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26843. * @param ray Defines the ray we are currently tryin to visualize
  26844. */
  26845. function RayHelper(ray) {
  26846. this.ray = ray;
  26847. }
  26848. /**
  26849. * Helper function to create a colored helper in a scene in one line.
  26850. * @param ray Defines the ray we are currently tryin to visualize
  26851. * @param scene Defines the scene the ray is used in
  26852. * @param color Defines the color we want to see the ray in
  26853. * @returns The newly created ray helper.
  26854. */
  26855. RayHelper.CreateAndShow = function (ray, scene, color) {
  26856. var helper = new RayHelper(ray);
  26857. helper.show(scene, color);
  26858. return helper;
  26859. };
  26860. /**
  26861. * Shows the ray we are willing to debug.
  26862. * @param scene Defines the scene the ray needs to be rendered in
  26863. * @param color Defines the color the ray needs to be rendered in
  26864. */
  26865. RayHelper.prototype.show = function (scene, color) {
  26866. if (!this._renderFunction && this.ray) {
  26867. var ray = this.ray;
  26868. this._renderFunction = this._render.bind(this);
  26869. this._scene = scene;
  26870. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26871. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26872. if (this._renderFunction) {
  26873. this._scene.registerBeforeRender(this._renderFunction);
  26874. }
  26875. }
  26876. if (color && this._renderLine) {
  26877. this._renderLine.color.copyFrom(color);
  26878. }
  26879. };
  26880. /**
  26881. * Hides the ray we are debugging.
  26882. */
  26883. RayHelper.prototype.hide = function () {
  26884. if (this._renderFunction && this._scene) {
  26885. this._scene.unregisterBeforeRender(this._renderFunction);
  26886. this._scene = null;
  26887. this._renderFunction = null;
  26888. if (this._renderLine) {
  26889. this._renderLine.dispose();
  26890. this._renderLine = null;
  26891. }
  26892. this._renderPoints = [];
  26893. }
  26894. };
  26895. RayHelper.prototype._render = function () {
  26896. var ray = this.ray;
  26897. if (!ray) {
  26898. return;
  26899. }
  26900. var point = this._renderPoints[1];
  26901. var len = Math.min(ray.length, 1000000);
  26902. point.copyFrom(ray.direction);
  26903. point.scaleInPlace(len);
  26904. point.addInPlace(ray.origin);
  26905. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26906. };
  26907. /**
  26908. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26909. * @param mesh Defines the mesh we want the helper attached to
  26910. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26911. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26912. * @param length Defines the length of the ray
  26913. */
  26914. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26915. this._attachedToMesh = mesh;
  26916. var ray = this.ray;
  26917. if (!ray) {
  26918. return;
  26919. }
  26920. if (!ray.direction) {
  26921. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26922. }
  26923. if (!ray.origin) {
  26924. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26925. }
  26926. if (length) {
  26927. ray.length = length;
  26928. }
  26929. if (!meshSpaceOrigin) {
  26930. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26931. }
  26932. if (!meshSpaceDirection) {
  26933. // -1 so that this will work with Mesh.lookAt
  26934. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26935. }
  26936. if (!this._meshSpaceDirection) {
  26937. this._meshSpaceDirection = meshSpaceDirection.clone();
  26938. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26939. }
  26940. else {
  26941. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26942. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26943. }
  26944. if (!this._updateToMeshFunction) {
  26945. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26946. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26947. }
  26948. this._updateToMesh();
  26949. };
  26950. /**
  26951. * Detach the ray helper from the mesh it has previously been attached to.
  26952. */
  26953. RayHelper.prototype.detachFromMesh = function () {
  26954. if (this._attachedToMesh) {
  26955. if (this._updateToMeshFunction) {
  26956. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26957. }
  26958. this._attachedToMesh = null;
  26959. this._updateToMeshFunction = null;
  26960. }
  26961. };
  26962. RayHelper.prototype._updateToMesh = function () {
  26963. var ray = this.ray;
  26964. if (!this._attachedToMesh || !ray) {
  26965. return;
  26966. }
  26967. if (this._attachedToMesh._isDisposed) {
  26968. this.detachFromMesh();
  26969. return;
  26970. }
  26971. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26972. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26973. };
  26974. /**
  26975. * Dispose the helper and release its associated resources.
  26976. */
  26977. RayHelper.prototype.dispose = function () {
  26978. this.hide();
  26979. this.detachFromMesh();
  26980. this.ray = null;
  26981. };
  26982. return RayHelper;
  26983. }());
  26984. /***/ }),
  26985. /***/ "./Debug/skeletonViewer.ts":
  26986. /*!*********************************!*\
  26987. !*** ./Debug/skeletonViewer.ts ***!
  26988. \*********************************/
  26989. /*! exports provided: SkeletonViewer */
  26990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26991. "use strict";
  26992. __webpack_require__.r(__webpack_exports__);
  26993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26994. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26995. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26996. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26997. /**
  26998. * Class used to render a debug view of a given skeleton
  26999. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  27000. */
  27001. var SkeletonViewer = /** @class */ (function () {
  27002. /**
  27003. * Creates a new SkeletonViewer
  27004. * @param skeleton defines the skeleton to render
  27005. * @param mesh defines the mesh attached to the skeleton
  27006. * @param scene defines the hosting scene
  27007. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  27008. * @param renderingGroupId defines the rendering group id to use with the viewer
  27009. */
  27010. function SkeletonViewer(
  27011. /** defines the skeleton to render */
  27012. skeleton,
  27013. /** defines the mesh attached to the skeleton */
  27014. mesh, scene,
  27015. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  27016. autoUpdateBonesMatrices,
  27017. /** defines the rendering group id to use with the viewer */
  27018. renderingGroupId) {
  27019. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  27020. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  27021. this.skeleton = skeleton;
  27022. this.mesh = mesh;
  27023. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  27024. this.renderingGroupId = renderingGroupId;
  27025. /** Gets or sets the color used to render the skeleton */
  27026. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  27027. this._debugLines = new Array();
  27028. this._isEnabled = false;
  27029. this._scene = scene;
  27030. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  27031. this._utilityLayer.pickUtilitySceneFirst = false;
  27032. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27033. this.update();
  27034. this._renderFunction = this.update.bind(this);
  27035. }
  27036. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  27037. /**
  27038. * Returns the mesh used to render the bones
  27039. */
  27040. get: function () {
  27041. return this._debugMesh;
  27042. },
  27043. enumerable: true,
  27044. configurable: true
  27045. });
  27046. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27047. get: function () {
  27048. return this._isEnabled;
  27049. },
  27050. /** Gets or sets a boolean indicating if the viewer is enabled */
  27051. set: function (value) {
  27052. if (this._isEnabled === value) {
  27053. return;
  27054. }
  27055. this._isEnabled = value;
  27056. if (value) {
  27057. this._scene.registerBeforeRender(this._renderFunction);
  27058. }
  27059. else {
  27060. this._scene.unregisterBeforeRender(this._renderFunction);
  27061. }
  27062. },
  27063. enumerable: true,
  27064. configurable: true
  27065. });
  27066. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27067. if (x === void 0) { x = 0; }
  27068. if (y === void 0) { y = 0; }
  27069. if (z === void 0) { z = 0; }
  27070. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27071. var parentBone = bone.getParent();
  27072. tmat.copyFrom(bone.getLocalMatrix());
  27073. if (x !== 0 || y !== 0 || z !== 0) {
  27074. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27075. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27076. tmat2.setTranslationFromFloats(x, y, z);
  27077. tmat2.multiplyToRef(tmat, tmat);
  27078. }
  27079. if (parentBone) {
  27080. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27081. }
  27082. tmat.multiplyToRef(meshMat, tmat);
  27083. position.x = tmat.m[12];
  27084. position.y = tmat.m[13];
  27085. position.z = tmat.m[14];
  27086. };
  27087. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27088. var len = bones.length;
  27089. var meshPos = this.mesh.position;
  27090. for (var i = 0; i < len; i++) {
  27091. var bone = bones[i];
  27092. var points = this._debugLines[i];
  27093. if (!points) {
  27094. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27095. this._debugLines[i] = points;
  27096. }
  27097. this._getBonePosition(points[0], bone, meshMat);
  27098. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27099. points[0].subtractInPlace(meshPos);
  27100. points[1].subtractInPlace(meshPos);
  27101. }
  27102. };
  27103. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27104. var len = bones.length;
  27105. var boneNum = 0;
  27106. var meshPos = this.mesh.position;
  27107. for (var i = len - 1; i >= 0; i--) {
  27108. var childBone = bones[i];
  27109. var parentBone = childBone.getParent();
  27110. if (!parentBone) {
  27111. continue;
  27112. }
  27113. var points = this._debugLines[boneNum];
  27114. if (!points) {
  27115. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27116. this._debugLines[boneNum] = points;
  27117. }
  27118. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  27119. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  27120. points[0].subtractInPlace(meshPos);
  27121. points[1].subtractInPlace(meshPos);
  27122. boneNum++;
  27123. }
  27124. };
  27125. /** Update the viewer to sync with current skeleton state */
  27126. SkeletonViewer.prototype.update = function () {
  27127. if (!this._utilityLayer) {
  27128. return;
  27129. }
  27130. if (this.autoUpdateBonesMatrices) {
  27131. this.skeleton.computeAbsoluteTransforms();
  27132. }
  27133. if (this.skeleton.bones[0].length === undefined) {
  27134. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  27135. }
  27136. else {
  27137. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  27138. }
  27139. var targetScene = this._utilityLayer.utilityLayerScene;
  27140. if (!this._debugMesh) {
  27141. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27142. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27143. }
  27144. else {
  27145. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27146. }
  27147. this._debugMesh.position.copyFrom(this.mesh.position);
  27148. this._debugMesh.color = this.color;
  27149. };
  27150. /** Release associated resources */
  27151. SkeletonViewer.prototype.dispose = function () {
  27152. this.isEnabled = false;
  27153. if (this._debugMesh) {
  27154. this.isEnabled = false;
  27155. this._debugMesh.dispose();
  27156. this._debugMesh = null;
  27157. }
  27158. if (this._utilityLayer) {
  27159. this._utilityLayer.dispose();
  27160. this._utilityLayer = null;
  27161. }
  27162. };
  27163. return SkeletonViewer;
  27164. }());
  27165. /***/ }),
  27166. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  27167. /*!*****************************************************!*\
  27168. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  27169. \*****************************************************/
  27170. /*! exports provided: _OcclusionDataStorage */
  27171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27172. "use strict";
  27173. __webpack_require__.r(__webpack_exports__);
  27174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  27175. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27176. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  27177. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  27178. /** @hidden */
  27179. var _OcclusionDataStorage = /** @class */ (function () {
  27180. function _OcclusionDataStorage() {
  27181. /** @hidden */
  27182. this.occlusionInternalRetryCounter = 0;
  27183. /** @hidden */
  27184. this.isOcclusionQueryInProgress = false;
  27185. /** @hidden */
  27186. this.isOccluded = false;
  27187. /** @hidden */
  27188. this.occlusionRetryCount = -1;
  27189. /** @hidden */
  27190. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  27191. /** @hidden */
  27192. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  27193. }
  27194. return _OcclusionDataStorage;
  27195. }());
  27196. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  27197. return this._gl.createQuery();
  27198. };
  27199. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  27200. this._gl.deleteQuery(query);
  27201. return this;
  27202. };
  27203. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  27204. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  27205. };
  27206. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  27207. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  27208. };
  27209. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  27210. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27211. this._gl.beginQuery(glAlgorithm, query);
  27212. return this;
  27213. };
  27214. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  27215. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27216. this._gl.endQuery(glAlgorithm);
  27217. return this;
  27218. };
  27219. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  27220. var timerQuery = this.getCaps().timerQuery;
  27221. if (timerQuery.createQueryEXT) {
  27222. return timerQuery.createQueryEXT();
  27223. }
  27224. return this.createQuery();
  27225. };
  27226. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  27227. var timerQuery = this.getCaps().timerQuery;
  27228. if (timerQuery.deleteQueryEXT) {
  27229. timerQuery.deleteQueryEXT(query);
  27230. return;
  27231. }
  27232. this.deleteQuery(query);
  27233. };
  27234. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  27235. var timerQuery = this.getCaps().timerQuery;
  27236. if (timerQuery.getQueryObjectEXT) {
  27237. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  27238. }
  27239. return this.getQueryResult(query);
  27240. };
  27241. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  27242. var timerQuery = this.getCaps().timerQuery;
  27243. if (timerQuery.getQueryObjectEXT) {
  27244. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  27245. }
  27246. return this.isQueryResultAvailable(query);
  27247. };
  27248. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  27249. var caps = this.getCaps();
  27250. var timerQuery = caps.timerQuery;
  27251. if (!timerQuery) {
  27252. return null;
  27253. }
  27254. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  27255. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27256. if (caps.canUseTimestampForTimerQuery) {
  27257. token._startTimeQuery = this._createTimeQuery();
  27258. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  27259. }
  27260. else {
  27261. if (this._currentNonTimestampToken) {
  27262. return this._currentNonTimestampToken;
  27263. }
  27264. token._timeElapsedQuery = this._createTimeQuery();
  27265. if (timerQuery.beginQueryEXT) {
  27266. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27267. }
  27268. else {
  27269. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27270. }
  27271. this._currentNonTimestampToken = token;
  27272. }
  27273. return token;
  27274. };
  27275. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  27276. var caps = this.getCaps();
  27277. var timerQuery = caps.timerQuery;
  27278. if (!timerQuery || !token) {
  27279. return -1;
  27280. }
  27281. if (caps.canUseTimestampForTimerQuery) {
  27282. if (!token._startTimeQuery) {
  27283. return -1;
  27284. }
  27285. if (!token._endTimeQuery) {
  27286. token._endTimeQuery = this._createTimeQuery();
  27287. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  27288. }
  27289. }
  27290. else if (!token._timeElapsedQueryEnded) {
  27291. if (!token._timeElapsedQuery) {
  27292. return -1;
  27293. }
  27294. if (timerQuery.endQueryEXT) {
  27295. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  27296. }
  27297. else {
  27298. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  27299. }
  27300. token._timeElapsedQueryEnded = true;
  27301. }
  27302. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27303. var available = false;
  27304. if (token._endTimeQuery) {
  27305. available = this._getTimeQueryAvailability(token._endTimeQuery);
  27306. }
  27307. else if (token._timeElapsedQuery) {
  27308. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  27309. }
  27310. if (available && !disjoint) {
  27311. var result = 0;
  27312. if (caps.canUseTimestampForTimerQuery) {
  27313. if (!token._startTimeQuery || !token._endTimeQuery) {
  27314. return -1;
  27315. }
  27316. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  27317. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  27318. result = timeEnd - timeStart;
  27319. this._deleteTimeQuery(token._startTimeQuery);
  27320. this._deleteTimeQuery(token._endTimeQuery);
  27321. token._startTimeQuery = null;
  27322. token._endTimeQuery = null;
  27323. }
  27324. else {
  27325. if (!token._timeElapsedQuery) {
  27326. return -1;
  27327. }
  27328. result = this._getTimeQueryResult(token._timeElapsedQuery);
  27329. this._deleteTimeQuery(token._timeElapsedQuery);
  27330. token._timeElapsedQuery = null;
  27331. token._timeElapsedQueryEnded = false;
  27332. this._currentNonTimestampToken = null;
  27333. }
  27334. return result;
  27335. }
  27336. return -1;
  27337. };
  27338. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  27339. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  27340. };
  27341. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  27342. get: function () {
  27343. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  27344. },
  27345. enumerable: false,
  27346. configurable: true
  27347. });
  27348. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  27349. get: function () {
  27350. if (!this.__occlusionDataStorage) {
  27351. this.__occlusionDataStorage = new _OcclusionDataStorage();
  27352. }
  27353. return this.__occlusionDataStorage;
  27354. },
  27355. enumerable: false,
  27356. configurable: true
  27357. });
  27358. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  27359. get: function () {
  27360. return this._occlusionDataStorage.isOccluded;
  27361. },
  27362. set: function (value) {
  27363. this._occlusionDataStorage.isOccluded = value;
  27364. },
  27365. enumerable: true,
  27366. configurable: true
  27367. });
  27368. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  27369. get: function () {
  27370. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  27371. },
  27372. set: function (value) {
  27373. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  27374. },
  27375. enumerable: true,
  27376. configurable: true
  27377. });
  27378. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  27379. get: function () {
  27380. return this._occlusionDataStorage.occlusionType;
  27381. },
  27382. set: function (value) {
  27383. this._occlusionDataStorage.occlusionType = value;
  27384. },
  27385. enumerable: true,
  27386. configurable: true
  27387. });
  27388. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  27389. get: function () {
  27390. return this._occlusionDataStorage.occlusionRetryCount;
  27391. },
  27392. set: function (value) {
  27393. this._occlusionDataStorage.occlusionRetryCount = value;
  27394. },
  27395. enumerable: true,
  27396. configurable: true
  27397. });
  27398. // We also need to update AbstractMesh as there is a portion of the code there
  27399. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  27400. var dataStorage = this._occlusionDataStorage;
  27401. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  27402. dataStorage.isOccluded = false;
  27403. return false;
  27404. }
  27405. var engine = this.getEngine();
  27406. if (engine.webGLVersion < 2) {
  27407. dataStorage.isOccluded = false;
  27408. return false;
  27409. }
  27410. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  27411. dataStorage.isOccluded = false;
  27412. return false;
  27413. }
  27414. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  27415. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  27416. if (isOcclusionQueryAvailable) {
  27417. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  27418. dataStorage.isOcclusionQueryInProgress = false;
  27419. dataStorage.occlusionInternalRetryCounter = 0;
  27420. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  27421. }
  27422. else {
  27423. dataStorage.occlusionInternalRetryCounter++;
  27424. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  27425. dataStorage.isOcclusionQueryInProgress = false;
  27426. dataStorage.occlusionInternalRetryCounter = 0;
  27427. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  27428. // if strict continue the last state of the object.
  27429. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  27430. }
  27431. else {
  27432. return false;
  27433. }
  27434. }
  27435. }
  27436. var scene = this.getScene();
  27437. if (scene.getBoundingBoxRenderer) {
  27438. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  27439. if (!this._occlusionQuery) {
  27440. this._occlusionQuery = engine.createQuery();
  27441. }
  27442. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  27443. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  27444. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  27445. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  27446. }
  27447. return dataStorage.isOccluded;
  27448. };
  27449. /***/ }),
  27450. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  27451. /*!********************************************************!*\
  27452. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  27453. \********************************************************/
  27454. /*! exports provided: _forceTransformFeedbackToBundle */
  27455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27456. "use strict";
  27457. __webpack_require__.r(__webpack_exports__);
  27458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  27459. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27460. /** @hidden */
  27461. var _forceTransformFeedbackToBundle = true;
  27462. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  27463. return this._gl.createTransformFeedback();
  27464. };
  27465. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  27466. this._gl.deleteTransformFeedback(value);
  27467. };
  27468. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  27469. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  27470. };
  27471. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  27472. if (usePoints === void 0) { usePoints = true; }
  27473. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  27474. };
  27475. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  27476. this._gl.endTransformFeedback();
  27477. };
  27478. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  27479. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  27480. };
  27481. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  27482. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  27483. };
  27484. /***/ }),
  27485. /***/ "./Engines/Extensions/index.ts":
  27486. /*!*************************************!*\
  27487. !*** ./Engines/Extensions/index.ts ***!
  27488. \*************************************/
  27489. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  27490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27491. "use strict";
  27492. __webpack_require__.r(__webpack_exports__);
  27493. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  27494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  27495. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  27496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  27497. /***/ }),
  27498. /***/ "./Engines/constants.ts":
  27499. /*!******************************!*\
  27500. !*** ./Engines/constants.ts ***!
  27501. \******************************/
  27502. /*! exports provided: Constants */
  27503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27504. "use strict";
  27505. __webpack_require__.r(__webpack_exports__);
  27506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27507. /** Defines the cross module used constants to avoid circular dependncies */
  27508. var Constants = /** @class */ (function () {
  27509. function Constants() {
  27510. }
  27511. /** Defines that alpha blending is disabled */
  27512. Constants.ALPHA_DISABLE = 0;
  27513. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27514. Constants.ALPHA_ADD = 1;
  27515. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27516. Constants.ALPHA_COMBINE = 2;
  27517. /** Defines that alpha blending to DEST - SRC * DEST */
  27518. Constants.ALPHA_SUBTRACT = 3;
  27519. /** Defines that alpha blending to SRC * DEST */
  27520. Constants.ALPHA_MULTIPLY = 4;
  27521. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27522. Constants.ALPHA_MAXIMIZED = 5;
  27523. /** Defines that alpha blending to SRC + DEST */
  27524. Constants.ALPHA_ONEONE = 6;
  27525. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27526. Constants.ALPHA_PREMULTIPLIED = 7;
  27527. /**
  27528. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27529. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27530. */
  27531. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27532. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27533. Constants.ALPHA_INTERPOLATE = 9;
  27534. /**
  27535. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27536. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27537. */
  27538. Constants.ALPHA_SCREENMODE = 10;
  27539. /** Defines that the ressource is not delayed*/
  27540. Constants.DELAYLOADSTATE_NONE = 0;
  27541. /** Defines that the ressource was successfully delay loaded */
  27542. Constants.DELAYLOADSTATE_LOADED = 1;
  27543. /** Defines that the ressource is currently delay loading */
  27544. Constants.DELAYLOADSTATE_LOADING = 2;
  27545. /** Defines that the ressource is delayed and has not started loading */
  27546. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27547. // Depht or Stencil test Constants.
  27548. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27549. Constants.NEVER = 0x0200;
  27550. /** 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 */
  27551. Constants.ALWAYS = 0x0207;
  27552. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27553. Constants.LESS = 0x0201;
  27554. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27555. Constants.EQUAL = 0x0202;
  27556. /** 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 */
  27557. Constants.LEQUAL = 0x0203;
  27558. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27559. Constants.GREATER = 0x0204;
  27560. /** 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 */
  27561. Constants.GEQUAL = 0x0206;
  27562. /** 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 */
  27563. Constants.NOTEQUAL = 0x0205;
  27564. // Stencil Actions Constants.
  27565. /** Passed to stencilOperation to specify that stencil value must be kept */
  27566. Constants.KEEP = 0x1E00;
  27567. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27568. Constants.REPLACE = 0x1E01;
  27569. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27570. Constants.INCR = 0x1E02;
  27571. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27572. Constants.DECR = 0x1E03;
  27573. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27574. Constants.INVERT = 0x150A;
  27575. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27576. Constants.INCR_WRAP = 0x8507;
  27577. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27578. Constants.DECR_WRAP = 0x8508;
  27579. /** Texture is not repeating outside of 0..1 UVs */
  27580. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27581. /** Texture is repeating outside of 0..1 UVs */
  27582. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27583. /** Texture is repeating and mirrored */
  27584. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27585. /** ALPHA */
  27586. Constants.TEXTUREFORMAT_ALPHA = 0;
  27587. /** LUMINANCE */
  27588. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27589. /** LUMINANCE_ALPHA */
  27590. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27591. /** RGB */
  27592. Constants.TEXTUREFORMAT_RGB = 4;
  27593. /** RGBA */
  27594. Constants.TEXTUREFORMAT_RGBA = 5;
  27595. /** RED */
  27596. Constants.TEXTUREFORMAT_RED = 6;
  27597. /** RED (2nd reference) */
  27598. Constants.TEXTUREFORMAT_R = 6;
  27599. /** RG */
  27600. Constants.TEXTUREFORMAT_RG = 7;
  27601. /** RED_INTEGER */
  27602. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27603. /** RED_INTEGER (2nd reference) */
  27604. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27605. /** RG_INTEGER */
  27606. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27607. /** RGB_INTEGER */
  27608. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27609. /** RGBA_INTEGER */
  27610. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27611. /** UNSIGNED_BYTE */
  27612. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27613. /** UNSIGNED_BYTE (2nd reference) */
  27614. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27615. /** FLOAT */
  27616. Constants.TEXTURETYPE_FLOAT = 1;
  27617. /** HALF_FLOAT */
  27618. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27619. /** BYTE */
  27620. Constants.TEXTURETYPE_BYTE = 3;
  27621. /** SHORT */
  27622. Constants.TEXTURETYPE_SHORT = 4;
  27623. /** UNSIGNED_SHORT */
  27624. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27625. /** INT */
  27626. Constants.TEXTURETYPE_INT = 6;
  27627. /** UNSIGNED_INT */
  27628. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27629. /** UNSIGNED_SHORT_4_4_4_4 */
  27630. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27631. /** UNSIGNED_SHORT_5_5_5_1 */
  27632. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27633. /** UNSIGNED_SHORT_5_6_5 */
  27634. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27635. /** UNSIGNED_INT_2_10_10_10_REV */
  27636. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27637. /** UNSIGNED_INT_24_8 */
  27638. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27639. /** UNSIGNED_INT_10F_11F_11F_REV */
  27640. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27641. /** UNSIGNED_INT_5_9_9_9_REV */
  27642. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27643. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27644. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27645. /** nearest is mag = nearest and min = nearest and mip = linear */
  27646. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27647. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27648. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27649. /** Trilinear is mag = linear and min = linear and mip = linear */
  27650. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27651. /** nearest is mag = nearest and min = nearest and mip = linear */
  27652. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27653. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27654. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27655. /** Trilinear is mag = linear and min = linear and mip = linear */
  27656. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27657. /** mag = nearest and min = nearest and mip = nearest */
  27658. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27659. /** mag = nearest and min = linear and mip = nearest */
  27660. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27661. /** mag = nearest and min = linear and mip = linear */
  27662. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27663. /** mag = nearest and min = linear and mip = none */
  27664. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27665. /** mag = nearest and min = nearest and mip = none */
  27666. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27667. /** mag = linear and min = nearest and mip = nearest */
  27668. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27669. /** mag = linear and min = nearest and mip = linear */
  27670. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27671. /** mag = linear and min = linear and mip = none */
  27672. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27673. /** mag = linear and min = nearest and mip = none */
  27674. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27675. /** Explicit coordinates mode */
  27676. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27677. /** Spherical coordinates mode */
  27678. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27679. /** Planar coordinates mode */
  27680. Constants.TEXTURE_PLANAR_MODE = 2;
  27681. /** Cubic coordinates mode */
  27682. Constants.TEXTURE_CUBIC_MODE = 3;
  27683. /** Projection coordinates mode */
  27684. Constants.TEXTURE_PROJECTION_MODE = 4;
  27685. /** Skybox coordinates mode */
  27686. Constants.TEXTURE_SKYBOX_MODE = 5;
  27687. /** Inverse Cubic coordinates mode */
  27688. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27689. /** Equirectangular coordinates mode */
  27690. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27691. /** Equirectangular Fixed coordinates mode */
  27692. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27693. /** Equirectangular Fixed Mirrored coordinates mode */
  27694. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27695. // Texture rescaling mode
  27696. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27697. Constants.SCALEMODE_FLOOR = 1;
  27698. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27699. Constants.SCALEMODE_NEAREST = 2;
  27700. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27701. Constants.SCALEMODE_CEILING = 3;
  27702. /**
  27703. * The dirty texture flag value
  27704. */
  27705. Constants.MATERIAL_TextureDirtyFlag = 1;
  27706. /**
  27707. * The dirty light flag value
  27708. */
  27709. Constants.MATERIAL_LightDirtyFlag = 2;
  27710. /**
  27711. * The dirty fresnel flag value
  27712. */
  27713. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27714. /**
  27715. * The dirty attribute flag value
  27716. */
  27717. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27718. /**
  27719. * The dirty misc flag value
  27720. */
  27721. Constants.MATERIAL_MiscDirtyFlag = 16;
  27722. /**
  27723. * The all dirty flag value
  27724. */
  27725. Constants.MATERIAL_AllDirtyFlag = 31;
  27726. /**
  27727. * Returns the triangle fill mode
  27728. */
  27729. Constants.MATERIAL_TriangleFillMode = 0;
  27730. /**
  27731. * Returns the wireframe mode
  27732. */
  27733. Constants.MATERIAL_WireFrameFillMode = 1;
  27734. /**
  27735. * Returns the point fill mode
  27736. */
  27737. Constants.MATERIAL_PointFillMode = 2;
  27738. /**
  27739. * Returns the point list draw mode
  27740. */
  27741. Constants.MATERIAL_PointListDrawMode = 3;
  27742. /**
  27743. * Returns the line list draw mode
  27744. */
  27745. Constants.MATERIAL_LineListDrawMode = 4;
  27746. /**
  27747. * Returns the line loop draw mode
  27748. */
  27749. Constants.MATERIAL_LineLoopDrawMode = 5;
  27750. /**
  27751. * Returns the line strip draw mode
  27752. */
  27753. Constants.MATERIAL_LineStripDrawMode = 6;
  27754. /**
  27755. * Returns the triangle strip draw mode
  27756. */
  27757. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27758. /**
  27759. * Returns the triangle fan draw mode
  27760. */
  27761. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27762. /**
  27763. * Stores the clock-wise side orientation
  27764. */
  27765. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27766. /**
  27767. * Stores the counter clock-wise side orientation
  27768. */
  27769. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27770. /**
  27771. * Nothing
  27772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27773. */
  27774. Constants.ACTION_NothingTrigger = 0;
  27775. /**
  27776. * On pick
  27777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27778. */
  27779. Constants.ACTION_OnPickTrigger = 1;
  27780. /**
  27781. * On left pick
  27782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27783. */
  27784. Constants.ACTION_OnLeftPickTrigger = 2;
  27785. /**
  27786. * On right pick
  27787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27788. */
  27789. Constants.ACTION_OnRightPickTrigger = 3;
  27790. /**
  27791. * On center pick
  27792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27793. */
  27794. Constants.ACTION_OnCenterPickTrigger = 4;
  27795. /**
  27796. * On pick down
  27797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27798. */
  27799. Constants.ACTION_OnPickDownTrigger = 5;
  27800. /**
  27801. * On double pick
  27802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27803. */
  27804. Constants.ACTION_OnDoublePickTrigger = 6;
  27805. /**
  27806. * On pick up
  27807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27808. */
  27809. Constants.ACTION_OnPickUpTrigger = 7;
  27810. /**
  27811. * On pick out.
  27812. * This trigger will only be raised if you also declared a OnPickDown
  27813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27814. */
  27815. Constants.ACTION_OnPickOutTrigger = 16;
  27816. /**
  27817. * On long press
  27818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27819. */
  27820. Constants.ACTION_OnLongPressTrigger = 8;
  27821. /**
  27822. * On pointer over
  27823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27824. */
  27825. Constants.ACTION_OnPointerOverTrigger = 9;
  27826. /**
  27827. * On pointer out
  27828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27829. */
  27830. Constants.ACTION_OnPointerOutTrigger = 10;
  27831. /**
  27832. * On every frame
  27833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27834. */
  27835. Constants.ACTION_OnEveryFrameTrigger = 11;
  27836. /**
  27837. * On intersection enter
  27838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27839. */
  27840. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27841. /**
  27842. * On intersection exit
  27843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27844. */
  27845. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27846. /**
  27847. * On key down
  27848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27849. */
  27850. Constants.ACTION_OnKeyDownTrigger = 14;
  27851. /**
  27852. * On key up
  27853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27854. */
  27855. Constants.ACTION_OnKeyUpTrigger = 15;
  27856. /**
  27857. * Billboard mode will only apply to Y axis
  27858. */
  27859. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27860. /**
  27861. * Billboard mode will apply to all axes
  27862. */
  27863. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27864. /**
  27865. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27866. */
  27867. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27868. /**
  27869. * Gets or sets base Assets URL
  27870. */
  27871. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27872. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27873. * Test order :
  27874. * Is the bounding sphere outside the frustum ?
  27875. * If not, are the bounding box vertices outside the frustum ?
  27876. * It not, then the cullable object is in the frustum.
  27877. */
  27878. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27879. /** Culling strategy : Bounding Sphere Only.
  27880. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27881. * It's also less accurate than the standard because some not visible objects can still be selected.
  27882. * Test : is the bounding sphere outside the frustum ?
  27883. * If not, then the cullable object is in the frustum.
  27884. */
  27885. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27886. /** Culling strategy : Optimistic Inclusion.
  27887. * This in an inclusion test first, then the standard exclusion test.
  27888. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27889. * 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.
  27890. * Anyway, it's as accurate as the standard strategy.
  27891. * Test :
  27892. * Is the cullable object bounding sphere center in the frustum ?
  27893. * If not, apply the default culling strategy.
  27894. */
  27895. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27896. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27897. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27898. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27899. * 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.
  27900. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27901. * Test :
  27902. * Is the cullable object bounding sphere center in the frustum ?
  27903. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27904. */
  27905. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27906. /**
  27907. * No logging while loading
  27908. */
  27909. Constants.SCENELOADER_NO_LOGGING = 0;
  27910. /**
  27911. * Minimal logging while loading
  27912. */
  27913. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27914. /**
  27915. * Summary logging while loading
  27916. */
  27917. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27918. /**
  27919. * Detailled logging while loading
  27920. */
  27921. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27922. return Constants;
  27923. }());
  27924. /***/ }),
  27925. /***/ "./Engines/engine.ts":
  27926. /*!***************************!*\
  27927. !*** ./Engines/engine.ts ***!
  27928. \***************************/
  27929. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27931. "use strict";
  27932. __webpack_require__.r(__webpack_exports__);
  27933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27938. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27939. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27940. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27941. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27942. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27943. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27944. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27945. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27946. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27947. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27948. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27949. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27950. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27951. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27952. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27953. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27954. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27955. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  27956. /**
  27957. * Keeps track of all the buffer info used in engine.
  27958. */
  27959. var BufferPointer = /** @class */ (function () {
  27960. function BufferPointer() {
  27961. }
  27962. return BufferPointer;
  27963. }());
  27964. /**
  27965. * Interface for attribute information associated with buffer instanciation
  27966. */
  27967. var InstancingAttributeInfo = /** @class */ (function () {
  27968. function InstancingAttributeInfo() {
  27969. }
  27970. return InstancingAttributeInfo;
  27971. }());
  27972. /**
  27973. * Define options used to create a depth texture
  27974. */
  27975. var DepthTextureCreationOptions = /** @class */ (function () {
  27976. function DepthTextureCreationOptions() {
  27977. }
  27978. return DepthTextureCreationOptions;
  27979. }());
  27980. /**
  27981. * Class used to describe the capabilities of the engine relatively to the current browser
  27982. */
  27983. var EngineCapabilities = /** @class */ (function () {
  27984. function EngineCapabilities() {
  27985. }
  27986. return EngineCapabilities;
  27987. }());
  27988. /**
  27989. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27990. */
  27991. var Engine = /** @class */ (function () {
  27992. /**
  27993. * Creates a new engine
  27994. * @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
  27995. * @param antialias defines enable antialiasing (default: false)
  27996. * @param options defines further options to be sent to the getContext() function
  27997. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27998. */
  27999. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  28000. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  28001. var _this = this;
  28002. // Public members
  28003. /**
  28004. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28005. */
  28006. this.forcePOTTextures = false;
  28007. /**
  28008. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28009. */
  28010. this.isFullscreen = false;
  28011. /**
  28012. * Gets a boolean indicating if the pointer is currently locked
  28013. */
  28014. this.isPointerLock = false;
  28015. /**
  28016. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28017. */
  28018. this.cullBackFaces = true;
  28019. /**
  28020. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28021. */
  28022. this.renderEvenInBackground = true;
  28023. /**
  28024. * Gets or sets a boolean indicating that cache can be kept between frames
  28025. */
  28026. this.preventCacheWipeBetweenFrames = false;
  28027. /**
  28028. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28029. **/
  28030. this.enableOfflineSupport = false;
  28031. /**
  28032. * 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)
  28033. **/
  28034. this.disableManifestCheck = false;
  28035. /**
  28036. * Gets the list of created scenes
  28037. */
  28038. this.scenes = new Array();
  28039. /**
  28040. * Event raised when a new scene is created
  28041. */
  28042. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28043. /**
  28044. * Gets the list of created postprocesses
  28045. */
  28046. this.postProcesses = new Array();
  28047. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28048. this.validateShaderPrograms = false;
  28049. // Observables
  28050. /**
  28051. * Observable event triggered each time the rendering canvas is resized
  28052. */
  28053. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28054. /**
  28055. * Observable event triggered each time the canvas loses focus
  28056. */
  28057. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28058. /**
  28059. * Observable event triggered each time the canvas gains focus
  28060. */
  28061. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28062. /**
  28063. * Observable event triggered each time the canvas receives pointerout event
  28064. */
  28065. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28066. /**
  28067. * Observable event triggered before each texture is initialized
  28068. */
  28069. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28070. //WebVR
  28071. this._vrDisplay = undefined;
  28072. this._vrSupported = false;
  28073. this._vrExclusivePointerMode = false;
  28074. // Uniform buffers list
  28075. /**
  28076. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28077. */
  28078. this.disableUniformBuffers = false;
  28079. /** @hidden */
  28080. this._uniformBuffers = new Array();
  28081. // Observables
  28082. /**
  28083. * Observable raised when the engine begins a new frame
  28084. */
  28085. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28086. /**
  28087. * If set, will be used to request the next animation frame for the render loop
  28088. */
  28089. this.customAnimationFrameRequester = null;
  28090. /**
  28091. * Observable raised when the engine ends the current frame
  28092. */
  28093. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28094. /**
  28095. * Observable raised when the engine is about to compile a shader
  28096. */
  28097. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28098. /**
  28099. * Observable raised when the engine has jsut compiled a shader
  28100. */
  28101. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28102. this._windowIsBackground = false;
  28103. this._webGLVersion = 1.0;
  28104. this._highPrecisionShadersAllowed = true;
  28105. /** @hidden */
  28106. this._badOS = false;
  28107. /** @hidden */
  28108. this._badDesktopOS = false;
  28109. /**
  28110. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28111. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28112. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28113. */
  28114. this.disableTextureBindingOptimization = false;
  28115. /**
  28116. * Observable signaled when VR display mode changes
  28117. */
  28118. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28119. /**
  28120. * Observable signaled when VR request present is complete
  28121. */
  28122. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28123. /**
  28124. * Observable signaled when VR request present starts
  28125. */
  28126. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28127. this._colorWrite = true;
  28128. /** @hidden */
  28129. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28130. /** @hidden */
  28131. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28132. this._renderingQueueLaunched = false;
  28133. this._activeRenderLoops = new Array();
  28134. // Deterministic lockstepMaxSteps
  28135. this._deterministicLockstep = false;
  28136. this._lockstepMaxSteps = 4;
  28137. // Lost context
  28138. /**
  28139. * Observable signaled when a context lost event is raised
  28140. */
  28141. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28142. /**
  28143. * Observable signaled when a context restored event is raised
  28144. */
  28145. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28146. this._contextWasLost = false;
  28147. this._doNotHandleContextLost = false;
  28148. // FPS
  28149. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  28150. this._fps = 60;
  28151. this._deltaTime = 0;
  28152. /**
  28153. * Turn this value on if you want to pause FPS computation when in background
  28154. */
  28155. this.disablePerformanceMonitorInBackground = false;
  28156. // States
  28157. /** @hidden */
  28158. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  28159. /** @hidden */
  28160. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  28161. /** @hidden */
  28162. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  28163. /** @hidden */
  28164. this._alphaMode = Engine.ALPHA_DISABLE;
  28165. // Cache
  28166. this._internalTexturesCache = new Array();
  28167. /** @hidden */
  28168. this._activeChannel = 0;
  28169. this._currentTextureChannel = -1;
  28170. /** @hidden */
  28171. this._boundTexturesCache = {};
  28172. this._compiledEffects = {};
  28173. this._vertexAttribArraysEnabled = [];
  28174. this._uintIndicesCurrentlySet = false;
  28175. this._currentBoundBuffer = new Array();
  28176. /** @hidden */
  28177. this._currentFramebuffer = null;
  28178. this._currentBufferPointers = new Array();
  28179. this._currentInstanceLocations = new Array();
  28180. this._currentInstanceBuffers = new Array();
  28181. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28182. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28183. this._vaoRecordInProgress = false;
  28184. this._mustWipeVertexAttributes = false;
  28185. this._nextFreeTextureSlots = new Array();
  28186. this._maxSimultaneousTextures = 0;
  28187. this._activeRequests = new Array();
  28188. // Hardware supported Compressed Textures
  28189. this._texturesSupported = new Array();
  28190. /**
  28191. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28192. */
  28193. this.premultipliedAlpha = true;
  28194. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  28195. this._onVRFullScreenTriggered = function () {
  28196. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  28197. //get the old size before we change
  28198. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  28199. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  28200. //get the width and height, change the render size
  28201. var leftEye = _this._vrDisplay.getEyeParameters('left');
  28202. _this.setHardwareScalingLevel(1);
  28203. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28204. }
  28205. else {
  28206. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  28207. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  28208. }
  28209. };
  28210. this._unpackFlipYCached = null;
  28211. /**
  28212. * In case you are sharing the context with other applications, it might
  28213. * be interested to not cache the unpack flip y state to ensure a consistent
  28214. * value would be set.
  28215. */
  28216. this.enableUnpackFlipYCached = true;
  28217. this._boundUniforms = {};
  28218. // Register promises
  28219. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  28220. var canvas = null;
  28221. Engine.Instances.push(this);
  28222. if (!canvasOrContext) {
  28223. return;
  28224. }
  28225. options = options || {};
  28226. if (canvasOrContext.getContext) {
  28227. canvas = canvasOrContext;
  28228. this._renderingCanvas = canvas;
  28229. if (antialias != null) {
  28230. options.antialias = antialias;
  28231. }
  28232. if (options.deterministicLockstep === undefined) {
  28233. options.deterministicLockstep = false;
  28234. }
  28235. if (options.lockstepMaxSteps === undefined) {
  28236. options.lockstepMaxSteps = 4;
  28237. }
  28238. if (options.preserveDrawingBuffer === undefined) {
  28239. options.preserveDrawingBuffer = false;
  28240. }
  28241. if (options.audioEngine === undefined) {
  28242. options.audioEngine = true;
  28243. }
  28244. if (options.stencil === undefined) {
  28245. options.stencil = true;
  28246. }
  28247. if (options.premultipliedAlpha === false) {
  28248. this.premultipliedAlpha = false;
  28249. }
  28250. this._deterministicLockstep = options.deterministicLockstep;
  28251. this._lockstepMaxSteps = options.lockstepMaxSteps;
  28252. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  28253. // Exceptions
  28254. if (navigator && navigator.userAgent) {
  28255. var ua = navigator.userAgent;
  28256. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  28257. var exception = _a[_i];
  28258. var key = exception.key;
  28259. var targets = exception.targets;
  28260. if (ua.indexOf(key) > -1) {
  28261. if (exception.capture && exception.captureConstraint) {
  28262. var capture = exception.capture;
  28263. var constraint = exception.captureConstraint;
  28264. var regex = new RegExp(capture);
  28265. var matches = regex.exec(ua);
  28266. if (matches && matches.length > 0) {
  28267. var capturedValue = parseInt(matches[matches.length - 1]);
  28268. if (capturedValue >= constraint) {
  28269. continue;
  28270. }
  28271. }
  28272. }
  28273. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  28274. var target = targets_1[_b];
  28275. switch (target) {
  28276. case "uniformBuffer":
  28277. this.disableUniformBuffers = true;
  28278. break;
  28279. case "textureBindingOptimization":
  28280. this.disableTextureBindingOptimization = true;
  28281. break;
  28282. }
  28283. }
  28284. }
  28285. }
  28286. }
  28287. // GL
  28288. if (!options.disableWebGL2Support) {
  28289. try {
  28290. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  28291. if (this._gl) {
  28292. this._webGLVersion = 2.0;
  28293. // Prevent weird browsers to lie :-)
  28294. if (!this._gl.deleteQuery) {
  28295. this._webGLVersion = 1.0;
  28296. }
  28297. }
  28298. }
  28299. catch (e) {
  28300. // Do nothing
  28301. }
  28302. }
  28303. if (!this._gl) {
  28304. if (!canvas) {
  28305. throw new Error("The provided canvas is null or undefined.");
  28306. }
  28307. try {
  28308. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  28309. }
  28310. catch (e) {
  28311. throw new Error("WebGL not supported");
  28312. }
  28313. }
  28314. if (!this._gl) {
  28315. throw new Error("WebGL not supported");
  28316. }
  28317. // Ensures a consistent color space unpacking of textures cross browser.
  28318. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  28319. this._onCanvasFocus = function () {
  28320. _this.onCanvasFocusObservable.notifyObservers(_this);
  28321. };
  28322. this._onCanvasBlur = function () {
  28323. _this.onCanvasBlurObservable.notifyObservers(_this);
  28324. };
  28325. canvas.addEventListener("focus", this._onCanvasFocus);
  28326. canvas.addEventListener("blur", this._onCanvasBlur);
  28327. this._onBlur = function () {
  28328. if (_this.disablePerformanceMonitorInBackground) {
  28329. _this._performanceMonitor.disable();
  28330. }
  28331. _this._windowIsBackground = true;
  28332. };
  28333. this._onFocus = function () {
  28334. if (_this.disablePerformanceMonitorInBackground) {
  28335. _this._performanceMonitor.enable();
  28336. }
  28337. _this._windowIsBackground = false;
  28338. };
  28339. this._onCanvasPointerOut = function (ev) {
  28340. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  28341. };
  28342. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28343. window.addEventListener("blur", this._onBlur);
  28344. window.addEventListener("focus", this._onFocus);
  28345. }
  28346. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  28347. // Context lost
  28348. if (!this._doNotHandleContextLost) {
  28349. this._onContextLost = function (evt) {
  28350. evt.preventDefault();
  28351. _this._contextWasLost = true;
  28352. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  28353. _this.onContextLostObservable.notifyObservers(_this);
  28354. };
  28355. this._onContextRestored = function () {
  28356. // Adding a timeout to avoid race condition at browser level
  28357. setTimeout(function () {
  28358. // Rebuild gl context
  28359. _this._initGLContext();
  28360. // Rebuild effects
  28361. _this._rebuildEffects();
  28362. // Rebuild textures
  28363. _this._rebuildInternalTextures();
  28364. // Rebuild buffers
  28365. _this._rebuildBuffers();
  28366. // Cache
  28367. _this.wipeCaches(true);
  28368. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  28369. _this.onContextRestoredObservable.notifyObservers(_this);
  28370. _this._contextWasLost = false;
  28371. }, 0);
  28372. };
  28373. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  28374. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  28375. }
  28376. if (!options.doNotHandleTouchAction) {
  28377. this._disableTouchAction();
  28378. }
  28379. }
  28380. else {
  28381. this._gl = canvasOrContext;
  28382. this._renderingCanvas = this._gl.canvas;
  28383. if (this._gl.renderbufferStorageMultisample) {
  28384. this._webGLVersion = 2.0;
  28385. }
  28386. var attributes = this._gl.getContextAttributes();
  28387. if (attributes) {
  28388. options.stencil = attributes.stencil;
  28389. }
  28390. }
  28391. if (options.useHighPrecisionFloats !== undefined) {
  28392. this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
  28393. }
  28394. // Viewport
  28395. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  28396. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  28397. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  28398. this.resize();
  28399. this._isStencilEnable = options.stencil ? true : false;
  28400. this._initGLContext();
  28401. if (canvas) {
  28402. var anyDoc_1 = document;
  28403. // Fullscreen
  28404. this._onFullscreenChange = function () {
  28405. if (anyDoc_1.fullscreen !== undefined) {
  28406. _this.isFullscreen = anyDoc_1.fullscreen;
  28407. }
  28408. else if (anyDoc_1.mozFullScreen !== undefined) {
  28409. _this.isFullscreen = anyDoc_1.mozFullScreen;
  28410. }
  28411. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  28412. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  28413. }
  28414. else if (anyDoc_1.msIsFullScreen !== undefined) {
  28415. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  28416. }
  28417. // Pointer lock
  28418. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  28419. canvas.requestPointerLock = canvas.requestPointerLock ||
  28420. canvas.msRequestPointerLock ||
  28421. canvas.mozRequestPointerLock ||
  28422. canvas.webkitRequestPointerLock;
  28423. if (canvas.requestPointerLock) {
  28424. canvas.requestPointerLock();
  28425. }
  28426. }
  28427. };
  28428. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  28429. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  28430. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  28431. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  28432. // Pointer lock
  28433. this._onPointerLockChange = function () {
  28434. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  28435. anyDoc_1.webkitPointerLockElement === canvas ||
  28436. anyDoc_1.msPointerLockElement === canvas ||
  28437. anyDoc_1.pointerLockElement === canvas);
  28438. };
  28439. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  28440. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  28441. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  28442. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  28443. this._onVRDisplayPointerRestricted = function () {
  28444. if (canvas) {
  28445. canvas.requestPointerLock();
  28446. }
  28447. };
  28448. this._onVRDisplayPointerUnrestricted = function () {
  28449. if (!anyDoc_1.exitPointerLock) {
  28450. return;
  28451. }
  28452. anyDoc_1.exitPointerLock();
  28453. };
  28454. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28455. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28456. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28457. }
  28458. }
  28459. // Create Audio Engine if needed.
  28460. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  28461. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  28462. }
  28463. // Prepare buffer pointers
  28464. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  28465. this._currentBufferPointers[i] = new BufferPointer();
  28466. }
  28467. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  28468. // Load WebVR Devices
  28469. if (options.autoEnableWebVR) {
  28470. this.initWebVR();
  28471. }
  28472. // Detect if we are running on a faulty buggy OS.
  28473. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  28474. // Detect if we are running on a faulty buggy desktop OS.
  28475. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  28476. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  28477. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  28478. }
  28479. Object.defineProperty(Engine, "Instances", {
  28480. /** Gets the list of created engines */
  28481. get: function () {
  28482. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  28483. },
  28484. enumerable: true,
  28485. configurable: true
  28486. });
  28487. Object.defineProperty(Engine, "LastCreatedEngine", {
  28488. /**
  28489. * Gets the latest created engine
  28490. */
  28491. get: function () {
  28492. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  28493. },
  28494. enumerable: true,
  28495. configurable: true
  28496. });
  28497. Object.defineProperty(Engine, "LastCreatedScene", {
  28498. /**
  28499. * Gets the latest created scene
  28500. */
  28501. get: function () {
  28502. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  28503. },
  28504. enumerable: true,
  28505. configurable: true
  28506. });
  28507. /**
  28508. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28509. * @param flag defines which part of the materials must be marked as dirty
  28510. * @param predicate defines a predicate used to filter which materials should be affected
  28511. */
  28512. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  28513. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  28514. var engine = Engine.Instances[engineIndex];
  28515. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28516. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28517. }
  28518. }
  28519. };
  28520. Object.defineProperty(Engine, "NpmPackage", {
  28521. /**
  28522. * Returns the current npm package of the sdk
  28523. */
  28524. // Not mixed with Version for tooling purpose.
  28525. get: function () {
  28526. return "babylonjs@4.0.0-alpha.32";
  28527. },
  28528. enumerable: true,
  28529. configurable: true
  28530. });
  28531. Object.defineProperty(Engine, "Version", {
  28532. /**
  28533. * Returns the current version of the framework
  28534. */
  28535. get: function () {
  28536. return "4.0.0-alpha.32";
  28537. },
  28538. enumerable: true,
  28539. configurable: true
  28540. });
  28541. Object.defineProperty(Engine.prototype, "description", {
  28542. /**
  28543. * Returns a string describing the current engine
  28544. */
  28545. get: function () {
  28546. var description = "WebGL" + this.webGLVersion;
  28547. if (this._caps.parallelShaderCompile) {
  28548. description += " - Parallel shader compilation";
  28549. }
  28550. return description;
  28551. },
  28552. enumerable: true,
  28553. configurable: true
  28554. });
  28555. Object.defineProperty(Engine, "ShadersRepository", {
  28556. /**
  28557. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28558. */
  28559. get: function () {
  28560. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28561. },
  28562. set: function (value) {
  28563. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28564. },
  28565. enumerable: true,
  28566. configurable: true
  28567. });
  28568. /**
  28569. * Method called to create the default loading screen.
  28570. * This can be overriden in your own app.
  28571. * @param canvas The rendering canvas element
  28572. * @returns The loading screen
  28573. */
  28574. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28575. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28576. };
  28577. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28578. /**
  28579. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28580. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28581. */
  28582. get: function () {
  28583. return this._vrExclusivePointerMode;
  28584. },
  28585. enumerable: true,
  28586. configurable: true
  28587. });
  28588. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28589. /**
  28590. * Gets a boolean indicating that the engine supports uniform buffers
  28591. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28592. */
  28593. get: function () {
  28594. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28595. },
  28596. enumerable: true,
  28597. configurable: true
  28598. });
  28599. Object.defineProperty(Engine.prototype, "_shouldUseHighPrecisionShader", {
  28600. /** @hidden */
  28601. get: function () {
  28602. return this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed;
  28603. },
  28604. enumerable: true,
  28605. configurable: true
  28606. });
  28607. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28608. /**
  28609. * Gets a boolean indicating that only power of 2 textures are supported
  28610. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28611. */
  28612. get: function () {
  28613. return this._webGLVersion < 2 || this.forcePOTTextures;
  28614. },
  28615. enumerable: true,
  28616. configurable: true
  28617. });
  28618. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28619. /**
  28620. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28622. */
  28623. get: function () {
  28624. return this._doNotHandleContextLost;
  28625. },
  28626. set: function (value) {
  28627. this._doNotHandleContextLost = value;
  28628. },
  28629. enumerable: true,
  28630. configurable: true
  28631. });
  28632. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28633. /**
  28634. * Gets the performance monitor attached to this engine
  28635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28636. */
  28637. get: function () {
  28638. return this._performanceMonitor;
  28639. },
  28640. enumerable: true,
  28641. configurable: true
  28642. });
  28643. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28644. /**
  28645. * Gets the list of texture formats supported
  28646. */
  28647. get: function () {
  28648. return this._texturesSupported;
  28649. },
  28650. enumerable: true,
  28651. configurable: true
  28652. });
  28653. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28654. /**
  28655. * Gets the list of texture formats in use
  28656. */
  28657. get: function () {
  28658. return this._textureFormatInUse;
  28659. },
  28660. enumerable: true,
  28661. configurable: true
  28662. });
  28663. Object.defineProperty(Engine.prototype, "currentViewport", {
  28664. /**
  28665. * Gets the current viewport
  28666. */
  28667. get: function () {
  28668. return this._cachedViewport;
  28669. },
  28670. enumerable: true,
  28671. configurable: true
  28672. });
  28673. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28674. /**
  28675. * Gets the default empty texture
  28676. */
  28677. get: function () {
  28678. if (!this._emptyTexture) {
  28679. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28680. }
  28681. return this._emptyTexture;
  28682. },
  28683. enumerable: true,
  28684. configurable: true
  28685. });
  28686. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28687. /**
  28688. * Gets the default empty 3D texture
  28689. */
  28690. get: function () {
  28691. if (!this._emptyTexture3D) {
  28692. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28693. }
  28694. return this._emptyTexture3D;
  28695. },
  28696. enumerable: true,
  28697. configurable: true
  28698. });
  28699. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28700. /**
  28701. * Gets the default empty cube texture
  28702. */
  28703. get: function () {
  28704. if (!this._emptyCubeTexture) {
  28705. var faceData = new Uint8Array(4);
  28706. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28707. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28708. }
  28709. return this._emptyCubeTexture;
  28710. },
  28711. enumerable: true,
  28712. configurable: true
  28713. });
  28714. Engine.prototype._disableTouchAction = function () {
  28715. if (!this._renderingCanvas) {
  28716. return;
  28717. }
  28718. this._renderingCanvas.setAttribute("touch-action", "none");
  28719. this._renderingCanvas.style.touchAction = "none";
  28720. this._renderingCanvas.style.msTouchAction = "none";
  28721. };
  28722. Engine.prototype._rebuildInternalTextures = function () {
  28723. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28724. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28725. var internalTexture = currentState_1[_i];
  28726. internalTexture._rebuild();
  28727. }
  28728. };
  28729. Engine.prototype._rebuildEffects = function () {
  28730. for (var key in this._compiledEffects) {
  28731. var effect = this._compiledEffects[key];
  28732. effect._prepareEffect();
  28733. }
  28734. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28735. };
  28736. /**
  28737. * Gets a boolean indicating if all created effects are ready
  28738. * @returns true if all effects are ready
  28739. */
  28740. Engine.prototype.areAllEffectsReady = function () {
  28741. for (var key in this._compiledEffects) {
  28742. var effect = this._compiledEffects[key];
  28743. if (!effect.isReady()) {
  28744. return false;
  28745. }
  28746. }
  28747. return true;
  28748. };
  28749. Engine.prototype._rebuildBuffers = function () {
  28750. // Index / Vertex
  28751. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28752. var scene = _a[_i];
  28753. scene.resetCachedMaterial();
  28754. scene._rebuildGeometries();
  28755. scene._rebuildTextures();
  28756. }
  28757. // Uniforms
  28758. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28759. var uniformBuffer = _c[_b];
  28760. uniformBuffer._rebuild();
  28761. }
  28762. };
  28763. Engine.prototype._initGLContext = function () {
  28764. // Caps
  28765. this._caps = new EngineCapabilities();
  28766. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28767. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28768. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28769. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28770. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28771. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28772. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28773. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28774. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28775. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28776. // Infos
  28777. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28778. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28779. if (rendererInfo != null) {
  28780. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28781. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28782. }
  28783. if (!this._glVendor) {
  28784. this._glVendor = "Unknown vendor";
  28785. }
  28786. if (!this._glRenderer) {
  28787. this._glRenderer = "Unknown renderer";
  28788. }
  28789. // Constants
  28790. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28791. if (this._gl.RGBA16F !== 0x881A) {
  28792. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28793. }
  28794. if (this._gl.RGBA32F !== 0x8814) {
  28795. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28796. }
  28797. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28798. this._gl.DEPTH24_STENCIL8 = 35056;
  28799. }
  28800. // Extensions
  28801. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28802. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28803. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28804. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28805. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28806. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28807. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28808. 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');
  28809. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28810. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28811. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28812. this._caps.highPrecisionShaderSupported = false;
  28813. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28814. if (this._caps.timerQuery) {
  28815. if (this._webGLVersion === 1) {
  28816. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28817. }
  28818. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28819. }
  28820. // Checks if some of the format renders first to allow the use of webgl inspector.
  28821. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28822. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28823. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28824. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28825. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28826. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28827. if (this._webGLVersion > 1) {
  28828. this._gl.HALF_FLOAT_OES = 0x140B;
  28829. }
  28830. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28831. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28832. // Draw buffers
  28833. if (this._webGLVersion > 1) {
  28834. this._caps.drawBuffersExtension = true;
  28835. }
  28836. else {
  28837. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28838. if (drawBuffersExtension !== null) {
  28839. this._caps.drawBuffersExtension = true;
  28840. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28841. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28842. for (var i = 0; i < 16; i++) {
  28843. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28844. }
  28845. }
  28846. else {
  28847. this._caps.drawBuffersExtension = false;
  28848. }
  28849. }
  28850. // Shader compiler threads
  28851. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28852. // Depth Texture
  28853. if (this._webGLVersion > 1) {
  28854. this._caps.depthTextureExtension = true;
  28855. }
  28856. else {
  28857. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28858. if (depthTextureExtension != null) {
  28859. this._caps.depthTextureExtension = true;
  28860. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28861. }
  28862. }
  28863. // Vertex array object
  28864. if (this._webGLVersion > 1) {
  28865. this._caps.vertexArrayObject = true;
  28866. }
  28867. else {
  28868. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28869. if (vertexArrayObjectExtension != null) {
  28870. this._caps.vertexArrayObject = true;
  28871. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28872. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28873. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28874. }
  28875. else {
  28876. this._caps.vertexArrayObject = false;
  28877. }
  28878. }
  28879. // Instances count
  28880. if (this._webGLVersion > 1) {
  28881. this._caps.instancedArrays = true;
  28882. }
  28883. else {
  28884. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28885. if (instanceExtension != null) {
  28886. this._caps.instancedArrays = true;
  28887. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28888. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28889. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28890. }
  28891. else {
  28892. this._caps.instancedArrays = false;
  28893. }
  28894. }
  28895. // Intelligently add supported compressed formats in order to check for.
  28896. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28897. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28898. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28899. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28900. if (this._caps.astc) {
  28901. this.texturesSupported.push('-astc.ktx');
  28902. }
  28903. if (this._caps.s3tc) {
  28904. this.texturesSupported.push('-dxt.ktx');
  28905. }
  28906. if (this._caps.pvrtc) {
  28907. this.texturesSupported.push('-pvrtc.ktx');
  28908. }
  28909. if (this._caps.etc2) {
  28910. this.texturesSupported.push('-etc2.ktx');
  28911. }
  28912. if (this._caps.etc1) {
  28913. this.texturesSupported.push('-etc1.ktx');
  28914. }
  28915. if (this._gl.getShaderPrecisionFormat) {
  28916. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28917. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28918. if (vertex_highp && fragment_highp) {
  28919. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28920. }
  28921. }
  28922. // Depth buffer
  28923. this.setDepthBuffer(true);
  28924. this.setDepthFunctionToLessOrEqual();
  28925. this.setDepthWrite(true);
  28926. // Texture maps
  28927. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28928. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28929. this._nextFreeTextureSlots.push(slot);
  28930. }
  28931. };
  28932. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28933. /**
  28934. * Gets version of the current webGL context
  28935. */
  28936. get: function () {
  28937. return this._webGLVersion;
  28938. },
  28939. enumerable: true,
  28940. configurable: true
  28941. });
  28942. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28943. /**
  28944. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28945. */
  28946. get: function () {
  28947. return this._isStencilEnable;
  28948. },
  28949. enumerable: true,
  28950. configurable: true
  28951. });
  28952. Engine.prototype._prepareWorkingCanvas = function () {
  28953. if (this._workingCanvas) {
  28954. return;
  28955. }
  28956. this._workingCanvas = document.createElement("canvas");
  28957. var context = this._workingCanvas.getContext("2d");
  28958. if (context) {
  28959. this._workingContext = context;
  28960. }
  28961. };
  28962. /**
  28963. * Reset the texture cache to empty state
  28964. */
  28965. Engine.prototype.resetTextureCache = function () {
  28966. for (var key in this._boundTexturesCache) {
  28967. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28968. continue;
  28969. }
  28970. var boundTexture = this._boundTexturesCache[key];
  28971. if (boundTexture) {
  28972. this._removeDesignatedSlot(boundTexture);
  28973. }
  28974. this._boundTexturesCache[key] = null;
  28975. }
  28976. if (!this.disableTextureBindingOptimization) {
  28977. this._nextFreeTextureSlots = [];
  28978. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28979. this._nextFreeTextureSlots.push(slot);
  28980. }
  28981. }
  28982. this._currentTextureChannel = -1;
  28983. };
  28984. /**
  28985. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28986. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28987. * @returns true if engine is in deterministic lock step mode
  28988. */
  28989. Engine.prototype.isDeterministicLockStep = function () {
  28990. return this._deterministicLockstep;
  28991. };
  28992. /**
  28993. * Gets the max steps when engine is running in deterministic lock step
  28994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28995. * @returns the max steps
  28996. */
  28997. Engine.prototype.getLockstepMaxSteps = function () {
  28998. return this._lockstepMaxSteps;
  28999. };
  29000. /**
  29001. * Gets an object containing information about the current webGL context
  29002. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29003. */
  29004. Engine.prototype.getGlInfo = function () {
  29005. return {
  29006. vendor: this._glVendor,
  29007. renderer: this._glRenderer,
  29008. version: this._glVersion
  29009. };
  29010. };
  29011. /**
  29012. * Gets current aspect ratio
  29013. * @param camera defines the camera to use to get the aspect ratio
  29014. * @param useScreen defines if screen size must be used (or the current render target if any)
  29015. * @returns a number defining the aspect ratio
  29016. */
  29017. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  29018. if (useScreen === void 0) { useScreen = false; }
  29019. var viewport = camera.viewport;
  29020. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  29021. };
  29022. /**
  29023. * Gets current screen aspect ratio
  29024. * @returns a number defining the aspect ratio
  29025. */
  29026. Engine.prototype.getScreenAspectRatio = function () {
  29027. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  29028. };
  29029. /**
  29030. * Gets the current render width
  29031. * @param useScreen defines if screen size must be used (or the current render target if any)
  29032. * @returns a number defining the current render width
  29033. */
  29034. Engine.prototype.getRenderWidth = function (useScreen) {
  29035. if (useScreen === void 0) { useScreen = false; }
  29036. if (!useScreen && this._currentRenderTarget) {
  29037. return this._currentRenderTarget.width;
  29038. }
  29039. return this._gl.drawingBufferWidth;
  29040. };
  29041. /**
  29042. * Gets the current render height
  29043. * @param useScreen defines if screen size must be used (or the current render target if any)
  29044. * @returns a number defining the current render height
  29045. */
  29046. Engine.prototype.getRenderHeight = function (useScreen) {
  29047. if (useScreen === void 0) { useScreen = false; }
  29048. if (!useScreen && this._currentRenderTarget) {
  29049. return this._currentRenderTarget.height;
  29050. }
  29051. return this._gl.drawingBufferHeight;
  29052. };
  29053. /**
  29054. * Gets the HTML canvas attached with the current webGL context
  29055. * @returns a HTML canvas
  29056. */
  29057. Engine.prototype.getRenderingCanvas = function () {
  29058. return this._renderingCanvas;
  29059. };
  29060. /**
  29061. * Gets the client rect of the HTML canvas attached with the current webGL context
  29062. * @returns a client rectanglee
  29063. */
  29064. Engine.prototype.getRenderingCanvasClientRect = function () {
  29065. if (!this._renderingCanvas) {
  29066. return null;
  29067. }
  29068. return this._renderingCanvas.getBoundingClientRect();
  29069. };
  29070. /**
  29071. * Defines the hardware scaling level.
  29072. * By default the hardware scaling level is computed from the window device ratio.
  29073. * 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.
  29074. * @param level defines the level to use
  29075. */
  29076. Engine.prototype.setHardwareScalingLevel = function (level) {
  29077. this._hardwareScalingLevel = level;
  29078. this.resize();
  29079. };
  29080. /**
  29081. * Gets the current hardware scaling level.
  29082. * By default the hardware scaling level is computed from the window device ratio.
  29083. * 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.
  29084. * @returns a number indicating the current hardware scaling level
  29085. */
  29086. Engine.prototype.getHardwareScalingLevel = function () {
  29087. return this._hardwareScalingLevel;
  29088. };
  29089. /**
  29090. * Gets the list of loaded textures
  29091. * @returns an array containing all loaded textures
  29092. */
  29093. Engine.prototype.getLoadedTexturesCache = function () {
  29094. return this._internalTexturesCache;
  29095. };
  29096. /**
  29097. * Gets the object containing all engine capabilities
  29098. * @returns the EngineCapabilities object
  29099. */
  29100. Engine.prototype.getCaps = function () {
  29101. return this._caps;
  29102. };
  29103. /**
  29104. * Gets the current depth function
  29105. * @returns a number defining the depth function
  29106. */
  29107. Engine.prototype.getDepthFunction = function () {
  29108. return this._depthCullingState.depthFunc;
  29109. };
  29110. /**
  29111. * Sets the current depth function
  29112. * @param depthFunc defines the function to use
  29113. */
  29114. Engine.prototype.setDepthFunction = function (depthFunc) {
  29115. this._depthCullingState.depthFunc = depthFunc;
  29116. };
  29117. /**
  29118. * Sets the current depth function to GREATER
  29119. */
  29120. Engine.prototype.setDepthFunctionToGreater = function () {
  29121. this._depthCullingState.depthFunc = this._gl.GREATER;
  29122. };
  29123. /**
  29124. * Sets the current depth function to GEQUAL
  29125. */
  29126. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  29127. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  29128. };
  29129. /**
  29130. * Sets the current depth function to LESS
  29131. */
  29132. Engine.prototype.setDepthFunctionToLess = function () {
  29133. this._depthCullingState.depthFunc = this._gl.LESS;
  29134. };
  29135. /**
  29136. * Caches the the state of the stencil buffer
  29137. */
  29138. Engine.prototype.cacheStencilState = function () {
  29139. this._cachedStencilBuffer = this.getStencilBuffer();
  29140. this._cachedStencilFunction = this.getStencilFunction();
  29141. this._cachedStencilMask = this.getStencilMask();
  29142. this._cachedStencilOperationPass = this.getStencilOperationPass();
  29143. this._cachedStencilOperationFail = this.getStencilOperationFail();
  29144. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();
  29145. this._cachedStencilReference = this.getStencilFunctionReference();
  29146. };
  29147. /**
  29148. * Restores the state of the stencil buffer
  29149. */
  29150. Engine.prototype.restoreStencilState = function () {
  29151. this.setStencilFunction(this._cachedStencilFunction);
  29152. this.setStencilMask(this._cachedStencilMask);
  29153. this.setStencilBuffer(this._cachedStencilBuffer);
  29154. this.setStencilOperationPass(this._cachedStencilOperationPass);
  29155. this.setStencilOperationFail(this._cachedStencilOperationFail);
  29156. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);
  29157. this.setStencilFunctionReference(this._cachedStencilReference);
  29158. };
  29159. /**
  29160. * Sets the current depth function to LEQUAL
  29161. */
  29162. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  29163. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  29164. };
  29165. /**
  29166. * Gets a boolean indicating if stencil buffer is enabled
  29167. * @returns the current stencil buffer state
  29168. */
  29169. Engine.prototype.getStencilBuffer = function () {
  29170. return this._stencilState.stencilTest;
  29171. };
  29172. /**
  29173. * Enable or disable the stencil buffer
  29174. * @param enable defines if the stencil buffer must be enabled or disabled
  29175. */
  29176. Engine.prototype.setStencilBuffer = function (enable) {
  29177. this._stencilState.stencilTest = enable;
  29178. };
  29179. /**
  29180. * Gets the current stencil mask
  29181. * @returns a number defining the new stencil mask to use
  29182. */
  29183. Engine.prototype.getStencilMask = function () {
  29184. return this._stencilState.stencilMask;
  29185. };
  29186. /**
  29187. * Sets the current stencil mask
  29188. * @param mask defines the new stencil mask to use
  29189. */
  29190. Engine.prototype.setStencilMask = function (mask) {
  29191. this._stencilState.stencilMask = mask;
  29192. };
  29193. /**
  29194. * Gets the current stencil function
  29195. * @returns a number defining the stencil function to use
  29196. */
  29197. Engine.prototype.getStencilFunction = function () {
  29198. return this._stencilState.stencilFunc;
  29199. };
  29200. /**
  29201. * Gets the current stencil reference value
  29202. * @returns a number defining the stencil reference value to use
  29203. */
  29204. Engine.prototype.getStencilFunctionReference = function () {
  29205. return this._stencilState.stencilFuncRef;
  29206. };
  29207. /**
  29208. * Gets the current stencil mask
  29209. * @returns a number defining the stencil mask to use
  29210. */
  29211. Engine.prototype.getStencilFunctionMask = function () {
  29212. return this._stencilState.stencilFuncMask;
  29213. };
  29214. /**
  29215. * Sets the current stencil function
  29216. * @param stencilFunc defines the new stencil function to use
  29217. */
  29218. Engine.prototype.setStencilFunction = function (stencilFunc) {
  29219. this._stencilState.stencilFunc = stencilFunc;
  29220. };
  29221. /**
  29222. * Sets the current stencil reference
  29223. * @param reference defines the new stencil reference to use
  29224. */
  29225. Engine.prototype.setStencilFunctionReference = function (reference) {
  29226. this._stencilState.stencilFuncRef = reference;
  29227. };
  29228. /**
  29229. * Sets the current stencil mask
  29230. * @param mask defines the new stencil mask to use
  29231. */
  29232. Engine.prototype.setStencilFunctionMask = function (mask) {
  29233. this._stencilState.stencilFuncMask = mask;
  29234. };
  29235. /**
  29236. * Gets the current stencil operation when stencil fails
  29237. * @returns a number defining stencil operation to use when stencil fails
  29238. */
  29239. Engine.prototype.getStencilOperationFail = function () {
  29240. return this._stencilState.stencilOpStencilFail;
  29241. };
  29242. /**
  29243. * Gets the current stencil operation when depth fails
  29244. * @returns a number defining stencil operation to use when depth fails
  29245. */
  29246. Engine.prototype.getStencilOperationDepthFail = function () {
  29247. return this._stencilState.stencilOpDepthFail;
  29248. };
  29249. /**
  29250. * Gets the current stencil operation when stencil passes
  29251. * @returns a number defining stencil operation to use when stencil passes
  29252. */
  29253. Engine.prototype.getStencilOperationPass = function () {
  29254. return this._stencilState.stencilOpStencilDepthPass;
  29255. };
  29256. /**
  29257. * Sets the stencil operation to use when stencil fails
  29258. * @param operation defines the stencil operation to use when stencil fails
  29259. */
  29260. Engine.prototype.setStencilOperationFail = function (operation) {
  29261. this._stencilState.stencilOpStencilFail = operation;
  29262. };
  29263. /**
  29264. * Sets the stencil operation to use when depth fails
  29265. * @param operation defines the stencil operation to use when depth fails
  29266. */
  29267. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  29268. this._stencilState.stencilOpDepthFail = operation;
  29269. };
  29270. /**
  29271. * Sets the stencil operation to use when stencil passes
  29272. * @param operation defines the stencil operation to use when stencil passes
  29273. */
  29274. Engine.prototype.setStencilOperationPass = function (operation) {
  29275. this._stencilState.stencilOpStencilDepthPass = operation;
  29276. };
  29277. /**
  29278. * Sets a boolean indicating if the dithering state is enabled or disabled
  29279. * @param value defines the dithering state
  29280. */
  29281. Engine.prototype.setDitheringState = function (value) {
  29282. if (value) {
  29283. this._gl.enable(this._gl.DITHER);
  29284. }
  29285. else {
  29286. this._gl.disable(this._gl.DITHER);
  29287. }
  29288. };
  29289. /**
  29290. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29291. * @param value defines the rasterizer state
  29292. */
  29293. Engine.prototype.setRasterizerState = function (value) {
  29294. if (value) {
  29295. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  29296. }
  29297. else {
  29298. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  29299. }
  29300. };
  29301. /**
  29302. * stop executing a render loop function and remove it from the execution array
  29303. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29304. */
  29305. Engine.prototype.stopRenderLoop = function (renderFunction) {
  29306. if (!renderFunction) {
  29307. this._activeRenderLoops = [];
  29308. return;
  29309. }
  29310. var index = this._activeRenderLoops.indexOf(renderFunction);
  29311. if (index >= 0) {
  29312. this._activeRenderLoops.splice(index, 1);
  29313. }
  29314. };
  29315. /** @hidden */
  29316. Engine.prototype._renderLoop = function () {
  29317. if (!this._contextWasLost) {
  29318. var shouldRender = true;
  29319. if (!this.renderEvenInBackground && this._windowIsBackground) {
  29320. shouldRender = false;
  29321. }
  29322. if (shouldRender) {
  29323. // Start new frame
  29324. this.beginFrame();
  29325. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  29326. var renderFunction = this._activeRenderLoops[index];
  29327. renderFunction();
  29328. }
  29329. // Present
  29330. this.endFrame();
  29331. }
  29332. }
  29333. if (this._activeRenderLoops.length > 0) {
  29334. // Register new frame
  29335. if (this.customAnimationFrameRequester) {
  29336. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  29337. this._frameHandler = this.customAnimationFrameRequester.requestID;
  29338. }
  29339. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29340. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29341. }
  29342. else {
  29343. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29344. }
  29345. }
  29346. else {
  29347. this._renderingQueueLaunched = false;
  29348. }
  29349. };
  29350. /**
  29351. * Register and execute a render loop. The engine can have more than one render function
  29352. * @param renderFunction defines the function to continuously execute
  29353. */
  29354. Engine.prototype.runRenderLoop = function (renderFunction) {
  29355. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  29356. return;
  29357. }
  29358. this._activeRenderLoops.push(renderFunction);
  29359. if (!this._renderingQueueLaunched) {
  29360. this._renderingQueueLaunched = true;
  29361. this._bindedRenderFunction = this._renderLoop.bind(this);
  29362. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29363. }
  29364. };
  29365. /**
  29366. * Toggle full screen mode
  29367. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29368. */
  29369. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  29370. if (this.isFullscreen) {
  29371. this.exitFullscreen();
  29372. }
  29373. else {
  29374. this.enterFullscreen(requestPointerLock);
  29375. }
  29376. };
  29377. /**
  29378. * Enters full screen mode
  29379. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29380. */
  29381. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  29382. if (!this.isFullscreen) {
  29383. this._pointerLockRequested = requestPointerLock;
  29384. if (this._renderingCanvas) {
  29385. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  29386. }
  29387. }
  29388. };
  29389. /**
  29390. * Exits full screen mode
  29391. */
  29392. Engine.prototype.exitFullscreen = function () {
  29393. if (this.isFullscreen) {
  29394. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  29395. }
  29396. };
  29397. /**
  29398. * Clear the current render buffer or the current render target (if any is set up)
  29399. * @param color defines the color to use
  29400. * @param backBuffer defines if the back buffer must be cleared
  29401. * @param depth defines if the depth buffer must be cleared
  29402. * @param stencil defines if the stencil buffer must be cleared
  29403. */
  29404. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  29405. if (stencil === void 0) { stencil = false; }
  29406. this.applyStates();
  29407. var mode = 0;
  29408. if (backBuffer && color) {
  29409. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  29410. mode |= this._gl.COLOR_BUFFER_BIT;
  29411. }
  29412. if (depth) {
  29413. this._gl.clearDepth(1.0);
  29414. mode |= this._gl.DEPTH_BUFFER_BIT;
  29415. }
  29416. if (stencil) {
  29417. this._gl.clearStencil(0);
  29418. mode |= this._gl.STENCIL_BUFFER_BIT;
  29419. }
  29420. this._gl.clear(mode);
  29421. };
  29422. /**
  29423. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29424. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29425. * @param y defines the y-coordinate of the corner of the clear rectangle
  29426. * @param width defines the width of the clear rectangle
  29427. * @param height defines the height of the clear rectangle
  29428. * @param clearColor defines the clear color
  29429. */
  29430. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  29431. this.enableScissor(x, y, width, height);
  29432. this.clear(clearColor, true, true, true);
  29433. this.disableScissor();
  29434. };
  29435. /**
  29436. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29437. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29438. * @param y defines the y-coordinate of the corner of the clear rectangle
  29439. * @param width defines the width of the clear rectangle
  29440. * @param height defines the height of the clear rectangle
  29441. */
  29442. Engine.prototype.enableScissor = function (x, y, width, height) {
  29443. var gl = this._gl;
  29444. // Change state
  29445. gl.enable(gl.SCISSOR_TEST);
  29446. gl.scissor(x, y, width, height);
  29447. };
  29448. /**
  29449. * Disable previously set scissor test rectangle
  29450. */
  29451. Engine.prototype.disableScissor = function () {
  29452. var gl = this._gl;
  29453. gl.disable(gl.SCISSOR_TEST);
  29454. };
  29455. /** @hidden */
  29456. Engine.prototype._viewport = function (x, y, width, height) {
  29457. if (x !== this._viewportCached.x ||
  29458. y !== this._viewportCached.y ||
  29459. width !== this._viewportCached.z ||
  29460. height !== this._viewportCached.w) {
  29461. this._viewportCached.x = x;
  29462. this._viewportCached.y = y;
  29463. this._viewportCached.z = width;
  29464. this._viewportCached.w = height;
  29465. this._gl.viewport(x, y, width, height);
  29466. }
  29467. };
  29468. /**
  29469. * Set the WebGL's viewport
  29470. * @param viewport defines the viewport element to be used
  29471. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29472. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29473. */
  29474. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  29475. var width = requiredWidth || this.getRenderWidth();
  29476. var height = requiredHeight || this.getRenderHeight();
  29477. var x = viewport.x || 0;
  29478. var y = viewport.y || 0;
  29479. this._cachedViewport = viewport;
  29480. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  29481. };
  29482. /**
  29483. * Directly set the WebGL Viewport
  29484. * @param x defines the x coordinate of the viewport (in screen space)
  29485. * @param y defines the y coordinate of the viewport (in screen space)
  29486. * @param width defines the width of the viewport (in screen space)
  29487. * @param height defines the height of the viewport (in screen space)
  29488. * @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
  29489. */
  29490. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  29491. var currentViewport = this._cachedViewport;
  29492. this._cachedViewport = null;
  29493. this._viewport(x, y, width, height);
  29494. return currentViewport;
  29495. };
  29496. /**
  29497. * Begin a new frame
  29498. */
  29499. Engine.prototype.beginFrame = function () {
  29500. this.onBeginFrameObservable.notifyObservers(this);
  29501. this._measureFps();
  29502. };
  29503. /**
  29504. * Enf the current frame
  29505. */
  29506. Engine.prototype.endFrame = function () {
  29507. // Force a flush in case we are using a bad OS.
  29508. if (this._badOS) {
  29509. this.flushFramebuffer();
  29510. }
  29511. // Submit frame to the vr device, if enabled
  29512. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29513. // TODO: We should only submit the frame if we read frameData successfully.
  29514. try {
  29515. this._vrDisplay.submitFrame();
  29516. }
  29517. catch (e) {
  29518. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29519. }
  29520. }
  29521. this.onEndFrameObservable.notifyObservers(this);
  29522. };
  29523. /**
  29524. * Resize the view according to the canvas' size
  29525. */
  29526. Engine.prototype.resize = function () {
  29527. // We're not resizing the size of the canvas while in VR mode & presenting
  29528. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  29529. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  29530. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  29531. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  29532. }
  29533. };
  29534. /**
  29535. * Force a specific size of the canvas
  29536. * @param width defines the new canvas' width
  29537. * @param height defines the new canvas' height
  29538. */
  29539. Engine.prototype.setSize = function (width, height) {
  29540. if (!this._renderingCanvas) {
  29541. return;
  29542. }
  29543. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  29544. return;
  29545. }
  29546. this._renderingCanvas.width = width;
  29547. this._renderingCanvas.height = height;
  29548. for (var index = 0; index < this.scenes.length; index++) {
  29549. var scene = this.scenes[index];
  29550. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  29551. var cam = scene.cameras[camIndex];
  29552. cam._currentRenderId = 0;
  29553. }
  29554. }
  29555. if (this.onResizeObservable.hasObservers) {
  29556. this.onResizeObservable.notifyObservers(this);
  29557. }
  29558. };
  29559. // WebVR functions
  29560. /**
  29561. * Gets a boolean indicating if a webVR device was detected
  29562. * @returns true if a webVR device was detected
  29563. */
  29564. Engine.prototype.isVRDevicePresent = function () {
  29565. return !!this._vrDisplay;
  29566. };
  29567. /**
  29568. * Gets the current webVR device
  29569. * @returns the current webVR device (or null)
  29570. */
  29571. Engine.prototype.getVRDevice = function () {
  29572. return this._vrDisplay;
  29573. };
  29574. /**
  29575. * Initializes a webVR display and starts listening to display change events
  29576. * The onVRDisplayChangedObservable will be notified upon these changes
  29577. * @returns The onVRDisplayChangedObservable
  29578. */
  29579. Engine.prototype.initWebVR = function () {
  29580. this.initWebVRAsync();
  29581. return this.onVRDisplayChangedObservable;
  29582. };
  29583. /**
  29584. * Initializes a webVR display and starts listening to display change events
  29585. * The onVRDisplayChangedObservable will be notified upon these changes
  29586. * @returns A promise containing a VRDisplay and if vr is supported
  29587. */
  29588. Engine.prototype.initWebVRAsync = function () {
  29589. var _this = this;
  29590. var notifyObservers = function () {
  29591. var eventArgs = {
  29592. vrDisplay: _this._vrDisplay,
  29593. vrSupported: _this._vrSupported
  29594. };
  29595. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29596. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29597. };
  29598. if (!this._onVrDisplayConnect) {
  29599. this._onVrDisplayConnect = function (event) {
  29600. _this._vrDisplay = event.display;
  29601. notifyObservers();
  29602. };
  29603. this._onVrDisplayDisconnect = function () {
  29604. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29605. _this._vrDisplay = undefined;
  29606. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29607. notifyObservers();
  29608. };
  29609. this._onVrDisplayPresentChange = function () {
  29610. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29611. };
  29612. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29613. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29614. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29615. }
  29616. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29617. this._webVRInitPromise.then(notifyObservers);
  29618. return this._webVRInitPromise;
  29619. };
  29620. /**
  29621. * Call this function to switch to webVR mode
  29622. * Will do nothing if webVR is not supported or if there is no webVR device
  29623. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29624. */
  29625. Engine.prototype.enableVR = function () {
  29626. var _this = this;
  29627. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29628. var onResolved = function () {
  29629. _this.onVRRequestPresentComplete.notifyObservers(true);
  29630. _this._onVRFullScreenTriggered();
  29631. };
  29632. var onRejected = function () {
  29633. _this.onVRRequestPresentComplete.notifyObservers(false);
  29634. };
  29635. this.onVRRequestPresentStart.notifyObservers(this);
  29636. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29637. }
  29638. };
  29639. /**
  29640. * Call this function to leave webVR mode
  29641. * Will do nothing if webVR is not supported or if there is no webVR device
  29642. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29643. */
  29644. Engine.prototype.disableVR = function () {
  29645. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29646. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29647. }
  29648. };
  29649. Engine.prototype._getVRDisplaysAsync = function () {
  29650. var _this = this;
  29651. return new Promise(function (res) {
  29652. if (navigator.getVRDisplays) {
  29653. navigator.getVRDisplays().then(function (devices) {
  29654. _this._vrSupported = true;
  29655. // note that devices may actually be an empty array. This is fine;
  29656. // we expect this._vrDisplay to be undefined in this case.
  29657. _this._vrDisplay = devices[0];
  29658. res({
  29659. vrDisplay: _this._vrDisplay,
  29660. vrSupported: _this._vrSupported
  29661. });
  29662. });
  29663. }
  29664. else {
  29665. _this._vrDisplay = undefined;
  29666. _this._vrSupported = false;
  29667. res({
  29668. vrDisplay: _this._vrDisplay,
  29669. vrSupported: _this._vrSupported
  29670. });
  29671. }
  29672. });
  29673. };
  29674. /**
  29675. * Binds the frame buffer to the specified texture.
  29676. * @param texture The texture to render to or null for the default canvas
  29677. * @param faceIndex The face of the texture to render to in case of cube texture
  29678. * @param requiredWidth The width of the target to render to
  29679. * @param requiredHeight The height of the target to render to
  29680. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29681. * @param depthStencilTexture The depth stencil texture to use to render
  29682. * @param lodLevel defines le lod level to bind to the frame buffer
  29683. */
  29684. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29685. if (lodLevel === void 0) { lodLevel = 0; }
  29686. if (this._currentRenderTarget) {
  29687. this.unBindFramebuffer(this._currentRenderTarget);
  29688. }
  29689. this._currentRenderTarget = texture;
  29690. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29691. var gl = this._gl;
  29692. if (texture.isCube) {
  29693. if (faceIndex === undefined) {
  29694. faceIndex = 0;
  29695. }
  29696. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29697. if (depthStencilTexture) {
  29698. if (depthStencilTexture._generateStencilBuffer) {
  29699. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29700. }
  29701. else {
  29702. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29703. }
  29704. }
  29705. }
  29706. if (this._cachedViewport && !forceFullscreenViewport) {
  29707. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29708. }
  29709. else {
  29710. if (!requiredWidth) {
  29711. requiredWidth = texture.width;
  29712. if (lodLevel) {
  29713. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29714. }
  29715. }
  29716. if (!requiredHeight) {
  29717. requiredHeight = texture.height;
  29718. if (lodLevel) {
  29719. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29720. }
  29721. }
  29722. this._viewport(0, 0, requiredWidth, requiredHeight);
  29723. }
  29724. this.wipeCaches();
  29725. };
  29726. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29727. if (this._currentFramebuffer !== framebuffer) {
  29728. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29729. this._currentFramebuffer = framebuffer;
  29730. }
  29731. };
  29732. /**
  29733. * Unbind the current render target texture from the webGL context
  29734. * @param texture defines the render target texture to unbind
  29735. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29736. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29737. */
  29738. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29739. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29740. this._currentRenderTarget = null;
  29741. // If MSAA, we need to bitblt back to main texture
  29742. var gl = this._gl;
  29743. if (texture._MSAAFramebuffer) {
  29744. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29745. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29746. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29747. }
  29748. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29749. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29750. gl.generateMipmap(gl.TEXTURE_2D);
  29751. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29752. }
  29753. if (onBeforeUnbind) {
  29754. if (texture._MSAAFramebuffer) {
  29755. // Bind the correct framebuffer
  29756. this.bindUnboundFramebuffer(texture._framebuffer);
  29757. }
  29758. onBeforeUnbind();
  29759. }
  29760. this.bindUnboundFramebuffer(null);
  29761. };
  29762. /**
  29763. * Unbind a list of render target textures from the webGL context
  29764. * This is used only when drawBuffer extension or webGL2 are active
  29765. * @param textures defines the render target textures to unbind
  29766. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29767. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29768. */
  29769. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29770. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29771. this._currentRenderTarget = null;
  29772. // If MSAA, we need to bitblt back to main texture
  29773. var gl = this._gl;
  29774. if (textures[0]._MSAAFramebuffer) {
  29775. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29776. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29777. var attachments = textures[0]._attachments;
  29778. if (!attachments) {
  29779. attachments = new Array(textures.length);
  29780. textures[0]._attachments = attachments;
  29781. }
  29782. for (var i = 0; i < textures.length; i++) {
  29783. var texture = textures[i];
  29784. for (var j = 0; j < attachments.length; j++) {
  29785. attachments[j] = gl.NONE;
  29786. }
  29787. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29788. gl.readBuffer(attachments[i]);
  29789. gl.drawBuffers(attachments);
  29790. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29791. }
  29792. for (var i = 0; i < attachments.length; i++) {
  29793. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29794. }
  29795. gl.drawBuffers(attachments);
  29796. }
  29797. for (var i = 0; i < textures.length; i++) {
  29798. var texture = textures[i];
  29799. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29800. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29801. gl.generateMipmap(gl.TEXTURE_2D);
  29802. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29803. }
  29804. }
  29805. if (onBeforeUnbind) {
  29806. if (textures[0]._MSAAFramebuffer) {
  29807. // Bind the correct framebuffer
  29808. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29809. }
  29810. onBeforeUnbind();
  29811. }
  29812. this.bindUnboundFramebuffer(null);
  29813. };
  29814. /**
  29815. * Force the mipmap generation for the given render target texture
  29816. * @param texture defines the render target texture to use
  29817. */
  29818. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29819. if (texture.generateMipMaps) {
  29820. var gl = this._gl;
  29821. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29822. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29823. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29824. }
  29825. };
  29826. /**
  29827. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29828. */
  29829. Engine.prototype.flushFramebuffer = function () {
  29830. this._gl.flush();
  29831. };
  29832. /**
  29833. * Unbind the current render target and bind the default framebuffer
  29834. */
  29835. Engine.prototype.restoreDefaultFramebuffer = function () {
  29836. if (this._currentRenderTarget) {
  29837. this.unBindFramebuffer(this._currentRenderTarget);
  29838. }
  29839. else {
  29840. this.bindUnboundFramebuffer(null);
  29841. }
  29842. if (this._cachedViewport) {
  29843. this.setViewport(this._cachedViewport);
  29844. }
  29845. this.wipeCaches();
  29846. };
  29847. // UBOs
  29848. /**
  29849. * Create an uniform buffer
  29850. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29851. * @param elements defines the content of the uniform buffer
  29852. * @returns the webGL uniform buffer
  29853. */
  29854. Engine.prototype.createUniformBuffer = function (elements) {
  29855. var ubo = this._gl.createBuffer();
  29856. if (!ubo) {
  29857. throw new Error("Unable to create uniform buffer");
  29858. }
  29859. this.bindUniformBuffer(ubo);
  29860. if (elements instanceof Float32Array) {
  29861. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29862. }
  29863. else {
  29864. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29865. }
  29866. this.bindUniformBuffer(null);
  29867. ubo.references = 1;
  29868. return ubo;
  29869. };
  29870. /**
  29871. * Create a dynamic uniform buffer
  29872. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29873. * @param elements defines the content of the uniform buffer
  29874. * @returns the webGL uniform buffer
  29875. */
  29876. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29877. var ubo = this._gl.createBuffer();
  29878. if (!ubo) {
  29879. throw new Error("Unable to create dynamic uniform buffer");
  29880. }
  29881. this.bindUniformBuffer(ubo);
  29882. if (elements instanceof Float32Array) {
  29883. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29884. }
  29885. else {
  29886. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29887. }
  29888. this.bindUniformBuffer(null);
  29889. ubo.references = 1;
  29890. return ubo;
  29891. };
  29892. /**
  29893. * Update an existing uniform buffer
  29894. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29895. * @param uniformBuffer defines the target uniform buffer
  29896. * @param elements defines the content to update
  29897. * @param offset defines the offset in the uniform buffer where update should start
  29898. * @param count defines the size of the data to update
  29899. */
  29900. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29901. this.bindUniformBuffer(uniformBuffer);
  29902. if (offset === undefined) {
  29903. offset = 0;
  29904. }
  29905. if (count === undefined) {
  29906. if (elements instanceof Float32Array) {
  29907. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29908. }
  29909. else {
  29910. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29911. }
  29912. }
  29913. else {
  29914. if (elements instanceof Float32Array) {
  29915. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29916. }
  29917. else {
  29918. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29919. }
  29920. }
  29921. this.bindUniformBuffer(null);
  29922. };
  29923. // VBOs
  29924. Engine.prototype._resetVertexBufferBinding = function () {
  29925. this.bindArrayBuffer(null);
  29926. this._cachedVertexBuffers = null;
  29927. };
  29928. /**
  29929. * Creates a vertex buffer
  29930. * @param data the data for the vertex buffer
  29931. * @returns the new WebGL static buffer
  29932. */
  29933. Engine.prototype.createVertexBuffer = function (data) {
  29934. var vbo = this._gl.createBuffer();
  29935. if (!vbo) {
  29936. throw new Error("Unable to create vertex buffer");
  29937. }
  29938. this.bindArrayBuffer(vbo);
  29939. if (data instanceof Array) {
  29940. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29941. }
  29942. else {
  29943. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29944. }
  29945. this._resetVertexBufferBinding();
  29946. vbo.references = 1;
  29947. return vbo;
  29948. };
  29949. /**
  29950. * Creates a dynamic vertex buffer
  29951. * @param data the data for the dynamic vertex buffer
  29952. * @returns the new WebGL dynamic buffer
  29953. */
  29954. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29955. var vbo = this._gl.createBuffer();
  29956. if (!vbo) {
  29957. throw new Error("Unable to create dynamic vertex buffer");
  29958. }
  29959. this.bindArrayBuffer(vbo);
  29960. if (data instanceof Array) {
  29961. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29962. }
  29963. else {
  29964. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29965. }
  29966. this._resetVertexBufferBinding();
  29967. vbo.references = 1;
  29968. return vbo;
  29969. };
  29970. /**
  29971. * Update a dynamic index buffer
  29972. * @param indexBuffer defines the target index buffer
  29973. * @param indices defines the data to update
  29974. * @param offset defines the offset in the target index buffer where update should start
  29975. */
  29976. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29977. if (offset === void 0) { offset = 0; }
  29978. // Force cache update
  29979. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29980. this.bindIndexBuffer(indexBuffer);
  29981. var arrayBuffer;
  29982. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29983. arrayBuffer = indices;
  29984. }
  29985. else {
  29986. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29987. }
  29988. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29989. this._resetIndexBufferBinding();
  29990. };
  29991. /**
  29992. * Updates a dynamic vertex buffer.
  29993. * @param vertexBuffer the vertex buffer to update
  29994. * @param data the data used to update the vertex buffer
  29995. * @param byteOffset the byte offset of the data
  29996. * @param byteLength the byte length of the data
  29997. */
  29998. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29999. this.bindArrayBuffer(vertexBuffer);
  30000. if (byteOffset === undefined) {
  30001. byteOffset = 0;
  30002. }
  30003. if (byteLength === undefined) {
  30004. if (data instanceof Array) {
  30005. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  30006. }
  30007. else {
  30008. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  30009. }
  30010. }
  30011. else {
  30012. if (data instanceof Array) {
  30013. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  30014. }
  30015. else {
  30016. if (data instanceof ArrayBuffer) {
  30017. data = new Uint8Array(data, byteOffset, byteLength);
  30018. }
  30019. else {
  30020. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  30021. }
  30022. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30023. }
  30024. }
  30025. this._resetVertexBufferBinding();
  30026. };
  30027. Engine.prototype._resetIndexBufferBinding = function () {
  30028. this.bindIndexBuffer(null);
  30029. this._cachedIndexBuffer = null;
  30030. };
  30031. /**
  30032. * Creates a new index buffer
  30033. * @param indices defines the content of the index buffer
  30034. * @param updatable defines if the index buffer must be updatable
  30035. * @returns a new webGL buffer
  30036. */
  30037. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  30038. var vbo = this._gl.createBuffer();
  30039. if (!vbo) {
  30040. throw new Error("Unable to create index buffer");
  30041. }
  30042. this.bindIndexBuffer(vbo);
  30043. // Check for 32 bits indices
  30044. var arrayBuffer;
  30045. var need32Bits = false;
  30046. if (indices instanceof Uint16Array) {
  30047. arrayBuffer = indices;
  30048. }
  30049. else {
  30050. //check 32 bit support
  30051. if (this._caps.uintIndices) {
  30052. if (indices instanceof Uint32Array) {
  30053. arrayBuffer = indices;
  30054. need32Bits = true;
  30055. }
  30056. else {
  30057. //number[] or Int32Array, check if 32 bit is necessary
  30058. for (var index = 0; index < indices.length; index++) {
  30059. if (indices[index] > 65535) {
  30060. need32Bits = true;
  30061. break;
  30062. }
  30063. }
  30064. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30065. }
  30066. }
  30067. else {
  30068. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  30069. arrayBuffer = new Uint16Array(indices);
  30070. }
  30071. }
  30072. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  30073. this._resetIndexBufferBinding();
  30074. vbo.references = 1;
  30075. vbo.is32Bits = need32Bits;
  30076. return vbo;
  30077. };
  30078. /**
  30079. * Bind a webGL buffer to the webGL context
  30080. * @param buffer defines the buffer to bind
  30081. */
  30082. Engine.prototype.bindArrayBuffer = function (buffer) {
  30083. if (!this._vaoRecordInProgress) {
  30084. this._unbindVertexArrayObject();
  30085. }
  30086. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  30087. };
  30088. /**
  30089. * Bind an uniform buffer to the current webGL context
  30090. * @param buffer defines the buffer to bind
  30091. */
  30092. Engine.prototype.bindUniformBuffer = function (buffer) {
  30093. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  30094. };
  30095. /**
  30096. * Bind a buffer to the current webGL context at a given location
  30097. * @param buffer defines the buffer to bind
  30098. * @param location defines the index where to bind the buffer
  30099. */
  30100. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  30101. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  30102. };
  30103. /**
  30104. * Bind a specific block at a given index in a specific shader program
  30105. * @param shaderProgram defines the shader program
  30106. * @param blockName defines the block name
  30107. * @param index defines the index where to bind the block
  30108. */
  30109. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  30110. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  30111. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  30112. };
  30113. Engine.prototype.bindIndexBuffer = function (buffer) {
  30114. if (!this._vaoRecordInProgress) {
  30115. this._unbindVertexArrayObject();
  30116. }
  30117. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  30118. };
  30119. Engine.prototype.bindBuffer = function (buffer, target) {
  30120. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  30121. this._gl.bindBuffer(target, buffer);
  30122. this._currentBoundBuffer[target] = buffer;
  30123. }
  30124. };
  30125. /**
  30126. * update the bound buffer with the given data
  30127. * @param data defines the data to update
  30128. */
  30129. Engine.prototype.updateArrayBuffer = function (data) {
  30130. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30131. };
  30132. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  30133. var pointer = this._currentBufferPointers[indx];
  30134. var changed = false;
  30135. if (!pointer.active) {
  30136. changed = true;
  30137. pointer.active = true;
  30138. pointer.index = indx;
  30139. pointer.size = size;
  30140. pointer.type = type;
  30141. pointer.normalized = normalized;
  30142. pointer.stride = stride;
  30143. pointer.offset = offset;
  30144. pointer.buffer = buffer;
  30145. }
  30146. else {
  30147. if (pointer.buffer !== buffer) {
  30148. pointer.buffer = buffer;
  30149. changed = true;
  30150. }
  30151. if (pointer.size !== size) {
  30152. pointer.size = size;
  30153. changed = true;
  30154. }
  30155. if (pointer.type !== type) {
  30156. pointer.type = type;
  30157. changed = true;
  30158. }
  30159. if (pointer.normalized !== normalized) {
  30160. pointer.normalized = normalized;
  30161. changed = true;
  30162. }
  30163. if (pointer.stride !== stride) {
  30164. pointer.stride = stride;
  30165. changed = true;
  30166. }
  30167. if (pointer.offset !== offset) {
  30168. pointer.offset = offset;
  30169. changed = true;
  30170. }
  30171. }
  30172. if (changed || this._vaoRecordInProgress) {
  30173. this.bindArrayBuffer(buffer);
  30174. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  30175. }
  30176. };
  30177. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  30178. if (indexBuffer == null) {
  30179. return;
  30180. }
  30181. if (this._cachedIndexBuffer !== indexBuffer) {
  30182. this._cachedIndexBuffer = indexBuffer;
  30183. this.bindIndexBuffer(indexBuffer);
  30184. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  30185. }
  30186. };
  30187. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  30188. var attributes = effect.getAttributesNames();
  30189. if (!this._vaoRecordInProgress) {
  30190. this._unbindVertexArrayObject();
  30191. }
  30192. this.unbindAllAttributes();
  30193. for (var index = 0; index < attributes.length; index++) {
  30194. var order = effect.getAttributeLocation(index);
  30195. if (order >= 0) {
  30196. var vertexBuffer = vertexBuffers[attributes[index]];
  30197. if (!vertexBuffer) {
  30198. continue;
  30199. }
  30200. this._gl.enableVertexAttribArray(order);
  30201. if (!this._vaoRecordInProgress) {
  30202. this._vertexAttribArraysEnabled[order] = true;
  30203. }
  30204. var buffer = vertexBuffer.getBuffer();
  30205. if (buffer) {
  30206. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  30207. if (vertexBuffer.getIsInstanced()) {
  30208. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  30209. if (!this._vaoRecordInProgress) {
  30210. this._currentInstanceLocations.push(order);
  30211. this._currentInstanceBuffers.push(buffer);
  30212. }
  30213. }
  30214. }
  30215. }
  30216. }
  30217. };
  30218. /**
  30219. * Records a vertex array object
  30220. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30221. * @param vertexBuffers defines the list of vertex buffers to store
  30222. * @param indexBuffer defines the index buffer to store
  30223. * @param effect defines the effect to store
  30224. * @returns the new vertex array object
  30225. */
  30226. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  30227. var vao = this._gl.createVertexArray();
  30228. this._vaoRecordInProgress = true;
  30229. this._gl.bindVertexArray(vao);
  30230. this._mustWipeVertexAttributes = true;
  30231. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30232. this.bindIndexBuffer(indexBuffer);
  30233. this._vaoRecordInProgress = false;
  30234. this._gl.bindVertexArray(null);
  30235. return vao;
  30236. };
  30237. /**
  30238. * Bind a specific vertex array object
  30239. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30240. * @param vertexArrayObject defines the vertex array object to bind
  30241. * @param indexBuffer defines the index buffer to bind
  30242. */
  30243. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  30244. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  30245. this._cachedVertexArrayObject = vertexArrayObject;
  30246. this._gl.bindVertexArray(vertexArrayObject);
  30247. this._cachedVertexBuffers = null;
  30248. this._cachedIndexBuffer = null;
  30249. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  30250. this._mustWipeVertexAttributes = true;
  30251. }
  30252. };
  30253. /**
  30254. * Bind webGl buffers directly to the webGL context
  30255. * @param vertexBuffer defines the vertex buffer to bind
  30256. * @param indexBuffer defines the index buffer to bind
  30257. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30258. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30259. * @param effect defines the effect associated with the vertex buffer
  30260. */
  30261. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  30262. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  30263. this._cachedVertexBuffers = vertexBuffer;
  30264. this._cachedEffectForVertexBuffers = effect;
  30265. var attributesCount = effect.getAttributesCount();
  30266. this._unbindVertexArrayObject();
  30267. this.unbindAllAttributes();
  30268. var offset = 0;
  30269. for (var index = 0; index < attributesCount; index++) {
  30270. if (index < vertexDeclaration.length) {
  30271. var order = effect.getAttributeLocation(index);
  30272. if (order >= 0) {
  30273. this._gl.enableVertexAttribArray(order);
  30274. this._vertexAttribArraysEnabled[order] = true;
  30275. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  30276. }
  30277. offset += vertexDeclaration[index] * 4;
  30278. }
  30279. }
  30280. }
  30281. this._bindIndexBufferWithCache(indexBuffer);
  30282. };
  30283. Engine.prototype._unbindVertexArrayObject = function () {
  30284. if (!this._cachedVertexArrayObject) {
  30285. return;
  30286. }
  30287. this._cachedVertexArrayObject = null;
  30288. this._gl.bindVertexArray(null);
  30289. };
  30290. /**
  30291. * Bind a list of vertex buffers to the webGL context
  30292. * @param vertexBuffers defines the list of vertex buffers to bind
  30293. * @param indexBuffer defines the index buffer to bind
  30294. * @param effect defines the effect associated with the vertex buffers
  30295. */
  30296. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  30297. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  30298. this._cachedVertexBuffers = vertexBuffers;
  30299. this._cachedEffectForVertexBuffers = effect;
  30300. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30301. }
  30302. this._bindIndexBufferWithCache(indexBuffer);
  30303. };
  30304. /**
  30305. * Unbind all instance attributes
  30306. */
  30307. Engine.prototype.unbindInstanceAttributes = function () {
  30308. var boundBuffer;
  30309. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  30310. var instancesBuffer = this._currentInstanceBuffers[i];
  30311. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  30312. boundBuffer = instancesBuffer;
  30313. this.bindArrayBuffer(instancesBuffer);
  30314. }
  30315. var offsetLocation = this._currentInstanceLocations[i];
  30316. this._gl.vertexAttribDivisor(offsetLocation, 0);
  30317. }
  30318. this._currentInstanceBuffers.length = 0;
  30319. this._currentInstanceLocations.length = 0;
  30320. };
  30321. /**
  30322. * Release and free the memory of a vertex array object
  30323. * @param vao defines the vertex array object to delete
  30324. */
  30325. Engine.prototype.releaseVertexArrayObject = function (vao) {
  30326. this._gl.deleteVertexArray(vao);
  30327. };
  30328. /** @hidden */
  30329. Engine.prototype._releaseBuffer = function (buffer) {
  30330. buffer.references--;
  30331. if (buffer.references === 0) {
  30332. this._gl.deleteBuffer(buffer);
  30333. return true;
  30334. }
  30335. return false;
  30336. };
  30337. /**
  30338. * Creates a webGL buffer to use with instanciation
  30339. * @param capacity defines the size of the buffer
  30340. * @returns the webGL buffer
  30341. */
  30342. Engine.prototype.createInstancesBuffer = function (capacity) {
  30343. var buffer = this._gl.createBuffer();
  30344. if (!buffer) {
  30345. throw new Error("Unable to create instance buffer");
  30346. }
  30347. buffer.capacity = capacity;
  30348. this.bindArrayBuffer(buffer);
  30349. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  30350. return buffer;
  30351. };
  30352. /**
  30353. * Delete a webGL buffer used with instanciation
  30354. * @param buffer defines the webGL buffer to delete
  30355. */
  30356. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  30357. this._gl.deleteBuffer(buffer);
  30358. };
  30359. /**
  30360. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30361. * @param instancesBuffer defines the webGL buffer to update and bind
  30362. * @param data defines the data to store in the buffer
  30363. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30364. */
  30365. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  30366. this.bindArrayBuffer(instancesBuffer);
  30367. if (data) {
  30368. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30369. }
  30370. if (offsetLocations[0].index !== undefined) {
  30371. var stride = 0;
  30372. for (var i = 0; i < offsetLocations.length; i++) {
  30373. var ai = offsetLocations[i];
  30374. stride += ai.attributeSize * 4;
  30375. }
  30376. for (var i = 0; i < offsetLocations.length; i++) {
  30377. var ai = offsetLocations[i];
  30378. if (!this._vertexAttribArraysEnabled[ai.index]) {
  30379. this._gl.enableVertexAttribArray(ai.index);
  30380. this._vertexAttribArraysEnabled[ai.index] = true;
  30381. }
  30382. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  30383. this._gl.vertexAttribDivisor(ai.index, 1);
  30384. this._currentInstanceLocations.push(ai.index);
  30385. this._currentInstanceBuffers.push(instancesBuffer);
  30386. }
  30387. }
  30388. else {
  30389. for (var index = 0; index < 4; index++) {
  30390. var offsetLocation = offsetLocations[index];
  30391. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  30392. this._gl.enableVertexAttribArray(offsetLocation);
  30393. this._vertexAttribArraysEnabled[offsetLocation] = true;
  30394. }
  30395. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  30396. this._gl.vertexAttribDivisor(offsetLocation, 1);
  30397. this._currentInstanceLocations.push(offsetLocation);
  30398. this._currentInstanceBuffers.push(instancesBuffer);
  30399. }
  30400. }
  30401. };
  30402. /**
  30403. * Apply all cached states (depth, culling, stencil and alpha)
  30404. */
  30405. Engine.prototype.applyStates = function () {
  30406. this._depthCullingState.apply(this._gl);
  30407. this._stencilState.apply(this._gl);
  30408. this._alphaState.apply(this._gl);
  30409. };
  30410. /**
  30411. * Send a draw order
  30412. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30413. * @param indexStart defines the starting index
  30414. * @param indexCount defines the number of index to draw
  30415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30416. */
  30417. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  30418. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  30419. };
  30420. /**
  30421. * Draw a list of points
  30422. * @param verticesStart defines the index of first vertex to draw
  30423. * @param verticesCount defines the count of vertices to draw
  30424. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30425. */
  30426. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  30427. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  30428. };
  30429. /**
  30430. * Draw a list of unindexed primitives
  30431. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30432. * @param verticesStart defines the index of first vertex to draw
  30433. * @param verticesCount defines the count of vertices to draw
  30434. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30435. */
  30436. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  30437. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  30438. };
  30439. /**
  30440. * Draw a list of indexed primitives
  30441. * @param fillMode defines the primitive to use
  30442. * @param indexStart defines the starting index
  30443. * @param indexCount defines the number of index to draw
  30444. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30445. */
  30446. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  30447. // Apply states
  30448. this.applyStates();
  30449. this._drawCalls.addCount(1, false);
  30450. // Render
  30451. var drawMode = this._drawMode(fillMode);
  30452. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  30453. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  30454. if (instancesCount) {
  30455. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  30456. }
  30457. else {
  30458. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  30459. }
  30460. };
  30461. /**
  30462. * Draw a list of unindexed primitives
  30463. * @param fillMode defines the primitive to use
  30464. * @param verticesStart defines the index of first vertex to draw
  30465. * @param verticesCount defines the count of vertices to draw
  30466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30467. */
  30468. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  30469. // Apply states
  30470. this.applyStates();
  30471. this._drawCalls.addCount(1, false);
  30472. var drawMode = this._drawMode(fillMode);
  30473. if (instancesCount) {
  30474. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  30475. }
  30476. else {
  30477. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  30478. }
  30479. };
  30480. Engine.prototype._drawMode = function (fillMode) {
  30481. switch (fillMode) {
  30482. // Triangle views
  30483. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  30484. return this._gl.TRIANGLES;
  30485. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  30486. return this._gl.POINTS;
  30487. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  30488. return this._gl.LINES;
  30489. // Draw modes
  30490. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  30491. return this._gl.POINTS;
  30492. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  30493. return this._gl.LINES;
  30494. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  30495. return this._gl.LINE_LOOP;
  30496. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  30497. return this._gl.LINE_STRIP;
  30498. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  30499. return this._gl.TRIANGLE_STRIP;
  30500. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  30501. return this._gl.TRIANGLE_FAN;
  30502. default:
  30503. return this._gl.TRIANGLES;
  30504. }
  30505. };
  30506. // Shaders
  30507. /** @hidden */
  30508. Engine.prototype._releaseEffect = function (effect) {
  30509. if (this._compiledEffects[effect._key]) {
  30510. delete this._compiledEffects[effect._key];
  30511. this._deleteProgram(effect.getProgram());
  30512. }
  30513. };
  30514. /** @hidden */
  30515. Engine.prototype._deleteProgram = function (program) {
  30516. if (program) {
  30517. program.__SPECTOR_rebuildProgram = null;
  30518. if (program.transformFeedback) {
  30519. this.deleteTransformFeedback(program.transformFeedback);
  30520. program.transformFeedback = null;
  30521. }
  30522. this._gl.deleteProgram(program);
  30523. }
  30524. };
  30525. /**
  30526. * Create a new effect (used to store vertex/fragment shaders)
  30527. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30528. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30529. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30530. * @param samplers defines an array of string used to represent textures
  30531. * @param defines defines the string containing the defines to use to compile the shaders
  30532. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30533. * @param onCompiled defines a function to call when the effect creation is successful
  30534. * @param onError defines a function to call when the effect creation has failed
  30535. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30536. * @returns the new Effect
  30537. */
  30538. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  30539. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  30540. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  30541. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  30542. if (this._compiledEffects[name]) {
  30543. var compiledEffect = this._compiledEffects[name];
  30544. if (onCompiled && compiledEffect.isReady()) {
  30545. onCompiled(compiledEffect);
  30546. }
  30547. return compiledEffect;
  30548. }
  30549. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  30550. effect._key = name;
  30551. this._compiledEffects[name] = effect;
  30552. return effect;
  30553. };
  30554. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30555. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30556. };
  30557. Engine.prototype._compileRawShader = function (source, type) {
  30558. var gl = this._gl;
  30559. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30560. if (!shader) {
  30561. throw new Error("Something went wrong while compile the shader.");
  30562. }
  30563. gl.shaderSource(shader, source);
  30564. gl.compileShader(shader);
  30565. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  30566. var log = gl.getShaderInfoLog(shader);
  30567. if (log) {
  30568. throw new Error(log);
  30569. }
  30570. }
  30571. return shader;
  30572. };
  30573. /**
  30574. * Directly creates a webGL program
  30575. * @param vertexCode defines the vertex shader code to use
  30576. * @param fragmentCode defines the fragment shader code to use
  30577. * @param context defines the webGL context to use (if not set, the current one will be used)
  30578. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30579. * @returns the new webGL program
  30580. */
  30581. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30582. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30583. context = context || this._gl;
  30584. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30585. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30586. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30587. };
  30588. /**
  30589. * Creates a webGL program
  30590. * @param vertexCode defines the vertex shader code to use
  30591. * @param fragmentCode defines the fragment shader code to use
  30592. * @param defines defines the string containing the defines to use to compile the shaders
  30593. * @param context defines the webGL context to use (if not set, the current one will be used)
  30594. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30595. * @returns the new webGL program
  30596. */
  30597. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30598. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30599. context = context || this._gl;
  30600. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30601. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30602. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30603. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30604. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30605. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30606. return program;
  30607. };
  30608. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30609. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30610. var shaderProgram = context.createProgram();
  30611. if (!shaderProgram) {
  30612. throw new Error("Unable to create program");
  30613. }
  30614. context.attachShader(shaderProgram, vertexShader);
  30615. context.attachShader(shaderProgram, fragmentShader);
  30616. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30617. var transformFeedback = this.createTransformFeedback();
  30618. this.bindTransformFeedback(transformFeedback);
  30619. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30620. shaderProgram.transformFeedback = transformFeedback;
  30621. }
  30622. context.linkProgram(shaderProgram);
  30623. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30624. this.bindTransformFeedback(null);
  30625. }
  30626. shaderProgram.context = context;
  30627. shaderProgram.vertexShader = vertexShader;
  30628. shaderProgram.fragmentShader = fragmentShader;
  30629. if (!this._caps.parallelShaderCompile) {
  30630. this._finalizeProgram(shaderProgram);
  30631. }
  30632. else {
  30633. shaderProgram.isParallelCompiled = true;
  30634. }
  30635. return shaderProgram;
  30636. };
  30637. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30638. var context = shaderProgram.context;
  30639. var vertexShader = shaderProgram.vertexShader;
  30640. var fragmentShader = shaderProgram.fragmentShader;
  30641. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30642. if (!linked) {
  30643. var error = context.getProgramInfoLog(shaderProgram);
  30644. if (error) {
  30645. throw new Error(error);
  30646. }
  30647. }
  30648. if (this.validateShaderPrograms) {
  30649. context.validateProgram(shaderProgram);
  30650. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30651. if (!validated) {
  30652. var error = context.getProgramInfoLog(shaderProgram);
  30653. if (error) {
  30654. throw new Error(error);
  30655. }
  30656. }
  30657. }
  30658. context.deleteShader(vertexShader);
  30659. context.deleteShader(fragmentShader);
  30660. shaderProgram.context = undefined;
  30661. shaderProgram.vertexShader = undefined;
  30662. shaderProgram.fragmentShader = undefined;
  30663. if (shaderProgram.onCompiled) {
  30664. shaderProgram.onCompiled();
  30665. shaderProgram.onCompiled = undefined;
  30666. }
  30667. };
  30668. /** @hidden */
  30669. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30670. if (!shaderProgram.isParallelCompiled) {
  30671. return true;
  30672. }
  30673. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30674. this._finalizeProgram(shaderProgram);
  30675. return true;
  30676. }
  30677. return false;
  30678. };
  30679. /** @hidden */
  30680. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30681. if (!shaderProgram.isParallelCompiled) {
  30682. action();
  30683. return;
  30684. }
  30685. shaderProgram.onCompiled = action;
  30686. };
  30687. /**
  30688. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30689. * @param shaderProgram defines the webGL program to use
  30690. * @param uniformsNames defines the list of uniform names
  30691. * @returns an array of webGL uniform locations
  30692. */
  30693. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30694. var results = new Array();
  30695. for (var index = 0; index < uniformsNames.length; index++) {
  30696. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30697. }
  30698. return results;
  30699. };
  30700. /**
  30701. * Gets the lsit of active attributes for a given webGL program
  30702. * @param shaderProgram defines the webGL program to use
  30703. * @param attributesNames defines the list of attribute names to get
  30704. * @returns an array of indices indicating the offset of each attribute
  30705. */
  30706. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30707. var results = [];
  30708. for (var index = 0; index < attributesNames.length; index++) {
  30709. try {
  30710. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30711. }
  30712. catch (e) {
  30713. results.push(-1);
  30714. }
  30715. }
  30716. return results;
  30717. };
  30718. /**
  30719. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30720. * @param effect defines the effect to activate
  30721. */
  30722. Engine.prototype.enableEffect = function (effect) {
  30723. if (!effect || effect === this._currentEffect) {
  30724. return;
  30725. }
  30726. // Use program
  30727. this.bindSamplers(effect);
  30728. this._currentEffect = effect;
  30729. if (effect.onBind) {
  30730. effect.onBind(effect);
  30731. }
  30732. if (effect._onBindObservable) {
  30733. effect._onBindObservable.notifyObservers(effect);
  30734. }
  30735. };
  30736. /**
  30737. * Set the value of an uniform to an array of int32
  30738. * @param uniform defines the webGL uniform location where to store the value
  30739. * @param array defines the array of int32 to store
  30740. */
  30741. Engine.prototype.setIntArray = function (uniform, array) {
  30742. if (!uniform) {
  30743. return;
  30744. }
  30745. this._gl.uniform1iv(uniform, array);
  30746. };
  30747. /**
  30748. * Set the value of an uniform to an array of int32 (stored as vec2)
  30749. * @param uniform defines the webGL uniform location where to store the value
  30750. * @param array defines the array of int32 to store
  30751. */
  30752. Engine.prototype.setIntArray2 = function (uniform, array) {
  30753. if (!uniform || array.length % 2 !== 0) {
  30754. return;
  30755. }
  30756. this._gl.uniform2iv(uniform, array);
  30757. };
  30758. /**
  30759. * Set the value of an uniform to an array of int32 (stored as vec3)
  30760. * @param uniform defines the webGL uniform location where to store the value
  30761. * @param array defines the array of int32 to store
  30762. */
  30763. Engine.prototype.setIntArray3 = function (uniform, array) {
  30764. if (!uniform || array.length % 3 !== 0) {
  30765. return;
  30766. }
  30767. this._gl.uniform3iv(uniform, array);
  30768. };
  30769. /**
  30770. * Set the value of an uniform to an array of int32 (stored as vec4)
  30771. * @param uniform defines the webGL uniform location where to store the value
  30772. * @param array defines the array of int32 to store
  30773. */
  30774. Engine.prototype.setIntArray4 = function (uniform, array) {
  30775. if (!uniform || array.length % 4 !== 0) {
  30776. return;
  30777. }
  30778. this._gl.uniform4iv(uniform, array);
  30779. };
  30780. /**
  30781. * Set the value of an uniform to an array of float32
  30782. * @param uniform defines the webGL uniform location where to store the value
  30783. * @param array defines the array of float32 to store
  30784. */
  30785. Engine.prototype.setFloatArray = function (uniform, array) {
  30786. if (!uniform) {
  30787. return;
  30788. }
  30789. this._gl.uniform1fv(uniform, array);
  30790. };
  30791. /**
  30792. * Set the value of an uniform to an array of float32 (stored as vec2)
  30793. * @param uniform defines the webGL uniform location where to store the value
  30794. * @param array defines the array of float32 to store
  30795. */
  30796. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30797. if (!uniform || array.length % 2 !== 0) {
  30798. return;
  30799. }
  30800. this._gl.uniform2fv(uniform, array);
  30801. };
  30802. /**
  30803. * Set the value of an uniform to an array of float32 (stored as vec3)
  30804. * @param uniform defines the webGL uniform location where to store the value
  30805. * @param array defines the array of float32 to store
  30806. */
  30807. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30808. if (!uniform || array.length % 3 !== 0) {
  30809. return;
  30810. }
  30811. this._gl.uniform3fv(uniform, array);
  30812. };
  30813. /**
  30814. * Set the value of an uniform to an array of float32 (stored as vec4)
  30815. * @param uniform defines the webGL uniform location where to store the value
  30816. * @param array defines the array of float32 to store
  30817. */
  30818. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30819. if (!uniform || array.length % 4 !== 0) {
  30820. return;
  30821. }
  30822. this._gl.uniform4fv(uniform, array);
  30823. };
  30824. /**
  30825. * Set the value of an uniform to an array of number
  30826. * @param uniform defines the webGL uniform location where to store the value
  30827. * @param array defines the array of number to store
  30828. */
  30829. Engine.prototype.setArray = function (uniform, array) {
  30830. if (!uniform) {
  30831. return;
  30832. }
  30833. this._gl.uniform1fv(uniform, array);
  30834. };
  30835. /**
  30836. * Set the value of an uniform to an array of number (stored as vec2)
  30837. * @param uniform defines the webGL uniform location where to store the value
  30838. * @param array defines the array of number to store
  30839. */
  30840. Engine.prototype.setArray2 = function (uniform, array) {
  30841. if (!uniform || array.length % 2 !== 0) {
  30842. return;
  30843. }
  30844. this._gl.uniform2fv(uniform, array);
  30845. };
  30846. /**
  30847. * Set the value of an uniform to an array of number (stored as vec3)
  30848. * @param uniform defines the webGL uniform location where to store the value
  30849. * @param array defines the array of number to store
  30850. */
  30851. Engine.prototype.setArray3 = function (uniform, array) {
  30852. if (!uniform || array.length % 3 !== 0) {
  30853. return;
  30854. }
  30855. this._gl.uniform3fv(uniform, array);
  30856. };
  30857. /**
  30858. * Set the value of an uniform to an array of number (stored as vec4)
  30859. * @param uniform defines the webGL uniform location where to store the value
  30860. * @param array defines the array of number to store
  30861. */
  30862. Engine.prototype.setArray4 = function (uniform, array) {
  30863. if (!uniform || array.length % 4 !== 0) {
  30864. return;
  30865. }
  30866. this._gl.uniform4fv(uniform, array);
  30867. };
  30868. /**
  30869. * Set the value of an uniform to an array of float32 (stored as matrices)
  30870. * @param uniform defines the webGL uniform location where to store the value
  30871. * @param matrices defines the array of float32 to store
  30872. */
  30873. Engine.prototype.setMatrices = function (uniform, matrices) {
  30874. if (!uniform) {
  30875. return;
  30876. }
  30877. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30878. };
  30879. /**
  30880. * Set the value of an uniform to a matrix
  30881. * @param uniform defines the webGL uniform location where to store the value
  30882. * @param matrix defines the matrix to store
  30883. */
  30884. Engine.prototype.setMatrix = function (uniform, matrix) {
  30885. if (!uniform) {
  30886. return;
  30887. }
  30888. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30889. };
  30890. /**
  30891. * Set the value of an uniform to a matrix (3x3)
  30892. * @param uniform defines the webGL uniform location where to store the value
  30893. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30894. */
  30895. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30896. if (!uniform) {
  30897. return;
  30898. }
  30899. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30900. };
  30901. /**
  30902. * Set the value of an uniform to a matrix (2x2)
  30903. * @param uniform defines the webGL uniform location where to store the value
  30904. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30905. */
  30906. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30907. if (!uniform) {
  30908. return;
  30909. }
  30910. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30911. };
  30912. /**
  30913. * Set the value of an uniform to a number (int)
  30914. * @param uniform defines the webGL uniform location where to store the value
  30915. * @param value defines the int number to store
  30916. */
  30917. Engine.prototype.setInt = function (uniform, value) {
  30918. if (!uniform) {
  30919. return;
  30920. }
  30921. this._gl.uniform1i(uniform, value);
  30922. };
  30923. /**
  30924. * Set the value of an uniform to a number (float)
  30925. * @param uniform defines the webGL uniform location where to store the value
  30926. * @param value defines the float number to store
  30927. */
  30928. Engine.prototype.setFloat = function (uniform, value) {
  30929. if (!uniform) {
  30930. return;
  30931. }
  30932. this._gl.uniform1f(uniform, value);
  30933. };
  30934. /**
  30935. * Set the value of an uniform to a vec2
  30936. * @param uniform defines the webGL uniform location where to store the value
  30937. * @param x defines the 1st component of the value
  30938. * @param y defines the 2nd component of the value
  30939. */
  30940. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30941. if (!uniform) {
  30942. return;
  30943. }
  30944. this._gl.uniform2f(uniform, x, y);
  30945. };
  30946. /**
  30947. * Set the value of an uniform to a vec3
  30948. * @param uniform defines the webGL uniform location where to store the value
  30949. * @param x defines the 1st component of the value
  30950. * @param y defines the 2nd component of the value
  30951. * @param z defines the 3rd component of the value
  30952. */
  30953. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30954. if (!uniform) {
  30955. return;
  30956. }
  30957. this._gl.uniform3f(uniform, x, y, z);
  30958. };
  30959. /**
  30960. * Set the value of an uniform to a boolean
  30961. * @param uniform defines the webGL uniform location where to store the value
  30962. * @param bool defines the boolean to store
  30963. */
  30964. Engine.prototype.setBool = function (uniform, bool) {
  30965. if (!uniform) {
  30966. return;
  30967. }
  30968. this._gl.uniform1i(uniform, bool);
  30969. };
  30970. /**
  30971. * Set the value of an uniform to a vec4
  30972. * @param uniform defines the webGL uniform location where to store the value
  30973. * @param x defines the 1st component of the value
  30974. * @param y defines the 2nd component of the value
  30975. * @param z defines the 3rd component of the value
  30976. * @param w defines the 4th component of the value
  30977. */
  30978. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30979. if (!uniform) {
  30980. return;
  30981. }
  30982. this._gl.uniform4f(uniform, x, y, z, w);
  30983. };
  30984. /**
  30985. * Set the value of an uniform to a Color3
  30986. * @param uniform defines the webGL uniform location where to store the value
  30987. * @param color3 defines the color to store
  30988. */
  30989. Engine.prototype.setColor3 = function (uniform, color3) {
  30990. if (!uniform) {
  30991. return;
  30992. }
  30993. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30994. };
  30995. /**
  30996. * Set the value of an uniform to a Color3 and an alpha value
  30997. * @param uniform defines the webGL uniform location where to store the value
  30998. * @param color3 defines the color to store
  30999. * @param alpha defines the alpha component to store
  31000. */
  31001. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  31002. if (!uniform) {
  31003. return;
  31004. }
  31005. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  31006. };
  31007. /**
  31008. * Sets a Color4 on a uniform variable
  31009. * @param uniform defines the uniform location
  31010. * @param color4 defines the value to be set
  31011. */
  31012. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  31013. if (!uniform) {
  31014. return;
  31015. }
  31016. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  31017. };
  31018. // States
  31019. /**
  31020. * Set various states to the webGL context
  31021. * @param culling defines backface culling state
  31022. * @param zOffset defines the value to apply to zOffset (0 by default)
  31023. * @param force defines if states must be applied even if cache is up to date
  31024. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31025. */
  31026. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  31027. if (zOffset === void 0) { zOffset = 0; }
  31028. if (reverseSide === void 0) { reverseSide = false; }
  31029. // Culling
  31030. if (this._depthCullingState.cull !== culling || force) {
  31031. this._depthCullingState.cull = culling;
  31032. }
  31033. // Cull face
  31034. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  31035. if (this._depthCullingState.cullFace !== cullFace || force) {
  31036. this._depthCullingState.cullFace = cullFace;
  31037. }
  31038. // Z offset
  31039. this.setZOffset(zOffset);
  31040. // Front face
  31041. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  31042. if (this._depthCullingState.frontFace !== frontFace || force) {
  31043. this._depthCullingState.frontFace = frontFace;
  31044. }
  31045. };
  31046. /**
  31047. * Set the z offset to apply to current rendering
  31048. * @param value defines the offset to apply
  31049. */
  31050. Engine.prototype.setZOffset = function (value) {
  31051. this._depthCullingState.zOffset = value;
  31052. };
  31053. /**
  31054. * Gets the current value of the zOffset
  31055. * @returns the current zOffset state
  31056. */
  31057. Engine.prototype.getZOffset = function () {
  31058. return this._depthCullingState.zOffset;
  31059. };
  31060. /**
  31061. * Enable or disable depth buffering
  31062. * @param enable defines the state to set
  31063. */
  31064. Engine.prototype.setDepthBuffer = function (enable) {
  31065. this._depthCullingState.depthTest = enable;
  31066. };
  31067. /**
  31068. * Gets a boolean indicating if depth writing is enabled
  31069. * @returns the current depth writing state
  31070. */
  31071. Engine.prototype.getDepthWrite = function () {
  31072. return this._depthCullingState.depthMask;
  31073. };
  31074. /**
  31075. * Enable or disable depth writing
  31076. * @param enable defines the state to set
  31077. */
  31078. Engine.prototype.setDepthWrite = function (enable) {
  31079. this._depthCullingState.depthMask = enable;
  31080. };
  31081. /**
  31082. * Enable or disable color writing
  31083. * @param enable defines the state to set
  31084. */
  31085. Engine.prototype.setColorWrite = function (enable) {
  31086. this._gl.colorMask(enable, enable, enable, enable);
  31087. this._colorWrite = enable;
  31088. };
  31089. /**
  31090. * Gets a boolean indicating if color writing is enabled
  31091. * @returns the current color writing state
  31092. */
  31093. Engine.prototype.getColorWrite = function () {
  31094. return this._colorWrite;
  31095. };
  31096. /**
  31097. * Sets alpha constants used by some alpha blending modes
  31098. * @param r defines the red component
  31099. * @param g defines the green component
  31100. * @param b defines the blue component
  31101. * @param a defines the alpha component
  31102. */
  31103. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  31104. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  31105. };
  31106. /**
  31107. * Sets the current alpha mode
  31108. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31109. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31111. */
  31112. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  31113. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  31114. if (this._alphaMode === mode) {
  31115. return;
  31116. }
  31117. switch (mode) {
  31118. case Engine.ALPHA_DISABLE:
  31119. this._alphaState.alphaBlend = false;
  31120. break;
  31121. case Engine.ALPHA_PREMULTIPLIED:
  31122. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31123. this._alphaState.alphaBlend = true;
  31124. break;
  31125. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  31126. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31127. this._alphaState.alphaBlend = true;
  31128. break;
  31129. case Engine.ALPHA_COMBINE:
  31130. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31131. this._alphaState.alphaBlend = true;
  31132. break;
  31133. case Engine.ALPHA_ONEONE:
  31134. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31135. this._alphaState.alphaBlend = true;
  31136. break;
  31137. case Engine.ALPHA_ADD:
  31138. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31139. this._alphaState.alphaBlend = true;
  31140. break;
  31141. case Engine.ALPHA_SUBTRACT:
  31142. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31143. this._alphaState.alphaBlend = true;
  31144. break;
  31145. case Engine.ALPHA_MULTIPLY:
  31146. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  31147. this._alphaState.alphaBlend = true;
  31148. break;
  31149. case Engine.ALPHA_MAXIMIZED:
  31150. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31151. this._alphaState.alphaBlend = true;
  31152. break;
  31153. case Engine.ALPHA_INTERPOLATE:
  31154. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  31155. this._alphaState.alphaBlend = true;
  31156. break;
  31157. case Engine.ALPHA_SCREENMODE:
  31158. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31159. this._alphaState.alphaBlend = true;
  31160. break;
  31161. }
  31162. if (!noDepthWriteChange) {
  31163. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  31164. }
  31165. this._alphaMode = mode;
  31166. };
  31167. /**
  31168. * Gets the current alpha mode
  31169. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31170. * @returns the current alpha mode
  31171. */
  31172. Engine.prototype.getAlphaMode = function () {
  31173. return this._alphaMode;
  31174. };
  31175. // Textures
  31176. /**
  31177. * Clears the list of texture accessible through engine.
  31178. * This can help preventing texture load conflict due to name collision.
  31179. */
  31180. Engine.prototype.clearInternalTexturesCache = function () {
  31181. this._internalTexturesCache = [];
  31182. };
  31183. /**
  31184. * Force the entire cache to be cleared
  31185. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31186. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31187. */
  31188. Engine.prototype.wipeCaches = function (bruteForce) {
  31189. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  31190. return;
  31191. }
  31192. this._currentEffect = null;
  31193. this._viewportCached.x = 0;
  31194. this._viewportCached.y = 0;
  31195. this._viewportCached.z = 0;
  31196. this._viewportCached.w = 0;
  31197. if (bruteForce) {
  31198. this.resetTextureCache();
  31199. this._currentProgram = null;
  31200. this._stencilState.reset();
  31201. this._depthCullingState.reset();
  31202. this.setDepthFunctionToLessOrEqual();
  31203. this._alphaState.reset();
  31204. this._unpackFlipYCached = null;
  31205. }
  31206. this._resetVertexBufferBinding();
  31207. this._cachedIndexBuffer = null;
  31208. this._cachedEffectForVertexBuffers = null;
  31209. this._unbindVertexArrayObject();
  31210. this.bindIndexBuffer(null);
  31211. };
  31212. /**
  31213. * Set the compressed texture format to use, based on the formats you have, and the formats
  31214. * supported by the hardware / browser.
  31215. *
  31216. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31217. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31218. * to API arguments needed to compressed textures. This puts the burden on the container
  31219. * generator to house the arcane code for determining these for current & future formats.
  31220. *
  31221. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31222. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31223. *
  31224. * Note: The result of this call is not taken into account when a texture is base64.
  31225. *
  31226. * @param formatsAvailable defines the list of those format families you have created
  31227. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31228. *
  31229. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31230. * @returns The extension selected.
  31231. */
  31232. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  31233. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  31234. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  31235. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  31236. return this._textureFormatInUse = this._texturesSupported[i];
  31237. }
  31238. }
  31239. }
  31240. // actively set format to nothing, to allow this to be called more than once
  31241. // and possibly fail the 2nd time
  31242. this._textureFormatInUse = null;
  31243. return null;
  31244. };
  31245. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  31246. var gl = this._gl;
  31247. var magFilter = gl.NEAREST;
  31248. var minFilter = gl.NEAREST;
  31249. switch (samplingMode) {
  31250. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  31251. magFilter = gl.LINEAR;
  31252. if (generateMipMaps) {
  31253. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31254. }
  31255. else {
  31256. minFilter = gl.LINEAR;
  31257. }
  31258. break;
  31259. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  31260. magFilter = gl.LINEAR;
  31261. if (generateMipMaps) {
  31262. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31263. }
  31264. else {
  31265. minFilter = gl.LINEAR;
  31266. }
  31267. break;
  31268. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  31269. magFilter = gl.NEAREST;
  31270. if (generateMipMaps) {
  31271. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31272. }
  31273. else {
  31274. minFilter = gl.NEAREST;
  31275. }
  31276. break;
  31277. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  31278. magFilter = gl.NEAREST;
  31279. if (generateMipMaps) {
  31280. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31281. }
  31282. else {
  31283. minFilter = gl.NEAREST;
  31284. }
  31285. break;
  31286. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  31287. magFilter = gl.NEAREST;
  31288. if (generateMipMaps) {
  31289. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31290. }
  31291. else {
  31292. minFilter = gl.LINEAR;
  31293. }
  31294. break;
  31295. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  31296. magFilter = gl.NEAREST;
  31297. if (generateMipMaps) {
  31298. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31299. }
  31300. else {
  31301. minFilter = gl.LINEAR;
  31302. }
  31303. break;
  31304. case Engine.TEXTURE_NEAREST_LINEAR:
  31305. magFilter = gl.NEAREST;
  31306. minFilter = gl.LINEAR;
  31307. break;
  31308. case Engine.TEXTURE_NEAREST_NEAREST:
  31309. magFilter = gl.NEAREST;
  31310. minFilter = gl.NEAREST;
  31311. break;
  31312. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  31313. magFilter = gl.LINEAR;
  31314. if (generateMipMaps) {
  31315. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31316. }
  31317. else {
  31318. minFilter = gl.NEAREST;
  31319. }
  31320. break;
  31321. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  31322. magFilter = gl.LINEAR;
  31323. if (generateMipMaps) {
  31324. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31325. }
  31326. else {
  31327. minFilter = gl.NEAREST;
  31328. }
  31329. break;
  31330. case Engine.TEXTURE_LINEAR_LINEAR:
  31331. magFilter = gl.LINEAR;
  31332. minFilter = gl.LINEAR;
  31333. break;
  31334. case Engine.TEXTURE_LINEAR_NEAREST:
  31335. magFilter = gl.LINEAR;
  31336. minFilter = gl.NEAREST;
  31337. break;
  31338. }
  31339. return {
  31340. min: minFilter,
  31341. mag: magFilter
  31342. };
  31343. };
  31344. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  31345. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  31346. var img;
  31347. var onload = function () {
  31348. loadedImages[index] = img;
  31349. loadedImages._internalCount++;
  31350. if (scene) {
  31351. scene._removePendingData(img);
  31352. }
  31353. if (loadedImages._internalCount === 6) {
  31354. onfinish(loadedImages);
  31355. }
  31356. };
  31357. var onerror = function (message, exception) {
  31358. if (scene) {
  31359. scene._removePendingData(img);
  31360. }
  31361. if (onErrorCallBack) {
  31362. onErrorCallBack(message, exception);
  31363. }
  31364. };
  31365. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  31366. if (scene) {
  31367. scene._addPendingData(img);
  31368. }
  31369. };
  31370. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  31371. if (onError === void 0) { onError = null; }
  31372. var loadedImages = [];
  31373. loadedImages._internalCount = 0;
  31374. for (var index = 0; index < 6; index++) {
  31375. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  31376. }
  31377. };
  31378. /** @hidden */
  31379. Engine.prototype._createTexture = function () {
  31380. var texture = this._gl.createTexture();
  31381. if (!texture) {
  31382. throw new Error("Unable to create texture");
  31383. }
  31384. return texture;
  31385. };
  31386. /**
  31387. * Usually called from Texture.ts.
  31388. * Passed information to create a WebGLTexture
  31389. * @param urlArg defines a value which contains one of the following:
  31390. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31391. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31392. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31393. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31394. * @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)
  31395. * @param scene needed for loading to the correct scene
  31396. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31397. * @param onLoad optional callback to be called upon successful completion
  31398. * @param onError optional callback to be called upon failure
  31399. * @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
  31400. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31401. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31402. * @param forcedExtension defines the extension to use to pick the right loader
  31403. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31404. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31405. */
  31406. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  31407. var _this = this;
  31408. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31409. if (onLoad === void 0) { onLoad = null; }
  31410. if (onError === void 0) { onError = null; }
  31411. if (buffer === void 0) { buffer = null; }
  31412. if (fallback === void 0) { fallback = null; }
  31413. if (format === void 0) { format = null; }
  31414. if (forcedExtension === void 0) { forcedExtension = null; }
  31415. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31416. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  31417. var fromData = url.substr(0, 5) === "data:";
  31418. var fromBlob = url.substr(0, 5) === "blob:";
  31419. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  31420. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  31421. // establish the file extension, if possible
  31422. var lastDot = url.lastIndexOf('.');
  31423. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  31424. var loader = null;
  31425. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31426. var availableLoader = _a[_i];
  31427. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  31428. loader = availableLoader;
  31429. break;
  31430. }
  31431. }
  31432. if (loader) {
  31433. url = loader.transformUrl(url, this._textureFormatInUse);
  31434. }
  31435. if (scene) {
  31436. scene._addPendingData(texture);
  31437. }
  31438. texture.url = url;
  31439. texture.generateMipMaps = !noMipmap;
  31440. texture.samplingMode = samplingMode;
  31441. texture.invertY = invertY;
  31442. if (!this._doNotHandleContextLost) {
  31443. // Keep a link to the buffer only if we plan to handle context lost
  31444. texture._buffer = buffer;
  31445. }
  31446. var onLoadObserver = null;
  31447. if (onLoad && !fallback) {
  31448. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  31449. }
  31450. if (!fallback) {
  31451. this._internalTexturesCache.push(texture);
  31452. }
  31453. var onInternalError = function (message, exception) {
  31454. if (scene) {
  31455. scene._removePendingData(texture);
  31456. }
  31457. var customFallback = false;
  31458. if (loader) {
  31459. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  31460. if (fallbackUrl) {
  31461. // Add Back
  31462. customFallback = true;
  31463. excludeLoaders.push(loader);
  31464. _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");
  31465. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  31466. }
  31467. }
  31468. if (!customFallback) {
  31469. if (onLoadObserver) {
  31470. texture.onLoadedObservable.remove(onLoadObserver);
  31471. }
  31472. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  31473. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  31474. }
  31475. }
  31476. if (onError) {
  31477. onError(message || "Unknown error", exception);
  31478. }
  31479. };
  31480. // processing for non-image formats
  31481. if (loader) {
  31482. var callback = function (data) {
  31483. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  31484. if (loadFailed) {
  31485. onInternalError("TextureLoader failed to load data");
  31486. }
  31487. else {
  31488. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  31489. done();
  31490. return false;
  31491. }, samplingMode);
  31492. }
  31493. });
  31494. };
  31495. if (!buffer) {
  31496. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  31497. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  31498. });
  31499. }
  31500. else {
  31501. callback(buffer);
  31502. }
  31503. }
  31504. else {
  31505. var onload = function (img) {
  31506. if (fromBlob && !_this._doNotHandleContextLost) {
  31507. // We need to store the image if we need to rebuild the texture
  31508. // in case of a webgl context lost
  31509. texture._buffer = img;
  31510. }
  31511. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  31512. var gl = _this._gl;
  31513. var isPot = (img.width === potWidth && img.height === potHeight);
  31514. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  31515. if (isPot) {
  31516. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31517. return false;
  31518. }
  31519. var maxTextureSize = _this._caps.maxTextureSize;
  31520. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  31521. _this._prepareWorkingCanvas();
  31522. if (!_this._workingCanvas || !_this._workingContext) {
  31523. return false;
  31524. }
  31525. _this._workingCanvas.width = potWidth;
  31526. _this._workingCanvas.height = potHeight;
  31527. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  31528. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31529. texture.width = potWidth;
  31530. texture.height = potHeight;
  31531. return false;
  31532. }
  31533. else {
  31534. // Using shaders when possible to rescale because canvas.drawImage is lossy
  31535. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  31536. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  31537. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31538. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31539. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  31540. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31541. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31542. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  31543. _this._releaseTexture(source_1);
  31544. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31545. continuationCallback();
  31546. });
  31547. }
  31548. return true;
  31549. }, samplingMode);
  31550. };
  31551. if (!fromData || isBase64) {
  31552. if (buffer instanceof HTMLImageElement) {
  31553. onload(buffer);
  31554. }
  31555. else {
  31556. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31557. }
  31558. }
  31559. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31560. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31561. }
  31562. else {
  31563. onload(buffer);
  31564. }
  31565. }
  31566. return texture;
  31567. };
  31568. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31569. var _this = this;
  31570. var rtt = this.createRenderTargetTexture({
  31571. width: destination.width,
  31572. height: destination.height,
  31573. }, {
  31574. generateMipMaps: false,
  31575. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31576. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31577. generateDepthBuffer: false,
  31578. generateStencilBuffer: false
  31579. });
  31580. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31581. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31582. }
  31583. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31584. _this._rescalePostProcess.onApply = function (effect) {
  31585. effect._bindTexture("textureSampler", source);
  31586. };
  31587. var hostingScene = scene;
  31588. if (!hostingScene) {
  31589. hostingScene = _this.scenes[_this.scenes.length - 1];
  31590. }
  31591. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31592. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31593. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31594. _this.unBindFramebuffer(rtt);
  31595. _this._releaseTexture(rtt);
  31596. if (onComplete) {
  31597. onComplete();
  31598. }
  31599. });
  31600. };
  31601. /**
  31602. * Update a raw texture
  31603. * @param texture defines the texture to update
  31604. * @param data defines the data to store in the texture
  31605. * @param format defines the format of the data
  31606. * @param invertY defines if data must be stored with Y axis inverted
  31607. * @param compression defines the compression used (null by default)
  31608. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31609. */
  31610. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31611. if (compression === void 0) { compression = null; }
  31612. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31613. if (!texture) {
  31614. return;
  31615. }
  31616. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31617. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31618. // babylon's internalFormat but gl's texImage2D format
  31619. var internalFormat = this._getInternalFormat(format);
  31620. var textureType = this._getWebGLTextureType(type);
  31621. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31622. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31623. if (!this._doNotHandleContextLost) {
  31624. texture._bufferView = data;
  31625. texture.format = format;
  31626. texture.type = type;
  31627. texture.invertY = invertY;
  31628. texture._compression = compression;
  31629. }
  31630. if (texture.width % 4 !== 0) {
  31631. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31632. }
  31633. if (compression && data) {
  31634. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31635. }
  31636. else {
  31637. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31638. }
  31639. if (texture.generateMipMaps) {
  31640. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31641. }
  31642. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31643. // this.resetTextureCache();
  31644. texture.isReady = true;
  31645. };
  31646. /**
  31647. * Creates a raw texture
  31648. * @param data defines the data to store in the texture
  31649. * @param width defines the width of the texture
  31650. * @param height defines the height of the texture
  31651. * @param format defines the format of the data
  31652. * @param generateMipMaps defines if the engine should generate the mip levels
  31653. * @param invertY defines if data must be stored with Y axis inverted
  31654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31655. * @param compression defines the compression used (null by default)
  31656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31657. * @returns the raw texture inside an InternalTexture
  31658. */
  31659. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31660. if (compression === void 0) { compression = null; }
  31661. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31662. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31663. texture.baseWidth = width;
  31664. texture.baseHeight = height;
  31665. texture.width = width;
  31666. texture.height = height;
  31667. texture.format = format;
  31668. texture.generateMipMaps = generateMipMaps;
  31669. texture.samplingMode = samplingMode;
  31670. texture.invertY = invertY;
  31671. texture._compression = compression;
  31672. texture.type = type;
  31673. if (!this._doNotHandleContextLost) {
  31674. texture._bufferView = data;
  31675. }
  31676. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31677. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31678. // Filters
  31679. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31680. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31681. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31682. if (generateMipMaps) {
  31683. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31684. }
  31685. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31686. this._internalTexturesCache.push(texture);
  31687. return texture;
  31688. };
  31689. /** @hidden */
  31690. Engine.prototype._unpackFlipY = function (value) {
  31691. if (this._unpackFlipYCached !== value) {
  31692. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31693. if (this.enableUnpackFlipYCached) {
  31694. this._unpackFlipYCached = value;
  31695. }
  31696. }
  31697. };
  31698. /** @hidden */
  31699. Engine.prototype._getUnpackAlignement = function () {
  31700. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31701. };
  31702. /**
  31703. * Creates a dynamic texture
  31704. * @param width defines the width of the texture
  31705. * @param height defines the height of the texture
  31706. * @param generateMipMaps defines if the engine should generate the mip levels
  31707. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31708. * @returns the dynamic texture inside an InternalTexture
  31709. */
  31710. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31711. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31712. texture.baseWidth = width;
  31713. texture.baseHeight = height;
  31714. if (generateMipMaps) {
  31715. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31716. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31717. }
  31718. // this.resetTextureCache();
  31719. texture.width = width;
  31720. texture.height = height;
  31721. texture.isReady = false;
  31722. texture.generateMipMaps = generateMipMaps;
  31723. texture.samplingMode = samplingMode;
  31724. this.updateTextureSamplingMode(samplingMode, texture);
  31725. this._internalTexturesCache.push(texture);
  31726. return texture;
  31727. };
  31728. /**
  31729. * Update the sampling mode of a given texture
  31730. * @param samplingMode defines the required sampling mode
  31731. * @param texture defines the texture to update
  31732. */
  31733. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31734. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31735. if (texture.isCube) {
  31736. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31737. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31738. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31739. }
  31740. else if (texture.is3D) {
  31741. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31742. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31743. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31744. }
  31745. else {
  31746. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31747. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31748. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31749. }
  31750. texture.samplingMode = samplingMode;
  31751. };
  31752. /**
  31753. * Update the content of a dynamic texture
  31754. * @param texture defines the texture to update
  31755. * @param canvas defines the canvas containing the source
  31756. * @param invertY defines if data must be stored with Y axis inverted
  31757. * @param premulAlpha defines if alpha is stored as premultiplied
  31758. * @param format defines the format of the data
  31759. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31760. */
  31761. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31762. if (premulAlpha === void 0) { premulAlpha = false; }
  31763. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31764. if (!texture) {
  31765. return;
  31766. }
  31767. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31768. this._unpackFlipY(invertY);
  31769. if (premulAlpha) {
  31770. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31771. }
  31772. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31773. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31774. if (texture.generateMipMaps) {
  31775. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31776. }
  31777. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31778. if (premulAlpha) {
  31779. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31780. }
  31781. texture.isReady = true;
  31782. };
  31783. /**
  31784. * Update a video texture
  31785. * @param texture defines the texture to update
  31786. * @param video defines the video element to use
  31787. * @param invertY defines if data must be stored with Y axis inverted
  31788. */
  31789. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31790. if (!texture || texture._isDisabled) {
  31791. return;
  31792. }
  31793. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31794. this._unpackFlipY(!invertY); // Video are upside down by default
  31795. try {
  31796. // Testing video texture support
  31797. if (this._videoTextureSupported === undefined) {
  31798. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31799. if (this._gl.getError() !== 0) {
  31800. this._videoTextureSupported = false;
  31801. }
  31802. else {
  31803. this._videoTextureSupported = true;
  31804. }
  31805. }
  31806. // Copy video through the current working canvas if video texture is not supported
  31807. if (!this._videoTextureSupported) {
  31808. if (!texture._workingCanvas) {
  31809. texture._workingCanvas = document.createElement("canvas");
  31810. var context = texture._workingCanvas.getContext("2d");
  31811. if (!context) {
  31812. throw new Error("Unable to get 2d context");
  31813. }
  31814. texture._workingContext = context;
  31815. texture._workingCanvas.width = texture.width;
  31816. texture._workingCanvas.height = texture.height;
  31817. }
  31818. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31819. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31820. }
  31821. else {
  31822. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31823. }
  31824. if (texture.generateMipMaps) {
  31825. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31826. }
  31827. if (!wasPreviouslyBound) {
  31828. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31829. }
  31830. // this.resetTextureCache();
  31831. texture.isReady = true;
  31832. }
  31833. catch (ex) {
  31834. // Something unexpected
  31835. // Let's disable the texture
  31836. texture._isDisabled = true;
  31837. }
  31838. };
  31839. /**
  31840. * Updates a depth texture Comparison Mode and Function.
  31841. * If the comparison Function is equal to 0, the mode will be set to none.
  31842. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31843. * @param texture The texture to set the comparison function for
  31844. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31845. */
  31846. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31847. if (this.webGLVersion === 1) {
  31848. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31849. return;
  31850. }
  31851. var gl = this._gl;
  31852. if (texture.isCube) {
  31853. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31854. if (comparisonFunction === 0) {
  31855. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31856. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31857. }
  31858. else {
  31859. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31860. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31861. }
  31862. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31863. }
  31864. else {
  31865. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31866. if (comparisonFunction === 0) {
  31867. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31868. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31869. }
  31870. else {
  31871. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31872. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31873. }
  31874. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31875. }
  31876. texture._comparisonFunction = comparisonFunction;
  31877. };
  31878. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31879. var width = size.width || size;
  31880. var height = size.height || size;
  31881. internalTexture.baseWidth = width;
  31882. internalTexture.baseHeight = height;
  31883. internalTexture.width = width;
  31884. internalTexture.height = height;
  31885. internalTexture.isReady = true;
  31886. internalTexture.samples = 1;
  31887. internalTexture.generateMipMaps = false;
  31888. internalTexture._generateDepthBuffer = true;
  31889. internalTexture._generateStencilBuffer = generateStencil;
  31890. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31891. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31892. internalTexture._comparisonFunction = comparisonFunction;
  31893. var gl = this._gl;
  31894. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31895. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31896. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31897. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31898. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31899. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31900. if (comparisonFunction === 0) {
  31901. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31902. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31903. }
  31904. else {
  31905. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31906. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31907. }
  31908. };
  31909. /**
  31910. * Creates a depth stencil texture.
  31911. * This is only available in WebGL 2 or with the depth texture extension available.
  31912. * @param size The size of face edge in the texture.
  31913. * @param options The options defining the texture.
  31914. * @returns The texture
  31915. */
  31916. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31917. if (options.isCube) {
  31918. var width = size.width || size;
  31919. return this._createDepthStencilCubeTexture(width, options);
  31920. }
  31921. else {
  31922. return this._createDepthStencilTexture(size, options);
  31923. }
  31924. };
  31925. /**
  31926. * Creates a depth stencil texture.
  31927. * This is only available in WebGL 2 or with the depth texture extension available.
  31928. * @param size The size of face edge in the texture.
  31929. * @param options The options defining the texture.
  31930. * @returns The texture
  31931. */
  31932. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31933. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31934. if (!this._caps.depthTextureExtension) {
  31935. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31936. return internalTexture;
  31937. }
  31938. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31939. var gl = this._gl;
  31940. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31941. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31942. if (this.webGLVersion > 1) {
  31943. if (internalOptions.generateStencil) {
  31944. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31945. }
  31946. else {
  31947. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31948. }
  31949. }
  31950. else {
  31951. if (internalOptions.generateStencil) {
  31952. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31953. }
  31954. else {
  31955. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31956. }
  31957. }
  31958. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31959. return internalTexture;
  31960. };
  31961. /**
  31962. * Creates a depth stencil cube texture.
  31963. * This is only available in WebGL 2.
  31964. * @param size The size of face edge in the cube texture.
  31965. * @param options The options defining the cube texture.
  31966. * @returns The cube texture
  31967. */
  31968. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31969. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31970. internalTexture.isCube = true;
  31971. if (this.webGLVersion === 1) {
  31972. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31973. return internalTexture;
  31974. }
  31975. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31976. var gl = this._gl;
  31977. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31978. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31979. // Create the depth/stencil buffer
  31980. for (var face = 0; face < 6; face++) {
  31981. if (internalOptions.generateStencil) {
  31982. 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);
  31983. }
  31984. else {
  31985. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31986. }
  31987. }
  31988. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31989. return internalTexture;
  31990. };
  31991. /**
  31992. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31993. * @param renderTarget The render target to set the frame buffer for
  31994. */
  31995. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31996. // Create the framebuffer
  31997. var internalTexture = renderTarget.getInternalTexture();
  31998. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31999. return;
  32000. }
  32001. var gl = this._gl;
  32002. var depthStencilTexture = renderTarget.depthStencilTexture;
  32003. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  32004. if (depthStencilTexture.isCube) {
  32005. if (depthStencilTexture._generateStencilBuffer) {
  32006. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32007. }
  32008. else {
  32009. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32010. }
  32011. }
  32012. else {
  32013. if (depthStencilTexture._generateStencilBuffer) {
  32014. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32015. }
  32016. else {
  32017. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32018. }
  32019. }
  32020. this.bindUnboundFramebuffer(null);
  32021. };
  32022. /**
  32023. * Creates a new render target texture
  32024. * @param size defines the size of the texture
  32025. * @param options defines the options used to create the texture
  32026. * @returns a new render target texture stored in an InternalTexture
  32027. */
  32028. Engine.prototype.createRenderTargetTexture = function (size, options) {
  32029. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  32030. if (options !== undefined && typeof options === "object") {
  32031. fullOptions.generateMipMaps = options.generateMipMaps;
  32032. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32033. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  32034. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  32035. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  32036. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  32037. }
  32038. else {
  32039. fullOptions.generateMipMaps = options;
  32040. fullOptions.generateDepthBuffer = true;
  32041. fullOptions.generateStencilBuffer = false;
  32042. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32043. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32044. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  32045. }
  32046. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32047. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32048. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32049. }
  32050. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32051. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32052. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32053. }
  32054. var gl = this._gl;
  32055. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32056. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32057. var width = size.width || size;
  32058. var height = size.height || size;
  32059. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  32060. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32061. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32062. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32063. }
  32064. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32065. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32066. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32067. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32068. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  32069. // Create the framebuffer
  32070. var currentFrameBuffer = this._currentFramebuffer;
  32071. var framebuffer = gl.createFramebuffer();
  32072. this.bindUnboundFramebuffer(framebuffer);
  32073. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32074. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  32075. if (fullOptions.generateMipMaps) {
  32076. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32077. }
  32078. // Unbind
  32079. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32080. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32081. this.bindUnboundFramebuffer(currentFrameBuffer);
  32082. texture._framebuffer = framebuffer;
  32083. texture.baseWidth = width;
  32084. texture.baseHeight = height;
  32085. texture.width = width;
  32086. texture.height = height;
  32087. texture.isReady = true;
  32088. texture.samples = 1;
  32089. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  32090. texture.samplingMode = fullOptions.samplingMode;
  32091. texture.type = fullOptions.type;
  32092. texture.format = fullOptions.format;
  32093. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32094. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  32095. // this.resetTextureCache();
  32096. this._internalTexturesCache.push(texture);
  32097. return texture;
  32098. };
  32099. /**
  32100. * Create a multi render target texture
  32101. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  32102. * @param size defines the size of the texture
  32103. * @param options defines the creation options
  32104. * @returns the cube texture as an InternalTexture
  32105. */
  32106. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  32107. var generateMipMaps = false;
  32108. var generateDepthBuffer = true;
  32109. var generateStencilBuffer = false;
  32110. var generateDepthTexture = false;
  32111. var textureCount = 1;
  32112. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  32113. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32114. var types = new Array();
  32115. var samplingModes = new Array();
  32116. if (options !== undefined) {
  32117. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  32118. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32119. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  32120. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  32121. textureCount = options.textureCount || 1;
  32122. if (options.types) {
  32123. types = options.types;
  32124. }
  32125. if (options.samplingModes) {
  32126. samplingModes = options.samplingModes;
  32127. }
  32128. }
  32129. var gl = this._gl;
  32130. // Create the framebuffer
  32131. var framebuffer = gl.createFramebuffer();
  32132. this.bindUnboundFramebuffer(framebuffer);
  32133. var width = size.width || size;
  32134. var height = size.height || size;
  32135. var textures = [];
  32136. var attachments = [];
  32137. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  32138. for (var i = 0; i < textureCount; i++) {
  32139. var samplingMode = samplingModes[i] || defaultSamplingMode;
  32140. var type = types[i] || defaultType;
  32141. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32142. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32143. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32144. }
  32145. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32146. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32147. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32148. }
  32149. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32150. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32151. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32152. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32153. }
  32154. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32155. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32156. textures.push(texture);
  32157. attachments.push(attachment);
  32158. gl.activeTexture(gl["TEXTURE" + i]);
  32159. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  32160. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32161. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32162. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32163. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32164. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32165. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32166. if (generateMipMaps) {
  32167. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32168. }
  32169. // Unbind
  32170. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32171. texture._framebuffer = framebuffer;
  32172. texture._depthStencilBuffer = depthStencilBuffer;
  32173. texture.baseWidth = width;
  32174. texture.baseHeight = height;
  32175. texture.width = width;
  32176. texture.height = height;
  32177. texture.isReady = true;
  32178. texture.samples = 1;
  32179. texture.generateMipMaps = generateMipMaps;
  32180. texture.samplingMode = samplingMode;
  32181. texture.type = type;
  32182. texture._generateDepthBuffer = generateDepthBuffer;
  32183. texture._generateStencilBuffer = generateStencilBuffer;
  32184. texture._attachments = attachments;
  32185. this._internalTexturesCache.push(texture);
  32186. }
  32187. if (generateDepthTexture && this._caps.depthTextureExtension) {
  32188. // Depth texture
  32189. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32190. gl.activeTexture(gl.TEXTURE0);
  32191. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  32192. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32193. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32194. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32195. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32196. 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);
  32197. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  32198. depthTexture._framebuffer = framebuffer;
  32199. depthTexture.baseWidth = width;
  32200. depthTexture.baseHeight = height;
  32201. depthTexture.width = width;
  32202. depthTexture.height = height;
  32203. depthTexture.isReady = true;
  32204. depthTexture.samples = 1;
  32205. depthTexture.generateMipMaps = generateMipMaps;
  32206. depthTexture.samplingMode = gl.NEAREST;
  32207. depthTexture._generateDepthBuffer = generateDepthBuffer;
  32208. depthTexture._generateStencilBuffer = generateStencilBuffer;
  32209. textures.push(depthTexture);
  32210. this._internalTexturesCache.push(depthTexture);
  32211. }
  32212. gl.drawBuffers(attachments);
  32213. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32214. this.bindUnboundFramebuffer(null);
  32215. this.resetTextureCache();
  32216. return textures;
  32217. };
  32218. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  32219. if (samples === void 0) { samples = 1; }
  32220. var depthStencilBuffer = null;
  32221. var gl = this._gl;
  32222. // Create the depth/stencil buffer
  32223. if (generateStencilBuffer) {
  32224. depthStencilBuffer = gl.createRenderbuffer();
  32225. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32226. if (samples > 1) {
  32227. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  32228. }
  32229. else {
  32230. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  32231. }
  32232. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32233. }
  32234. else if (generateDepthBuffer) {
  32235. depthStencilBuffer = gl.createRenderbuffer();
  32236. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32237. if (samples > 1) {
  32238. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  32239. }
  32240. else {
  32241. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  32242. }
  32243. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32244. }
  32245. return depthStencilBuffer;
  32246. };
  32247. /**
  32248. * Updates the sample count of a render target texture
  32249. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32250. * @param texture defines the texture to update
  32251. * @param samples defines the sample count to set
  32252. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32253. */
  32254. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  32255. if (this.webGLVersion < 2 || !texture) {
  32256. return 1;
  32257. }
  32258. if (texture.samples === samples) {
  32259. return samples;
  32260. }
  32261. var gl = this._gl;
  32262. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32263. // Dispose previous render buffers
  32264. if (texture._depthStencilBuffer) {
  32265. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32266. texture._depthStencilBuffer = null;
  32267. }
  32268. if (texture._MSAAFramebuffer) {
  32269. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32270. texture._MSAAFramebuffer = null;
  32271. }
  32272. if (texture._MSAARenderBuffer) {
  32273. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32274. texture._MSAARenderBuffer = null;
  32275. }
  32276. if (samples > 1) {
  32277. var framebuffer = gl.createFramebuffer();
  32278. if (!framebuffer) {
  32279. throw new Error("Unable to create multi sampled framebuffer");
  32280. }
  32281. texture._MSAAFramebuffer = framebuffer;
  32282. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  32283. var colorRenderbuffer = gl.createRenderbuffer();
  32284. if (!colorRenderbuffer) {
  32285. throw new Error("Unable to create multi sampled framebuffer");
  32286. }
  32287. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32288. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32289. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  32290. texture._MSAARenderBuffer = colorRenderbuffer;
  32291. }
  32292. else {
  32293. this.bindUnboundFramebuffer(texture._framebuffer);
  32294. }
  32295. texture.samples = samples;
  32296. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  32297. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32298. this.bindUnboundFramebuffer(null);
  32299. return samples;
  32300. };
  32301. /**
  32302. * Update the sample count for a given multiple render target texture
  32303. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32304. * @param textures defines the textures to update
  32305. * @param samples defines the sample count to set
  32306. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32307. */
  32308. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  32309. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  32310. return 1;
  32311. }
  32312. if (textures[0].samples === samples) {
  32313. return samples;
  32314. }
  32315. var gl = this._gl;
  32316. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32317. // Dispose previous render buffers
  32318. if (textures[0]._depthStencilBuffer) {
  32319. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  32320. textures[0]._depthStencilBuffer = null;
  32321. }
  32322. if (textures[0]._MSAAFramebuffer) {
  32323. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  32324. textures[0]._MSAAFramebuffer = null;
  32325. }
  32326. for (var i = 0; i < textures.length; i++) {
  32327. if (textures[i]._MSAARenderBuffer) {
  32328. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  32329. textures[i]._MSAARenderBuffer = null;
  32330. }
  32331. }
  32332. if (samples > 1) {
  32333. var framebuffer = gl.createFramebuffer();
  32334. if (!framebuffer) {
  32335. throw new Error("Unable to create multi sampled framebuffer");
  32336. }
  32337. this.bindUnboundFramebuffer(framebuffer);
  32338. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  32339. var attachments = [];
  32340. for (var i = 0; i < textures.length; i++) {
  32341. var texture = textures[i];
  32342. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32343. var colorRenderbuffer = gl.createRenderbuffer();
  32344. if (!colorRenderbuffer) {
  32345. throw new Error("Unable to create multi sampled framebuffer");
  32346. }
  32347. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32348. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32349. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  32350. texture._MSAAFramebuffer = framebuffer;
  32351. texture._MSAARenderBuffer = colorRenderbuffer;
  32352. texture.samples = samples;
  32353. texture._depthStencilBuffer = depthStencilBuffer;
  32354. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32355. attachments.push(attachment);
  32356. }
  32357. gl.drawBuffers(attachments);
  32358. }
  32359. else {
  32360. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  32361. }
  32362. this.bindUnboundFramebuffer(null);
  32363. return samples;
  32364. };
  32365. /** @hidden */
  32366. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  32367. if (faceIndex === void 0) { faceIndex = 0; }
  32368. if (lod === void 0) { lod = 0; }
  32369. var gl = this._gl;
  32370. var target = gl.TEXTURE_2D;
  32371. if (texture.isCube) {
  32372. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32373. }
  32374. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  32375. };
  32376. /** @hidden */
  32377. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  32378. if (faceIndex === void 0) { faceIndex = 0; }
  32379. if (lod === void 0) { lod = 0; }
  32380. var gl = this._gl;
  32381. var textureType = this._getWebGLTextureType(texture.type);
  32382. var format = this._getInternalFormat(texture.format);
  32383. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32384. this._unpackFlipY(texture.invertY);
  32385. var target = gl.TEXTURE_2D;
  32386. if (texture.isCube) {
  32387. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32388. }
  32389. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  32390. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  32391. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  32392. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  32393. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  32394. };
  32395. /** @hidden */
  32396. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  32397. if (faceIndex === void 0) { faceIndex = 0; }
  32398. if (lod === void 0) { lod = 0; }
  32399. var gl = this._gl;
  32400. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32401. this._bindTextureDirectly(bindTarget, texture, true);
  32402. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  32403. this._bindTextureDirectly(bindTarget, null, true);
  32404. };
  32405. /** @hidden */
  32406. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  32407. if (faceIndex === void 0) { faceIndex = 0; }
  32408. if (lod === void 0) { lod = 0; }
  32409. var gl = this._gl;
  32410. var textureType = this._getWebGLTextureType(texture.type);
  32411. var format = this._getInternalFormat(texture.format);
  32412. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32413. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32414. this._bindTextureDirectly(bindTarget, texture, true);
  32415. this._unpackFlipY(texture.invertY);
  32416. var target = gl.TEXTURE_2D;
  32417. if (texture.isCube) {
  32418. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32419. }
  32420. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  32421. this._bindTextureDirectly(bindTarget, null, true);
  32422. };
  32423. /**
  32424. * Creates a new render target cube texture
  32425. * @param size defines the size of the texture
  32426. * @param options defines the options used to create the texture
  32427. * @returns a new render target cube texture stored in an InternalTexture
  32428. */
  32429. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  32430. 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);
  32431. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  32432. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32433. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32434. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32435. }
  32436. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32437. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32438. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32439. }
  32440. var gl = this._gl;
  32441. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32442. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32443. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  32444. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32445. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32446. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  32447. }
  32448. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32449. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32450. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32451. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32452. for (var face = 0; face < 6; face++) {
  32453. 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);
  32454. }
  32455. // Create the framebuffer
  32456. var framebuffer = gl.createFramebuffer();
  32457. this.bindUnboundFramebuffer(framebuffer);
  32458. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  32459. // MipMaps
  32460. if (fullOptions.generateMipMaps) {
  32461. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32462. }
  32463. // Unbind
  32464. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32465. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32466. this.bindUnboundFramebuffer(null);
  32467. texture._framebuffer = framebuffer;
  32468. texture.width = size;
  32469. texture.height = size;
  32470. texture.isReady = true;
  32471. texture.isCube = true;
  32472. texture.samples = 1;
  32473. texture.generateMipMaps = fullOptions.generateMipMaps;
  32474. texture.samplingMode = fullOptions.samplingMode;
  32475. texture.type = fullOptions.type;
  32476. texture.format = fullOptions.format;
  32477. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32478. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  32479. this._internalTexturesCache.push(texture);
  32480. return texture;
  32481. };
  32482. /**
  32483. * Creates a cube texture
  32484. * @param rootUrl defines the url where the files to load is located
  32485. * @param scene defines the current scene
  32486. * @param files defines the list of files to load (1 per face)
  32487. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  32488. * @param onLoad defines an optional callback raised when the texture is loaded
  32489. * @param onError defines an optional callback raised if there is an issue to load the texture
  32490. * @param format defines the format of the data
  32491. * @param forcedExtension defines the extension to use to pick the right loader
  32492. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  32493. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  32494. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  32495. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  32496. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  32497. * @returns the cube texture as an InternalTexture
  32498. */
  32499. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  32500. var _this = this;
  32501. if (onLoad === void 0) { onLoad = null; }
  32502. if (onError === void 0) { onError = null; }
  32503. if (forcedExtension === void 0) { forcedExtension = null; }
  32504. if (createPolynomials === void 0) { createPolynomials = false; }
  32505. if (lodScale === void 0) { lodScale = 0; }
  32506. if (lodOffset === void 0) { lodOffset = 0; }
  32507. if (fallback === void 0) { fallback = null; }
  32508. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32509. var gl = this._gl;
  32510. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  32511. texture.isCube = true;
  32512. texture.url = rootUrl;
  32513. texture.generateMipMaps = !noMipmap;
  32514. texture._lodGenerationScale = lodScale;
  32515. texture._lodGenerationOffset = lodOffset;
  32516. if (!this._doNotHandleContextLost) {
  32517. texture._extension = forcedExtension;
  32518. texture._files = files;
  32519. }
  32520. var lastDot = rootUrl.lastIndexOf('.');
  32521. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  32522. var loader = null;
  32523. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32524. var availableLoader = _a[_i];
  32525. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  32526. loader = availableLoader;
  32527. break;
  32528. }
  32529. }
  32530. var onInternalError = function (request, exception) {
  32531. if (loader) {
  32532. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  32533. _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");
  32534. if (fallbackUrl) {
  32535. excludeLoaders.push(loader);
  32536. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  32537. return;
  32538. }
  32539. }
  32540. if (onError && request) {
  32541. onError(request.status + " " + request.statusText, exception);
  32542. }
  32543. };
  32544. if (loader) {
  32545. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  32546. var onloaddata = function (data) {
  32547. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32548. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  32549. };
  32550. if (files && files.length === 6) {
  32551. if (loader.supportCascades) {
  32552. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  32553. }
  32554. else if (onError) {
  32555. onError("Textures type does not support cascades.");
  32556. }
  32557. }
  32558. else {
  32559. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32560. }
  32561. }
  32562. else {
  32563. if (!files) {
  32564. throw new Error("Cannot load cubemap because files were not defined");
  32565. }
  32566. this._cascadeLoadImgs(scene, function (imgs) {
  32567. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32568. var height = width;
  32569. _this._prepareWorkingCanvas();
  32570. if (!_this._workingCanvas || !_this._workingContext) {
  32571. return;
  32572. }
  32573. _this._workingCanvas.width = width;
  32574. _this._workingCanvas.height = height;
  32575. var faces = [
  32576. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32577. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32578. ];
  32579. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32580. _this._unpackFlipY(false);
  32581. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32582. for (var index = 0; index < faces.length; index++) {
  32583. if (imgs[index].width !== width || imgs[index].height !== height) {
  32584. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32585. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32586. }
  32587. else {
  32588. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  32589. }
  32590. }
  32591. if (!noMipmap) {
  32592. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32593. }
  32594. _this._setCubeMapTextureParams(!noMipmap);
  32595. texture.width = width;
  32596. texture.height = height;
  32597. texture.isReady = true;
  32598. if (format) {
  32599. texture.format = format;
  32600. }
  32601. texture.onLoadedObservable.notifyObservers(texture);
  32602. texture.onLoadedObservable.clear();
  32603. if (onLoad) {
  32604. onLoad();
  32605. }
  32606. }, files, onError);
  32607. }
  32608. this._internalTexturesCache.push(texture);
  32609. return texture;
  32610. };
  32611. /**
  32612. * @hidden
  32613. */
  32614. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32615. var gl = this._gl;
  32616. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32617. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32618. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32619. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32620. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32621. // this.resetTextureCache();
  32622. };
  32623. /**
  32624. * Update a raw cube texture
  32625. * @param texture defines the texture to udpdate
  32626. * @param data defines the data to store
  32627. * @param format defines the data format
  32628. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32629. * @param invertY defines if data must be stored with Y axis inverted
  32630. * @param compression defines the compression used (null by default)
  32631. * @param level defines which level of the texture to update
  32632. */
  32633. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32634. if (compression === void 0) { compression = null; }
  32635. if (level === void 0) { level = 0; }
  32636. texture._bufferViewArray = data;
  32637. texture.format = format;
  32638. texture.type = type;
  32639. texture.invertY = invertY;
  32640. texture._compression = compression;
  32641. var gl = this._gl;
  32642. var textureType = this._getWebGLTextureType(type);
  32643. var internalFormat = this._getInternalFormat(format);
  32644. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32645. var needConversion = false;
  32646. if (internalFormat === gl.RGB) {
  32647. internalFormat = gl.RGBA;
  32648. needConversion = true;
  32649. }
  32650. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32651. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32652. if (texture.width % 4 !== 0) {
  32653. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32654. }
  32655. // Data are known to be in +X +Y +Z -X -Y -Z
  32656. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32657. var faceData = data[faceIndex];
  32658. if (compression) {
  32659. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32660. }
  32661. else {
  32662. if (needConversion) {
  32663. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32664. }
  32665. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32666. }
  32667. }
  32668. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32669. if (isPot && texture.generateMipMaps && level === 0) {
  32670. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32671. }
  32672. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32673. // this.resetTextureCache();
  32674. texture.isReady = true;
  32675. };
  32676. /**
  32677. * Creates a new raw cube texture
  32678. * @param data defines the array of data to use to create each face
  32679. * @param size defines the size of the textures
  32680. * @param format defines the format of the data
  32681. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32682. * @param generateMipMaps defines if the engine should generate the mip levels
  32683. * @param invertY defines if data must be stored with Y axis inverted
  32684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32685. * @param compression defines the compression used (null by default)
  32686. * @returns the cube texture as an InternalTexture
  32687. */
  32688. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32689. if (compression === void 0) { compression = null; }
  32690. var gl = this._gl;
  32691. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32692. texture.isCube = true;
  32693. texture.format = format;
  32694. texture.type = type;
  32695. if (!this._doNotHandleContextLost) {
  32696. texture._bufferViewArray = data;
  32697. }
  32698. var textureType = this._getWebGLTextureType(type);
  32699. var internalFormat = this._getInternalFormat(format);
  32700. if (internalFormat === gl.RGB) {
  32701. internalFormat = gl.RGBA;
  32702. }
  32703. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32704. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32705. generateMipMaps = false;
  32706. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32707. _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.");
  32708. }
  32709. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32710. generateMipMaps = false;
  32711. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32712. _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.");
  32713. }
  32714. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32715. generateMipMaps = false;
  32716. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32717. }
  32718. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32719. generateMipMaps = false;
  32720. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32721. }
  32722. var width = size;
  32723. var height = width;
  32724. texture.width = width;
  32725. texture.height = height;
  32726. // Double check on POT to generate Mips.
  32727. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32728. if (!isPot) {
  32729. generateMipMaps = false;
  32730. }
  32731. // Upload data if needed. The texture won't be ready until then.
  32732. if (data) {
  32733. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32734. }
  32735. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32736. // Filters
  32737. if (data && generateMipMaps) {
  32738. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32739. }
  32740. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32741. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32742. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32743. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32744. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32745. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32746. texture.generateMipMaps = generateMipMaps;
  32747. return texture;
  32748. };
  32749. /**
  32750. * Creates a new raw cube texture from a specified url
  32751. * @param url defines the url where the data is located
  32752. * @param scene defines the current scene
  32753. * @param size defines the size of the textures
  32754. * @param format defines the format of the data
  32755. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32756. * @param noMipmap defines if the engine should avoid generating the mip levels
  32757. * @param callback defines a callback used to extract texture data from loaded data
  32758. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32759. * @param onLoad defines a callback called when texture is loaded
  32760. * @param onError defines a callback called if there is an error
  32761. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32762. * @param invertY defines if data must be stored with Y axis inverted
  32763. * @returns the cube texture as an InternalTexture
  32764. */
  32765. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32766. var _this = this;
  32767. if (onLoad === void 0) { onLoad = null; }
  32768. if (onError === void 0) { onError = null; }
  32769. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32770. if (invertY === void 0) { invertY = false; }
  32771. var gl = this._gl;
  32772. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32773. scene._addPendingData(texture);
  32774. texture.url = url;
  32775. this._internalTexturesCache.push(texture);
  32776. var onerror = function (request, exception) {
  32777. scene._removePendingData(texture);
  32778. if (onError && request) {
  32779. onError(request.status + " " + request.statusText, exception);
  32780. }
  32781. };
  32782. var internalCallback = function (data) {
  32783. var width = texture.width;
  32784. var faceDataArrays = callback(data);
  32785. if (!faceDataArrays) {
  32786. return;
  32787. }
  32788. if (mipmapGenerator) {
  32789. var textureType = _this._getWebGLTextureType(type);
  32790. var internalFormat = _this._getInternalFormat(format);
  32791. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32792. var needConversion = false;
  32793. if (internalFormat === gl.RGB) {
  32794. internalFormat = gl.RGBA;
  32795. needConversion = true;
  32796. }
  32797. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32798. _this._unpackFlipY(false);
  32799. var mipData = mipmapGenerator(faceDataArrays);
  32800. for (var level = 0; level < mipData.length; level++) {
  32801. var mipSize = width >> level;
  32802. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32803. var mipFaceData = mipData[level][faceIndex];
  32804. if (needConversion) {
  32805. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32806. }
  32807. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32808. }
  32809. }
  32810. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32811. }
  32812. else {
  32813. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32814. }
  32815. texture.isReady = true;
  32816. // this.resetTextureCache();
  32817. scene._removePendingData(texture);
  32818. if (onLoad) {
  32819. onLoad();
  32820. }
  32821. };
  32822. this._loadFile(url, function (data) {
  32823. internalCallback(data);
  32824. }, undefined, scene.offlineProvider, true, onerror);
  32825. return texture;
  32826. };
  32827. /**
  32828. * Update a raw 3D texture
  32829. * @param texture defines the texture to update
  32830. * @param data defines the data to store
  32831. * @param format defines the data format
  32832. * @param invertY defines if data must be stored with Y axis inverted
  32833. * @param compression defines the used compression (can be null)
  32834. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32835. */
  32836. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32837. if (compression === void 0) { compression = null; }
  32838. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32839. var internalType = this._getWebGLTextureType(textureType);
  32840. var internalFormat = this._getInternalFormat(format);
  32841. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32842. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32843. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32844. if (!this._doNotHandleContextLost) {
  32845. texture._bufferView = data;
  32846. texture.format = format;
  32847. texture.invertY = invertY;
  32848. texture._compression = compression;
  32849. }
  32850. if (texture.width % 4 !== 0) {
  32851. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32852. }
  32853. if (compression && data) {
  32854. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32855. }
  32856. else {
  32857. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32858. }
  32859. if (texture.generateMipMaps) {
  32860. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32861. }
  32862. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32863. // this.resetTextureCache();
  32864. texture.isReady = true;
  32865. };
  32866. /**
  32867. * Creates a new raw 3D texture
  32868. * @param data defines the data used to create the texture
  32869. * @param width defines the width of the texture
  32870. * @param height defines the height of the texture
  32871. * @param depth defines the depth of the texture
  32872. * @param format defines the format of the texture
  32873. * @param generateMipMaps defines if the engine must generate mip levels
  32874. * @param invertY defines if data must be stored with Y axis inverted
  32875. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32876. * @param compression defines the compressed used (can be null)
  32877. * @param textureType defines the compressed used (can be null)
  32878. * @returns a new raw 3D texture (stored in an InternalTexture)
  32879. */
  32880. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32881. if (compression === void 0) { compression = null; }
  32882. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32883. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32884. texture.baseWidth = width;
  32885. texture.baseHeight = height;
  32886. texture.baseDepth = depth;
  32887. texture.width = width;
  32888. texture.height = height;
  32889. texture.depth = depth;
  32890. texture.format = format;
  32891. texture.type = textureType;
  32892. texture.generateMipMaps = generateMipMaps;
  32893. texture.samplingMode = samplingMode;
  32894. texture.is3D = true;
  32895. if (!this._doNotHandleContextLost) {
  32896. texture._bufferView = data;
  32897. }
  32898. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32899. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32900. // Filters
  32901. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32902. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32903. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32904. if (generateMipMaps) {
  32905. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32906. }
  32907. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32908. this._internalTexturesCache.push(texture);
  32909. return texture;
  32910. };
  32911. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32912. var gl = this._gl;
  32913. if (!gl) {
  32914. return;
  32915. }
  32916. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32917. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32918. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32919. if (!noMipmap && !isCompressed) {
  32920. gl.generateMipmap(gl.TEXTURE_2D);
  32921. }
  32922. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32923. // this.resetTextureCache();
  32924. if (scene) {
  32925. scene._removePendingData(texture);
  32926. }
  32927. texture.onLoadedObservable.notifyObservers(texture);
  32928. texture.onLoadedObservable.clear();
  32929. };
  32930. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32931. var _this = this;
  32932. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32933. var maxTextureSize = this.getCaps().maxTextureSize;
  32934. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32935. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32936. var gl = this._gl;
  32937. if (!gl) {
  32938. return;
  32939. }
  32940. if (!texture._webGLTexture) {
  32941. // this.resetTextureCache();
  32942. if (scene) {
  32943. scene._removePendingData(texture);
  32944. }
  32945. return;
  32946. }
  32947. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32948. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32949. texture.baseWidth = width;
  32950. texture.baseHeight = height;
  32951. texture.width = potWidth;
  32952. texture.height = potHeight;
  32953. texture.isReady = true;
  32954. if (processFunction(potWidth, potHeight, function () {
  32955. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32956. })) {
  32957. // Returning as texture needs extra async steps
  32958. return;
  32959. }
  32960. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32961. };
  32962. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32963. // Create new RGBA data container.
  32964. var rgbaData;
  32965. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32966. rgbaData = new Float32Array(width * height * 4);
  32967. }
  32968. else {
  32969. rgbaData = new Uint32Array(width * height * 4);
  32970. }
  32971. // Convert each pixel.
  32972. for (var x = 0; x < width; x++) {
  32973. for (var y = 0; y < height; y++) {
  32974. var index = (y * width + x) * 3;
  32975. var newIndex = (y * width + x) * 4;
  32976. // Map Old Value to new value.
  32977. rgbaData[newIndex + 0] = rgbData[index + 0];
  32978. rgbaData[newIndex + 1] = rgbData[index + 1];
  32979. rgbaData[newIndex + 2] = rgbData[index + 2];
  32980. // Add fully opaque alpha channel.
  32981. rgbaData[newIndex + 3] = 1;
  32982. }
  32983. }
  32984. return rgbaData;
  32985. };
  32986. /** @hidden */
  32987. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32988. var gl = this._gl;
  32989. if (texture._framebuffer) {
  32990. gl.deleteFramebuffer(texture._framebuffer);
  32991. texture._framebuffer = null;
  32992. }
  32993. if (texture._depthStencilBuffer) {
  32994. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32995. texture._depthStencilBuffer = null;
  32996. }
  32997. if (texture._MSAAFramebuffer) {
  32998. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32999. texture._MSAAFramebuffer = null;
  33000. }
  33001. if (texture._MSAARenderBuffer) {
  33002. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  33003. texture._MSAARenderBuffer = null;
  33004. }
  33005. };
  33006. /** @hidden */
  33007. Engine.prototype._releaseTexture = function (texture) {
  33008. var gl = this._gl;
  33009. this._releaseFramebufferObjects(texture);
  33010. gl.deleteTexture(texture._webGLTexture);
  33011. // Unbind channels
  33012. this.unbindAllTextures();
  33013. var index = this._internalTexturesCache.indexOf(texture);
  33014. if (index !== -1) {
  33015. this._internalTexturesCache.splice(index, 1);
  33016. }
  33017. // Integrated fixed lod samplers.
  33018. if (texture._lodTextureHigh) {
  33019. texture._lodTextureHigh.dispose();
  33020. }
  33021. if (texture._lodTextureMid) {
  33022. texture._lodTextureMid.dispose();
  33023. }
  33024. if (texture._lodTextureLow) {
  33025. texture._lodTextureLow.dispose();
  33026. }
  33027. // Set output texture of post process to null if the texture has been released/disposed
  33028. this.scenes.forEach(function (scene) {
  33029. scene.postProcesses.forEach(function (postProcess) {
  33030. if (postProcess._outputTexture == texture) {
  33031. postProcess._outputTexture = null;
  33032. }
  33033. });
  33034. scene.cameras.forEach(function (camera) {
  33035. camera._postProcesses.forEach(function (postProcess) {
  33036. if (postProcess) {
  33037. if (postProcess._outputTexture == texture) {
  33038. postProcess._outputTexture = null;
  33039. }
  33040. }
  33041. });
  33042. });
  33043. });
  33044. };
  33045. Engine.prototype.setProgram = function (program) {
  33046. if (this._currentProgram !== program) {
  33047. this._gl.useProgram(program);
  33048. this._currentProgram = program;
  33049. }
  33050. };
  33051. /**
  33052. * Binds an effect to the webGL context
  33053. * @param effect defines the effect to bind
  33054. */
  33055. Engine.prototype.bindSamplers = function (effect) {
  33056. this.setProgram(effect.getProgram());
  33057. var samplers = effect.getSamplers();
  33058. for (var index = 0; index < samplers.length; index++) {
  33059. var uniform = effect.getUniform(samplers[index]);
  33060. if (uniform) {
  33061. this._boundUniforms[index] = uniform;
  33062. }
  33063. }
  33064. this._currentEffect = null;
  33065. };
  33066. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  33067. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  33068. return;
  33069. }
  33070. // Remove
  33071. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33072. // Bind last to it
  33073. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  33074. // Bind to dummy
  33075. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  33076. };
  33077. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  33078. if (!internalTexture) {
  33079. return -1;
  33080. }
  33081. internalTexture._initialSlot = channel;
  33082. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  33083. if (channel !== internalTexture._designatedSlot) {
  33084. this._textureCollisions.addCount(1, false);
  33085. }
  33086. }
  33087. else {
  33088. if (channel !== internalTexture._designatedSlot) {
  33089. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  33090. return internalTexture._designatedSlot;
  33091. }
  33092. else {
  33093. // No slot for this texture, let's pick a new one (if we find a free slot)
  33094. if (this._nextFreeTextureSlots.length) {
  33095. return this._nextFreeTextureSlots[0];
  33096. }
  33097. // We need to recycle the oldest bound texture, sorry.
  33098. this._textureCollisions.addCount(1, false);
  33099. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  33100. }
  33101. }
  33102. }
  33103. return channel;
  33104. };
  33105. Engine.prototype._linkTrackers = function (previous, next) {
  33106. previous.next = next;
  33107. next.previous = previous;
  33108. };
  33109. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  33110. var currentSlot = internalTexture._designatedSlot;
  33111. if (currentSlot === -1) {
  33112. return -1;
  33113. }
  33114. internalTexture._designatedSlot = -1;
  33115. if (this.disableTextureBindingOptimization) {
  33116. return -1;
  33117. }
  33118. // Remove from bound list
  33119. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33120. // Free the slot
  33121. this._boundTexturesCache[currentSlot] = null;
  33122. this._nextFreeTextureSlots.push(currentSlot);
  33123. return currentSlot;
  33124. };
  33125. Engine.prototype._activateCurrentTexture = function () {
  33126. if (this._currentTextureChannel !== this._activeChannel) {
  33127. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33128. this._currentTextureChannel = this._activeChannel;
  33129. }
  33130. };
  33131. /** @hidden */
  33132. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33133. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33134. if (force === void 0) { force = false; }
  33135. var wasPreviouslyBound = false;
  33136. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  33137. this._activeChannel = texture._designatedSlot;
  33138. }
  33139. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33140. var isTextureForRendering = texture && texture._initialSlot > -1;
  33141. if (currentTextureBound !== texture || force) {
  33142. if (currentTextureBound) {
  33143. this._removeDesignatedSlot(currentTextureBound);
  33144. }
  33145. this._activateCurrentTexture();
  33146. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33147. this._boundTexturesCache[this._activeChannel] = texture;
  33148. if (texture) {
  33149. if (!this.disableTextureBindingOptimization) {
  33150. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  33151. if (slotIndex > -1) {
  33152. this._nextFreeTextureSlots.splice(slotIndex, 1);
  33153. }
  33154. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  33155. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  33156. }
  33157. texture._designatedSlot = this._activeChannel;
  33158. }
  33159. }
  33160. else if (forTextureDataUpdate) {
  33161. wasPreviouslyBound = true;
  33162. this._activateCurrentTexture();
  33163. }
  33164. if (isTextureForRendering && !forTextureDataUpdate) {
  33165. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  33166. }
  33167. return wasPreviouslyBound;
  33168. };
  33169. /** @hidden */
  33170. Engine.prototype._bindTexture = function (channel, texture) {
  33171. if (channel < 0) {
  33172. return;
  33173. }
  33174. if (texture) {
  33175. channel = this._getCorrectTextureChannel(channel, texture);
  33176. }
  33177. this._activeChannel = channel;
  33178. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33179. };
  33180. /**
  33181. * Sets a texture to the webGL context from a postprocess
  33182. * @param channel defines the channel to use
  33183. * @param postProcess defines the source postprocess
  33184. */
  33185. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33186. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33187. };
  33188. /**
  33189. * Binds the output of the passed in post process to the texture channel specified
  33190. * @param channel The channel the texture should be bound to
  33191. * @param postProcess The post process which's output should be bound
  33192. */
  33193. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33194. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33195. };
  33196. /**
  33197. * Unbind all textures from the webGL context
  33198. */
  33199. Engine.prototype.unbindAllTextures = function () {
  33200. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33201. this._activeChannel = channel;
  33202. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33203. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33204. if (this.webGLVersion > 1) {
  33205. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33206. }
  33207. }
  33208. };
  33209. /**
  33210. * Sets a texture to the according uniform.
  33211. * @param channel The texture channel
  33212. * @param uniform The uniform to set
  33213. * @param texture The texture to apply
  33214. */
  33215. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33216. if (channel < 0) {
  33217. return;
  33218. }
  33219. if (uniform) {
  33220. this._boundUniforms[channel] = uniform;
  33221. }
  33222. this._setTexture(channel, texture);
  33223. };
  33224. /**
  33225. * Sets a depth stencil texture from a render target to the according uniform.
  33226. * @param channel The texture channel
  33227. * @param uniform The uniform to set
  33228. * @param texture The render target texture containing the depth stencil texture to apply
  33229. */
  33230. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33231. if (channel < 0) {
  33232. return;
  33233. }
  33234. if (uniform) {
  33235. this._boundUniforms[channel] = uniform;
  33236. }
  33237. if (!texture || !texture.depthStencilTexture) {
  33238. this._setTexture(channel, null);
  33239. }
  33240. else {
  33241. this._setTexture(channel, texture, false, true);
  33242. }
  33243. };
  33244. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33245. var uniform = this._boundUniforms[sourceSlot];
  33246. if (uniform._currentState === destination) {
  33247. return;
  33248. }
  33249. this._gl.uniform1i(uniform, destination);
  33250. uniform._currentState = destination;
  33251. };
  33252. Engine.prototype._getTextureWrapMode = function (mode) {
  33253. switch (mode) {
  33254. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33255. return this._gl.REPEAT;
  33256. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33257. return this._gl.CLAMP_TO_EDGE;
  33258. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33259. return this._gl.MIRRORED_REPEAT;
  33260. }
  33261. return this._gl.REPEAT;
  33262. };
  33263. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33264. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33265. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33266. // Not ready?
  33267. if (!texture) {
  33268. if (this._boundTexturesCache[channel] != null) {
  33269. this._activeChannel = channel;
  33270. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33271. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33272. if (this.webGLVersion > 1) {
  33273. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33274. }
  33275. }
  33276. return false;
  33277. }
  33278. // Video
  33279. if (texture.video) {
  33280. this._activeChannel = channel;
  33281. texture.update();
  33282. }
  33283. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33284. texture.delayLoad();
  33285. return false;
  33286. }
  33287. var internalTexture;
  33288. if (depthStencilTexture) {
  33289. internalTexture = texture.depthStencilTexture;
  33290. }
  33291. else if (texture.isReady()) {
  33292. internalTexture = texture.getInternalTexture();
  33293. }
  33294. else if (texture.isCube) {
  33295. internalTexture = this.emptyCubeTexture;
  33296. }
  33297. else if (texture.is3D) {
  33298. internalTexture = this.emptyTexture3D;
  33299. }
  33300. else {
  33301. internalTexture = this.emptyTexture;
  33302. }
  33303. if (!isPartOfTextureArray) {
  33304. channel = this._getCorrectTextureChannel(channel, internalTexture);
  33305. }
  33306. var needToBind = true;
  33307. if (this._boundTexturesCache[channel] === internalTexture) {
  33308. this._moveBoundTextureOnTop(internalTexture);
  33309. if (!isPartOfTextureArray) {
  33310. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  33311. }
  33312. needToBind = false;
  33313. }
  33314. this._activeChannel = channel;
  33315. if (internalTexture && internalTexture.is3D) {
  33316. if (needToBind) {
  33317. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33318. }
  33319. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33320. internalTexture._cachedWrapU = texture.wrapU;
  33321. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33322. }
  33323. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33324. internalTexture._cachedWrapV = texture.wrapV;
  33325. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33326. }
  33327. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33328. internalTexture._cachedWrapR = texture.wrapR;
  33329. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33330. }
  33331. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33332. }
  33333. else if (internalTexture && internalTexture.isCube) {
  33334. if (needToBind) {
  33335. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33336. }
  33337. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33338. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33339. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33340. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33341. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33342. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33343. }
  33344. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33345. }
  33346. else {
  33347. if (needToBind) {
  33348. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33349. }
  33350. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33351. internalTexture._cachedWrapU = texture.wrapU;
  33352. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33353. }
  33354. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33355. internalTexture._cachedWrapV = texture.wrapV;
  33356. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33357. }
  33358. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33359. }
  33360. return true;
  33361. };
  33362. /**
  33363. * Sets an array of texture to the webGL context
  33364. * @param channel defines the channel where the texture array must be set
  33365. * @param uniform defines the associated uniform location
  33366. * @param textures defines the array of textures to bind
  33367. */
  33368. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33369. if (channel < 0 || !uniform) {
  33370. return;
  33371. }
  33372. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33373. this._textureUnits = new Int32Array(textures.length);
  33374. }
  33375. for (var i = 0; i < textures.length; i++) {
  33376. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  33377. }
  33378. this._gl.uniform1iv(uniform, this._textureUnits);
  33379. for (var index = 0; index < textures.length; index++) {
  33380. this._setTexture(this._textureUnits[index], textures[index], true);
  33381. }
  33382. };
  33383. /** @hidden */
  33384. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33385. var internalTexture = texture.getInternalTexture();
  33386. if (!internalTexture) {
  33387. return;
  33388. }
  33389. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33390. var value = texture.anisotropicFilteringLevel;
  33391. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33392. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33393. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33394. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33395. }
  33396. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33397. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33398. internalTexture._cachedAnisotropicFilteringLevel = value;
  33399. }
  33400. };
  33401. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33402. this._bindTextureDirectly(target, texture, true, true);
  33403. this._gl.texParameterf(target, parameter, value);
  33404. };
  33405. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33406. if (texture) {
  33407. this._bindTextureDirectly(target, texture, true, true);
  33408. }
  33409. this._gl.texParameteri(target, parameter, value);
  33410. };
  33411. /**
  33412. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33413. * @param x defines the x coordinate of the rectangle where pixels must be read
  33414. * @param y defines the y coordinate of the rectangle where pixels must be read
  33415. * @param width defines the width of the rectangle where pixels must be read
  33416. * @param height defines the height of the rectangle where pixels must be read
  33417. * @returns a Uint8Array containing RGBA colors
  33418. */
  33419. Engine.prototype.readPixels = function (x, y, width, height) {
  33420. var data = new Uint8Array(height * width * 4);
  33421. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33422. return data;
  33423. };
  33424. /**
  33425. * Add an externaly attached data from its key.
  33426. * This method call will fail and return false, if such key already exists.
  33427. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33428. * @param key the unique key that identifies the data
  33429. * @param data the data object to associate to the key for this Engine instance
  33430. * @return true if no such key were already present and the data was added successfully, false otherwise
  33431. */
  33432. Engine.prototype.addExternalData = function (key, data) {
  33433. if (!this._externalData) {
  33434. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33435. }
  33436. return this._externalData.add(key, data);
  33437. };
  33438. /**
  33439. * Get an externaly attached data from its key
  33440. * @param key the unique key that identifies the data
  33441. * @return the associated data, if present (can be null), or undefined if not present
  33442. */
  33443. Engine.prototype.getExternalData = function (key) {
  33444. if (!this._externalData) {
  33445. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33446. }
  33447. return this._externalData.get(key);
  33448. };
  33449. /**
  33450. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33451. * @param key the unique key that identifies the data
  33452. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33453. * @return the associated data, can be null if the factory returned null.
  33454. */
  33455. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  33456. if (!this._externalData) {
  33457. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33458. }
  33459. return this._externalData.getOrAddWithFactory(key, factory);
  33460. };
  33461. /**
  33462. * Remove an externaly attached data from the Engine instance
  33463. * @param key the unique key that identifies the data
  33464. * @return true if the data was successfully removed, false if it doesn't exist
  33465. */
  33466. Engine.prototype.removeExternalData = function (key) {
  33467. if (!this._externalData) {
  33468. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33469. }
  33470. return this._externalData.remove(key);
  33471. };
  33472. /**
  33473. * Unbind all vertex attributes from the webGL context
  33474. */
  33475. Engine.prototype.unbindAllAttributes = function () {
  33476. if (this._mustWipeVertexAttributes) {
  33477. this._mustWipeVertexAttributes = false;
  33478. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  33479. this._gl.disableVertexAttribArray(i);
  33480. this._vertexAttribArraysEnabled[i] = false;
  33481. this._currentBufferPointers[i].active = false;
  33482. }
  33483. return;
  33484. }
  33485. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  33486. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  33487. continue;
  33488. }
  33489. this._gl.disableVertexAttribArray(i);
  33490. this._vertexAttribArraysEnabled[i] = false;
  33491. this._currentBufferPointers[i].active = false;
  33492. }
  33493. };
  33494. /**
  33495. * 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
  33496. */
  33497. Engine.prototype.releaseEffects = function () {
  33498. for (var name in this._compiledEffects) {
  33499. this._deleteProgram(this._compiledEffects[name]._program);
  33500. }
  33501. this._compiledEffects = {};
  33502. };
  33503. /**
  33504. * Dispose and release all associated resources
  33505. */
  33506. Engine.prototype.dispose = function () {
  33507. this.hideLoadingUI();
  33508. this.stopRenderLoop();
  33509. this.onNewSceneAddedObservable.clear();
  33510. // Release postProcesses
  33511. while (this.postProcesses.length) {
  33512. this.postProcesses[0].dispose();
  33513. }
  33514. // Empty texture
  33515. if (this._emptyTexture) {
  33516. this._releaseTexture(this._emptyTexture);
  33517. this._emptyTexture = null;
  33518. }
  33519. if (this._emptyCubeTexture) {
  33520. this._releaseTexture(this._emptyCubeTexture);
  33521. this._emptyCubeTexture = null;
  33522. }
  33523. // Rescale PP
  33524. if (this._rescalePostProcess) {
  33525. this._rescalePostProcess.dispose();
  33526. }
  33527. // Release scenes
  33528. while (this.scenes.length) {
  33529. this.scenes[0].dispose();
  33530. }
  33531. // Release audio engine
  33532. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  33533. Engine.audioEngine.dispose();
  33534. }
  33535. // Release effects
  33536. this.releaseEffects();
  33537. // Unbind
  33538. this.unbindAllAttributes();
  33539. this._boundUniforms = [];
  33540. if (this._dummyFramebuffer) {
  33541. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  33542. }
  33543. //WebVR
  33544. this.disableVR();
  33545. // Events
  33546. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33547. window.removeEventListener("blur", this._onBlur);
  33548. window.removeEventListener("focus", this._onFocus);
  33549. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  33550. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  33551. if (this._renderingCanvas) {
  33552. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  33553. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  33554. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  33555. if (!this._doNotHandleContextLost) {
  33556. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  33557. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  33558. }
  33559. }
  33560. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33561. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33562. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33563. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33564. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33565. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33566. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33567. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33568. if (this._onVrDisplayConnect) {
  33569. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33570. if (this._onVrDisplayDisconnect) {
  33571. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33572. }
  33573. if (this._onVrDisplayPresentChange) {
  33574. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33575. }
  33576. this._onVrDisplayConnect = null;
  33577. this._onVrDisplayDisconnect = null;
  33578. }
  33579. }
  33580. // Remove from Instances
  33581. var index = Engine.Instances.indexOf(this);
  33582. if (index >= 0) {
  33583. Engine.Instances.splice(index, 1);
  33584. }
  33585. this._workingCanvas = null;
  33586. this._workingContext = null;
  33587. this._currentBufferPointers = [];
  33588. this._renderingCanvas = null;
  33589. this._currentProgram = null;
  33590. this._bindedRenderFunction = null;
  33591. this.onResizeObservable.clear();
  33592. this.onCanvasBlurObservable.clear();
  33593. this.onCanvasFocusObservable.clear();
  33594. this.onCanvasPointerOutObservable.clear();
  33595. this.onBeginFrameObservable.clear();
  33596. this.onEndFrameObservable.clear();
  33597. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33598. // Abort active requests
  33599. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33600. var request = _a[_i];
  33601. request.abort();
  33602. }
  33603. };
  33604. // Loading screen
  33605. /**
  33606. * Display the loading screen
  33607. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33608. */
  33609. Engine.prototype.displayLoadingUI = function () {
  33610. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33611. return;
  33612. }
  33613. var loadingScreen = this.loadingScreen;
  33614. if (loadingScreen) {
  33615. loadingScreen.displayLoadingUI();
  33616. }
  33617. };
  33618. /**
  33619. * Hide the loading screen
  33620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33621. */
  33622. Engine.prototype.hideLoadingUI = function () {
  33623. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33624. return;
  33625. }
  33626. var loadingScreen = this.loadingScreen;
  33627. if (loadingScreen) {
  33628. loadingScreen.hideLoadingUI();
  33629. }
  33630. };
  33631. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33632. /**
  33633. * Gets the current loading screen object
  33634. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33635. */
  33636. get: function () {
  33637. if (!this._loadingScreen && this._renderingCanvas) {
  33638. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33639. }
  33640. return this._loadingScreen;
  33641. },
  33642. /**
  33643. * Sets the current loading screen object
  33644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33645. */
  33646. set: function (loadingScreen) {
  33647. this._loadingScreen = loadingScreen;
  33648. },
  33649. enumerable: true,
  33650. configurable: true
  33651. });
  33652. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33653. /**
  33654. * Sets the current loading screen text
  33655. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33656. */
  33657. set: function (text) {
  33658. this.loadingScreen.loadingUIText = text;
  33659. },
  33660. enumerable: true,
  33661. configurable: true
  33662. });
  33663. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33664. /**
  33665. * Sets the current loading screen background color
  33666. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33667. */
  33668. set: function (color) {
  33669. this.loadingScreen.loadingUIBackgroundColor = color;
  33670. },
  33671. enumerable: true,
  33672. configurable: true
  33673. });
  33674. /**
  33675. * Attach a new callback raised when context lost event is fired
  33676. * @param callback defines the callback to call
  33677. */
  33678. Engine.prototype.attachContextLostEvent = function (callback) {
  33679. if (this._renderingCanvas) {
  33680. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33681. }
  33682. };
  33683. /**
  33684. * Attach a new callback raised when context restored event is fired
  33685. * @param callback defines the callback to call
  33686. */
  33687. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33688. if (this._renderingCanvas) {
  33689. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33690. }
  33691. };
  33692. /**
  33693. * Gets the source code of the vertex shader associated with a specific webGL program
  33694. * @param program defines the program to use
  33695. * @returns a string containing the source code of the vertex shader associated with the program
  33696. */
  33697. Engine.prototype.getVertexShaderSource = function (program) {
  33698. var shaders = this._gl.getAttachedShaders(program);
  33699. if (!shaders) {
  33700. return null;
  33701. }
  33702. return this._gl.getShaderSource(shaders[0]);
  33703. };
  33704. /**
  33705. * Gets the source code of the fragment shader associated with a specific webGL program
  33706. * @param program defines the program to use
  33707. * @returns a string containing the source code of the fragment shader associated with the program
  33708. */
  33709. Engine.prototype.getFragmentShaderSource = function (program) {
  33710. var shaders = this._gl.getAttachedShaders(program);
  33711. if (!shaders) {
  33712. return null;
  33713. }
  33714. return this._gl.getShaderSource(shaders[1]);
  33715. };
  33716. /**
  33717. * Get the current error code of the webGL context
  33718. * @returns the error code
  33719. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33720. */
  33721. Engine.prototype.getError = function () {
  33722. return this._gl.getError();
  33723. };
  33724. // FPS
  33725. /**
  33726. * Gets the current framerate
  33727. * @returns a number representing the framerate
  33728. */
  33729. Engine.prototype.getFps = function () {
  33730. return this._fps;
  33731. };
  33732. /**
  33733. * Gets the time spent between current and previous frame
  33734. * @returns a number representing the delta time in ms
  33735. */
  33736. Engine.prototype.getDeltaTime = function () {
  33737. return this._deltaTime;
  33738. };
  33739. Engine.prototype._measureFps = function () {
  33740. this._performanceMonitor.sampleFrame();
  33741. this._fps = this._performanceMonitor.averageFPS;
  33742. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33743. };
  33744. /** @hidden */
  33745. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33746. if (faceIndex === void 0) { faceIndex = -1; }
  33747. if (level === void 0) { level = 0; }
  33748. if (buffer === void 0) { buffer = null; }
  33749. var gl = this._gl;
  33750. if (!this._dummyFramebuffer) {
  33751. var dummy = gl.createFramebuffer();
  33752. if (!dummy) {
  33753. throw new Error("Unable to create dummy framebuffer");
  33754. }
  33755. this._dummyFramebuffer = dummy;
  33756. }
  33757. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33758. if (faceIndex > -1) {
  33759. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33760. }
  33761. else {
  33762. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33763. }
  33764. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33765. switch (readType) {
  33766. case gl.UNSIGNED_BYTE:
  33767. if (!buffer) {
  33768. buffer = new Uint8Array(4 * width * height);
  33769. }
  33770. readType = gl.UNSIGNED_BYTE;
  33771. break;
  33772. default:
  33773. if (!buffer) {
  33774. buffer = new Float32Array(4 * width * height);
  33775. }
  33776. readType = gl.FLOAT;
  33777. break;
  33778. }
  33779. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33780. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33781. return buffer;
  33782. };
  33783. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33784. if (this._webGLVersion > 1) {
  33785. return this._caps.colorBufferFloat;
  33786. }
  33787. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33788. };
  33789. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33790. if (this._webGLVersion > 1) {
  33791. return this._caps.colorBufferFloat;
  33792. }
  33793. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33794. };
  33795. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33796. Engine.prototype._canRenderToFramebuffer = function (type) {
  33797. var gl = this._gl;
  33798. //clear existing errors
  33799. while (gl.getError() !== gl.NO_ERROR) { }
  33800. var successful = true;
  33801. var texture = gl.createTexture();
  33802. gl.bindTexture(gl.TEXTURE_2D, texture);
  33803. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33804. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33805. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33806. var fb = gl.createFramebuffer();
  33807. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33808. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33809. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33810. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33811. successful = successful && (gl.getError() === gl.NO_ERROR);
  33812. //try render by clearing frame buffer's color buffer
  33813. if (successful) {
  33814. gl.clear(gl.COLOR_BUFFER_BIT);
  33815. successful = successful && (gl.getError() === gl.NO_ERROR);
  33816. }
  33817. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33818. if (successful) {
  33819. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33820. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33821. var readFormat = gl.RGBA;
  33822. var readType = gl.UNSIGNED_BYTE;
  33823. var buffer = new Uint8Array(4);
  33824. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33825. successful = successful && (gl.getError() === gl.NO_ERROR);
  33826. }
  33827. //clean up
  33828. gl.deleteTexture(texture);
  33829. gl.deleteFramebuffer(fb);
  33830. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33831. //clear accumulated errors
  33832. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33833. return successful;
  33834. };
  33835. /** @hidden */
  33836. Engine.prototype._getWebGLTextureType = function (type) {
  33837. if (this._webGLVersion === 1) {
  33838. switch (type) {
  33839. case Engine.TEXTURETYPE_FLOAT:
  33840. return this._gl.FLOAT;
  33841. case Engine.TEXTURETYPE_HALF_FLOAT:
  33842. return this._gl.HALF_FLOAT_OES;
  33843. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33844. return this._gl.UNSIGNED_BYTE;
  33845. }
  33846. return this._gl.UNSIGNED_BYTE;
  33847. }
  33848. switch (type) {
  33849. case Engine.TEXTURETYPE_BYTE:
  33850. return this._gl.BYTE;
  33851. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33852. return this._gl.UNSIGNED_BYTE;
  33853. case Engine.TEXTURETYPE_SHORT:
  33854. return this._gl.SHORT;
  33855. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33856. return this._gl.UNSIGNED_SHORT;
  33857. case Engine.TEXTURETYPE_INT:
  33858. return this._gl.INT;
  33859. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33860. return this._gl.UNSIGNED_INT;
  33861. case Engine.TEXTURETYPE_FLOAT:
  33862. return this._gl.FLOAT;
  33863. case Engine.TEXTURETYPE_HALF_FLOAT:
  33864. return this._gl.HALF_FLOAT;
  33865. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33866. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33867. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33868. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33869. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33870. return this._gl.UNSIGNED_SHORT_5_6_5;
  33871. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33872. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33873. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33874. return this._gl.UNSIGNED_INT_24_8;
  33875. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33876. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33877. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33878. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33879. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33880. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33881. }
  33882. return this._gl.UNSIGNED_BYTE;
  33883. };
  33884. Engine.prototype._getInternalFormat = function (format) {
  33885. var internalFormat = this._gl.RGBA;
  33886. switch (format) {
  33887. case Engine.TEXTUREFORMAT_ALPHA:
  33888. internalFormat = this._gl.ALPHA;
  33889. break;
  33890. case Engine.TEXTUREFORMAT_LUMINANCE:
  33891. internalFormat = this._gl.LUMINANCE;
  33892. break;
  33893. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33894. internalFormat = this._gl.LUMINANCE_ALPHA;
  33895. break;
  33896. case Engine.TEXTUREFORMAT_RED:
  33897. internalFormat = this._gl.RED;
  33898. break;
  33899. case Engine.TEXTUREFORMAT_RG:
  33900. internalFormat = this._gl.RG;
  33901. break;
  33902. case Engine.TEXTUREFORMAT_RGB:
  33903. internalFormat = this._gl.RGB;
  33904. break;
  33905. case Engine.TEXTUREFORMAT_RGBA:
  33906. internalFormat = this._gl.RGBA;
  33907. break;
  33908. }
  33909. if (this._webGLVersion > 1) {
  33910. switch (format) {
  33911. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33912. internalFormat = this._gl.RED_INTEGER;
  33913. break;
  33914. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33915. internalFormat = this._gl.RG_INTEGER;
  33916. break;
  33917. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33918. internalFormat = this._gl.RGB_INTEGER;
  33919. break;
  33920. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33921. internalFormat = this._gl.RGBA_INTEGER;
  33922. break;
  33923. }
  33924. }
  33925. return internalFormat;
  33926. };
  33927. /** @hidden */
  33928. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33929. if (this._webGLVersion === 1) {
  33930. if (format !== undefined) {
  33931. switch (format) {
  33932. case Engine.TEXTUREFORMAT_ALPHA:
  33933. return this._gl.ALPHA;
  33934. case Engine.TEXTUREFORMAT_LUMINANCE:
  33935. return this._gl.LUMINANCE;
  33936. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33937. return this._gl.LUMINANCE_ALPHA;
  33938. }
  33939. }
  33940. return this._gl.RGBA;
  33941. }
  33942. switch (type) {
  33943. case Engine.TEXTURETYPE_BYTE:
  33944. switch (format) {
  33945. case Engine.TEXTUREFORMAT_RED:
  33946. return this._gl.R8_SNORM;
  33947. case Engine.TEXTUREFORMAT_RG:
  33948. return this._gl.RG8_SNORM;
  33949. case Engine.TEXTUREFORMAT_RGB:
  33950. return this._gl.RGB8_SNORM;
  33951. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33952. return this._gl.R8I;
  33953. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33954. return this._gl.RG8I;
  33955. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33956. return this._gl.RGB8I;
  33957. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33958. return this._gl.RGBA8I;
  33959. default:
  33960. return this._gl.RGBA8_SNORM;
  33961. }
  33962. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33963. switch (format) {
  33964. case Engine.TEXTUREFORMAT_RED:
  33965. return this._gl.R8;
  33966. case Engine.TEXTUREFORMAT_RG:
  33967. return this._gl.RG8;
  33968. case Engine.TEXTUREFORMAT_RGB:
  33969. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33970. case Engine.TEXTUREFORMAT_RGBA:
  33971. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33972. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33973. return this._gl.R8UI;
  33974. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33975. return this._gl.RG8UI;
  33976. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33977. return this._gl.RGB8UI;
  33978. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33979. return this._gl.RGBA8UI;
  33980. default:
  33981. return this._gl.RGBA8;
  33982. }
  33983. case Engine.TEXTURETYPE_SHORT:
  33984. switch (format) {
  33985. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33986. return this._gl.R16I;
  33987. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33988. return this._gl.RG16I;
  33989. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33990. return this._gl.RGB16I;
  33991. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33992. return this._gl.RGBA16I;
  33993. default:
  33994. return this._gl.RGBA16I;
  33995. }
  33996. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33997. switch (format) {
  33998. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33999. return this._gl.R16UI;
  34000. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34001. return this._gl.RG16UI;
  34002. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34003. return this._gl.RGB16UI;
  34004. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34005. return this._gl.RGBA16UI;
  34006. default:
  34007. return this._gl.RGBA16UI;
  34008. }
  34009. case Engine.TEXTURETYPE_INT:
  34010. switch (format) {
  34011. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34012. return this._gl.R32I;
  34013. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34014. return this._gl.RG32I;
  34015. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34016. return this._gl.RGB32I;
  34017. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34018. return this._gl.RGBA32I;
  34019. default:
  34020. return this._gl.RGBA32I;
  34021. }
  34022. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34023. switch (format) {
  34024. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34025. return this._gl.R32UI;
  34026. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34027. return this._gl.RG32UI;
  34028. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34029. return this._gl.RGB32UI;
  34030. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34031. return this._gl.RGBA32UI;
  34032. default:
  34033. return this._gl.RGBA32UI;
  34034. }
  34035. case Engine.TEXTURETYPE_FLOAT:
  34036. switch (format) {
  34037. case Engine.TEXTUREFORMAT_RED:
  34038. return this._gl.R32F; // By default. Other possibility is R16F.
  34039. case Engine.TEXTUREFORMAT_RG:
  34040. return this._gl.RG32F; // By default. Other possibility is RG16F.
  34041. case Engine.TEXTUREFORMAT_RGB:
  34042. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  34043. case Engine.TEXTUREFORMAT_RGBA:
  34044. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  34045. default:
  34046. return this._gl.RGBA32F;
  34047. }
  34048. case Engine.TEXTURETYPE_HALF_FLOAT:
  34049. switch (format) {
  34050. case Engine.TEXTUREFORMAT_RED:
  34051. return this._gl.R16F;
  34052. case Engine.TEXTUREFORMAT_RG:
  34053. return this._gl.RG16F;
  34054. case Engine.TEXTUREFORMAT_RGB:
  34055. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  34056. case Engine.TEXTUREFORMAT_RGBA:
  34057. return this._gl.RGBA16F;
  34058. default:
  34059. return this._gl.RGBA16F;
  34060. }
  34061. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34062. return this._gl.RGB565;
  34063. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34064. return this._gl.R11F_G11F_B10F;
  34065. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34066. return this._gl.RGB9_E5;
  34067. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34068. return this._gl.RGBA4;
  34069. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34070. return this._gl.RGB5_A1;
  34071. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34072. switch (format) {
  34073. case Engine.TEXTUREFORMAT_RGBA:
  34074. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  34075. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34076. return this._gl.RGB10_A2UI;
  34077. default:
  34078. return this._gl.RGB10_A2;
  34079. }
  34080. }
  34081. return this._gl.RGBA8;
  34082. };
  34083. /** @hidden */
  34084. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  34085. if (type === Engine.TEXTURETYPE_FLOAT) {
  34086. return this._gl.RGBA32F;
  34087. }
  34088. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  34089. return this._gl.RGBA16F;
  34090. }
  34091. return this._gl.RGBA8;
  34092. };
  34093. /** @hidden */
  34094. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34095. var _this = this;
  34096. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34097. this._activeRequests.push(request);
  34098. request.onCompleteObservable.add(function (request) {
  34099. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34100. });
  34101. return request;
  34102. };
  34103. /** @hidden */
  34104. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34105. var _this = this;
  34106. return new Promise(function (resolve, reject) {
  34107. _this._loadFile(url, function (data) {
  34108. resolve(data);
  34109. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34110. reject(exception);
  34111. });
  34112. });
  34113. };
  34114. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  34115. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  34116. var onload = function (data) {
  34117. loadedFiles[index] = data;
  34118. loadedFiles._internalCount++;
  34119. if (loadedFiles._internalCount === 6) {
  34120. onfinish(loadedFiles);
  34121. }
  34122. };
  34123. var onerror = function (request, exception) {
  34124. if (onErrorCallBack && request) {
  34125. onErrorCallBack(request.status + " " + request.statusText, exception);
  34126. }
  34127. };
  34128. this._loadFile(url, onload, undefined, undefined, true, onerror);
  34129. };
  34130. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  34131. if (onError === void 0) { onError = null; }
  34132. var loadedFiles = [];
  34133. loadedFiles._internalCount = 0;
  34134. for (var index = 0; index < 6; index++) {
  34135. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  34136. }
  34137. };
  34138. // Statics
  34139. /**
  34140. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34141. * @returns true if the engine can be created
  34142. * @ignorenaming
  34143. */
  34144. Engine.isSupported = function () {
  34145. try {
  34146. var tempcanvas = document.createElement("canvas");
  34147. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34148. return gl != null && !!window.WebGLRenderingContext;
  34149. }
  34150. catch (e) {
  34151. return false;
  34152. }
  34153. };
  34154. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34155. Engine.ExceptionList = [
  34156. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34157. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34158. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34159. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34160. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34161. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  34162. ];
  34163. /**
  34164. * Hidden
  34165. */
  34166. Engine._TextureLoaders = [];
  34167. // Const statics
  34168. /** Defines that alpha blending is disabled */
  34169. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  34170. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34171. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  34172. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34173. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  34174. /** Defines that alpha blending to DEST - SRC * DEST */
  34175. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  34176. /** Defines that alpha blending to SRC * DEST */
  34177. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  34178. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34179. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  34180. /** Defines that alpha blending to SRC + DEST */
  34181. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  34182. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34183. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  34184. /**
  34185. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34186. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34187. */
  34188. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34189. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34190. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  34191. /**
  34192. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34193. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34194. */
  34195. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  34196. /** Defines that the ressource is not delayed*/
  34197. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  34198. /** Defines that the ressource was successfully delay loaded */
  34199. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  34200. /** Defines that the ressource is currently delay loading */
  34201. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  34202. /** Defines that the ressource is delayed and has not started loading */
  34203. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34204. // Depht or Stencil test Constants.
  34205. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34206. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  34207. /** 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 */
  34208. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  34209. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34210. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  34211. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34212. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  34213. /** 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 */
  34214. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  34215. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34216. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  34217. /** 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 */
  34218. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  34219. /** 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 */
  34220. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  34221. // Stencil Actions Constants.
  34222. /** Passed to stencilOperation to specify that stencil value must be kept */
  34223. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  34224. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34225. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  34226. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34227. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  34228. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34229. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  34230. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34231. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  34232. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34233. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  34234. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34235. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  34236. /** Texture is not repeating outside of 0..1 UVs */
  34237. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34238. /** Texture is repeating outside of 0..1 UVs */
  34239. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34240. /** Texture is repeating and mirrored */
  34241. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34242. /** ALPHA */
  34243. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  34244. /** LUMINANCE */
  34245. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34246. /** LUMINANCE_ALPHA */
  34247. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34248. /** RGB */
  34249. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  34250. /** RGBA */
  34251. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  34252. /** RED */
  34253. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  34254. /** RED (2nd reference) */
  34255. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  34256. /** RG */
  34257. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  34258. /** RED_INTEGER */
  34259. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34260. /** RED_INTEGER (2nd reference) */
  34261. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34262. /** RG_INTEGER */
  34263. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34264. /** RGB_INTEGER */
  34265. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34266. /** RGBA_INTEGER */
  34267. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34268. /** UNSIGNED_BYTE */
  34269. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34270. /** UNSIGNED_BYTE (2nd reference) */
  34271. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34272. /** FLOAT */
  34273. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  34274. /** HALF_FLOAT */
  34275. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34276. /** BYTE */
  34277. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  34278. /** SHORT */
  34279. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  34280. /** UNSIGNED_SHORT */
  34281. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34282. /** INT */
  34283. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  34284. /** UNSIGNED_INT */
  34285. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34286. /** UNSIGNED_SHORT_4_4_4_4 */
  34287. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34288. /** UNSIGNED_SHORT_5_5_5_1 */
  34289. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34290. /** UNSIGNED_SHORT_5_6_5 */
  34291. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34292. /** UNSIGNED_INT_2_10_10_10_REV */
  34293. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34294. /** UNSIGNED_INT_24_8 */
  34295. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34296. /** UNSIGNED_INT_10F_11F_11F_REV */
  34297. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34298. /** UNSIGNED_INT_5_9_9_9_REV */
  34299. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34300. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34301. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34302. /** nearest is mag = nearest and min = nearest and mip = linear */
  34303. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34304. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34305. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34306. /** Trilinear is mag = linear and min = linear and mip = linear */
  34307. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34308. /** nearest is mag = nearest and min = nearest and mip = linear */
  34309. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34310. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34311. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34312. /** Trilinear is mag = linear and min = linear and mip = linear */
  34313. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34314. /** mag = nearest and min = nearest and mip = nearest */
  34315. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34316. /** mag = nearest and min = linear and mip = nearest */
  34317. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34318. /** mag = nearest and min = linear and mip = linear */
  34319. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34320. /** mag = nearest and min = linear and mip = none */
  34321. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  34322. /** mag = nearest and min = nearest and mip = none */
  34323. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  34324. /** mag = linear and min = nearest and mip = nearest */
  34325. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34326. /** mag = linear and min = nearest and mip = linear */
  34327. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34328. /** mag = linear and min = linear and mip = none */
  34329. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  34330. /** mag = linear and min = nearest and mip = none */
  34331. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  34332. /** Explicit coordinates mode */
  34333. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  34334. /** Spherical coordinates mode */
  34335. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  34336. /** Planar coordinates mode */
  34337. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  34338. /** Cubic coordinates mode */
  34339. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  34340. /** Projection coordinates mode */
  34341. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  34342. /** Skybox coordinates mode */
  34343. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  34344. /** Inverse Cubic coordinates mode */
  34345. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  34346. /** Equirectangular coordinates mode */
  34347. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34348. /** Equirectangular Fixed coordinates mode */
  34349. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34350. /** Equirectangular Fixed Mirrored coordinates mode */
  34351. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34352. // Texture rescaling mode
  34353. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34354. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  34355. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34356. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  34357. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34358. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  34359. // Updatable statics so stick with vars here
  34360. /**
  34361. * Gets or sets the epsilon value used by collision engine
  34362. */
  34363. Engine.CollisionsEpsilon = 0.001;
  34364. /**
  34365. * Method called to create the default rescale post process on each engine.
  34366. */
  34367. Engine._RescalePostProcessFactory = null;
  34368. return Engine;
  34369. }());
  34370. /***/ }),
  34371. /***/ "./Engines/engineStore.ts":
  34372. /*!********************************!*\
  34373. !*** ./Engines/engineStore.ts ***!
  34374. \********************************/
  34375. /*! exports provided: EngineStore */
  34376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34377. "use strict";
  34378. __webpack_require__.r(__webpack_exports__);
  34379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34380. /**
  34381. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34382. * during the life time of the application.
  34383. */
  34384. var EngineStore = /** @class */ (function () {
  34385. function EngineStore() {
  34386. }
  34387. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34388. /**
  34389. * Gets the latest created engine
  34390. */
  34391. get: function () {
  34392. if (this.Instances.length === 0) {
  34393. return null;
  34394. }
  34395. return this.Instances[this.Instances.length - 1];
  34396. },
  34397. enumerable: true,
  34398. configurable: true
  34399. });
  34400. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34401. /**
  34402. * Gets the latest created scene
  34403. */
  34404. get: function () {
  34405. var lastCreatedEngine = this.LastCreatedEngine;
  34406. if (!lastCreatedEngine) {
  34407. return null;
  34408. }
  34409. if (lastCreatedEngine.scenes.length === 0) {
  34410. return null;
  34411. }
  34412. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  34413. },
  34414. enumerable: true,
  34415. configurable: true
  34416. });
  34417. /** Gets the list of created engines */
  34418. EngineStore.Instances = new Array();
  34419. return EngineStore;
  34420. }());
  34421. /***/ }),
  34422. /***/ "./Engines/index.ts":
  34423. /*!**************************!*\
  34424. !*** ./Engines/index.ts ***!
  34425. \**************************/
  34426. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34428. "use strict";
  34429. __webpack_require__.r(__webpack_exports__);
  34430. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34432. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34437. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34439. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34442. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34445. /***/ }),
  34446. /***/ "./Engines/nullEngine.ts":
  34447. /*!*******************************!*\
  34448. !*** ./Engines/nullEngine.ts ***!
  34449. \*******************************/
  34450. /*! exports provided: NullEngineOptions, NullEngine */
  34451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34452. "use strict";
  34453. __webpack_require__.r(__webpack_exports__);
  34454. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34456. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34457. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34458. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34459. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34460. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34461. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34462. /**
  34463. * Options to create the null engine
  34464. */
  34465. var NullEngineOptions = /** @class */ (function () {
  34466. function NullEngineOptions() {
  34467. /**
  34468. * Render width (Default: 512)
  34469. */
  34470. this.renderWidth = 512;
  34471. /**
  34472. * Render height (Default: 256)
  34473. */
  34474. this.renderHeight = 256;
  34475. /**
  34476. * Texture size (Default: 512)
  34477. */
  34478. this.textureSize = 512;
  34479. /**
  34480. * If delta time between frames should be constant
  34481. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34482. */
  34483. this.deterministicLockstep = false;
  34484. /**
  34485. * Maximum about of steps between frames (Default: 4)
  34486. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34487. */
  34488. this.lockstepMaxSteps = 4;
  34489. }
  34490. return NullEngineOptions;
  34491. }());
  34492. /**
  34493. * The null engine class provides support for headless version of babylon.js.
  34494. * This can be used in server side scenario or for testing purposes
  34495. */
  34496. var NullEngine = /** @class */ (function (_super) {
  34497. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  34498. function NullEngine(options) {
  34499. if (options === void 0) { options = new NullEngineOptions(); }
  34500. var _this = _super.call(this, null) || this;
  34501. if (options.deterministicLockstep === undefined) {
  34502. options.deterministicLockstep = false;
  34503. }
  34504. if (options.lockstepMaxSteps === undefined) {
  34505. options.lockstepMaxSteps = 4;
  34506. }
  34507. _this._options = options;
  34508. // Init caps
  34509. // We consider we are on a webgl1 capable device
  34510. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  34511. _this._caps.maxTexturesImageUnits = 16;
  34512. _this._caps.maxVertexTextureImageUnits = 16;
  34513. _this._caps.maxTextureSize = 512;
  34514. _this._caps.maxCubemapTextureSize = 512;
  34515. _this._caps.maxRenderTextureSize = 512;
  34516. _this._caps.maxVertexAttribs = 16;
  34517. _this._caps.maxVaryingVectors = 16;
  34518. _this._caps.maxFragmentUniformVectors = 16;
  34519. _this._caps.maxVertexUniformVectors = 16;
  34520. // Extensions
  34521. _this._caps.standardDerivatives = false;
  34522. _this._caps.astc = null;
  34523. _this._caps.s3tc = null;
  34524. _this._caps.pvrtc = null;
  34525. _this._caps.etc1 = null;
  34526. _this._caps.etc2 = null;
  34527. _this._caps.textureAnisotropicFilterExtension = null;
  34528. _this._caps.maxAnisotropy = 0;
  34529. _this._caps.uintIndices = false;
  34530. _this._caps.fragmentDepthSupported = false;
  34531. _this._caps.highPrecisionShaderSupported = true;
  34532. _this._caps.colorBufferFloat = false;
  34533. _this._caps.textureFloat = false;
  34534. _this._caps.textureFloatLinearFiltering = false;
  34535. _this._caps.textureFloatRender = false;
  34536. _this._caps.textureHalfFloat = false;
  34537. _this._caps.textureHalfFloatLinearFiltering = false;
  34538. _this._caps.textureHalfFloatRender = false;
  34539. _this._caps.textureLOD = false;
  34540. _this._caps.drawBuffersExtension = false;
  34541. _this._caps.depthTextureExtension = false;
  34542. _this._caps.vertexArrayObject = false;
  34543. _this._caps.instancedArrays = false;
  34544. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  34545. // Wrappers
  34546. var theCurrentGlobal = (typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : window);
  34547. if (typeof URL === "undefined") {
  34548. theCurrentGlobal.URL = {
  34549. createObjectURL: function () { },
  34550. revokeObjectURL: function () { }
  34551. };
  34552. }
  34553. if (typeof Blob === "undefined") {
  34554. theCurrentGlobal.Blob = function () { };
  34555. }
  34556. return _this;
  34557. }
  34558. /**
  34559. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34560. */
  34561. NullEngine.prototype.isDeterministicLockStep = function () {
  34562. return this._options.deterministicLockstep;
  34563. };
  34564. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34565. NullEngine.prototype.getLockstepMaxSteps = function () {
  34566. return this._options.lockstepMaxSteps;
  34567. };
  34568. /**
  34569. * Sets hardware scaling, used to save performance if needed
  34570. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34571. */
  34572. NullEngine.prototype.getHardwareScalingLevel = function () {
  34573. return 1.0;
  34574. };
  34575. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34576. return {
  34577. capacity: 0,
  34578. references: 1,
  34579. is32Bits: false
  34580. };
  34581. };
  34582. NullEngine.prototype.createIndexBuffer = function (indices) {
  34583. return {
  34584. capacity: 0,
  34585. references: 1,
  34586. is32Bits: false
  34587. };
  34588. };
  34589. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34590. if (stencil === void 0) { stencil = false; }
  34591. };
  34592. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34593. if (useScreen === void 0) { useScreen = false; }
  34594. if (!useScreen && this._currentRenderTarget) {
  34595. return this._currentRenderTarget.width;
  34596. }
  34597. return this._options.renderWidth;
  34598. };
  34599. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34600. if (useScreen === void 0) { useScreen = false; }
  34601. if (!useScreen && this._currentRenderTarget) {
  34602. return this._currentRenderTarget.height;
  34603. }
  34604. return this._options.renderHeight;
  34605. };
  34606. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34607. this._cachedViewport = viewport;
  34608. };
  34609. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34610. return {
  34611. transformFeedback: null,
  34612. __SPECTOR_rebuildProgram: null,
  34613. isParallelCompiled: false
  34614. };
  34615. };
  34616. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34617. return [];
  34618. };
  34619. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34620. return [];
  34621. };
  34622. NullEngine.prototype.bindSamplers = function (effect) {
  34623. this._currentEffect = null;
  34624. };
  34625. NullEngine.prototype.enableEffect = function (effect) {
  34626. this._currentEffect = effect;
  34627. if (effect.onBind) {
  34628. effect.onBind(effect);
  34629. }
  34630. if (effect._onBindObservable) {
  34631. effect._onBindObservable.notifyObservers(effect);
  34632. }
  34633. };
  34634. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34635. if (zOffset === void 0) { zOffset = 0; }
  34636. if (reverseSide === void 0) { reverseSide = false; }
  34637. };
  34638. NullEngine.prototype.setIntArray = function (uniform, array) {
  34639. };
  34640. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34641. };
  34642. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34643. };
  34644. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34645. };
  34646. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34647. };
  34648. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34649. };
  34650. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34651. };
  34652. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34653. };
  34654. NullEngine.prototype.setArray = function (uniform, array) {
  34655. };
  34656. NullEngine.prototype.setArray2 = function (uniform, array) {
  34657. };
  34658. NullEngine.prototype.setArray3 = function (uniform, array) {
  34659. };
  34660. NullEngine.prototype.setArray4 = function (uniform, array) {
  34661. };
  34662. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34663. };
  34664. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34665. };
  34666. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34667. };
  34668. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34669. };
  34670. NullEngine.prototype.setFloat = function (uniform, value) {
  34671. };
  34672. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34673. };
  34674. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34675. };
  34676. NullEngine.prototype.setBool = function (uniform, bool) {
  34677. };
  34678. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34679. };
  34680. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34681. };
  34682. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34683. };
  34684. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34685. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34686. if (this._alphaMode === mode) {
  34687. return;
  34688. }
  34689. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34690. if (!noDepthWriteChange) {
  34691. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34692. }
  34693. this._alphaMode = mode;
  34694. };
  34695. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34696. };
  34697. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34698. if (this.preventCacheWipeBetweenFrames) {
  34699. return;
  34700. }
  34701. this.resetTextureCache();
  34702. this._currentEffect = null;
  34703. if (bruteForce) {
  34704. this._currentProgram = null;
  34705. this._stencilState.reset();
  34706. this._depthCullingState.reset();
  34707. this._alphaState.reset();
  34708. }
  34709. this._cachedVertexBuffers = null;
  34710. this._cachedIndexBuffer = null;
  34711. this._cachedEffectForVertexBuffers = null;
  34712. };
  34713. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34714. };
  34715. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34716. };
  34717. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34718. };
  34719. /** @hidden */
  34720. NullEngine.prototype._createTexture = function () {
  34721. return {};
  34722. };
  34723. /** @hidden */
  34724. NullEngine.prototype._releaseTexture = function (texture) {
  34725. };
  34726. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34727. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34728. if (onLoad === void 0) { onLoad = null; }
  34729. if (onError === void 0) { onError = null; }
  34730. if (buffer === void 0) { buffer = null; }
  34731. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34732. var url = String(urlArg);
  34733. texture.url = url;
  34734. texture.generateMipMaps = !noMipmap;
  34735. texture.samplingMode = samplingMode;
  34736. texture.invertY = invertY;
  34737. texture.baseWidth = this._options.textureSize;
  34738. texture.baseHeight = this._options.textureSize;
  34739. texture.width = this._options.textureSize;
  34740. texture.height = this._options.textureSize;
  34741. if (format) {
  34742. texture.format = format;
  34743. }
  34744. texture.isReady = true;
  34745. if (onLoad) {
  34746. onLoad();
  34747. }
  34748. this._internalTexturesCache.push(texture);
  34749. return texture;
  34750. };
  34751. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34752. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34753. if (options !== undefined && typeof options === "object") {
  34754. fullOptions.generateMipMaps = options.generateMipMaps;
  34755. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34756. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34757. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34758. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34759. }
  34760. else {
  34761. fullOptions.generateMipMaps = options;
  34762. fullOptions.generateDepthBuffer = true;
  34763. fullOptions.generateStencilBuffer = false;
  34764. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34765. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34766. }
  34767. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34768. var width = size.width || size;
  34769. var height = size.height || size;
  34770. texture._depthStencilBuffer = {};
  34771. texture._framebuffer = {};
  34772. texture.baseWidth = width;
  34773. texture.baseHeight = height;
  34774. texture.width = width;
  34775. texture.height = height;
  34776. texture.isReady = true;
  34777. texture.samples = 1;
  34778. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34779. texture.samplingMode = fullOptions.samplingMode;
  34780. texture.type = fullOptions.type;
  34781. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34782. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34783. this._internalTexturesCache.push(texture);
  34784. return texture;
  34785. };
  34786. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34787. texture.samplingMode = samplingMode;
  34788. };
  34789. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34790. if (this._currentRenderTarget) {
  34791. this.unBindFramebuffer(this._currentRenderTarget);
  34792. }
  34793. this._currentRenderTarget = texture;
  34794. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34795. if (this._cachedViewport && !forceFullscreenViewport) {
  34796. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34797. }
  34798. };
  34799. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34800. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34801. this._currentRenderTarget = null;
  34802. if (onBeforeUnbind) {
  34803. if (texture._MSAAFramebuffer) {
  34804. this._currentFramebuffer = texture._framebuffer;
  34805. }
  34806. onBeforeUnbind();
  34807. }
  34808. this._currentFramebuffer = null;
  34809. };
  34810. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34811. var vbo = {
  34812. capacity: 1,
  34813. references: 1,
  34814. is32Bits: false
  34815. };
  34816. return vbo;
  34817. };
  34818. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34819. if (premulAlpha === void 0) { premulAlpha = false; }
  34820. };
  34821. NullEngine.prototype.areAllEffectsReady = function () {
  34822. return true;
  34823. };
  34824. /**
  34825. * @hidden
  34826. * Get the current error code of the webGL context
  34827. * @returns the error code
  34828. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34829. */
  34830. NullEngine.prototype.getError = function () {
  34831. return 0;
  34832. };
  34833. /** @hidden */
  34834. NullEngine.prototype._getUnpackAlignement = function () {
  34835. return 1;
  34836. };
  34837. /** @hidden */
  34838. NullEngine.prototype._unpackFlipY = function (value) {
  34839. };
  34840. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34841. if (offset === void 0) { offset = 0; }
  34842. };
  34843. /**
  34844. * Updates a dynamic vertex buffer.
  34845. * @param vertexBuffer the vertex buffer to update
  34846. * @param data the data used to update the vertex buffer
  34847. * @param byteOffset the byte offset of the data (optional)
  34848. * @param byteLength the byte length of the data (optional)
  34849. */
  34850. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34851. };
  34852. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34853. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34854. this._boundTexturesCache[this._activeChannel] = texture;
  34855. return true;
  34856. }
  34857. return false;
  34858. };
  34859. /** @hidden */
  34860. NullEngine.prototype._bindTexture = function (channel, texture) {
  34861. if (channel < 0) {
  34862. return;
  34863. }
  34864. this._bindTextureDirectly(0, texture);
  34865. };
  34866. /** @hidden */
  34867. NullEngine.prototype._releaseBuffer = function (buffer) {
  34868. buffer.references--;
  34869. if (buffer.references === 0) {
  34870. return true;
  34871. }
  34872. return false;
  34873. };
  34874. NullEngine.prototype.releaseEffects = function () {
  34875. };
  34876. NullEngine.prototype.displayLoadingUI = function () {
  34877. };
  34878. NullEngine.prototype.hideLoadingUI = function () {
  34879. };
  34880. /** @hidden */
  34881. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34882. if (faceIndex === void 0) { faceIndex = 0; }
  34883. if (lod === void 0) { lod = 0; }
  34884. };
  34885. /** @hidden */
  34886. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34887. if (faceIndex === void 0) { faceIndex = 0; }
  34888. if (lod === void 0) { lod = 0; }
  34889. };
  34890. /** @hidden */
  34891. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34892. if (faceIndex === void 0) { faceIndex = 0; }
  34893. if (lod === void 0) { lod = 0; }
  34894. };
  34895. /** @hidden */
  34896. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34897. if (faceIndex === void 0) { faceIndex = 0; }
  34898. if (lod === void 0) { lod = 0; }
  34899. };
  34900. return NullEngine;
  34901. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34902. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  34903. /***/ }),
  34904. /***/ "./Events/clipboardEvents.ts":
  34905. /*!***********************************!*\
  34906. !*** ./Events/clipboardEvents.ts ***!
  34907. \***********************************/
  34908. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34910. "use strict";
  34911. __webpack_require__.r(__webpack_exports__);
  34912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34914. /**
  34915. * Gather the list of clipboard event types as constants.
  34916. */
  34917. var ClipboardEventTypes = /** @class */ (function () {
  34918. function ClipboardEventTypes() {
  34919. }
  34920. /**
  34921. * The clipboard event is fired when a copy command is active (pressed).
  34922. */
  34923. ClipboardEventTypes.COPY = 0x01; //
  34924. /**
  34925. * The clipboard event is fired when a cut command is active (pressed).
  34926. */
  34927. ClipboardEventTypes.CUT = 0x02;
  34928. /**
  34929. * The clipboard event is fired when a paste command is active (pressed).
  34930. */
  34931. ClipboardEventTypes.PASTE = 0x03;
  34932. return ClipboardEventTypes;
  34933. }());
  34934. /**
  34935. * This class is used to store clipboard related info for the onClipboardObservable event.
  34936. */
  34937. var ClipboardInfo = /** @class */ (function () {
  34938. /**
  34939. *Creates an instance of ClipboardInfo.
  34940. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34941. * @param event Defines the related dom event
  34942. */
  34943. function ClipboardInfo(
  34944. /**
  34945. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34946. */
  34947. type,
  34948. /**
  34949. * Defines the related dom event
  34950. */
  34951. event) {
  34952. this.type = type;
  34953. this.event = event;
  34954. }
  34955. /**
  34956. * Get the clipboard event's type from the keycode.
  34957. * @param keyCode Defines the keyCode for the current keyboard event.
  34958. * @return {number}
  34959. */
  34960. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34961. var charCode = keyCode;
  34962. //TODO: add codes for extended ASCII
  34963. switch (charCode) {
  34964. case 67: return ClipboardEventTypes.COPY;
  34965. case 86: return ClipboardEventTypes.PASTE;
  34966. case 88: return ClipboardEventTypes.CUT;
  34967. default: return -1;
  34968. }
  34969. };
  34970. return ClipboardInfo;
  34971. }());
  34972. /***/ }),
  34973. /***/ "./Events/index.ts":
  34974. /*!*************************!*\
  34975. !*** ./Events/index.ts ***!
  34976. \*************************/
  34977. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34979. "use strict";
  34980. __webpack_require__.r(__webpack_exports__);
  34981. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34985. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34990. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34993. /***/ }),
  34994. /***/ "./Events/keyboardEvents.ts":
  34995. /*!**********************************!*\
  34996. !*** ./Events/keyboardEvents.ts ***!
  34997. \**********************************/
  34998. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35000. "use strict";
  35001. __webpack_require__.r(__webpack_exports__);
  35002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  35003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  35004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  35005. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35006. /**
  35007. * Gather the list of keyboard event types as constants.
  35008. */
  35009. var KeyboardEventTypes = /** @class */ (function () {
  35010. function KeyboardEventTypes() {
  35011. }
  35012. /**
  35013. * The keydown event is fired when a key becomes active (pressed).
  35014. */
  35015. KeyboardEventTypes.KEYDOWN = 0x01;
  35016. /**
  35017. * The keyup event is fired when a key has been released.
  35018. */
  35019. KeyboardEventTypes.KEYUP = 0x02;
  35020. return KeyboardEventTypes;
  35021. }());
  35022. /**
  35023. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35024. */
  35025. var KeyboardInfo = /** @class */ (function () {
  35026. /**
  35027. * Instantiates a new keyboard info.
  35028. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35029. * @param type Defines the type of event (KeyboardEventTypes)
  35030. * @param event Defines the related dom event
  35031. */
  35032. function KeyboardInfo(
  35033. /**
  35034. * Defines the type of event (KeyboardEventTypes)
  35035. */
  35036. type,
  35037. /**
  35038. * Defines the related dom event
  35039. */
  35040. event) {
  35041. this.type = type;
  35042. this.event = event;
  35043. }
  35044. return KeyboardInfo;
  35045. }());
  35046. /**
  35047. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35048. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  35049. */
  35050. var KeyboardInfoPre = /** @class */ (function (_super) {
  35051. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  35052. /**
  35053. * Instantiates a new keyboard pre info.
  35054. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35055. * @param type Defines the type of event (KeyboardEventTypes)
  35056. * @param event Defines the related dom event
  35057. */
  35058. function KeyboardInfoPre(
  35059. /**
  35060. * Defines the type of event (KeyboardEventTypes)
  35061. */
  35062. type,
  35063. /**
  35064. * Defines the related dom event
  35065. */
  35066. event) {
  35067. var _this = _super.call(this, type, event) || this;
  35068. _this.type = type;
  35069. _this.event = event;
  35070. _this.skipOnPointerObservable = false;
  35071. return _this;
  35072. }
  35073. return KeyboardInfoPre;
  35074. }(KeyboardInfo));
  35075. /***/ }),
  35076. /***/ "./Events/pointerEvents.ts":
  35077. /*!*********************************!*\
  35078. !*** ./Events/pointerEvents.ts ***!
  35079. \*********************************/
  35080. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  35081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35082. "use strict";
  35083. __webpack_require__.r(__webpack_exports__);
  35084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  35085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  35086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  35087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  35088. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35089. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  35090. /**
  35091. * Gather the list of pointer event types as constants.
  35092. */
  35093. var PointerEventTypes = /** @class */ (function () {
  35094. function PointerEventTypes() {
  35095. }
  35096. /**
  35097. * 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.
  35098. */
  35099. PointerEventTypes.POINTERDOWN = 0x01;
  35100. /**
  35101. * The pointerup event is fired when a pointer is no longer active.
  35102. */
  35103. PointerEventTypes.POINTERUP = 0x02;
  35104. /**
  35105. * The pointermove event is fired when a pointer changes coordinates.
  35106. */
  35107. PointerEventTypes.POINTERMOVE = 0x04;
  35108. /**
  35109. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35110. */
  35111. PointerEventTypes.POINTERWHEEL = 0x08;
  35112. /**
  35113. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35114. */
  35115. PointerEventTypes.POINTERPICK = 0x10;
  35116. /**
  35117. * The pointertap event is fired when a the object has been touched and released without drag.
  35118. */
  35119. PointerEventTypes.POINTERTAP = 0x20;
  35120. /**
  35121. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35122. */
  35123. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35124. return PointerEventTypes;
  35125. }());
  35126. /**
  35127. * Base class of pointer info types.
  35128. */
  35129. var PointerInfoBase = /** @class */ (function () {
  35130. /**
  35131. * Instantiates the base class of pointers info.
  35132. * @param type Defines the type of event (PointerEventTypes)
  35133. * @param event Defines the related dom event
  35134. */
  35135. function PointerInfoBase(
  35136. /**
  35137. * Defines the type of event (PointerEventTypes)
  35138. */
  35139. type,
  35140. /**
  35141. * Defines the related dom event
  35142. */
  35143. event) {
  35144. this.type = type;
  35145. this.event = event;
  35146. }
  35147. return PointerInfoBase;
  35148. }());
  35149. /**
  35150. * This class is used to store pointer related info for the onPrePointerObservable event.
  35151. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35152. */
  35153. var PointerInfoPre = /** @class */ (function (_super) {
  35154. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35155. /**
  35156. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35157. * @param type Defines the type of event (PointerEventTypes)
  35158. * @param event Defines the related dom event
  35159. * @param localX Defines the local x coordinates of the pointer when the event occured
  35160. * @param localY Defines the local y coordinates of the pointer when the event occured
  35161. */
  35162. function PointerInfoPre(type, event, localX, localY) {
  35163. var _this = _super.call(this, type, event) || this;
  35164. /**
  35165. * Ray from a pointer if availible (eg. 6dof controller)
  35166. */
  35167. _this.ray = null;
  35168. _this.skipOnPointerObservable = false;
  35169. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35170. return _this;
  35171. }
  35172. return PointerInfoPre;
  35173. }(PointerInfoBase));
  35174. /**
  35175. * This type contains all the data related to a pointer event in Babylon.js.
  35176. * 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.
  35177. */
  35178. var PointerInfo = /** @class */ (function (_super) {
  35179. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35180. /**
  35181. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35182. * @param type Defines the type of event (PointerEventTypes)
  35183. * @param event Defines the related dom event
  35184. * @param pickInfo Defines the picking info associated to the info (if any)\
  35185. */
  35186. function PointerInfo(type, event,
  35187. /**
  35188. * Defines the picking info associated to the info (if any)\
  35189. */
  35190. pickInfo) {
  35191. var _this = _super.call(this, type, event) || this;
  35192. _this.pickInfo = pickInfo;
  35193. return _this;
  35194. }
  35195. return PointerInfo;
  35196. }(PointerInfoBase));
  35197. /***/ }),
  35198. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35199. /*!****************************************************!*\
  35200. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35201. \****************************************************/
  35202. /*! exports provided: DaydreamController */
  35203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35204. "use strict";
  35205. __webpack_require__.r(__webpack_exports__);
  35206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35207. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35208. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35209. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35210. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35211. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35212. /**
  35213. * Google Daydream controller
  35214. */
  35215. var DaydreamController = /** @class */ (function (_super) {
  35216. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35217. /**
  35218. * Creates a new DaydreamController from a gamepad
  35219. * @param vrGamepad the gamepad that the controller should be created from
  35220. */
  35221. function DaydreamController(vrGamepad) {
  35222. var _this = _super.call(this, vrGamepad) || this;
  35223. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35224. return _this;
  35225. }
  35226. /**
  35227. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35228. * @param scene scene in which to add meshes
  35229. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35230. */
  35231. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35232. var _this = this;
  35233. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35234. _this._defaultModel = newMeshes[1];
  35235. _this.attachToMesh(_this._defaultModel);
  35236. if (meshLoaded) {
  35237. meshLoaded(_this._defaultModel);
  35238. }
  35239. });
  35240. };
  35241. /**
  35242. * Called once for each button that changed state since the last frame
  35243. * @param buttonIdx Which button index changed
  35244. * @param state New state of the button
  35245. * @param changes Which properties on the state changed since last frame
  35246. */
  35247. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35248. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35249. if (buttonIdx === 0) {
  35250. var observable = this.onTriggerStateChangedObservable;
  35251. if (observable) {
  35252. observable.notifyObservers(state);
  35253. }
  35254. }
  35255. else {
  35256. // If the app or home buttons are ever made available
  35257. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35258. }
  35259. };
  35260. /**
  35261. * Base Url for the controller model.
  35262. */
  35263. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35264. /**
  35265. * File name for the controller model.
  35266. */
  35267. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35268. /**
  35269. * Gamepad Id prefix used to identify Daydream Controller.
  35270. */
  35271. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35272. return DaydreamController;
  35273. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35274. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35275. canCreate: function (gamepadInfo) {
  35276. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35277. },
  35278. create: function (gamepadInfo) {
  35279. return new DaydreamController(gamepadInfo);
  35280. }
  35281. });
  35282. /***/ }),
  35283. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35284. /*!**************************************************!*\
  35285. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35286. \**************************************************/
  35287. /*! exports provided: GearVRController */
  35288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35289. "use strict";
  35290. __webpack_require__.r(__webpack_exports__);
  35291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35293. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35294. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35295. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35296. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35297. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35298. /**
  35299. * Gear VR Controller
  35300. */
  35301. var GearVRController = /** @class */ (function (_super) {
  35302. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35303. /**
  35304. * Creates a new GearVRController from a gamepad
  35305. * @param vrGamepad the gamepad that the controller should be created from
  35306. */
  35307. function GearVRController(vrGamepad) {
  35308. var _this = _super.call(this, vrGamepad) || this;
  35309. _this._buttonIndexToObservableNameMap = [
  35310. 'onTrackpadChangedObservable',
  35311. 'onTriggerStateChangedObservable' // Trigger
  35312. ];
  35313. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35314. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35315. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35316. _this._disableTrackPosition(_this._calculatedPosition);
  35317. return _this;
  35318. }
  35319. /**
  35320. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35321. * @param scene scene in which to add meshes
  35322. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35323. */
  35324. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35325. var _this = this;
  35326. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35327. // Offset the controller so it will rotate around the users wrist
  35328. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35329. newMeshes[1].parent = mesh;
  35330. newMeshes[1].position.z = -0.15;
  35331. _this._defaultModel = mesh;
  35332. _this.attachToMesh(_this._defaultModel);
  35333. if (meshLoaded) {
  35334. meshLoaded(_this._defaultModel);
  35335. }
  35336. });
  35337. };
  35338. /**
  35339. * Called once for each button that changed state since the last frame
  35340. * @param buttonIdx Which button index changed
  35341. * @param state New state of the button
  35342. * @param changes Which properties on the state changed since last frame
  35343. */
  35344. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35345. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35346. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35347. // Only emit events for buttons that we know how to map from index to observable
  35348. var observable = this[observableName];
  35349. if (observable) {
  35350. observable.notifyObservers(state);
  35351. }
  35352. }
  35353. };
  35354. /**
  35355. * Base Url for the controller model.
  35356. */
  35357. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35358. /**
  35359. * File name for the controller model.
  35360. */
  35361. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35362. /**
  35363. * Gamepad Id prefix used to identify this controller.
  35364. */
  35365. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35366. return GearVRController;
  35367. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35368. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35369. canCreate: function (gamepadInfo) {
  35370. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35371. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35372. },
  35373. create: function (gamepadInfo) {
  35374. return new GearVRController(gamepadInfo);
  35375. }
  35376. });
  35377. /***/ }),
  35378. /***/ "./Gamepads/Controllers/genericController.ts":
  35379. /*!***************************************************!*\
  35380. !*** ./Gamepads/Controllers/genericController.ts ***!
  35381. \***************************************************/
  35382. /*! exports provided: GenericController */
  35383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35384. "use strict";
  35385. __webpack_require__.r(__webpack_exports__);
  35386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35387. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35388. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35389. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35390. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35391. /**
  35392. * Generic Controller
  35393. */
  35394. var GenericController = /** @class */ (function (_super) {
  35395. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35396. /**
  35397. * Creates a new GenericController from a gamepad
  35398. * @param vrGamepad the gamepad that the controller should be created from
  35399. */
  35400. function GenericController(vrGamepad) {
  35401. return _super.call(this, vrGamepad) || this;
  35402. }
  35403. /**
  35404. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35405. * @param scene scene in which to add meshes
  35406. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35407. */
  35408. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35409. var _this = this;
  35410. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35411. _this._defaultModel = newMeshes[1];
  35412. _this.attachToMesh(_this._defaultModel);
  35413. if (meshLoaded) {
  35414. meshLoaded(_this._defaultModel);
  35415. }
  35416. });
  35417. };
  35418. /**
  35419. * Called once for each button that changed state since the last frame
  35420. * @param buttonIdx Which button index changed
  35421. * @param state New state of the button
  35422. * @param changes Which properties on the state changed since last frame
  35423. */
  35424. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35425. console.log("Button id: " + buttonIdx + "state: ");
  35426. console.dir(state);
  35427. };
  35428. /**
  35429. * Base Url for the controller model.
  35430. */
  35431. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35432. /**
  35433. * File name for the controller model.
  35434. */
  35435. GenericController.MODEL_FILENAME = 'generic.babylon';
  35436. return GenericController;
  35437. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35438. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35439. /***/ }),
  35440. /***/ "./Gamepads/Controllers/index.ts":
  35441. /*!***************************************!*\
  35442. !*** ./Gamepads/Controllers/index.ts ***!
  35443. \***************************************/
  35444. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35446. "use strict";
  35447. __webpack_require__.r(__webpack_exports__);
  35448. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35450. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35452. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35454. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35456. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35460. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35462. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35464. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35466. /***/ }),
  35467. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35468. /*!*******************************************************!*\
  35469. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35470. \*******************************************************/
  35471. /*! exports provided: OculusTouchController */
  35472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35473. "use strict";
  35474. __webpack_require__.r(__webpack_exports__);
  35475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35476. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35477. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35478. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35479. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35480. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35481. /**
  35482. * Oculus Touch Controller
  35483. */
  35484. var OculusTouchController = /** @class */ (function (_super) {
  35485. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  35486. /**
  35487. * Creates a new OculusTouchController from a gamepad
  35488. * @param vrGamepad the gamepad that the controller should be created from
  35489. */
  35490. function OculusTouchController(vrGamepad) {
  35491. var _this = _super.call(this, vrGamepad) || this;
  35492. /**
  35493. * Fired when the secondary trigger on this controller is modified
  35494. */
  35495. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35496. /**
  35497. * Fired when the thumb rest on this controller is modified
  35498. */
  35499. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35500. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  35501. return _this;
  35502. }
  35503. /**
  35504. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35505. * @param scene scene in which to add meshes
  35506. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35507. */
  35508. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35509. var _this = this;
  35510. var meshName;
  35511. // Hand
  35512. if (this.hand === 'left') {
  35513. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  35514. }
  35515. else { // Right is the default if no hand is specified
  35516. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  35517. }
  35518. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  35519. /*
  35520. Parent Mesh name: oculus_touch_left
  35521. - body
  35522. - trigger
  35523. - thumbstick
  35524. - grip
  35525. - button_y
  35526. - button_x
  35527. - button_enter
  35528. */
  35529. _this._defaultModel = newMeshes[1];
  35530. _this.attachToMesh(_this._defaultModel);
  35531. if (meshLoaded) {
  35532. meshLoaded(_this._defaultModel);
  35533. }
  35534. });
  35535. };
  35536. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  35537. /**
  35538. * Fired when the A button on this controller is modified
  35539. */
  35540. get: function () {
  35541. if (this.hand === 'right') {
  35542. return this.onMainButtonStateChangedObservable;
  35543. }
  35544. else {
  35545. throw new Error('No A button on left hand');
  35546. }
  35547. },
  35548. enumerable: true,
  35549. configurable: true
  35550. });
  35551. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  35552. /**
  35553. * Fired when the B button on this controller is modified
  35554. */
  35555. get: function () {
  35556. if (this.hand === 'right') {
  35557. return this.onSecondaryButtonStateChangedObservable;
  35558. }
  35559. else {
  35560. throw new Error('No B button on left hand');
  35561. }
  35562. },
  35563. enumerable: true,
  35564. configurable: true
  35565. });
  35566. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35567. /**
  35568. * Fired when the X button on this controller is modified
  35569. */
  35570. get: function () {
  35571. if (this.hand === 'left') {
  35572. return this.onMainButtonStateChangedObservable;
  35573. }
  35574. else {
  35575. throw new Error('No X button on right hand');
  35576. }
  35577. },
  35578. enumerable: true,
  35579. configurable: true
  35580. });
  35581. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35582. /**
  35583. * Fired when the Y button on this controller is modified
  35584. */
  35585. get: function () {
  35586. if (this.hand === 'left') {
  35587. return this.onSecondaryButtonStateChangedObservable;
  35588. }
  35589. else {
  35590. throw new Error('No Y button on right hand');
  35591. }
  35592. },
  35593. enumerable: true,
  35594. configurable: true
  35595. });
  35596. /**
  35597. * Called once for each button that changed state since the last frame
  35598. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35599. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35600. * 2) secondary trigger (same)
  35601. * 3) A (right) X (left), touch, pressed = value
  35602. * 4) B / Y
  35603. * 5) thumb rest
  35604. * @param buttonIdx Which button index changed
  35605. * @param state New state of the button
  35606. * @param changes Which properties on the state changed since last frame
  35607. */
  35608. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35609. var notifyObject = state; //{ state: state, changes: changes };
  35610. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35611. switch (buttonIdx) {
  35612. case 0:
  35613. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35614. return;
  35615. case 1: // index trigger
  35616. if (this._defaultModel) {
  35617. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35618. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35619. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35620. }
  35621. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35622. return;
  35623. case 2: // secondary trigger
  35624. if (this._defaultModel) {
  35625. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35626. }
  35627. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35628. return;
  35629. case 3:
  35630. if (this._defaultModel) {
  35631. if (notifyObject.pressed) {
  35632. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35633. }
  35634. else {
  35635. (this._defaultModel.getChildren()[1]).position.y = 0;
  35636. }
  35637. }
  35638. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35639. return;
  35640. case 4:
  35641. if (this._defaultModel) {
  35642. if (notifyObject.pressed) {
  35643. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35644. }
  35645. else {
  35646. (this._defaultModel.getChildren()[2]).position.y = 0;
  35647. }
  35648. }
  35649. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35650. return;
  35651. case 5:
  35652. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35653. return;
  35654. }
  35655. };
  35656. /**
  35657. * Base Url for the controller model.
  35658. */
  35659. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35660. /**
  35661. * File name for the left controller model.
  35662. */
  35663. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35664. /**
  35665. * File name for the right controller model.
  35666. */
  35667. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35668. return OculusTouchController;
  35669. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35670. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35671. canCreate: function (gamepadInfo) {
  35672. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35673. },
  35674. create: function (gamepadInfo) {
  35675. return new OculusTouchController(gamepadInfo);
  35676. }
  35677. });
  35678. /***/ }),
  35679. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35680. /*!*******************************************************!*\
  35681. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35682. \*******************************************************/
  35683. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35685. "use strict";
  35686. __webpack_require__.r(__webpack_exports__);
  35687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35690. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35691. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35692. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35693. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35694. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35695. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35696. /**
  35697. * Defines the types of pose enabled controllers that are supported
  35698. */
  35699. var PoseEnabledControllerType;
  35700. (function (PoseEnabledControllerType) {
  35701. /**
  35702. * HTC Vive
  35703. */
  35704. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35705. /**
  35706. * Oculus Rift
  35707. */
  35708. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35709. /**
  35710. * Windows mixed reality
  35711. */
  35712. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35713. /**
  35714. * Samsung gear VR
  35715. */
  35716. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35717. /**
  35718. * Google Daydream
  35719. */
  35720. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35721. /**
  35722. * Generic
  35723. */
  35724. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35725. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35726. /**
  35727. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35728. */
  35729. var PoseEnabledControllerHelper = /** @class */ (function () {
  35730. function PoseEnabledControllerHelper() {
  35731. }
  35732. /**
  35733. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35734. * @param vrGamepad the gamepad to initialized
  35735. * @returns a vr controller of the type the gamepad identified as
  35736. */
  35737. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35738. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35739. var factory = _a[_i];
  35740. if (factory.canCreate(vrGamepad)) {
  35741. return factory.create(vrGamepad);
  35742. }
  35743. }
  35744. if (this._DefaultControllerFactory) {
  35745. return this._DefaultControllerFactory(vrGamepad);
  35746. }
  35747. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35748. };
  35749. /** @hidden */
  35750. PoseEnabledControllerHelper._ControllerFactories = [];
  35751. /** @hidden */
  35752. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35753. return PoseEnabledControllerHelper;
  35754. }());
  35755. /**
  35756. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35757. */
  35758. var PoseEnabledController = /** @class */ (function (_super) {
  35759. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35760. /**
  35761. * Creates a new PoseEnabledController from a gamepad
  35762. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35763. */
  35764. function PoseEnabledController(browserGamepad) {
  35765. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35766. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35767. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35768. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35769. /**
  35770. * The device position in babylon space
  35771. */
  35772. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35773. /**
  35774. * The device rotation in babylon space
  35775. */
  35776. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35777. /**
  35778. * The scale factor of the device in babylon space
  35779. */
  35780. _this.deviceScaleFactor = 1;
  35781. // Used to convert 6dof controllers to 3dof
  35782. _this._trackPosition = true;
  35783. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35784. _this._draggedRoomRotation = 0;
  35785. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35786. /**
  35787. * Internal, matrix used to convert room space to babylon space
  35788. * @hidden
  35789. */
  35790. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35791. /**
  35792. * Node to be used when casting a ray from the controller
  35793. * @hidden
  35794. */
  35795. _this._pointingPoseNode = null;
  35796. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35797. /**
  35798. * @hidden
  35799. */
  35800. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35801. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35802. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35803. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35804. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35805. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35806. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35807. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35808. return _this;
  35809. }
  35810. /**
  35811. * @hidden
  35812. */
  35813. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35814. if (this._trackPosition) {
  35815. this._calculatedPosition.copyFrom(fixedPosition);
  35816. this._trackPosition = false;
  35817. }
  35818. };
  35819. /**
  35820. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35821. */
  35822. PoseEnabledController.prototype.update = function () {
  35823. _super.prototype.update.call(this);
  35824. this._updatePoseAndMesh();
  35825. };
  35826. /**
  35827. * Updates only the pose device and mesh without doing any button event checking
  35828. */
  35829. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35830. var pose = this.browserGamepad.pose;
  35831. this.updateFromDevice(pose);
  35832. 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) {
  35833. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35834. camera._computeDevicePosition();
  35835. this._deviceToWorld.setTranslation(camera.devicePosition);
  35836. if (camera.deviceRotationQuaternion) {
  35837. var camera = camera;
  35838. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35839. // Find the radian distance away that the headset is from the controllers rotation
  35840. 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));
  35841. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35842. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35843. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35844. this._draggedRoomRotation += rotationAmount;
  35845. // Rotate controller around headset
  35846. var sin = Math.sin(-rotationAmount);
  35847. var cos = Math.cos(-rotationAmount);
  35848. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35849. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35850. }
  35851. }
  35852. }
  35853. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35854. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35855. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35856. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35857. if (this._mesh) {
  35858. this._mesh.position.copyFrom(this.devicePosition);
  35859. if (this._mesh.rotationQuaternion) {
  35860. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35861. }
  35862. }
  35863. };
  35864. /**
  35865. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35866. * @param poseData raw pose fromthe device
  35867. */
  35868. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35869. if (poseData) {
  35870. this.rawPose = poseData;
  35871. if (poseData.position) {
  35872. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35873. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35874. this._deviceRoomPosition.z *= -1;
  35875. }
  35876. if (this._trackPosition) {
  35877. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35878. }
  35879. this._calculatedPosition.addInPlace(this.position);
  35880. }
  35881. var pose = this.rawPose;
  35882. if (poseData.orientation && pose.orientation) {
  35883. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35884. if (this._mesh) {
  35885. if (this._mesh.getScene().useRightHandedSystem) {
  35886. this._deviceRoomRotationQuaternion.z *= -1;
  35887. this._deviceRoomRotationQuaternion.w *= -1;
  35888. }
  35889. else {
  35890. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35891. }
  35892. }
  35893. // if the camera is set, rotate to the camera's rotation
  35894. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35895. }
  35896. }
  35897. };
  35898. /**
  35899. * Attaches a mesh to the controller
  35900. * @param mesh the mesh to be attached
  35901. */
  35902. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35903. if (this._mesh) {
  35904. this._mesh.parent = null;
  35905. }
  35906. this._mesh = mesh;
  35907. if (this._poseControlledCamera) {
  35908. this._mesh.parent = this._poseControlledCamera;
  35909. }
  35910. if (!this._mesh.rotationQuaternion) {
  35911. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35912. }
  35913. // 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
  35914. this._updatePoseAndMesh();
  35915. if (this._pointingPoseNode) {
  35916. var parents = [];
  35917. var obj = this._pointingPoseNode;
  35918. while (obj.parent) {
  35919. parents.push(obj.parent);
  35920. obj = obj.parent;
  35921. }
  35922. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35923. }
  35924. this._meshAttachedObservable.notifyObservers(mesh);
  35925. };
  35926. /**
  35927. * Attaches the controllers mesh to a camera
  35928. * @param camera the camera the mesh should be attached to
  35929. */
  35930. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35931. this._poseControlledCamera = camera;
  35932. if (this._mesh) {
  35933. this._mesh.parent = this._poseControlledCamera;
  35934. }
  35935. };
  35936. /**
  35937. * Disposes of the controller
  35938. */
  35939. PoseEnabledController.prototype.dispose = function () {
  35940. if (this._mesh) {
  35941. this._mesh.dispose();
  35942. }
  35943. this._mesh = null;
  35944. _super.prototype.dispose.call(this);
  35945. };
  35946. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35947. /**
  35948. * The mesh that is attached to the controller
  35949. */
  35950. get: function () {
  35951. return this._mesh;
  35952. },
  35953. enumerable: true,
  35954. configurable: true
  35955. });
  35956. /**
  35957. * Gets the ray of the controller in the direction the controller is pointing
  35958. * @param length the length the resulting ray should be
  35959. * @returns a ray in the direction the controller is pointing
  35960. */
  35961. PoseEnabledController.prototype.getForwardRay = function (length) {
  35962. if (length === void 0) { length = 100; }
  35963. if (!this.mesh) {
  35964. 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);
  35965. }
  35966. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35967. var origin = m.getTranslation();
  35968. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35969. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35970. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35971. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35972. };
  35973. /**
  35974. * Name of the child mesh that can be used to cast a ray from the controller
  35975. */
  35976. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35977. return PoseEnabledController;
  35978. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35979. /***/ }),
  35980. /***/ "./Gamepads/Controllers/viveController.ts":
  35981. /*!************************************************!*\
  35982. !*** ./Gamepads/Controllers/viveController.ts ***!
  35983. \************************************************/
  35984. /*! exports provided: ViveController */
  35985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35986. "use strict";
  35987. __webpack_require__.r(__webpack_exports__);
  35988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35989. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35990. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35991. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35992. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35993. /**
  35994. * Vive Controller
  35995. */
  35996. var ViveController = /** @class */ (function (_super) {
  35997. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35998. /**
  35999. * Creates a new ViveController from a gamepad
  36000. * @param vrGamepad the gamepad that the controller should be created from
  36001. */
  36002. function ViveController(vrGamepad) {
  36003. var _this = _super.call(this, vrGamepad) || this;
  36004. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  36005. _this._invertLeftStickY = true;
  36006. return _this;
  36007. }
  36008. /**
  36009. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36010. * @param scene scene in which to add meshes
  36011. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36012. */
  36013. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  36014. var _this = this;
  36015. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  36016. /*
  36017. Parent Mesh name: ViveWand
  36018. - body
  36019. - r_gripper
  36020. - l_gripper
  36021. - menu_button
  36022. - system_button
  36023. - trackpad
  36024. - trigger
  36025. - LED
  36026. */
  36027. _this._defaultModel = newMeshes[1];
  36028. _this.attachToMesh(_this._defaultModel);
  36029. if (meshLoaded) {
  36030. meshLoaded(_this._defaultModel);
  36031. }
  36032. });
  36033. };
  36034. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  36035. /**
  36036. * Fired when the left button on this controller is modified
  36037. */
  36038. get: function () {
  36039. return this.onMainButtonStateChangedObservable;
  36040. },
  36041. enumerable: true,
  36042. configurable: true
  36043. });
  36044. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  36045. /**
  36046. * Fired when the right button on this controller is modified
  36047. */
  36048. get: function () {
  36049. return this.onMainButtonStateChangedObservable;
  36050. },
  36051. enumerable: true,
  36052. configurable: true
  36053. });
  36054. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  36055. /**
  36056. * Fired when the menu button on this controller is modified
  36057. */
  36058. get: function () {
  36059. return this.onSecondaryButtonStateChangedObservable;
  36060. },
  36061. enumerable: true,
  36062. configurable: true
  36063. });
  36064. /**
  36065. * Called once for each button that changed state since the last frame
  36066. * Vive mapping:
  36067. * 0: touchpad
  36068. * 1: trigger
  36069. * 2: left AND right buttons
  36070. * 3: menu button
  36071. * @param buttonIdx Which button index changed
  36072. * @param state New state of the button
  36073. * @param changes Which properties on the state changed since last frame
  36074. */
  36075. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36076. var notifyObject = state; //{ state: state, changes: changes };
  36077. switch (buttonIdx) {
  36078. case 0:
  36079. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36080. return;
  36081. case 1: // index trigger
  36082. if (this._defaultModel) {
  36083. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  36084. }
  36085. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36086. return;
  36087. case 2: // left AND right button
  36088. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36089. return;
  36090. case 3:
  36091. if (this._defaultModel) {
  36092. if (notifyObject.pressed) {
  36093. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36094. }
  36095. else {
  36096. (this._defaultModel.getChildren()[2]).position.y = 0;
  36097. }
  36098. }
  36099. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36100. return;
  36101. }
  36102. };
  36103. /**
  36104. * Base Url for the controller model.
  36105. */
  36106. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36107. /**
  36108. * File name for the controller model.
  36109. */
  36110. ViveController.MODEL_FILENAME = 'wand.babylon';
  36111. return ViveController;
  36112. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36113. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36114. canCreate: function (gamepadInfo) {
  36115. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36116. },
  36117. create: function (gamepadInfo) {
  36118. return new ViveController(gamepadInfo);
  36119. }
  36120. });
  36121. /***/ }),
  36122. /***/ "./Gamepads/Controllers/webVRController.ts":
  36123. /*!*************************************************!*\
  36124. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36125. \*************************************************/
  36126. /*! exports provided: WebVRController */
  36127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36128. "use strict";
  36129. __webpack_require__.r(__webpack_exports__);
  36130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36132. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36133. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36134. /**
  36135. * Defines the WebVRController object that represents controllers tracked in 3D space
  36136. */
  36137. var WebVRController = /** @class */ (function (_super) {
  36138. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36139. /**
  36140. * Creates a new WebVRController from a gamepad
  36141. * @param vrGamepad the gamepad that the WebVRController should be created from
  36142. */
  36143. function WebVRController(vrGamepad) {
  36144. var _this = _super.call(this, vrGamepad) || this;
  36145. // Observables
  36146. /**
  36147. * Fired when the trigger state has changed
  36148. */
  36149. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36150. /**
  36151. * Fired when the main button state has changed
  36152. */
  36153. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36154. /**
  36155. * Fired when the secondary button state has changed
  36156. */
  36157. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36158. /**
  36159. * Fired when the pad state has changed
  36160. */
  36161. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36162. /**
  36163. * Fired when controllers stick values have changed
  36164. */
  36165. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36166. /**
  36167. * X and Y axis corrisponding to the controllers joystick
  36168. */
  36169. _this.pad = { x: 0, y: 0 };
  36170. // avoid GC, store state in a tmp object
  36171. _this._changes = {
  36172. pressChanged: false,
  36173. touchChanged: false,
  36174. valueChanged: false,
  36175. changed: false
  36176. };
  36177. _this._buttons = new Array(vrGamepad.buttons.length);
  36178. _this.hand = vrGamepad.hand;
  36179. return _this;
  36180. }
  36181. /**
  36182. * Fired when a controller button's state has changed
  36183. * @param callback the callback containing the button that was modified
  36184. */
  36185. WebVRController.prototype.onButtonStateChange = function (callback) {
  36186. this._onButtonStateChange = callback;
  36187. };
  36188. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36189. /**
  36190. * The default controller model for the controller
  36191. */
  36192. get: function () {
  36193. return this._defaultModel;
  36194. },
  36195. enumerable: true,
  36196. configurable: true
  36197. });
  36198. /**
  36199. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36200. */
  36201. WebVRController.prototype.update = function () {
  36202. _super.prototype.update.call(this);
  36203. for (var index = 0; index < this._buttons.length; index++) {
  36204. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36205. }
  36206. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36207. this.pad.x = this.leftStick.x;
  36208. this.pad.y = this.leftStick.y;
  36209. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36210. }
  36211. };
  36212. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36213. if (!newState) {
  36214. newState = {
  36215. pressed: false,
  36216. touched: false,
  36217. value: 0
  36218. };
  36219. }
  36220. if (!currentState) {
  36221. this._buttons[buttonIndex] = {
  36222. pressed: newState.pressed,
  36223. touched: newState.touched,
  36224. value: newState.value
  36225. };
  36226. return;
  36227. }
  36228. this._checkChanges(newState, currentState);
  36229. if (this._changes.changed) {
  36230. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36231. this._handleButtonChange(buttonIndex, newState, this._changes);
  36232. }
  36233. this._buttons[buttonIndex].pressed = newState.pressed;
  36234. this._buttons[buttonIndex].touched = newState.touched;
  36235. // oculus triggers are never 0, thou not touched.
  36236. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36237. };
  36238. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36239. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36240. this._changes.touchChanged = newState.touched !== currentState.touched;
  36241. this._changes.valueChanged = newState.value !== currentState.value;
  36242. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36243. return this._changes;
  36244. };
  36245. /**
  36246. * Disposes of th webVRCOntroller
  36247. */
  36248. WebVRController.prototype.dispose = function () {
  36249. _super.prototype.dispose.call(this);
  36250. this.onTriggerStateChangedObservable.clear();
  36251. this.onMainButtonStateChangedObservable.clear();
  36252. this.onSecondaryButtonStateChangedObservable.clear();
  36253. this.onPadStateChangedObservable.clear();
  36254. this.onPadValuesChangedObservable.clear();
  36255. };
  36256. return WebVRController;
  36257. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36258. /***/ }),
  36259. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36260. /*!*********************************************************!*\
  36261. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36262. \*********************************************************/
  36263. /*! exports provided: WindowsMotionController */
  36264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36265. "use strict";
  36266. __webpack_require__.r(__webpack_exports__);
  36267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36268. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36269. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36270. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36271. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36272. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36273. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36274. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36275. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36276. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36277. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36278. /**
  36279. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36280. */
  36281. var LoadedMeshInfo = /** @class */ (function () {
  36282. function LoadedMeshInfo() {
  36283. /**
  36284. * Map of the button meshes contained in the controller
  36285. */
  36286. this.buttonMeshes = {};
  36287. /**
  36288. * Map of the axis meshes contained in the controller
  36289. */
  36290. this.axisMeshes = {};
  36291. }
  36292. return LoadedMeshInfo;
  36293. }());
  36294. /**
  36295. * Defines the WindowsMotionController object that the state of the windows motion controller
  36296. */
  36297. var WindowsMotionController = /** @class */ (function (_super) {
  36298. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36299. /**
  36300. * Creates a new WindowsMotionController from a gamepad
  36301. * @param vrGamepad the gamepad that the controller should be created from
  36302. */
  36303. function WindowsMotionController(vrGamepad) {
  36304. var _this = _super.call(this, vrGamepad) || this;
  36305. _this._mapping = {
  36306. // Semantic button names
  36307. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36308. // A mapping of the button name to glTF model node name
  36309. // that should be transformed by button value.
  36310. buttonMeshNames: {
  36311. 'trigger': 'SELECT',
  36312. 'menu': 'MENU',
  36313. 'grip': 'GRASP',
  36314. 'thumbstick': 'THUMBSTICK_PRESS',
  36315. 'trackpad': 'TOUCHPAD_PRESS'
  36316. },
  36317. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36318. buttonObservableNames: {
  36319. 'trigger': 'onTriggerStateChangedObservable',
  36320. 'menu': 'onSecondaryButtonStateChangedObservable',
  36321. 'grip': 'onMainButtonStateChangedObservable',
  36322. 'thumbstick': 'onPadStateChangedObservable',
  36323. 'trackpad': 'onTrackpadChangedObservable'
  36324. },
  36325. // A mapping of the axis name to glTF model node name
  36326. // that should be transformed by axis value.
  36327. // This array mirrors the browserGamepad.axes array, such that
  36328. // the mesh corresponding to axis 0 is in this array index 0.
  36329. axisMeshNames: [
  36330. 'THUMBSTICK_X',
  36331. 'THUMBSTICK_Y',
  36332. 'TOUCHPAD_TOUCH_X',
  36333. 'TOUCHPAD_TOUCH_Y'
  36334. ],
  36335. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36336. };
  36337. /**
  36338. * Fired when the trackpad on this controller is clicked
  36339. */
  36340. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36341. /**
  36342. * Fired when the trackpad on this controller is modified
  36343. */
  36344. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36345. /**
  36346. * The current x and y values of this controller's trackpad
  36347. */
  36348. _this.trackpad = { x: 0, y: 0 };
  36349. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36350. _this._loadedMeshInfo = null;
  36351. return _this;
  36352. }
  36353. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36354. /**
  36355. * Fired when the trigger on this controller is modified
  36356. */
  36357. get: function () {
  36358. return this.onTriggerStateChangedObservable;
  36359. },
  36360. enumerable: true,
  36361. configurable: true
  36362. });
  36363. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36364. /**
  36365. * Fired when the menu button on this controller is modified
  36366. */
  36367. get: function () {
  36368. return this.onSecondaryButtonStateChangedObservable;
  36369. },
  36370. enumerable: true,
  36371. configurable: true
  36372. });
  36373. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36374. /**
  36375. * Fired when the grip button on this controller is modified
  36376. */
  36377. get: function () {
  36378. return this.onMainButtonStateChangedObservable;
  36379. },
  36380. enumerable: true,
  36381. configurable: true
  36382. });
  36383. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36384. /**
  36385. * Fired when the thumbstick button on this controller is modified
  36386. */
  36387. get: function () {
  36388. return this.onPadStateChangedObservable;
  36389. },
  36390. enumerable: true,
  36391. configurable: true
  36392. });
  36393. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36394. /**
  36395. * Fired when the touchpad button on this controller is modified
  36396. */
  36397. get: function () {
  36398. return this.onTrackpadChangedObservable;
  36399. },
  36400. enumerable: true,
  36401. configurable: true
  36402. });
  36403. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36404. /**
  36405. * Fired when the touchpad values on this controller are modified
  36406. */
  36407. get: function () {
  36408. return this.onTrackpadValuesChangedObservable;
  36409. },
  36410. enumerable: true,
  36411. configurable: true
  36412. });
  36413. WindowsMotionController.prototype._updateTrackpad = function () {
  36414. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36415. this.trackpad.x = this.browserGamepad["axes"][2];
  36416. this.trackpad.y = this.browserGamepad["axes"][3];
  36417. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36418. }
  36419. };
  36420. /**
  36421. * Called once per frame by the engine.
  36422. */
  36423. WindowsMotionController.prototype.update = function () {
  36424. _super.prototype.update.call(this);
  36425. if (this.browserGamepad.axes) {
  36426. this._updateTrackpad();
  36427. // Only need to animate axes if there is a loaded mesh
  36428. if (this._loadedMeshInfo) {
  36429. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36430. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36431. }
  36432. }
  36433. }
  36434. };
  36435. /**
  36436. * Called once for each button that changed state since the last frame
  36437. * @param buttonIdx Which button index changed
  36438. * @param state New state of the button
  36439. * @param changes Which properties on the state changed since last frame
  36440. */
  36441. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36442. var buttonName = this._mapping.buttons[buttonIdx];
  36443. if (!buttonName) {
  36444. return;
  36445. }
  36446. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36447. this._updateTrackpad();
  36448. // Only emit events for buttons that we know how to map from index to name
  36449. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36450. if (observable) {
  36451. observable.notifyObservers(state);
  36452. }
  36453. this._lerpButtonTransform(buttonName, state.value);
  36454. };
  36455. /**
  36456. * Moves the buttons on the controller mesh based on their current state
  36457. * @param buttonName the name of the button to move
  36458. * @param buttonValue the value of the button which determines the buttons new position
  36459. */
  36460. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36461. // If there is no loaded mesh, there is nothing to transform.
  36462. if (!this._loadedMeshInfo) {
  36463. return;
  36464. }
  36465. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36466. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36467. return;
  36468. }
  36469. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36470. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36471. };
  36472. /**
  36473. * Moves the axis on the controller mesh based on its current state
  36474. * @param axis the index of the axis
  36475. * @param axisValue the value of the axis which determines the meshes new position
  36476. * @hidden
  36477. */
  36478. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36479. if (!this._loadedMeshInfo) {
  36480. return;
  36481. }
  36482. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36483. if (!meshInfo) {
  36484. return;
  36485. }
  36486. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36487. return;
  36488. }
  36489. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  36490. var lerpValue = axisValue * 0.5 + 0.5;
  36491. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  36492. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  36493. };
  36494. /**
  36495. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36496. * @param scene scene in which to add meshes
  36497. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36498. */
  36499. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  36500. var _this = this;
  36501. if (forceDefault === void 0) { forceDefault = false; }
  36502. var path;
  36503. var filename;
  36504. // Checking if GLB loader is present
  36505. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  36506. // Determine the device specific folder based on the ID suffix
  36507. var device = 'default';
  36508. if (this.id && !forceDefault) {
  36509. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  36510. device = ((match && match[0]) || device);
  36511. }
  36512. // Hand
  36513. if (this.hand === 'left') {
  36514. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  36515. }
  36516. else { // Right is the default if no hand is specified
  36517. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  36518. }
  36519. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  36520. }
  36521. else {
  36522. _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");
  36523. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  36524. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  36525. }
  36526. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  36527. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  36528. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  36529. if (!_this._loadedMeshInfo) {
  36530. return;
  36531. }
  36532. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  36533. _this.attachToMesh(_this._defaultModel);
  36534. if (meshLoaded) {
  36535. meshLoaded(_this._defaultModel);
  36536. }
  36537. }, null, function (scene, message) {
  36538. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  36539. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  36540. if (!forceDefault) {
  36541. _this.initControllerMesh(scene, meshLoaded, true);
  36542. }
  36543. });
  36544. };
  36545. /**
  36546. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36547. * can be transformed by button presses and axes values, based on this._mapping.
  36548. *
  36549. * @param scene scene in which the meshes exist
  36550. * @param meshes list of meshes that make up the controller model to process
  36551. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36552. */
  36553. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  36554. var loadedMeshInfo = null;
  36555. // Create a new mesh to contain the glTF hierarchy
  36556. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  36557. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  36558. var childMesh = null;
  36559. for (var i = 0; i < meshes.length; i++) {
  36560. var mesh = meshes[i];
  36561. if (!mesh.parent) {
  36562. // Exclude controller meshes from picking results
  36563. mesh.isPickable = false;
  36564. // Handle root node, attach to the new parentMesh
  36565. childMesh = mesh;
  36566. break;
  36567. }
  36568. }
  36569. if (childMesh) {
  36570. childMesh.setParent(parentMesh);
  36571. // Create our mesh info. Note that this method will always return non-null.
  36572. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36573. }
  36574. else {
  36575. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36576. }
  36577. return loadedMeshInfo;
  36578. };
  36579. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36580. var loadedMeshInfo = new LoadedMeshInfo();
  36581. var i;
  36582. loadedMeshInfo.rootNode = rootNode;
  36583. // Reset the caches
  36584. loadedMeshInfo.buttonMeshes = {};
  36585. loadedMeshInfo.axisMeshes = {};
  36586. // Button Meshes
  36587. for (i = 0; i < this._mapping.buttons.length; i++) {
  36588. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36589. if (!buttonMeshName) {
  36590. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36591. continue;
  36592. }
  36593. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36594. if (!buttonMesh) {
  36595. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36596. continue;
  36597. }
  36598. var buttonMeshInfo = {
  36599. index: i,
  36600. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36601. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36602. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36603. };
  36604. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36605. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36606. }
  36607. else {
  36608. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36609. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36610. '(VALUE: ' + !!buttonMeshInfo.value +
  36611. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36612. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36613. ')');
  36614. }
  36615. }
  36616. // Axis Meshes
  36617. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36618. var axisMeshName = this._mapping.axisMeshNames[i];
  36619. if (!axisMeshName) {
  36620. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36621. continue;
  36622. }
  36623. var axisMesh = getChildByName(rootNode, axisMeshName);
  36624. if (!axisMesh) {
  36625. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36626. continue;
  36627. }
  36628. var axisMeshInfo = {
  36629. index: i,
  36630. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36631. min: getImmediateChildByName(axisMesh, 'MIN'),
  36632. max: getImmediateChildByName(axisMesh, 'MAX')
  36633. };
  36634. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36635. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36636. }
  36637. else {
  36638. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36639. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36640. '(VALUE: ' + !!axisMeshInfo.value +
  36641. ', MIN: ' + !!axisMeshInfo.min +
  36642. ', MAX:' + !!axisMeshInfo.max +
  36643. ')');
  36644. }
  36645. }
  36646. // Pointing Ray
  36647. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36648. if (!loadedMeshInfo.pointingPoseNode) {
  36649. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36650. }
  36651. else {
  36652. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36653. }
  36654. return loadedMeshInfo;
  36655. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36656. function getChildByName(node, name) {
  36657. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36658. }
  36659. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36660. function getImmediateChildByName(node, name) {
  36661. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36662. }
  36663. };
  36664. /**
  36665. * Gets the ray of the controller in the direction the controller is pointing
  36666. * @param length the length the resulting ray should be
  36667. * @returns a ray in the direction the controller is pointing
  36668. */
  36669. WindowsMotionController.prototype.getForwardRay = function (length) {
  36670. if (length === void 0) { length = 100; }
  36671. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36672. return _super.prototype.getForwardRay.call(this, length);
  36673. }
  36674. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36675. var origin = m.getTranslation();
  36676. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36677. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36678. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36679. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36680. };
  36681. /**
  36682. * Disposes of the controller
  36683. */
  36684. WindowsMotionController.prototype.dispose = function () {
  36685. _super.prototype.dispose.call(this);
  36686. this.onTrackpadChangedObservable.clear();
  36687. };
  36688. /**
  36689. * The base url used to load the left and right controller models
  36690. */
  36691. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36692. /**
  36693. * The name of the left controller model file
  36694. */
  36695. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36696. /**
  36697. * The name of the right controller model file
  36698. */
  36699. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36700. /**
  36701. * The controller name prefix for this controller type
  36702. */
  36703. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36704. /**
  36705. * The controller id pattern for this controller type
  36706. */
  36707. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36708. return WindowsMotionController;
  36709. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36710. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36711. canCreate: function (gamepadInfo) {
  36712. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36713. },
  36714. create: function (gamepadInfo) {
  36715. return new WindowsMotionController(gamepadInfo);
  36716. }
  36717. });
  36718. /***/ }),
  36719. /***/ "./Gamepads/gamepad.ts":
  36720. /*!*****************************!*\
  36721. !*** ./Gamepads/gamepad.ts ***!
  36722. \*****************************/
  36723. /*! exports provided: StickValues, Gamepad, GenericPad */
  36724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36725. "use strict";
  36726. __webpack_require__.r(__webpack_exports__);
  36727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36731. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36732. /**
  36733. * Represents a gamepad control stick position
  36734. */
  36735. var StickValues = /** @class */ (function () {
  36736. /**
  36737. * Initializes the gamepad x and y control stick values
  36738. * @param x The x component of the gamepad control stick value
  36739. * @param y The y component of the gamepad control stick value
  36740. */
  36741. function StickValues(
  36742. /**
  36743. * The x component of the control stick
  36744. */
  36745. x,
  36746. /**
  36747. * The y component of the control stick
  36748. */
  36749. y) {
  36750. this.x = x;
  36751. this.y = y;
  36752. }
  36753. return StickValues;
  36754. }());
  36755. /**
  36756. * Represents a gamepad
  36757. */
  36758. var Gamepad = /** @class */ (function () {
  36759. /**
  36760. * Initializes the gamepad
  36761. * @param id The id of the gamepad
  36762. * @param index The index of the gamepad
  36763. * @param browserGamepad The browser gamepad
  36764. * @param leftStickX The x component of the left joystick
  36765. * @param leftStickY The y component of the left joystick
  36766. * @param rightStickX The x component of the right joystick
  36767. * @param rightStickY The y component of the right joystick
  36768. */
  36769. function Gamepad(
  36770. /**
  36771. * The id of the gamepad
  36772. */
  36773. id,
  36774. /**
  36775. * The index of the gamepad
  36776. */
  36777. index,
  36778. /**
  36779. * The browser gamepad
  36780. */
  36781. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36782. if (leftStickX === void 0) { leftStickX = 0; }
  36783. if (leftStickY === void 0) { leftStickY = 1; }
  36784. if (rightStickX === void 0) { rightStickX = 2; }
  36785. if (rightStickY === void 0) { rightStickY = 3; }
  36786. this.id = id;
  36787. this.index = index;
  36788. this.browserGamepad = browserGamepad;
  36789. this._leftStick = { x: 0, y: 0 };
  36790. this._rightStick = { x: 0, y: 0 };
  36791. /** @hidden */
  36792. this._isConnected = true;
  36793. /**
  36794. * Specifies whether the left control stick should be Y-inverted
  36795. */
  36796. this._invertLeftStickY = false;
  36797. this.type = Gamepad.GAMEPAD;
  36798. this._leftStickAxisX = leftStickX;
  36799. this._leftStickAxisY = leftStickY;
  36800. this._rightStickAxisX = rightStickX;
  36801. this._rightStickAxisY = rightStickY;
  36802. if (this.browserGamepad.axes.length >= 2) {
  36803. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36804. }
  36805. if (this.browserGamepad.axes.length >= 4) {
  36806. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36807. }
  36808. }
  36809. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36810. /**
  36811. * Specifies if the gamepad has been connected
  36812. */
  36813. get: function () {
  36814. return this._isConnected;
  36815. },
  36816. enumerable: true,
  36817. configurable: true
  36818. });
  36819. /**
  36820. * Callback triggered when the left joystick has changed
  36821. * @param callback
  36822. */
  36823. Gamepad.prototype.onleftstickchanged = function (callback) {
  36824. this._onleftstickchanged = callback;
  36825. };
  36826. /**
  36827. * Callback triggered when the right joystick has changed
  36828. * @param callback
  36829. */
  36830. Gamepad.prototype.onrightstickchanged = function (callback) {
  36831. this._onrightstickchanged = callback;
  36832. };
  36833. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36834. /**
  36835. * Gets the left joystick
  36836. */
  36837. get: function () {
  36838. return this._leftStick;
  36839. },
  36840. /**
  36841. * Sets the left joystick values
  36842. */
  36843. set: function (newValues) {
  36844. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36845. this._onleftstickchanged(newValues);
  36846. }
  36847. this._leftStick = newValues;
  36848. },
  36849. enumerable: true,
  36850. configurable: true
  36851. });
  36852. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36853. /**
  36854. * Gets the right joystick
  36855. */
  36856. get: function () {
  36857. return this._rightStick;
  36858. },
  36859. /**
  36860. * Sets the right joystick value
  36861. */
  36862. set: function (newValues) {
  36863. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36864. this._onrightstickchanged(newValues);
  36865. }
  36866. this._rightStick = newValues;
  36867. },
  36868. enumerable: true,
  36869. configurable: true
  36870. });
  36871. /**
  36872. * Updates the gamepad joystick positions
  36873. */
  36874. Gamepad.prototype.update = function () {
  36875. if (this._leftStick) {
  36876. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36877. if (this._invertLeftStickY) {
  36878. this.leftStick.y *= -1;
  36879. }
  36880. }
  36881. if (this._rightStick) {
  36882. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36883. }
  36884. };
  36885. /**
  36886. * Disposes the gamepad
  36887. */
  36888. Gamepad.prototype.dispose = function () {
  36889. };
  36890. /**
  36891. * Represents a gamepad controller
  36892. */
  36893. Gamepad.GAMEPAD = 0;
  36894. /**
  36895. * Represents a generic controller
  36896. */
  36897. Gamepad.GENERIC = 1;
  36898. /**
  36899. * Represents an XBox controller
  36900. */
  36901. Gamepad.XBOX = 2;
  36902. /**
  36903. * Represents a pose-enabled controller
  36904. */
  36905. Gamepad.POSE_ENABLED = 3;
  36906. return Gamepad;
  36907. }());
  36908. /**
  36909. * Represents a generic gamepad
  36910. */
  36911. var GenericPad = /** @class */ (function (_super) {
  36912. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36913. /**
  36914. * Initializes the generic gamepad
  36915. * @param id The id of the generic gamepad
  36916. * @param index The index of the generic gamepad
  36917. * @param browserGamepad The browser gamepad
  36918. */
  36919. function GenericPad(id, index, browserGamepad) {
  36920. var _this = _super.call(this, id, index, browserGamepad) || this;
  36921. /**
  36922. * Observable triggered when a button has been pressed
  36923. */
  36924. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36925. /**
  36926. * Observable triggered when a button has been released
  36927. */
  36928. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36929. _this.type = Gamepad.GENERIC;
  36930. _this._buttons = new Array(browserGamepad.buttons.length);
  36931. return _this;
  36932. }
  36933. /**
  36934. * Callback triggered when a button has been pressed
  36935. * @param callback Called when a button has been pressed
  36936. */
  36937. GenericPad.prototype.onbuttondown = function (callback) {
  36938. this._onbuttondown = callback;
  36939. };
  36940. /**
  36941. * Callback triggered when a button has been released
  36942. * @param callback Called when a button has been released
  36943. */
  36944. GenericPad.prototype.onbuttonup = function (callback) {
  36945. this._onbuttonup = callback;
  36946. };
  36947. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36948. if (newValue !== currentValue) {
  36949. if (newValue === 1) {
  36950. if (this._onbuttondown) {
  36951. this._onbuttondown(buttonIndex);
  36952. }
  36953. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36954. }
  36955. if (newValue === 0) {
  36956. if (this._onbuttonup) {
  36957. this._onbuttonup(buttonIndex);
  36958. }
  36959. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36960. }
  36961. }
  36962. return newValue;
  36963. };
  36964. /**
  36965. * Updates the generic gamepad
  36966. */
  36967. GenericPad.prototype.update = function () {
  36968. _super.prototype.update.call(this);
  36969. for (var index = 0; index < this._buttons.length; index++) {
  36970. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36971. }
  36972. };
  36973. /**
  36974. * Disposes the generic gamepad
  36975. */
  36976. GenericPad.prototype.dispose = function () {
  36977. _super.prototype.dispose.call(this);
  36978. this.onButtonDownObservable.clear();
  36979. this.onButtonUpObservable.clear();
  36980. };
  36981. return GenericPad;
  36982. }(Gamepad));
  36983. /***/ }),
  36984. /***/ "./Gamepads/gamepadManager.ts":
  36985. /*!************************************!*\
  36986. !*** ./Gamepads/gamepadManager.ts ***!
  36987. \************************************/
  36988. /*! exports provided: GamepadManager */
  36989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36990. "use strict";
  36991. __webpack_require__.r(__webpack_exports__);
  36992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36993. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36994. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36995. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36996. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36997. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36998. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36999. /**
  37000. * Manager for handling gamepads
  37001. */
  37002. var GamepadManager = /** @class */ (function () {
  37003. /**
  37004. * Initializes the gamepad manager
  37005. * @param _scene BabylonJS scene
  37006. */
  37007. function GamepadManager(_scene) {
  37008. var _this = this;
  37009. this._scene = _scene;
  37010. this._babylonGamepads = [];
  37011. this._oneGamepadConnected = false;
  37012. /** @hidden */
  37013. this._isMonitoring = false;
  37014. /**
  37015. * observable to be triggered when the gamepad controller has been disconnected
  37016. */
  37017. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37018. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  37019. this._gamepadEventSupported = false;
  37020. }
  37021. else {
  37022. this._gamepadEventSupported = 'GamepadEvent' in window;
  37023. this._gamepadSupport = (navigator.getGamepads ||
  37024. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  37025. }
  37026. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  37027. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  37028. for (var i in _this._babylonGamepads) {
  37029. var gamepad = _this._babylonGamepads[i];
  37030. if (gamepad && gamepad._isConnected) {
  37031. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  37032. }
  37033. }
  37034. });
  37035. this._onGamepadConnectedEvent = function (evt) {
  37036. var gamepad = evt.gamepad;
  37037. if (gamepad.index in _this._babylonGamepads) {
  37038. if (_this._babylonGamepads[gamepad.index].isConnected) {
  37039. return;
  37040. }
  37041. }
  37042. var newGamepad;
  37043. if (_this._babylonGamepads[gamepad.index]) {
  37044. newGamepad = _this._babylonGamepads[gamepad.index];
  37045. newGamepad.browserGamepad = gamepad;
  37046. newGamepad._isConnected = true;
  37047. }
  37048. else {
  37049. newGamepad = _this._addNewGamepad(gamepad);
  37050. }
  37051. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37052. _this._startMonitoringGamepads();
  37053. };
  37054. this._onGamepadDisconnectedEvent = function (evt) {
  37055. var gamepad = evt.gamepad;
  37056. // Remove the gamepad from the list of gamepads to monitor.
  37057. for (var i in _this._babylonGamepads) {
  37058. if (_this._babylonGamepads[i].index === gamepad.index) {
  37059. var disconnectedGamepad = _this._babylonGamepads[i];
  37060. disconnectedGamepad._isConnected = false;
  37061. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  37062. break;
  37063. }
  37064. }
  37065. };
  37066. if (this._gamepadSupport) {
  37067. //first add already-connected gamepads
  37068. this._updateGamepadObjects();
  37069. if (this._babylonGamepads.length) {
  37070. this._startMonitoringGamepads();
  37071. }
  37072. // Checking if the gamepad connected event is supported (like in Firefox)
  37073. if (this._gamepadEventSupported) {
  37074. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  37075. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  37076. }
  37077. else {
  37078. this._startMonitoringGamepads();
  37079. }
  37080. }
  37081. }
  37082. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  37083. /**
  37084. * The gamepads in the game pad manager
  37085. */
  37086. get: function () {
  37087. return this._babylonGamepads;
  37088. },
  37089. enumerable: true,
  37090. configurable: true
  37091. });
  37092. /**
  37093. * Get the gamepad controllers based on type
  37094. * @param type The type of gamepad controller
  37095. * @returns Nullable gamepad
  37096. */
  37097. GamepadManager.prototype.getGamepadByType = function (type) {
  37098. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37099. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37100. var gamepad = _a[_i];
  37101. if (gamepad && gamepad.type === type) {
  37102. return gamepad;
  37103. }
  37104. }
  37105. return null;
  37106. };
  37107. /**
  37108. * Disposes the gamepad manager
  37109. */
  37110. GamepadManager.prototype.dispose = function () {
  37111. if (this._gamepadEventSupported) {
  37112. if (this._onGamepadConnectedEvent) {
  37113. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37114. }
  37115. if (this._onGamepadDisconnectedEvent) {
  37116. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37117. }
  37118. this._onGamepadConnectedEvent = null;
  37119. this._onGamepadDisconnectedEvent = null;
  37120. }
  37121. this._babylonGamepads.forEach(function (gamepad) {
  37122. gamepad.dispose();
  37123. });
  37124. this.onGamepadConnectedObservable.clear();
  37125. this.onGamepadDisconnectedObservable.clear();
  37126. this._oneGamepadConnected = false;
  37127. this._stopMonitoringGamepads();
  37128. this._babylonGamepads = [];
  37129. };
  37130. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37131. if (!this._oneGamepadConnected) {
  37132. this._oneGamepadConnected = true;
  37133. }
  37134. var newGamepad;
  37135. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37136. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37137. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37138. }
  37139. // if pose is supported, use the (WebVR) pose enabled controller
  37140. else if (gamepad.pose) {
  37141. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37142. }
  37143. else {
  37144. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37145. }
  37146. this._babylonGamepads[newGamepad.index] = newGamepad;
  37147. return newGamepad;
  37148. };
  37149. GamepadManager.prototype._startMonitoringGamepads = function () {
  37150. if (!this._isMonitoring) {
  37151. this._isMonitoring = true;
  37152. //back-comp
  37153. if (!this._scene) {
  37154. this._checkGamepadsStatus();
  37155. }
  37156. }
  37157. };
  37158. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37159. this._isMonitoring = false;
  37160. };
  37161. /** @hidden */
  37162. GamepadManager.prototype._checkGamepadsStatus = function () {
  37163. var _this = this;
  37164. // Hack to be compatible Chrome
  37165. this._updateGamepadObjects();
  37166. for (var i in this._babylonGamepads) {
  37167. var gamepad = this._babylonGamepads[i];
  37168. if (!gamepad || !gamepad.isConnected) {
  37169. continue;
  37170. }
  37171. gamepad.update();
  37172. }
  37173. if (this._isMonitoring && !this._scene) {
  37174. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37175. }
  37176. };
  37177. // This function is called only on Chrome, which does not properly support
  37178. // connection/disconnection events and forces you to recopy again the gamepad object
  37179. GamepadManager.prototype._updateGamepadObjects = function () {
  37180. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37181. for (var i = 0; i < gamepads.length; i++) {
  37182. var gamepad = gamepads[i];
  37183. if (gamepad) {
  37184. if (!this._babylonGamepads[gamepad.index]) {
  37185. var newGamepad = this._addNewGamepad(gamepad);
  37186. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37187. }
  37188. else {
  37189. // Forced to copy again this object for Chrome for unknown reason
  37190. this._babylonGamepads[i].browserGamepad = gamepad;
  37191. if (!this._babylonGamepads[i].isConnected) {
  37192. this._babylonGamepads[i]._isConnected = true;
  37193. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37194. }
  37195. }
  37196. }
  37197. }
  37198. };
  37199. return GamepadManager;
  37200. }());
  37201. /***/ }),
  37202. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37203. /*!*******************************************!*\
  37204. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37205. \*******************************************/
  37206. /*! exports provided: GamepadSystemSceneComponent */
  37207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37208. "use strict";
  37209. __webpack_require__.r(__webpack_exports__);
  37210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37211. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37212. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37213. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37214. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37215. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37216. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37217. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37218. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37219. get: function () {
  37220. if (!this._gamepadManager) {
  37221. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37222. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37223. if (!component) {
  37224. component = new GamepadSystemSceneComponent(this);
  37225. this._addComponent(component);
  37226. }
  37227. }
  37228. return this._gamepadManager;
  37229. },
  37230. enumerable: true,
  37231. configurable: true
  37232. });
  37233. /**
  37234. * Adds a gamepad to the free camera inputs manager
  37235. */
  37236. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37237. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37238. return this;
  37239. };
  37240. /**
  37241. * Adds a gamepad to the arc rotate camera inputs manager
  37242. */
  37243. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37244. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37245. return this;
  37246. };
  37247. /**
  37248. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37249. */
  37250. var GamepadSystemSceneComponent = /** @class */ (function () {
  37251. /**
  37252. * Creates a new instance of the component for the given scene
  37253. * @param scene Defines the scene to register the component in
  37254. */
  37255. function GamepadSystemSceneComponent(scene) {
  37256. /**
  37257. * The component name helpfull to identify the component in the list of scene components.
  37258. */
  37259. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37260. this.scene = scene;
  37261. }
  37262. /**
  37263. * Registers the component in a given scene
  37264. */
  37265. GamepadSystemSceneComponent.prototype.register = function () {
  37266. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37267. };
  37268. /**
  37269. * Rebuilds the elements related to this component in case of
  37270. * context lost for instance.
  37271. */
  37272. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37273. // Nothing to do for gamepads
  37274. };
  37275. /**
  37276. * Disposes the component and the associated ressources
  37277. */
  37278. GamepadSystemSceneComponent.prototype.dispose = function () {
  37279. var gamepadManager = this.scene._gamepadManager;
  37280. if (gamepadManager) {
  37281. gamepadManager.dispose();
  37282. this.scene._gamepadManager = null;
  37283. }
  37284. };
  37285. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37286. var gamepadManager = this.scene._gamepadManager;
  37287. if (gamepadManager && gamepadManager._isMonitoring) {
  37288. gamepadManager._checkGamepadsStatus();
  37289. }
  37290. };
  37291. return GamepadSystemSceneComponent;
  37292. }());
  37293. /***/ }),
  37294. /***/ "./Gamepads/index.ts":
  37295. /*!***************************!*\
  37296. !*** ./Gamepads/index.ts ***!
  37297. \***************************/
  37298. /*! exports provided: StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  37299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37300. "use strict";
  37301. __webpack_require__.r(__webpack_exports__);
  37302. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37313. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37317. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37319. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37321. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37325. /***/ }),
  37326. /***/ "./Gamepads/xboxGamepad.ts":
  37327. /*!*********************************!*\
  37328. !*** ./Gamepads/xboxGamepad.ts ***!
  37329. \*********************************/
  37330. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37332. "use strict";
  37333. __webpack_require__.r(__webpack_exports__);
  37334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37337. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37338. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37339. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37340. /**
  37341. * Defines supported buttons for XBox360 compatible gamepads
  37342. */
  37343. var Xbox360Button;
  37344. (function (Xbox360Button) {
  37345. /** A */
  37346. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37347. /** B */
  37348. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37349. /** X */
  37350. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37351. /** Y */
  37352. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37353. /** Start */
  37354. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37355. /** Back */
  37356. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37357. /** Left button */
  37358. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37359. /** Right button */
  37360. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37361. /** Left stick */
  37362. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37363. /** Right stick */
  37364. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37365. })(Xbox360Button || (Xbox360Button = {}));
  37366. /** Defines values for XBox360 DPad */
  37367. var Xbox360Dpad;
  37368. (function (Xbox360Dpad) {
  37369. /** Up */
  37370. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37371. /** Down */
  37372. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37373. /** Left */
  37374. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37375. /** Right */
  37376. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37377. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37378. /**
  37379. * Defines a XBox360 gamepad
  37380. */
  37381. var Xbox360Pad = /** @class */ (function (_super) {
  37382. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37383. /**
  37384. * Creates a new XBox360 gamepad object
  37385. * @param id defines the id of this gamepad
  37386. * @param index defines its index
  37387. * @param gamepad defines the internal HTML gamepad object
  37388. * @param xboxOne defines if it is a XBox One gamepad
  37389. */
  37390. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37391. if (xboxOne === void 0) { xboxOne = false; }
  37392. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37393. _this._leftTrigger = 0;
  37394. _this._rightTrigger = 0;
  37395. /** Observable raised when a button is pressed */
  37396. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37397. /** Observable raised when a button is released */
  37398. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37399. /** Observable raised when a pad is pressed */
  37400. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37401. /** Observable raised when a pad is released */
  37402. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37403. _this._buttonA = 0;
  37404. _this._buttonB = 0;
  37405. _this._buttonX = 0;
  37406. _this._buttonY = 0;
  37407. _this._buttonBack = 0;
  37408. _this._buttonStart = 0;
  37409. _this._buttonLB = 0;
  37410. _this._buttonRB = 0;
  37411. _this._buttonLeftStick = 0;
  37412. _this._buttonRightStick = 0;
  37413. _this._dPadUp = 0;
  37414. _this._dPadDown = 0;
  37415. _this._dPadLeft = 0;
  37416. _this._dPadRight = 0;
  37417. _this._isXboxOnePad = false;
  37418. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37419. _this._isXboxOnePad = xboxOne;
  37420. return _this;
  37421. }
  37422. /**
  37423. * Defines the callback to call when left trigger is pressed
  37424. * @param callback defines the callback to use
  37425. */
  37426. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37427. this._onlefttriggerchanged = callback;
  37428. };
  37429. /**
  37430. * Defines the callback to call when right trigger is pressed
  37431. * @param callback defines the callback to use
  37432. */
  37433. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37434. this._onrighttriggerchanged = callback;
  37435. };
  37436. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37437. /**
  37438. * Gets the left trigger value
  37439. */
  37440. get: function () {
  37441. return this._leftTrigger;
  37442. },
  37443. /**
  37444. * Sets the left trigger value
  37445. */
  37446. set: function (newValue) {
  37447. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37448. this._onlefttriggerchanged(newValue);
  37449. }
  37450. this._leftTrigger = newValue;
  37451. },
  37452. enumerable: true,
  37453. configurable: true
  37454. });
  37455. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37456. /**
  37457. * Gets the right trigger value
  37458. */
  37459. get: function () {
  37460. return this._rightTrigger;
  37461. },
  37462. /**
  37463. * Sets the right trigger value
  37464. */
  37465. set: function (newValue) {
  37466. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37467. this._onrighttriggerchanged(newValue);
  37468. }
  37469. this._rightTrigger = newValue;
  37470. },
  37471. enumerable: true,
  37472. configurable: true
  37473. });
  37474. /**
  37475. * Defines the callback to call when a button is pressed
  37476. * @param callback defines the callback to use
  37477. */
  37478. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37479. this._onbuttondown = callback;
  37480. };
  37481. /**
  37482. * Defines the callback to call when a button is released
  37483. * @param callback defines the callback to use
  37484. */
  37485. Xbox360Pad.prototype.onbuttonup = function (callback) {
  37486. this._onbuttonup = callback;
  37487. };
  37488. /**
  37489. * Defines the callback to call when a pad is pressed
  37490. * @param callback defines the callback to use
  37491. */
  37492. Xbox360Pad.prototype.ondpaddown = function (callback) {
  37493. this._ondpaddown = callback;
  37494. };
  37495. /**
  37496. * Defines the callback to call when a pad is released
  37497. * @param callback defines the callback to use
  37498. */
  37499. Xbox360Pad.prototype.ondpadup = function (callback) {
  37500. this._ondpadup = callback;
  37501. };
  37502. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  37503. if (newValue !== currentValue) {
  37504. if (newValue === 1) {
  37505. if (this._onbuttondown) {
  37506. this._onbuttondown(buttonType);
  37507. }
  37508. this.onButtonDownObservable.notifyObservers(buttonType);
  37509. }
  37510. if (newValue === 0) {
  37511. if (this._onbuttonup) {
  37512. this._onbuttonup(buttonType);
  37513. }
  37514. this.onButtonUpObservable.notifyObservers(buttonType);
  37515. }
  37516. }
  37517. return newValue;
  37518. };
  37519. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  37520. if (newValue !== currentValue) {
  37521. if (newValue === 1) {
  37522. if (this._ondpaddown) {
  37523. this._ondpaddown(buttonType);
  37524. }
  37525. this.onPadDownObservable.notifyObservers(buttonType);
  37526. }
  37527. if (newValue === 0) {
  37528. if (this._ondpadup) {
  37529. this._ondpadup(buttonType);
  37530. }
  37531. this.onPadUpObservable.notifyObservers(buttonType);
  37532. }
  37533. }
  37534. return newValue;
  37535. };
  37536. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  37537. /**
  37538. * Gets the value of the `A` button
  37539. */
  37540. get: function () {
  37541. return this._buttonA;
  37542. },
  37543. /**
  37544. * Sets the value of the `A` button
  37545. */
  37546. set: function (value) {
  37547. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  37548. },
  37549. enumerable: true,
  37550. configurable: true
  37551. });
  37552. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  37553. /**
  37554. * Gets the value of the `B` button
  37555. */
  37556. get: function () {
  37557. return this._buttonB;
  37558. },
  37559. /**
  37560. * Sets the value of the `B` button
  37561. */
  37562. set: function (value) {
  37563. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37564. },
  37565. enumerable: true,
  37566. configurable: true
  37567. });
  37568. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37569. /**
  37570. * Gets the value of the `X` button
  37571. */
  37572. get: function () {
  37573. return this._buttonX;
  37574. },
  37575. /**
  37576. * Sets the value of the `X` button
  37577. */
  37578. set: function (value) {
  37579. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37580. },
  37581. enumerable: true,
  37582. configurable: true
  37583. });
  37584. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37585. /**
  37586. * Gets the value of the `Y` button
  37587. */
  37588. get: function () {
  37589. return this._buttonY;
  37590. },
  37591. /**
  37592. * Sets the value of the `Y` button
  37593. */
  37594. set: function (value) {
  37595. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37596. },
  37597. enumerable: true,
  37598. configurable: true
  37599. });
  37600. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37601. /**
  37602. * Gets the value of the `Start` button
  37603. */
  37604. get: function () {
  37605. return this._buttonStart;
  37606. },
  37607. /**
  37608. * Sets the value of the `Start` button
  37609. */
  37610. set: function (value) {
  37611. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37612. },
  37613. enumerable: true,
  37614. configurable: true
  37615. });
  37616. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37617. /**
  37618. * Gets the value of the `Back` button
  37619. */
  37620. get: function () {
  37621. return this._buttonBack;
  37622. },
  37623. /**
  37624. * Sets the value of the `Back` button
  37625. */
  37626. set: function (value) {
  37627. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37628. },
  37629. enumerable: true,
  37630. configurable: true
  37631. });
  37632. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37633. /**
  37634. * Gets the value of the `Left` button
  37635. */
  37636. get: function () {
  37637. return this._buttonLB;
  37638. },
  37639. /**
  37640. * Sets the value of the `Left` button
  37641. */
  37642. set: function (value) {
  37643. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37644. },
  37645. enumerable: true,
  37646. configurable: true
  37647. });
  37648. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37649. /**
  37650. * Gets the value of the `Right` button
  37651. */
  37652. get: function () {
  37653. return this._buttonRB;
  37654. },
  37655. /**
  37656. * Sets the value of the `Right` button
  37657. */
  37658. set: function (value) {
  37659. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37660. },
  37661. enumerable: true,
  37662. configurable: true
  37663. });
  37664. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37665. /**
  37666. * Gets the value of the Left joystick
  37667. */
  37668. get: function () {
  37669. return this._buttonLeftStick;
  37670. },
  37671. /**
  37672. * Sets the value of the Left joystick
  37673. */
  37674. set: function (value) {
  37675. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37676. },
  37677. enumerable: true,
  37678. configurable: true
  37679. });
  37680. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37681. /**
  37682. * Gets the value of the Right joystick
  37683. */
  37684. get: function () {
  37685. return this._buttonRightStick;
  37686. },
  37687. /**
  37688. * Sets the value of the Right joystick
  37689. */
  37690. set: function (value) {
  37691. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37692. },
  37693. enumerable: true,
  37694. configurable: true
  37695. });
  37696. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37697. /**
  37698. * Gets the value of D-pad up
  37699. */
  37700. get: function () {
  37701. return this._dPadUp;
  37702. },
  37703. /**
  37704. * Sets the value of D-pad up
  37705. */
  37706. set: function (value) {
  37707. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37708. },
  37709. enumerable: true,
  37710. configurable: true
  37711. });
  37712. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37713. /**
  37714. * Gets the value of D-pad down
  37715. */
  37716. get: function () {
  37717. return this._dPadDown;
  37718. },
  37719. /**
  37720. * Sets the value of D-pad down
  37721. */
  37722. set: function (value) {
  37723. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37724. },
  37725. enumerable: true,
  37726. configurable: true
  37727. });
  37728. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37729. /**
  37730. * Gets the value of D-pad left
  37731. */
  37732. get: function () {
  37733. return this._dPadLeft;
  37734. },
  37735. /**
  37736. * Sets the value of D-pad left
  37737. */
  37738. set: function (value) {
  37739. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37740. },
  37741. enumerable: true,
  37742. configurable: true
  37743. });
  37744. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37745. /**
  37746. * Gets the value of D-pad right
  37747. */
  37748. get: function () {
  37749. return this._dPadRight;
  37750. },
  37751. /**
  37752. * Sets the value of D-pad right
  37753. */
  37754. set: function (value) {
  37755. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37756. },
  37757. enumerable: true,
  37758. configurable: true
  37759. });
  37760. /**
  37761. * Force the gamepad to synchronize with device values
  37762. */
  37763. Xbox360Pad.prototype.update = function () {
  37764. _super.prototype.update.call(this);
  37765. if (this._isXboxOnePad) {
  37766. this.buttonA = this.browserGamepad.buttons[0].value;
  37767. this.buttonB = this.browserGamepad.buttons[1].value;
  37768. this.buttonX = this.browserGamepad.buttons[2].value;
  37769. this.buttonY = this.browserGamepad.buttons[3].value;
  37770. this.buttonLB = this.browserGamepad.buttons[4].value;
  37771. this.buttonRB = this.browserGamepad.buttons[5].value;
  37772. this.leftTrigger = this.browserGamepad.axes[2];
  37773. this.rightTrigger = this.browserGamepad.axes[5];
  37774. this.buttonBack = this.browserGamepad.buttons[9].value;
  37775. this.buttonStart = this.browserGamepad.buttons[8].value;
  37776. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37777. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37778. this.dPadUp = this.browserGamepad.buttons[11].value;
  37779. this.dPadDown = this.browserGamepad.buttons[12].value;
  37780. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37781. this.dPadRight = this.browserGamepad.buttons[14].value;
  37782. }
  37783. else {
  37784. this.buttonA = this.browserGamepad.buttons[0].value;
  37785. this.buttonB = this.browserGamepad.buttons[1].value;
  37786. this.buttonX = this.browserGamepad.buttons[2].value;
  37787. this.buttonY = this.browserGamepad.buttons[3].value;
  37788. this.buttonLB = this.browserGamepad.buttons[4].value;
  37789. this.buttonRB = this.browserGamepad.buttons[5].value;
  37790. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37791. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37792. this.buttonBack = this.browserGamepad.buttons[8].value;
  37793. this.buttonStart = this.browserGamepad.buttons[9].value;
  37794. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37795. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37796. this.dPadUp = this.browserGamepad.buttons[12].value;
  37797. this.dPadDown = this.browserGamepad.buttons[13].value;
  37798. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37799. this.dPadRight = this.browserGamepad.buttons[15].value;
  37800. }
  37801. };
  37802. /**
  37803. * Disposes the gamepad
  37804. */
  37805. Xbox360Pad.prototype.dispose = function () {
  37806. _super.prototype.dispose.call(this);
  37807. this.onButtonDownObservable.clear();
  37808. this.onButtonUpObservable.clear();
  37809. this.onPadDownObservable.clear();
  37810. this.onPadUpObservable.clear();
  37811. };
  37812. return Xbox360Pad;
  37813. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37814. /***/ }),
  37815. /***/ "./Gizmos/axisDragGizmo.ts":
  37816. /*!*********************************!*\
  37817. !*** ./Gizmos/axisDragGizmo.ts ***!
  37818. \*********************************/
  37819. /*! exports provided: AxisDragGizmo */
  37820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37821. "use strict";
  37822. __webpack_require__.r(__webpack_exports__);
  37823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37824. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37825. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37826. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37827. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37828. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37829. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37830. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37831. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37832. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37833. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37834. /**
  37835. * Single axis drag gizmo
  37836. */
  37837. var AxisDragGizmo = /** @class */ (function (_super) {
  37838. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37839. /**
  37840. * Creates an AxisDragGizmo
  37841. * @param gizmoLayer The utility layer the gizmo will be added to
  37842. * @param dragAxis The axis which the gizmo will be able to drag on
  37843. * @param color The color of the gizmo
  37844. */
  37845. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37846. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37847. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37848. var _this = _super.call(this, gizmoLayer) || this;
  37849. _this._pointerObserver = null;
  37850. /**
  37851. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37852. */
  37853. _this.snapDistance = 0;
  37854. /**
  37855. * Event that fires each time the gizmo snaps to a new location.
  37856. * * snapDistance is the the change in distance
  37857. */
  37858. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37859. // Create Material
  37860. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37861. coloredMaterial.disableLighting = true;
  37862. coloredMaterial.emissiveColor = color;
  37863. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37864. hoverMaterial.disableLighting = true;
  37865. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37866. // Build mesh on root node
  37867. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37868. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37869. arrow.scaling.scaleInPlace(1 / 3);
  37870. arrow.parent = _this._rootMesh;
  37871. var currentSnapDragDistance = 0;
  37872. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37873. var tmpSnapEvent = { snapDistance: 0 };
  37874. // Add drag behavior to handle events when the gizmo is dragged
  37875. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37876. _this.dragBehavior.moveAttached = false;
  37877. _this._rootMesh.addBehavior(_this.dragBehavior);
  37878. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37879. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37880. _this.dragBehavior.onDragObservable.add(function (event) {
  37881. if (_this.attachedMesh) {
  37882. // Convert delta to local translation if it has a parent
  37883. if (_this.attachedMesh.parent) {
  37884. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37885. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37886. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37887. }
  37888. else {
  37889. localDelta.copyFrom(event.delta);
  37890. }
  37891. // Snapping logic
  37892. if (_this.snapDistance == 0) {
  37893. _this.attachedMesh.position.addInPlace(localDelta);
  37894. }
  37895. else {
  37896. currentSnapDragDistance += event.dragDistance;
  37897. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37898. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37899. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37900. localDelta.normalizeToRef(tmpVector);
  37901. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37902. _this.attachedMesh.position.addInPlace(tmpVector);
  37903. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37904. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37905. }
  37906. }
  37907. }
  37908. });
  37909. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37910. if (_this._customMeshSet) {
  37911. return;
  37912. }
  37913. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37914. var material = isHovered ? hoverMaterial : coloredMaterial;
  37915. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37916. m.material = material;
  37917. if (m.color) {
  37918. m.color = material.emissiveColor;
  37919. }
  37920. });
  37921. });
  37922. return _this;
  37923. }
  37924. /** @hidden */
  37925. AxisDragGizmo._CreateArrow = function (scene, material) {
  37926. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37927. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37928. 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);
  37929. line.color = material.emissiveColor;
  37930. cylinder.parent = arrow;
  37931. line.parent = arrow;
  37932. // Position arrow pointing in its drag axis
  37933. cylinder.scaling.scaleInPlace(0.05);
  37934. cylinder.material = material;
  37935. cylinder.rotation.x = Math.PI / 2;
  37936. cylinder.position.z += 0.3;
  37937. line.scaling.scaleInPlace(0.26);
  37938. line.rotation.x = Math.PI / 2;
  37939. line.material = material;
  37940. return arrow;
  37941. };
  37942. /** @hidden */
  37943. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37944. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37945. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37946. var mesh = _a[_i];
  37947. var childInstance = mesh.createInstance(mesh.name);
  37948. childInstance.parent = instance;
  37949. }
  37950. return instance;
  37951. };
  37952. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37953. if (this.dragBehavior) {
  37954. this.dragBehavior.enabled = value ? true : false;
  37955. }
  37956. };
  37957. /**
  37958. * Disposes of the gizmo
  37959. */
  37960. AxisDragGizmo.prototype.dispose = function () {
  37961. this.onSnapObservable.clear();
  37962. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37963. this.dragBehavior.detach();
  37964. _super.prototype.dispose.call(this);
  37965. };
  37966. return AxisDragGizmo;
  37967. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37968. /***/ }),
  37969. /***/ "./Gizmos/axisScaleGizmo.ts":
  37970. /*!**********************************!*\
  37971. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37972. \**********************************/
  37973. /*! exports provided: AxisScaleGizmo */
  37974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37975. "use strict";
  37976. __webpack_require__.r(__webpack_exports__);
  37977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37978. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37979. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37980. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37981. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37982. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37983. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37984. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37985. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37986. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37987. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37988. /**
  37989. * Single axis scale gizmo
  37990. */
  37991. var AxisScaleGizmo = /** @class */ (function (_super) {
  37992. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37993. /**
  37994. * Creates an AxisScaleGizmo
  37995. * @param gizmoLayer The utility layer the gizmo will be added to
  37996. * @param dragAxis The axis which the gizmo will be able to scale on
  37997. * @param color The color of the gizmo
  37998. */
  37999. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  38000. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38001. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38002. var _this = _super.call(this, gizmoLayer) || this;
  38003. _this._pointerObserver = null;
  38004. /**
  38005. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38006. */
  38007. _this.snapDistance = 0;
  38008. /**
  38009. * Event that fires each time the gizmo snaps to a new location.
  38010. * * snapDistance is the the change in distance
  38011. */
  38012. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38013. /**
  38014. * If the scaling operation should be done on all axis (default: false)
  38015. */
  38016. _this.uniformScaling = false;
  38017. // Create Material
  38018. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38019. _this._coloredMaterial.disableLighting = true;
  38020. _this._coloredMaterial.emissiveColor = color;
  38021. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38022. hoverMaterial.disableLighting = true;
  38023. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38024. // Build mesh on root node
  38025. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38026. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  38027. 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);
  38028. arrowTail.color = _this._coloredMaterial.emissiveColor;
  38029. arrow.addChild(arrowMesh);
  38030. arrow.addChild(arrowTail);
  38031. // Position arrow pointing in its drag axis
  38032. arrowMesh.scaling.scaleInPlace(0.1);
  38033. arrowMesh.material = _this._coloredMaterial;
  38034. arrowMesh.rotation.x = Math.PI / 2;
  38035. arrowMesh.position.z += 0.3;
  38036. arrowTail.scaling.scaleInPlace(0.26);
  38037. arrowTail.rotation.x = Math.PI / 2;
  38038. arrowTail.material = _this._coloredMaterial;
  38039. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38040. _this._rootMesh.addChild(arrow);
  38041. arrow.scaling.scaleInPlace(1 / 3);
  38042. // Add drag behavior to handle events when the gizmo is dragged
  38043. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38044. _this.dragBehavior.moveAttached = false;
  38045. _this._rootMesh.addBehavior(_this.dragBehavior);
  38046. var currentSnapDragDistance = 0;
  38047. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38048. var tmpSnapEvent = { snapDistance: 0 };
  38049. _this.dragBehavior.onDragObservable.add(function (event) {
  38050. if (_this.attachedMesh) {
  38051. // Snapping logic
  38052. var snapped = false;
  38053. var dragSteps = 0;
  38054. if (_this.uniformScaling) {
  38055. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  38056. if (tmpVector.y < 0) {
  38057. tmpVector.scaleInPlace(-1);
  38058. }
  38059. }
  38060. else {
  38061. tmpVector.copyFrom(dragAxis);
  38062. }
  38063. if (_this.snapDistance == 0) {
  38064. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  38065. }
  38066. else {
  38067. currentSnapDragDistance += event.dragDistance;
  38068. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38069. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38070. if (currentSnapDragDistance < 0) {
  38071. dragSteps *= -1;
  38072. }
  38073. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38074. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  38075. snapped = true;
  38076. }
  38077. else {
  38078. tmpVector.scaleInPlace(0);
  38079. }
  38080. }
  38081. _this.attachedMesh.scaling.addInPlace(tmpVector);
  38082. if (snapped) {
  38083. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38084. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38085. }
  38086. }
  38087. });
  38088. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38089. if (_this._customMeshSet) {
  38090. return;
  38091. }
  38092. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38093. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38094. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38095. m.material = material;
  38096. if (m.color) {
  38097. m.color = material.emissiveColor;
  38098. }
  38099. });
  38100. });
  38101. return _this;
  38102. }
  38103. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38104. if (this.dragBehavior) {
  38105. this.dragBehavior.enabled = value ? true : false;
  38106. }
  38107. };
  38108. /**
  38109. * Disposes of the gizmo
  38110. */
  38111. AxisScaleGizmo.prototype.dispose = function () {
  38112. this.onSnapObservable.clear();
  38113. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38114. this.dragBehavior.detach();
  38115. _super.prototype.dispose.call(this);
  38116. };
  38117. /**
  38118. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38119. * @param mesh The mesh to replace the default mesh of the gizmo
  38120. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38121. */
  38122. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38123. var _this = this;
  38124. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38125. _super.prototype.setCustomMesh.call(this, mesh);
  38126. if (useGizmoMaterial) {
  38127. this._rootMesh.getChildMeshes().forEach(function (m) {
  38128. m.material = _this._coloredMaterial;
  38129. if (m.color) {
  38130. m.color = _this._coloredMaterial.emissiveColor;
  38131. }
  38132. });
  38133. this._customMeshSet = false;
  38134. }
  38135. };
  38136. return AxisScaleGizmo;
  38137. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38138. /***/ }),
  38139. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38140. /*!************************************!*\
  38141. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38142. \************************************/
  38143. /*! exports provided: BoundingBoxGizmo */
  38144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38145. "use strict";
  38146. __webpack_require__.r(__webpack_exports__);
  38147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38148. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38149. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38150. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38151. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38152. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38153. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38154. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38155. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38156. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38157. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38158. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38159. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38160. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38161. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38162. /**
  38163. * Bounding box gizmo
  38164. */
  38165. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38166. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38167. /**
  38168. * Creates an BoundingBoxGizmo
  38169. * @param gizmoLayer The utility layer the gizmo will be added to
  38170. * @param color The color of the gizmo
  38171. */
  38172. function BoundingBoxGizmo(color, gizmoLayer) {
  38173. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38174. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38175. var _this = _super.call(this, gizmoLayer) || this;
  38176. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38177. _this._renderObserver = null;
  38178. _this._pointerObserver = null;
  38179. _this._scaleDragSpeed = 0.2;
  38180. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38181. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38182. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38183. /**
  38184. * 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)
  38185. */
  38186. _this.ignoreChildren = false;
  38187. /**
  38188. * 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)
  38189. */
  38190. _this.includeChildPredicate = null;
  38191. /**
  38192. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38193. */
  38194. _this.rotationSphereSize = 0.1;
  38195. /**
  38196. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38197. */
  38198. _this.scaleBoxSize = 0.1;
  38199. /**
  38200. * 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)
  38201. */
  38202. _this.fixedDragMeshScreenSize = false;
  38203. /**
  38204. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38205. */
  38206. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38207. /**
  38208. * Fired when a rotation sphere or scale box is dragged
  38209. */
  38210. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38211. /**
  38212. * Fired when a scale box is dragged
  38213. */
  38214. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38215. /**
  38216. * Fired when a scale box drag is ended
  38217. */
  38218. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38219. /**
  38220. * Fired when a rotation sphere is dragged
  38221. */
  38222. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38223. /**
  38224. * Fired when a rotation sphere drag is ended
  38225. */
  38226. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38227. /**
  38228. * 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)
  38229. */
  38230. _this.scalePivot = null;
  38231. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38232. // Dragging
  38233. _this._dragMesh = null;
  38234. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38235. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38236. _this._updateScale = false;
  38237. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38238. // Create Materials
  38239. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38240. _this.coloredMaterial.disableLighting = true;
  38241. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38242. _this.hoverColoredMaterial.disableLighting = true;
  38243. // Build bounding box out of lines
  38244. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38245. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38246. var lines = [];
  38247. 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));
  38248. 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));
  38249. 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));
  38250. 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));
  38251. 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));
  38252. 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));
  38253. 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));
  38254. 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));
  38255. 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));
  38256. 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));
  38257. 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));
  38258. 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));
  38259. lines.forEach(function (l) {
  38260. l.color = color;
  38261. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38262. l.isPickable = false;
  38263. _this._lineBoundingBox.addChild(l);
  38264. });
  38265. _this._rootMesh.addChild(_this._lineBoundingBox);
  38266. _this.setColor(color);
  38267. // Create rotation spheres
  38268. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38269. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38270. var _loop_1 = function (i_1) {
  38271. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38272. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38273. sphere.material = this_1.coloredMaterial;
  38274. // Drag behavior
  38275. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38276. _dragBehavior.moveAttached = false;
  38277. _dragBehavior.updateDragPlane = false;
  38278. sphere.addBehavior(_dragBehavior);
  38279. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38280. var totalTurnAmountOfDrag = 0;
  38281. _dragBehavior.onDragStartObservable.add(function () {
  38282. startingTurnDirection.copyFrom(sphere.forward);
  38283. totalTurnAmountOfDrag = 0;
  38284. });
  38285. _dragBehavior.onDragObservable.add(function (event) {
  38286. _this.onRotationSphereDragObservable.notifyObservers({});
  38287. if (_this.attachedMesh) {
  38288. var originalParent = _this.attachedMesh.parent;
  38289. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38290. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38291. return;
  38292. }
  38293. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38294. var worldDragDirection = startingTurnDirection;
  38295. // Project the world right on to the drag plane
  38296. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38297. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38298. // project drag delta on to the resulting drag axis and rotate based on that
  38299. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38300. // Make rotation relative to size of mesh.
  38301. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38302. // Rotate based on axis
  38303. if (!_this.attachedMesh.rotationQuaternion) {
  38304. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38305. }
  38306. if (!_this._anchorMesh.rotationQuaternion) {
  38307. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38308. }
  38309. // Do not allow the object to turn more than a full circle
  38310. totalTurnAmountOfDrag += projectDist;
  38311. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38312. if (i_1 >= 8) {
  38313. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38314. }
  38315. else if (i_1 >= 4) {
  38316. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38317. }
  38318. else {
  38319. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38320. }
  38321. // Rotate around center of bounding box
  38322. _this._anchorMesh.addChild(_this.attachedMesh);
  38323. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38324. _this._anchorMesh.removeChild(_this.attachedMesh);
  38325. _this.attachedMesh.setParent(originalParent);
  38326. }
  38327. _this.updateBoundingBox();
  38328. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38329. }
  38330. _this._updateDummy();
  38331. });
  38332. // Selection/deselection
  38333. _dragBehavior.onDragStartObservable.add(function () {
  38334. _this.onDragStartObservable.notifyObservers({});
  38335. _this._selectNode(sphere);
  38336. });
  38337. _dragBehavior.onDragEndObservable.add(function () {
  38338. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38339. _this._selectNode(null);
  38340. _this._updateDummy();
  38341. });
  38342. this_1._rotateSpheresParent.addChild(sphere);
  38343. };
  38344. var this_1 = this, _dragBehavior;
  38345. for (var i_1 = 0; i_1 < 12; i_1++) {
  38346. _loop_1(i_1);
  38347. }
  38348. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38349. // Create scale cubes
  38350. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38351. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38352. for (var i = 0; i < 2; i++) {
  38353. for (var j = 0; j < 2; j++) {
  38354. var _loop_2 = function () {
  38355. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38356. box.material = this_2.coloredMaterial;
  38357. // Dragging logic
  38358. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38359. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38360. _dragBehavior.moveAttached = false;
  38361. box.addBehavior(_dragBehavior);
  38362. _dragBehavior.onDragObservable.add(function (event) {
  38363. _this.onScaleBoxDragObservable.notifyObservers({});
  38364. if (_this.attachedMesh) {
  38365. var originalParent = _this.attachedMesh.parent;
  38366. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38367. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38368. return;
  38369. }
  38370. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38371. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38372. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38373. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38374. _this.updateBoundingBox();
  38375. if (_this.scalePivot) {
  38376. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38377. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38378. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38379. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38380. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38381. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38382. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38383. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38384. }
  38385. else {
  38386. // Scale from the position of the opposite corner
  38387. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38388. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38389. }
  38390. _this._anchorMesh.addChild(_this.attachedMesh);
  38391. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38392. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38393. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38394. }
  38395. _this._anchorMesh.removeChild(_this.attachedMesh);
  38396. _this.attachedMesh.setParent(originalParent);
  38397. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38398. }
  38399. _this._updateDummy();
  38400. });
  38401. // Selection/deselection
  38402. _dragBehavior.onDragStartObservable.add(function () {
  38403. _this.onDragStartObservable.notifyObservers({});
  38404. _this._selectNode(box);
  38405. });
  38406. _dragBehavior.onDragEndObservable.add(function () {
  38407. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38408. _this._selectNode(null);
  38409. _this._updateDummy();
  38410. });
  38411. this_2._scaleBoxesParent.addChild(box);
  38412. };
  38413. var this_2 = this, _dragBehavior;
  38414. for (var k = 0; k < 2; k++) {
  38415. _loop_2();
  38416. }
  38417. }
  38418. }
  38419. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38420. // Hover color change
  38421. var pointerIds = new Array();
  38422. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38423. if (!pointerIds[pointerInfo.event.pointerId]) {
  38424. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38425. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38426. pointerIds[pointerInfo.event.pointerId] = mesh;
  38427. mesh.material = _this.hoverColoredMaterial;
  38428. }
  38429. });
  38430. }
  38431. else {
  38432. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38433. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38434. delete pointerIds[pointerInfo.event.pointerId];
  38435. }
  38436. }
  38437. });
  38438. // Update bounding box positions
  38439. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38440. // Only update the bouding box if scaling has changed
  38441. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38442. _this.updateBoundingBox();
  38443. }
  38444. else if (_this.fixedDragMeshScreenSize) {
  38445. _this._updateRotationSpheres();
  38446. _this._updateScaleBoxes();
  38447. }
  38448. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38449. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38450. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38451. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38452. }
  38453. });
  38454. _this.updateBoundingBox();
  38455. return _this;
  38456. }
  38457. /**
  38458. * Sets the color of the bounding box gizmo
  38459. * @param color the color to set
  38460. */
  38461. BoundingBoxGizmo.prototype.setColor = function (color) {
  38462. this.coloredMaterial.emissiveColor = color;
  38463. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38464. this._lineBoundingBox.getChildren().forEach(function (l) {
  38465. if (l.color) {
  38466. l.color = color;
  38467. }
  38468. });
  38469. };
  38470. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38471. var _this = this;
  38472. if (value) {
  38473. // Reset anchor mesh to match attached mesh's scale
  38474. // This is needed to avoid invalid box/sphere position on first drag
  38475. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38476. var originalParent = value.parent;
  38477. this._anchorMesh.addChild(value);
  38478. this._anchorMesh.removeChild(value);
  38479. value.setParent(originalParent);
  38480. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38481. this.updateBoundingBox();
  38482. value.getChildMeshes(false).forEach(function (m) {
  38483. m.markAsDirty("scaling");
  38484. });
  38485. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  38486. _this._updateDummy();
  38487. });
  38488. }
  38489. };
  38490. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  38491. this._rotateSpheresParent.getChildMeshes()
  38492. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  38493. m.isVisible = (!selectedMesh || m == selectedMesh);
  38494. });
  38495. };
  38496. /**
  38497. * Updates the bounding box information for the Gizmo
  38498. */
  38499. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  38500. if (this.attachedMesh) {
  38501. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  38502. var originalParent = this.attachedMesh.parent;
  38503. this.attachedMesh.setParent(null);
  38504. this._update();
  38505. // Rotate based on axis
  38506. if (!this.attachedMesh.rotationQuaternion) {
  38507. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  38508. }
  38509. if (!this._anchorMesh.rotationQuaternion) {
  38510. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  38511. }
  38512. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38513. // Store original position and reset mesh to origin before computing the bounding box
  38514. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38515. this._tmpVector.copyFrom(this.attachedMesh.position);
  38516. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  38517. this.attachedMesh.position.set(0, 0, 0);
  38518. // Update bounding dimensions/positions
  38519. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  38520. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  38521. // Update gizmo to match bounding box scaling and rotation
  38522. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  38523. 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);
  38524. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  38525. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  38526. this._lineBoundingBox.computeWorldMatrix();
  38527. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  38528. // restore position/rotation values
  38529. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  38530. this.attachedMesh.position.copyFrom(this._tmpVector);
  38531. this.attachedMesh.setParent(originalParent);
  38532. }
  38533. this._updateRotationSpheres();
  38534. this._updateScaleBoxes();
  38535. if (this.attachedMesh) {
  38536. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  38537. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  38538. }
  38539. };
  38540. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  38541. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  38542. for (var i = 0; i < 3; i++) {
  38543. for (var j = 0; j < 2; j++) {
  38544. for (var k = 0; k < 2; k++) {
  38545. var index = ((i * 4) + (j * 2)) + k;
  38546. if (i == 0) {
  38547. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38548. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38549. 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));
  38550. }
  38551. if (i == 1) {
  38552. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  38553. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38554. 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));
  38555. }
  38556. if (i == 2) {
  38557. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  38558. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38559. 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));
  38560. }
  38561. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38562. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38563. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38564. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38565. }
  38566. else {
  38567. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  38568. }
  38569. }
  38570. }
  38571. }
  38572. };
  38573. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38574. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38575. for (var i = 0; i < 2; i++) {
  38576. for (var j = 0; j < 2; j++) {
  38577. for (var k = 0; k < 2; k++) {
  38578. var index = ((i * 4) + (j * 2)) + k;
  38579. if (scaleBoxes[index]) {
  38580. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38581. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38582. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38583. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38584. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38585. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38586. }
  38587. else {
  38588. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38589. }
  38590. }
  38591. }
  38592. }
  38593. }
  38594. };
  38595. /**
  38596. * Enables rotation on the specified axis and disables rotation on the others
  38597. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38598. */
  38599. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38600. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38601. if (i < 4) {
  38602. m.setEnabled(axis.indexOf("x") != -1);
  38603. }
  38604. else if (i < 8) {
  38605. m.setEnabled(axis.indexOf("y") != -1);
  38606. }
  38607. else {
  38608. m.setEnabled(axis.indexOf("z") != -1);
  38609. }
  38610. });
  38611. };
  38612. /**
  38613. * Enables/disables scaling
  38614. * @param enable if scaling should be enabled
  38615. */
  38616. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38617. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38618. m.setEnabled(enable);
  38619. });
  38620. };
  38621. BoundingBoxGizmo.prototype._updateDummy = function () {
  38622. if (this._dragMesh) {
  38623. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38624. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38625. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38626. }
  38627. };
  38628. /**
  38629. * Enables a pointer drag behavior on the bounding box of the gizmo
  38630. */
  38631. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38632. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38633. this._dragMesh.visibility = 0;
  38634. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38635. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38636. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38637. };
  38638. /**
  38639. * Disposes of the gizmo
  38640. */
  38641. BoundingBoxGizmo.prototype.dispose = function () {
  38642. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38643. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38644. this._lineBoundingBox.dispose();
  38645. this._rotateSpheresParent.dispose();
  38646. this._scaleBoxesParent.dispose();
  38647. if (this._dragMesh) {
  38648. this._dragMesh.dispose();
  38649. }
  38650. _super.prototype.dispose.call(this);
  38651. };
  38652. /**
  38653. * 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)
  38654. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38655. * @returns the bounding box mesh with the passed in mesh as a child
  38656. */
  38657. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38658. var makeNotPickable = function (root) {
  38659. root.isPickable = false;
  38660. root.getChildMeshes().forEach(function (c) {
  38661. makeNotPickable(c);
  38662. });
  38663. };
  38664. makeNotPickable(mesh);
  38665. // Reset position to get boudning box from origin with no rotation
  38666. if (!mesh.rotationQuaternion) {
  38667. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38668. }
  38669. var oldPos = mesh.position.clone();
  38670. var oldRot = mesh.rotationQuaternion.clone();
  38671. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38672. mesh.position.set(0, 0, 0);
  38673. // Update bounding dimensions/positions
  38674. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38675. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38676. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38677. // Adjust scale to avoid undefined behavior when adding child
  38678. if (box.scaling.y === 0) {
  38679. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38680. }
  38681. if (box.scaling.x === 0) {
  38682. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38683. }
  38684. if (box.scaling.z === 0) {
  38685. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38686. }
  38687. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38688. // Restore original positions
  38689. mesh.addChild(box);
  38690. mesh.rotationQuaternion.copyFrom(oldRot);
  38691. mesh.position.copyFrom(oldPos);
  38692. // Reverse parenting
  38693. mesh.removeChild(box);
  38694. box.addChild(mesh);
  38695. box.visibility = 0;
  38696. return box;
  38697. };
  38698. /**
  38699. * CustomMeshes are not supported by this gizmo
  38700. * @param mesh The mesh to replace the default mesh of the gizmo
  38701. */
  38702. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38703. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38704. };
  38705. return BoundingBoxGizmo;
  38706. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38707. /***/ }),
  38708. /***/ "./Gizmos/gizmo.ts":
  38709. /*!*************************!*\
  38710. !*** ./Gizmos/gizmo.ts ***!
  38711. \*************************/
  38712. /*! exports provided: Gizmo */
  38713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38714. "use strict";
  38715. __webpack_require__.r(__webpack_exports__);
  38716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38718. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38719. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38720. /**
  38721. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38722. */
  38723. var Gizmo = /** @class */ (function () {
  38724. /**
  38725. * Creates a gizmo
  38726. * @param gizmoLayer The utility layer the gizmo will be added to
  38727. */
  38728. function Gizmo(
  38729. /** The utility layer the gizmo will be added to */
  38730. gizmoLayer) {
  38731. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38732. var _this = this;
  38733. this.gizmoLayer = gizmoLayer;
  38734. /**
  38735. * Ratio for the scale of the gizmo (Default: 1)
  38736. */
  38737. this.scaleRatio = 1;
  38738. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38739. /**
  38740. * If a custom mesh has been set (Default: false)
  38741. */
  38742. this._customMeshSet = false;
  38743. /**
  38744. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38745. */
  38746. this.updateGizmoRotationToMatchAttachedMesh = true;
  38747. /**
  38748. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38749. */
  38750. this.updateGizmoPositionToMatchAttachedMesh = true;
  38751. /**
  38752. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38753. */
  38754. this._updateScale = true;
  38755. this._interactionsEnabled = true;
  38756. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38757. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38758. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38759. _this._update();
  38760. });
  38761. this.attachedMesh = null;
  38762. }
  38763. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38764. /**
  38765. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38766. * * When set, interactions will be enabled
  38767. */
  38768. get: function () {
  38769. return this._attachedMesh;
  38770. },
  38771. set: function (value) {
  38772. this._attachedMesh = value;
  38773. this._rootMesh.setEnabled(value ? true : false);
  38774. this._attachedMeshChanged(value);
  38775. },
  38776. enumerable: true,
  38777. configurable: true
  38778. });
  38779. /**
  38780. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38781. * @param mesh The mesh to replace the default mesh of the gizmo
  38782. */
  38783. Gizmo.prototype.setCustomMesh = function (mesh) {
  38784. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38785. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38786. }
  38787. this._rootMesh.getChildMeshes().forEach(function (c) {
  38788. c.dispose();
  38789. });
  38790. mesh.parent = this._rootMesh;
  38791. this._customMeshSet = true;
  38792. };
  38793. Gizmo.prototype._attachedMeshChanged = function (value) {
  38794. };
  38795. /**
  38796. * @hidden
  38797. * Updates the gizmo to match the attached mesh's position/rotation
  38798. */
  38799. Gizmo.prototype._update = function () {
  38800. if (this.attachedMesh) {
  38801. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38802. if (!this._rootMesh.rotationQuaternion) {
  38803. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38804. }
  38805. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38806. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38807. if (this.attachedMesh.scaling.x < 0) {
  38808. this.attachedMesh.scaling.x *= -1;
  38809. }
  38810. if (this.attachedMesh.scaling.y < 0) {
  38811. this.attachedMesh.scaling.y *= -1;
  38812. }
  38813. if (this.attachedMesh.scaling.z < 0) {
  38814. this.attachedMesh.scaling.z *= -1;
  38815. }
  38816. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38817. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38818. this.attachedMesh.computeWorldMatrix();
  38819. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38820. }
  38821. else if (this._rootMesh.rotationQuaternion) {
  38822. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38823. }
  38824. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38825. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38826. }
  38827. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38828. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38829. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38830. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38831. }
  38832. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38833. var dist = this._tempVector.length() * this.scaleRatio;
  38834. this._rootMesh.scaling.set(dist, dist, dist);
  38835. }
  38836. }
  38837. };
  38838. /**
  38839. * Disposes of the gizmo
  38840. */
  38841. Gizmo.prototype.dispose = function () {
  38842. this._rootMesh.dispose();
  38843. if (this._beforeRenderObserver) {
  38844. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38845. }
  38846. };
  38847. return Gizmo;
  38848. }());
  38849. /***/ }),
  38850. /***/ "./Gizmos/gizmoManager.ts":
  38851. /*!********************************!*\
  38852. !*** ./Gizmos/gizmoManager.ts ***!
  38853. \********************************/
  38854. /*! exports provided: GizmoManager */
  38855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38856. "use strict";
  38857. __webpack_require__.r(__webpack_exports__);
  38858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38859. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38860. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38861. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38862. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38863. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38864. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38865. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38866. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38867. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38868. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38869. /**
  38870. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38871. */
  38872. var GizmoManager = /** @class */ (function () {
  38873. /**
  38874. * Instatiates a gizmo manager
  38875. * @param scene the scene to overlay the gizmos on top of
  38876. */
  38877. function GizmoManager(scene) {
  38878. var _this = this;
  38879. this.scene = scene;
  38880. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38881. this.clearGizmoOnEmptyPointerEvent = false;
  38882. /** Fires an event when the manager is attached to a mesh */
  38883. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38884. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38885. this._pointerObserver = null;
  38886. this._attachedMesh = null;
  38887. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38888. /**
  38889. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38890. */
  38891. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38892. /**
  38893. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38894. */
  38895. this.attachableMeshes = null;
  38896. /**
  38897. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38898. */
  38899. this.usePointerToAttachGizmos = true;
  38900. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38901. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38902. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38903. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38904. // Instatiate/dispose gizmos based on pointer actions
  38905. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38906. if (!_this.usePointerToAttachGizmos) {
  38907. return;
  38908. }
  38909. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38910. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38911. var node = pointerInfo.pickInfo.pickedMesh;
  38912. if (_this.attachableMeshes == null) {
  38913. // Attach to the most parent node
  38914. while (node && node.parent != null) {
  38915. node = node.parent;
  38916. }
  38917. }
  38918. else {
  38919. // Attach to the parent node that is an attachableMesh
  38920. var found = false;
  38921. _this.attachableMeshes.forEach(function (mesh) {
  38922. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38923. node = mesh;
  38924. found = true;
  38925. }
  38926. });
  38927. if (!found) {
  38928. node = null;
  38929. }
  38930. }
  38931. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38932. if (_this._attachedMesh != node) {
  38933. _this.attachToMesh(node);
  38934. }
  38935. }
  38936. else {
  38937. if (_this.clearGizmoOnEmptyPointerEvent) {
  38938. _this.attachToMesh(null);
  38939. }
  38940. }
  38941. }
  38942. else {
  38943. if (_this.clearGizmoOnEmptyPointerEvent) {
  38944. _this.attachToMesh(null);
  38945. }
  38946. }
  38947. }
  38948. });
  38949. }
  38950. /**
  38951. * Attaches a set of gizmos to the specified mesh
  38952. * @param mesh The mesh the gizmo's should be attached to
  38953. */
  38954. GizmoManager.prototype.attachToMesh = function (mesh) {
  38955. if (this._attachedMesh) {
  38956. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38957. }
  38958. this._attachedMesh = mesh;
  38959. for (var key in this.gizmos) {
  38960. var gizmo = (this.gizmos[key]);
  38961. if (gizmo && this._gizmosEnabled[key]) {
  38962. gizmo.attachedMesh = mesh;
  38963. }
  38964. }
  38965. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38966. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38967. }
  38968. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38969. };
  38970. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38971. get: function () {
  38972. return this._gizmosEnabled.positionGizmo;
  38973. },
  38974. /**
  38975. * If the position gizmo is enabled
  38976. */
  38977. set: function (value) {
  38978. if (value) {
  38979. if (!this.gizmos.positionGizmo) {
  38980. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38981. }
  38982. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38983. }
  38984. else if (this.gizmos.positionGizmo) {
  38985. this.gizmos.positionGizmo.attachedMesh = null;
  38986. }
  38987. this._gizmosEnabled.positionGizmo = value;
  38988. },
  38989. enumerable: true,
  38990. configurable: true
  38991. });
  38992. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38993. get: function () {
  38994. return this._gizmosEnabled.rotationGizmo;
  38995. },
  38996. /**
  38997. * If the rotation gizmo is enabled
  38998. */
  38999. set: function (value) {
  39000. if (value) {
  39001. if (!this.gizmos.rotationGizmo) {
  39002. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  39003. }
  39004. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  39005. }
  39006. else if (this.gizmos.rotationGizmo) {
  39007. this.gizmos.rotationGizmo.attachedMesh = null;
  39008. }
  39009. this._gizmosEnabled.rotationGizmo = value;
  39010. },
  39011. enumerable: true,
  39012. configurable: true
  39013. });
  39014. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  39015. get: function () {
  39016. return this._gizmosEnabled.scaleGizmo;
  39017. },
  39018. /**
  39019. * If the scale gizmo is enabled
  39020. */
  39021. set: function (value) {
  39022. if (value) {
  39023. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  39024. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  39025. }
  39026. else if (this.gizmos.scaleGizmo) {
  39027. this.gizmos.scaleGizmo.attachedMesh = null;
  39028. }
  39029. this._gizmosEnabled.scaleGizmo = value;
  39030. },
  39031. enumerable: true,
  39032. configurable: true
  39033. });
  39034. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  39035. get: function () {
  39036. return this._gizmosEnabled.boundingBoxGizmo;
  39037. },
  39038. /**
  39039. * If the boundingBox gizmo is enabled
  39040. */
  39041. set: function (value) {
  39042. if (value) {
  39043. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  39044. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  39045. if (this._attachedMesh) {
  39046. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39047. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39048. }
  39049. }
  39050. else if (this.gizmos.boundingBoxGizmo) {
  39051. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  39052. }
  39053. this._gizmosEnabled.boundingBoxGizmo = value;
  39054. },
  39055. enumerable: true,
  39056. configurable: true
  39057. });
  39058. /**
  39059. * Disposes of the gizmo manager
  39060. */
  39061. GizmoManager.prototype.dispose = function () {
  39062. this.scene.onPointerObservable.remove(this._pointerObserver);
  39063. for (var key in this.gizmos) {
  39064. var gizmo = (this.gizmos[key]);
  39065. if (gizmo) {
  39066. gizmo.dispose();
  39067. }
  39068. }
  39069. this._defaultKeepDepthUtilityLayer.dispose();
  39070. this._defaultUtilityLayer.dispose();
  39071. this.boundingBoxDragBehavior.detach();
  39072. this.onAttachedToMeshObservable.clear();
  39073. };
  39074. return GizmoManager;
  39075. }());
  39076. /***/ }),
  39077. /***/ "./Gizmos/index.ts":
  39078. /*!*************************!*\
  39079. !*** ./Gizmos/index.ts ***!
  39080. \*************************/
  39081. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  39082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39083. "use strict";
  39084. __webpack_require__.r(__webpack_exports__);
  39085. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  39087. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  39089. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  39091. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  39093. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39095. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39097. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39099. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39101. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39103. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39105. /***/ }),
  39106. /***/ "./Gizmos/lightGizmo.ts":
  39107. /*!******************************!*\
  39108. !*** ./Gizmos/lightGizmo.ts ***!
  39109. \******************************/
  39110. /*! exports provided: LightGizmo */
  39111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39112. "use strict";
  39113. __webpack_require__.r(__webpack_exports__);
  39114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39115. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39116. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39117. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39118. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39119. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39120. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39121. /**
  39122. * Gizmo that enables viewing a light
  39123. */
  39124. var LightGizmo = /** @class */ (function (_super) {
  39125. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39126. /**
  39127. * Creates a LightGizmo
  39128. * @param gizmoLayer The utility layer the gizmo will be added to
  39129. */
  39130. function LightGizmo(gizmoLayer) {
  39131. var _this = _super.call(this, gizmoLayer) || this;
  39132. _this._light = null;
  39133. _this._box = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("light", 0.02, 0, 0.02, 16, 1, _this.gizmoLayer.utilityLayerScene);
  39134. _this._box.rotation.x = -Math.PI / 2;
  39135. _this._box.bakeCurrentTransformIntoVertices();
  39136. _this._box.material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", _this.gizmoLayer.utilityLayerScene);
  39137. _this._box.material.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Yellow();
  39138. _this._rootMesh.addChild(_this._box);
  39139. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39140. return _this;
  39141. }
  39142. Object.defineProperty(LightGizmo.prototype, "light", {
  39143. get: function () {
  39144. return this._light;
  39145. },
  39146. /**
  39147. * The light that the gizmo is attached to
  39148. */
  39149. set: function (light) {
  39150. this._light = light;
  39151. if (light.position) {
  39152. this.attachedMesh.position.copyFrom(light.position);
  39153. }
  39154. if (light.direction) {
  39155. this._box.setDirection(light.direction);
  39156. }
  39157. },
  39158. enumerable: true,
  39159. configurable: true
  39160. });
  39161. /**
  39162. * @hidden
  39163. * Updates the gizmo to match the attached mesh's position/rotation
  39164. */
  39165. LightGizmo.prototype._update = function () {
  39166. _super.prototype._update.call(this);
  39167. if (!this._light) {
  39168. return;
  39169. }
  39170. if (this._light.position) {
  39171. this._light.position.copyFrom(this.attachedMesh.position);
  39172. }
  39173. if (this._light.direction) {
  39174. this._light.direction.copyFrom(this._box.forward);
  39175. }
  39176. if (!this._light.isEnabled()) {
  39177. this._box.material.emissiveColor.set(0, 0, 0);
  39178. }
  39179. else {
  39180. this._box.material.emissiveColor.set(1, 1, 1);
  39181. }
  39182. };
  39183. return LightGizmo;
  39184. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39185. /***/ }),
  39186. /***/ "./Gizmos/planeRotationGizmo.ts":
  39187. /*!**************************************!*\
  39188. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39189. \**************************************/
  39190. /*! exports provided: PlaneRotationGizmo */
  39191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39192. "use strict";
  39193. __webpack_require__.r(__webpack_exports__);
  39194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39195. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39196. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39197. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39198. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39199. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39200. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39201. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39202. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39203. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39204. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39205. /**
  39206. * Single plane rotation gizmo
  39207. */
  39208. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39209. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39210. /**
  39211. * Creates a PlaneRotationGizmo
  39212. * @param gizmoLayer The utility layer the gizmo will be added to
  39213. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39214. * @param color The color of the gizmo
  39215. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39216. */
  39217. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39218. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39219. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39220. if (tessellation === void 0) { tessellation = 32; }
  39221. var _this = _super.call(this, gizmoLayer) || this;
  39222. _this._pointerObserver = null;
  39223. /**
  39224. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39225. */
  39226. _this.snapDistance = 0;
  39227. /**
  39228. * Event that fires each time the gizmo snaps to a new location.
  39229. * * snapDistance is the the change in distance
  39230. */
  39231. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39232. // Create Material
  39233. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39234. coloredMaterial.disableLighting = true;
  39235. coloredMaterial.emissiveColor = color;
  39236. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39237. hoverMaterial.disableLighting = true;
  39238. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39239. // Build mesh on root node
  39240. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39241. // Create circle out of lines
  39242. var radius = 0.8;
  39243. var points = new Array();
  39244. for (var i = 0; i < tessellation; i++) {
  39245. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  39246. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  39247. }
  39248. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  39249. rotationMesh.color = coloredMaterial.emissiveColor;
  39250. // Position arrow pointing in its drag axis
  39251. rotationMesh.scaling.scaleInPlace(0.26);
  39252. rotationMesh.material = coloredMaterial;
  39253. rotationMesh.rotation.x = Math.PI / 2;
  39254. parentMesh.addChild(rotationMesh);
  39255. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39256. _this._rootMesh.addChild(parentMesh);
  39257. parentMesh.scaling.scaleInPlace(1 / 3);
  39258. // Add drag behavior to handle events when the gizmo is dragged
  39259. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39260. _this.dragBehavior.moveAttached = false;
  39261. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39262. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39263. _this._rootMesh.addBehavior(_this.dragBehavior);
  39264. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39265. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39266. if (_this.attachedMesh) {
  39267. lastDragPosition.copyFrom(e.dragPlanePoint);
  39268. }
  39269. });
  39270. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39271. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39272. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39273. var tmpSnapEvent = { snapDistance: 0 };
  39274. var currentSnapDragDistance = 0;
  39275. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39276. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39277. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39278. _this.dragBehavior.onDragObservable.add(function (event) {
  39279. if (_this.attachedMesh) {
  39280. if (!_this.attachedMesh.rotationQuaternion) {
  39281. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39282. }
  39283. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39284. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39285. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39286. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39287. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39288. var angle = Math.atan2(cross.length(), dot);
  39289. planeNormalTowardsCamera.copyFrom(planeNormal);
  39290. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39291. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39292. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39293. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39294. }
  39295. // Flip up vector depending on which side the camera is on
  39296. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39297. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39298. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39299. planeNormalTowardsCamera.scaleInPlace(-1);
  39300. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39301. }
  39302. }
  39303. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  39304. if (halfCircleSide) {
  39305. angle = -angle;
  39306. }
  39307. // Snapping logic
  39308. var snapped = false;
  39309. if (_this.snapDistance != 0) {
  39310. currentSnapDragDistance += angle;
  39311. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  39312. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  39313. if (currentSnapDragDistance < 0) {
  39314. dragSteps *= -1;
  39315. }
  39316. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  39317. angle = _this.snapDistance * dragSteps;
  39318. snapped = true;
  39319. }
  39320. else {
  39321. angle = 0;
  39322. }
  39323. }
  39324. // If the mesh has a parent, convert needed world rotation to local rotation
  39325. tmpMatrix.reset();
  39326. if (_this.attachedMesh.parent) {
  39327. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  39328. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  39329. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  39330. }
  39331. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  39332. var quaternionCoefficient = Math.sin(angle / 2);
  39333. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  39334. // 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
  39335. if (tmpMatrix.determinant() > 0) {
  39336. amountToRotate.toEulerAnglesToRef(tmpVector);
  39337. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  39338. }
  39339. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39340. // Rotate selected mesh quaternion over fixed axis
  39341. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  39342. }
  39343. else {
  39344. // Rotate selected mesh quaternion over rotated axis
  39345. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  39346. }
  39347. lastDragPosition.copyFrom(event.dragPlanePoint);
  39348. if (snapped) {
  39349. tmpSnapEvent.snapDistance = angle;
  39350. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  39351. }
  39352. }
  39353. });
  39354. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  39355. if (_this._customMeshSet) {
  39356. return;
  39357. }
  39358. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  39359. var material = isHovered ? hoverMaterial : coloredMaterial;
  39360. _this._rootMesh.getChildMeshes().forEach(function (m) {
  39361. m.material = material;
  39362. if (m.color) {
  39363. m.color = material.emissiveColor;
  39364. }
  39365. });
  39366. });
  39367. return _this;
  39368. }
  39369. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  39370. if (this.dragBehavior) {
  39371. this.dragBehavior.enabled = value ? true : false;
  39372. }
  39373. };
  39374. /**
  39375. * Disposes of the gizmo
  39376. */
  39377. PlaneRotationGizmo.prototype.dispose = function () {
  39378. this.onSnapObservable.clear();
  39379. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39380. this.dragBehavior.detach();
  39381. _super.prototype.dispose.call(this);
  39382. };
  39383. return PlaneRotationGizmo;
  39384. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  39385. /***/ }),
  39386. /***/ "./Gizmos/positionGizmo.ts":
  39387. /*!*********************************!*\
  39388. !*** ./Gizmos/positionGizmo.ts ***!
  39389. \*********************************/
  39390. /*! exports provided: PositionGizmo */
  39391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39392. "use strict";
  39393. __webpack_require__.r(__webpack_exports__);
  39394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  39395. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39396. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39397. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39398. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39399. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39400. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39401. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39402. /**
  39403. * Gizmo that enables dragging a mesh along 3 axis
  39404. */
  39405. var PositionGizmo = /** @class */ (function (_super) {
  39406. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  39407. /**
  39408. * Creates a PositionGizmo
  39409. * @param gizmoLayer The utility layer the gizmo will be added to
  39410. */
  39411. function PositionGizmo(gizmoLayer) {
  39412. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39413. var _this = _super.call(this, gizmoLayer) || this;
  39414. /** Fires an event when any of it's sub gizmos are dragged */
  39415. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39416. /** Fires an event when any of it's sub gizmos are released from dragging */
  39417. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39418. _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);
  39419. _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);
  39420. _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);
  39421. // Relay drag events
  39422. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39423. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39424. _this.onDragStartObservable.notifyObservers({});
  39425. });
  39426. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39427. _this.onDragEndObservable.notifyObservers({});
  39428. });
  39429. });
  39430. _this.attachedMesh = null;
  39431. return _this;
  39432. }
  39433. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  39434. get: function () {
  39435. return this.xGizmo.attachedMesh;
  39436. },
  39437. set: function (mesh) {
  39438. if (this.xGizmo) {
  39439. this.xGizmo.attachedMesh = mesh;
  39440. this.yGizmo.attachedMesh = mesh;
  39441. this.zGizmo.attachedMesh = mesh;
  39442. }
  39443. },
  39444. enumerable: true,
  39445. configurable: true
  39446. });
  39447. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39448. get: function () {
  39449. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39450. },
  39451. set: function (value) {
  39452. if (this.xGizmo) {
  39453. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39454. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39455. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39456. }
  39457. },
  39458. enumerable: true,
  39459. configurable: true
  39460. });
  39461. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  39462. get: function () {
  39463. return this.xGizmo.snapDistance;
  39464. },
  39465. /**
  39466. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39467. */
  39468. set: function (value) {
  39469. if (this.xGizmo) {
  39470. this.xGizmo.snapDistance = value;
  39471. this.yGizmo.snapDistance = value;
  39472. this.zGizmo.snapDistance = value;
  39473. }
  39474. },
  39475. enumerable: true,
  39476. configurable: true
  39477. });
  39478. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  39479. get: function () {
  39480. return this.xGizmo.scaleRatio;
  39481. },
  39482. /**
  39483. * Ratio for the scale of the gizmo (Default: 1)
  39484. */
  39485. set: function (value) {
  39486. if (this.xGizmo) {
  39487. this.xGizmo.scaleRatio = value;
  39488. this.yGizmo.scaleRatio = value;
  39489. this.zGizmo.scaleRatio = value;
  39490. }
  39491. },
  39492. enumerable: true,
  39493. configurable: true
  39494. });
  39495. /**
  39496. * Disposes of the gizmo
  39497. */
  39498. PositionGizmo.prototype.dispose = function () {
  39499. this.xGizmo.dispose();
  39500. this.yGizmo.dispose();
  39501. this.zGizmo.dispose();
  39502. this.onDragStartObservable.clear();
  39503. this.onDragEndObservable.clear();
  39504. };
  39505. /**
  39506. * CustomMeshes are not supported by this gizmo
  39507. * @param mesh The mesh to replace the default mesh of the gizmo
  39508. */
  39509. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  39510. _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)");
  39511. };
  39512. return PositionGizmo;
  39513. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39514. /***/ }),
  39515. /***/ "./Gizmos/rotationGizmo.ts":
  39516. /*!*********************************!*\
  39517. !*** ./Gizmos/rotationGizmo.ts ***!
  39518. \*********************************/
  39519. /*! exports provided: RotationGizmo */
  39520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39521. "use strict";
  39522. __webpack_require__.r(__webpack_exports__);
  39523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  39524. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39525. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39526. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39527. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39528. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39529. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39530. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39531. /**
  39532. * Gizmo that enables rotating a mesh along 3 axis
  39533. */
  39534. var RotationGizmo = /** @class */ (function (_super) {
  39535. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  39536. /**
  39537. * Creates a RotationGizmo
  39538. * @param gizmoLayer The utility layer the gizmo will be added to
  39539. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39540. */
  39541. function RotationGizmo(gizmoLayer, tessellation) {
  39542. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39543. if (tessellation === void 0) { tessellation = 32; }
  39544. var _this = _super.call(this, gizmoLayer) || this;
  39545. /** Fires an event when any of it's sub gizmos are dragged */
  39546. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39547. /** Fires an event when any of it's sub gizmos are released from dragging */
  39548. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39549. _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);
  39550. _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);
  39551. _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);
  39552. // Relay drag events
  39553. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39554. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39555. _this.onDragStartObservable.notifyObservers({});
  39556. });
  39557. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39558. _this.onDragEndObservable.notifyObservers({});
  39559. });
  39560. });
  39561. _this.attachedMesh = null;
  39562. return _this;
  39563. }
  39564. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  39565. get: function () {
  39566. return this.xGizmo.attachedMesh;
  39567. },
  39568. set: function (mesh) {
  39569. if (this.xGizmo) {
  39570. this.xGizmo.attachedMesh = mesh;
  39571. this.yGizmo.attachedMesh = mesh;
  39572. this.zGizmo.attachedMesh = mesh;
  39573. }
  39574. },
  39575. enumerable: true,
  39576. configurable: true
  39577. });
  39578. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39579. get: function () {
  39580. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39581. },
  39582. set: function (value) {
  39583. if (this.xGizmo) {
  39584. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39585. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39586. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39587. }
  39588. },
  39589. enumerable: true,
  39590. configurable: true
  39591. });
  39592. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  39593. get: function () {
  39594. return this.xGizmo.snapDistance;
  39595. },
  39596. /**
  39597. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39598. */
  39599. set: function (value) {
  39600. if (this.xGizmo) {
  39601. this.xGizmo.snapDistance = value;
  39602. this.yGizmo.snapDistance = value;
  39603. this.zGizmo.snapDistance = value;
  39604. }
  39605. },
  39606. enumerable: true,
  39607. configurable: true
  39608. });
  39609. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  39610. get: function () {
  39611. return this.xGizmo.scaleRatio;
  39612. },
  39613. /**
  39614. * Ratio for the scale of the gizmo (Default: 1)
  39615. */
  39616. set: function (value) {
  39617. if (this.xGizmo) {
  39618. this.xGizmo.scaleRatio = value;
  39619. this.yGizmo.scaleRatio = value;
  39620. this.zGizmo.scaleRatio = value;
  39621. }
  39622. },
  39623. enumerable: true,
  39624. configurable: true
  39625. });
  39626. /**
  39627. * Disposes of the gizmo
  39628. */
  39629. RotationGizmo.prototype.dispose = function () {
  39630. this.xGizmo.dispose();
  39631. this.yGizmo.dispose();
  39632. this.zGizmo.dispose();
  39633. this.onDragStartObservable.clear();
  39634. this.onDragEndObservable.clear();
  39635. };
  39636. /**
  39637. * CustomMeshes are not supported by this gizmo
  39638. * @param mesh The mesh to replace the default mesh of the gizmo
  39639. */
  39640. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  39641. _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)");
  39642. };
  39643. return RotationGizmo;
  39644. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39645. /***/ }),
  39646. /***/ "./Gizmos/scaleGizmo.ts":
  39647. /*!******************************!*\
  39648. !*** ./Gizmos/scaleGizmo.ts ***!
  39649. \******************************/
  39650. /*! exports provided: ScaleGizmo */
  39651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39652. "use strict";
  39653. __webpack_require__.r(__webpack_exports__);
  39654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  39655. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39656. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39657. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39659. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  39660. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39661. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39662. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39663. /**
  39664. * Gizmo that enables scaling a mesh along 3 axis
  39665. */
  39666. var ScaleGizmo = /** @class */ (function (_super) {
  39667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  39668. /**
  39669. * Creates a ScaleGizmo
  39670. * @param gizmoLayer The utility layer the gizmo will be added to
  39671. */
  39672. function ScaleGizmo(gizmoLayer) {
  39673. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39674. var _this = _super.call(this, gizmoLayer) || this;
  39675. /** Fires an event when any of it's sub gizmos are dragged */
  39676. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39677. /** Fires an event when any of it's sub gizmos are released from dragging */
  39678. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39679. _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);
  39680. _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);
  39681. _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);
  39682. // Create uniform scale gizmo
  39683. _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);
  39684. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  39685. _this.uniformScaleGizmo.uniformScaling = true;
  39686. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39687. uniformScalingMesh.scaling.scaleInPlace(0.02);
  39688. uniformScalingMesh.visibility = 0;
  39689. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39690. octahedron.scaling.scaleInPlace(0.007);
  39691. uniformScalingMesh.addChild(octahedron);
  39692. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  39693. // Relay drag events
  39694. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  39695. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39696. _this.onDragStartObservable.notifyObservers({});
  39697. });
  39698. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39699. _this.onDragEndObservable.notifyObservers({});
  39700. });
  39701. });
  39702. _this.attachedMesh = null;
  39703. return _this;
  39704. }
  39705. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  39706. get: function () {
  39707. return this.xGizmo.attachedMesh;
  39708. },
  39709. set: function (mesh) {
  39710. if (this.xGizmo) {
  39711. this.xGizmo.attachedMesh = mesh;
  39712. this.yGizmo.attachedMesh = mesh;
  39713. this.zGizmo.attachedMesh = mesh;
  39714. this.uniformScaleGizmo.attachedMesh = mesh;
  39715. }
  39716. },
  39717. enumerable: true,
  39718. configurable: true
  39719. });
  39720. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39721. get: function () {
  39722. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39723. },
  39724. set: function (value) {
  39725. if (!value) {
  39726. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39727. }
  39728. if (this.xGizmo) {
  39729. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39730. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39731. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39732. }
  39733. },
  39734. enumerable: true,
  39735. configurable: true
  39736. });
  39737. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39738. get: function () {
  39739. return this.xGizmo.snapDistance;
  39740. },
  39741. /**
  39742. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39743. */
  39744. set: function (value) {
  39745. if (this.xGizmo) {
  39746. this.xGizmo.snapDistance = value;
  39747. this.yGizmo.snapDistance = value;
  39748. this.zGizmo.snapDistance = value;
  39749. this.uniformScaleGizmo.snapDistance = value;
  39750. }
  39751. },
  39752. enumerable: true,
  39753. configurable: true
  39754. });
  39755. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39756. get: function () {
  39757. return this.xGizmo.scaleRatio;
  39758. },
  39759. /**
  39760. * Ratio for the scale of the gizmo (Default: 1)
  39761. */
  39762. set: function (value) {
  39763. if (this.xGizmo) {
  39764. this.xGizmo.scaleRatio = value;
  39765. this.yGizmo.scaleRatio = value;
  39766. this.zGizmo.scaleRatio = value;
  39767. this.uniformScaleGizmo.scaleRatio = value;
  39768. }
  39769. },
  39770. enumerable: true,
  39771. configurable: true
  39772. });
  39773. /**
  39774. * Disposes of the gizmo
  39775. */
  39776. ScaleGizmo.prototype.dispose = function () {
  39777. this.xGizmo.dispose();
  39778. this.yGizmo.dispose();
  39779. this.zGizmo.dispose();
  39780. this.uniformScaleGizmo.dispose();
  39781. this.onDragStartObservable.clear();
  39782. this.onDragEndObservable.clear();
  39783. };
  39784. return ScaleGizmo;
  39785. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39786. /***/ }),
  39787. /***/ "./Helpers/environmentHelper.ts":
  39788. /*!**************************************!*\
  39789. !*** ./Helpers/environmentHelper.ts ***!
  39790. \**************************************/
  39791. /*! exports provided: EnvironmentHelper */
  39792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39793. "use strict";
  39794. __webpack_require__.r(__webpack_exports__);
  39795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39796. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39797. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39798. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39799. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39800. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39801. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39802. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39803. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39804. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39805. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39806. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39807. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39808. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39809. /**
  39810. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39811. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39812. * It also helps with the default setup of your imageProcessing configuration.
  39813. */
  39814. var EnvironmentHelper = /** @class */ (function () {
  39815. /**
  39816. * constructor
  39817. * @param options Defines the options we want to customize the helper
  39818. * @param scene The scene to add the material to
  39819. */
  39820. function EnvironmentHelper(options, scene) {
  39821. var _this = this;
  39822. this._errorHandler = function (message, exception) {
  39823. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39824. };
  39825. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39826. this._scene = scene;
  39827. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39828. this._setupBackground();
  39829. this._setupImageProcessing();
  39830. }
  39831. /**
  39832. * Creates the default options for the helper.
  39833. */
  39834. EnvironmentHelper._getDefaultOptions = function () {
  39835. return {
  39836. createGround: true,
  39837. groundSize: 15,
  39838. groundTexture: this._groundTextureCDNUrl,
  39839. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39840. groundOpacity: 0.9,
  39841. enableGroundShadow: true,
  39842. groundShadowLevel: 0.5,
  39843. enableGroundMirror: false,
  39844. groundMirrorSizeRatio: 0.3,
  39845. groundMirrorBlurKernel: 64,
  39846. groundMirrorAmount: 1,
  39847. groundMirrorFresnelWeight: 1,
  39848. groundMirrorFallOffDistance: 0,
  39849. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39850. groundYBias: 0.00001,
  39851. createSkybox: true,
  39852. skyboxSize: 20,
  39853. skyboxTexture: this._skyboxTextureCDNUrl,
  39854. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39855. backgroundYRotation: 0,
  39856. sizeAuto: true,
  39857. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39858. setupImageProcessing: true,
  39859. environmentTexture: this._environmentTextureCDNUrl,
  39860. cameraExposure: 0.8,
  39861. cameraContrast: 1.2,
  39862. toneMappingEnabled: true,
  39863. };
  39864. };
  39865. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39866. /**
  39867. * Gets the root mesh created by the helper.
  39868. */
  39869. get: function () {
  39870. return this._rootMesh;
  39871. },
  39872. enumerable: true,
  39873. configurable: true
  39874. });
  39875. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  39876. /**
  39877. * Gets the skybox created by the helper.
  39878. */
  39879. get: function () {
  39880. return this._skybox;
  39881. },
  39882. enumerable: true,
  39883. configurable: true
  39884. });
  39885. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  39886. /**
  39887. * Gets the skybox texture created by the helper.
  39888. */
  39889. get: function () {
  39890. return this._skyboxTexture;
  39891. },
  39892. enumerable: true,
  39893. configurable: true
  39894. });
  39895. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39896. /**
  39897. * Gets the skybox material created by the helper.
  39898. */
  39899. get: function () {
  39900. return this._skyboxMaterial;
  39901. },
  39902. enumerable: true,
  39903. configurable: true
  39904. });
  39905. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39906. /**
  39907. * Gets the ground mesh created by the helper.
  39908. */
  39909. get: function () {
  39910. return this._ground;
  39911. },
  39912. enumerable: true,
  39913. configurable: true
  39914. });
  39915. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39916. /**
  39917. * Gets the ground texture created by the helper.
  39918. */
  39919. get: function () {
  39920. return this._groundTexture;
  39921. },
  39922. enumerable: true,
  39923. configurable: true
  39924. });
  39925. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39926. /**
  39927. * Gets the ground mirror created by the helper.
  39928. */
  39929. get: function () {
  39930. return this._groundMirror;
  39931. },
  39932. enumerable: true,
  39933. configurable: true
  39934. });
  39935. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39936. /**
  39937. * Gets the ground mirror render list to helps pushing the meshes
  39938. * you wish in the ground reflection.
  39939. */
  39940. get: function () {
  39941. if (this._groundMirror) {
  39942. return this._groundMirror.renderList;
  39943. }
  39944. return null;
  39945. },
  39946. enumerable: true,
  39947. configurable: true
  39948. });
  39949. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39950. /**
  39951. * Gets the ground material created by the helper.
  39952. */
  39953. get: function () {
  39954. return this._groundMaterial;
  39955. },
  39956. enumerable: true,
  39957. configurable: true
  39958. });
  39959. /**
  39960. * Updates the background according to the new options
  39961. * @param options
  39962. */
  39963. EnvironmentHelper.prototype.updateOptions = function (options) {
  39964. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39965. if (this._ground && !newOptions.createGround) {
  39966. this._ground.dispose();
  39967. this._ground = null;
  39968. }
  39969. if (this._groundMaterial && !newOptions.createGround) {
  39970. this._groundMaterial.dispose();
  39971. this._groundMaterial = null;
  39972. }
  39973. if (this._groundTexture) {
  39974. if (this._options.groundTexture != newOptions.groundTexture) {
  39975. this._groundTexture.dispose();
  39976. this._groundTexture = null;
  39977. }
  39978. }
  39979. if (this._skybox && !newOptions.createSkybox) {
  39980. this._skybox.dispose();
  39981. this._skybox = null;
  39982. }
  39983. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39984. this._skyboxMaterial.dispose();
  39985. this._skyboxMaterial = null;
  39986. }
  39987. if (this._skyboxTexture) {
  39988. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39989. this._skyboxTexture.dispose();
  39990. this._skyboxTexture = null;
  39991. }
  39992. }
  39993. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39994. this._groundMirror.dispose();
  39995. this._groundMirror = null;
  39996. }
  39997. if (this._scene.environmentTexture) {
  39998. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39999. this._scene.environmentTexture.dispose();
  40000. }
  40001. }
  40002. this._options = newOptions;
  40003. this._setupBackground();
  40004. this._setupImageProcessing();
  40005. };
  40006. /**
  40007. * Sets the primary color of all the available elements.
  40008. * @param color the main color to affect to the ground and the background
  40009. */
  40010. EnvironmentHelper.prototype.setMainColor = function (color) {
  40011. if (this.groundMaterial) {
  40012. this.groundMaterial.primaryColor = color;
  40013. }
  40014. if (this.skyboxMaterial) {
  40015. this.skyboxMaterial.primaryColor = color;
  40016. }
  40017. if (this.groundMirror) {
  40018. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  40019. }
  40020. };
  40021. /**
  40022. * Setup the image processing according to the specified options.
  40023. */
  40024. EnvironmentHelper.prototype._setupImageProcessing = function () {
  40025. if (this._options.setupImageProcessing) {
  40026. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  40027. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  40028. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  40029. this._setupEnvironmentTexture();
  40030. }
  40031. };
  40032. /**
  40033. * Setup the environment texture according to the specified options.
  40034. */
  40035. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  40036. if (this._scene.environmentTexture) {
  40037. return;
  40038. }
  40039. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40040. this._scene.environmentTexture = this._options.environmentTexture;
  40041. return;
  40042. }
  40043. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  40044. this._scene.environmentTexture = environmentTexture;
  40045. };
  40046. /**
  40047. * Setup the background according to the specified options.
  40048. */
  40049. EnvironmentHelper.prototype._setupBackground = function () {
  40050. if (!this._rootMesh) {
  40051. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  40052. }
  40053. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  40054. var sceneSize = this._getSceneSize();
  40055. if (this._options.createGround) {
  40056. this._setupGround(sceneSize);
  40057. this._setupGroundMaterial();
  40058. this._setupGroundDiffuseTexture();
  40059. if (this._options.enableGroundMirror) {
  40060. this._setupGroundMirrorTexture(sceneSize);
  40061. }
  40062. this._setupMirrorInGroundMaterial();
  40063. }
  40064. if (this._options.createSkybox) {
  40065. this._setupSkybox(sceneSize);
  40066. this._setupSkyboxMaterial();
  40067. this._setupSkyboxReflectionTexture();
  40068. }
  40069. this._rootMesh.position.x = sceneSize.rootPosition.x;
  40070. this._rootMesh.position.z = sceneSize.rootPosition.z;
  40071. this._rootMesh.position.y = sceneSize.rootPosition.y;
  40072. };
  40073. /**
  40074. * Get the scene sizes according to the setup.
  40075. */
  40076. EnvironmentHelper.prototype._getSceneSize = function () {
  40077. var _this = this;
  40078. var groundSize = this._options.groundSize;
  40079. var skyboxSize = this._options.skyboxSize;
  40080. var rootPosition = this._options.rootPosition;
  40081. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  40082. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40083. }
  40084. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  40085. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  40086. });
  40087. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  40088. if (this._options.sizeAuto) {
  40089. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  40090. this._scene.activeCamera.upperRadiusLimit) {
  40091. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  40092. skyboxSize = groundSize;
  40093. }
  40094. var sceneDiagonalLenght = sceneDiagonal.length();
  40095. if (sceneDiagonalLenght > groundSize) {
  40096. groundSize = sceneDiagonalLenght * 2;
  40097. skyboxSize = groundSize;
  40098. }
  40099. // 10 % bigger.
  40100. groundSize *= 1.1;
  40101. skyboxSize *= 1.5;
  40102. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40103. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40104. }
  40105. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40106. };
  40107. /**
  40108. * Setup the ground according to the specified options.
  40109. */
  40110. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40111. var _this = this;
  40112. if (!this._ground || this._ground.isDisposed()) {
  40113. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40114. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40115. this._ground.parent = this._rootMesh;
  40116. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40117. }
  40118. this._ground.receiveShadows = this._options.enableGroundShadow;
  40119. };
  40120. /**
  40121. * Setup the ground material according to the specified options.
  40122. */
  40123. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40124. if (!this._groundMaterial) {
  40125. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40126. }
  40127. this._groundMaterial.alpha = this._options.groundOpacity;
  40128. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40129. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40130. this._groundMaterial.primaryColor = this._options.groundColor;
  40131. this._groundMaterial.useRGBColor = false;
  40132. this._groundMaterial.enableNoise = true;
  40133. if (this._ground) {
  40134. this._ground.material = this._groundMaterial;
  40135. }
  40136. };
  40137. /**
  40138. * Setup the ground diffuse texture according to the specified options.
  40139. */
  40140. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40141. if (!this._groundMaterial) {
  40142. return;
  40143. }
  40144. if (this._groundTexture) {
  40145. return;
  40146. }
  40147. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40148. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40149. return;
  40150. }
  40151. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40152. diffuseTexture.gammaSpace = false;
  40153. diffuseTexture.hasAlpha = true;
  40154. this._groundMaterial.diffuseTexture = diffuseTexture;
  40155. };
  40156. /**
  40157. * Setup the ground mirror texture according to the specified options.
  40158. */
  40159. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40160. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40161. if (!this._groundMirror) {
  40162. 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);
  40163. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40164. this._groundMirror.anisotropicFilteringLevel = 1;
  40165. this._groundMirror.wrapU = wrapping;
  40166. this._groundMirror.wrapV = wrapping;
  40167. this._groundMirror.gammaSpace = false;
  40168. if (this._groundMirror.renderList) {
  40169. for (var i = 0; i < this._scene.meshes.length; i++) {
  40170. var mesh = this._scene.meshes[i];
  40171. if (mesh !== this._ground &&
  40172. mesh !== this._skybox &&
  40173. mesh !== this._rootMesh) {
  40174. this._groundMirror.renderList.push(mesh);
  40175. }
  40176. }
  40177. }
  40178. }
  40179. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40180. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40181. };
  40182. /**
  40183. * Setup the ground to receive the mirror texture.
  40184. */
  40185. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40186. if (this._groundMaterial) {
  40187. this._groundMaterial.reflectionTexture = this._groundMirror;
  40188. this._groundMaterial.reflectionFresnel = true;
  40189. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40190. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40191. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40192. }
  40193. };
  40194. /**
  40195. * Setup the skybox according to the specified options.
  40196. */
  40197. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40198. var _this = this;
  40199. if (!this._skybox || this._skybox.isDisposed()) {
  40200. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40201. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40202. }
  40203. this._skybox.parent = this._rootMesh;
  40204. };
  40205. /**
  40206. * Setup the skybox material according to the specified options.
  40207. */
  40208. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40209. if (!this._skybox) {
  40210. return;
  40211. }
  40212. if (!this._skyboxMaterial) {
  40213. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40214. }
  40215. this._skyboxMaterial.useRGBColor = false;
  40216. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40217. this._skyboxMaterial.enableNoise = true;
  40218. this._skybox.material = this._skyboxMaterial;
  40219. };
  40220. /**
  40221. * Setup the skybox reflection texture according to the specified options.
  40222. */
  40223. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40224. if (!this._skyboxMaterial) {
  40225. return;
  40226. }
  40227. if (this._skyboxTexture) {
  40228. return;
  40229. }
  40230. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40231. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40232. return;
  40233. }
  40234. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40235. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40236. this._skyboxTexture.gammaSpace = false;
  40237. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40238. };
  40239. /**
  40240. * Dispose all the elements created by the Helper.
  40241. */
  40242. EnvironmentHelper.prototype.dispose = function () {
  40243. if (this._groundMaterial) {
  40244. this._groundMaterial.dispose(true, true);
  40245. }
  40246. if (this._skyboxMaterial) {
  40247. this._skyboxMaterial.dispose(true, true);
  40248. }
  40249. this._rootMesh.dispose(false);
  40250. };
  40251. /**
  40252. * Default ground texture URL.
  40253. */
  40254. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40255. /**
  40256. * Default skybox texture URL.
  40257. */
  40258. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40259. /**
  40260. * Default environment texture URL.
  40261. */
  40262. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40263. return EnvironmentHelper;
  40264. }());
  40265. /***/ }),
  40266. /***/ "./Helpers/index.ts":
  40267. /*!**************************!*\
  40268. !*** ./Helpers/index.ts ***!
  40269. \**************************/
  40270. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40272. "use strict";
  40273. __webpack_require__.r(__webpack_exports__);
  40274. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40276. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40278. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40280. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40282. /***/ }),
  40283. /***/ "./Helpers/photoDome.ts":
  40284. /*!******************************!*\
  40285. !*** ./Helpers/photoDome.ts ***!
  40286. \******************************/
  40287. /*! exports provided: PhotoDome */
  40288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40289. "use strict";
  40290. __webpack_require__.r(__webpack_exports__);
  40291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40293. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40294. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40295. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40296. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40297. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40298. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40299. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40300. /**
  40301. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  40302. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  40303. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  40304. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40305. */
  40306. var PhotoDome = /** @class */ (function (_super) {
  40307. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  40308. /**
  40309. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  40310. * @param name Element's name, child elements will append suffixes for their own names.
  40311. * @param urlsOfPhoto defines the url of the photo to display
  40312. * @param options defines an object containing optional or exposed sub element properties
  40313. * @param onError defines a callback called when an error occured while loading the texture
  40314. */
  40315. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  40316. if (onError === void 0) { onError = null; }
  40317. var _this = _super.call(this, name, scene) || this;
  40318. _this._useDirectMapping = false;
  40319. /**
  40320. * Observable raised when an error occured while loading the 360 image
  40321. */
  40322. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40323. // set defaults and manage values
  40324. name = name || "photoDome";
  40325. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40326. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40327. if (options.useDirectMapping === undefined) {
  40328. _this._useDirectMapping = true;
  40329. }
  40330. else {
  40331. _this._useDirectMapping = options.useDirectMapping;
  40332. }
  40333. if (options.faceForward === undefined) {
  40334. options.faceForward = true;
  40335. }
  40336. _this._setReady(false);
  40337. // create
  40338. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40339. _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);
  40340. // configure material
  40341. material.opacityFresnel = false;
  40342. material.useEquirectangularFOV = true;
  40343. material.fovMultiplier = 1.0;
  40344. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  40345. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  40346. if (onError) {
  40347. onError(message, exception);
  40348. }
  40349. });
  40350. _this.photoTexture.onLoadObservable.addOnce(function () {
  40351. _this._setReady(true);
  40352. });
  40353. // configure mesh
  40354. _this._mesh.material = material;
  40355. _this._mesh.parent = _this;
  40356. // Initial rotation
  40357. if (options.faceForward && scene.activeCamera) {
  40358. var camera = scene.activeCamera;
  40359. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  40360. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  40361. direction.normalize();
  40362. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  40363. }
  40364. return _this;
  40365. }
  40366. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  40367. /**
  40368. * Gets or sets the texture being displayed on the sphere
  40369. */
  40370. get: function () {
  40371. return this._photoTexture;
  40372. },
  40373. set: function (value) {
  40374. if (this._photoTexture === value) {
  40375. return;
  40376. }
  40377. this._photoTexture = value;
  40378. if (this._useDirectMapping) {
  40379. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40380. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40381. this._material.diffuseTexture = this._photoTexture;
  40382. }
  40383. else {
  40384. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40385. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40386. this._material.reflectionTexture = this._photoTexture;
  40387. }
  40388. },
  40389. enumerable: true,
  40390. configurable: true
  40391. });
  40392. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  40393. /**
  40394. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40395. * Also see the options.resolution property.
  40396. */
  40397. get: function () {
  40398. return this._material.fovMultiplier;
  40399. },
  40400. set: function (value) {
  40401. this._material.fovMultiplier = value;
  40402. },
  40403. enumerable: true,
  40404. configurable: true
  40405. });
  40406. /**
  40407. * Releases resources associated with this node.
  40408. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40409. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40410. */
  40411. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40412. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40413. this._photoTexture.dispose();
  40414. this._mesh.dispose();
  40415. this._material.dispose();
  40416. this.onLoadErrorObservable.clear();
  40417. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40418. };
  40419. return PhotoDome;
  40420. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  40421. /***/ }),
  40422. /***/ "./Helpers/sceneHelpers.ts":
  40423. /*!*********************************!*\
  40424. !*** ./Helpers/sceneHelpers.ts ***!
  40425. \*********************************/
  40426. /*! exports provided: _forceSceneHelpersToBundle */
  40427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40428. "use strict";
  40429. __webpack_require__.r(__webpack_exports__);
  40430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  40431. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40432. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  40433. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40434. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40435. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40436. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40437. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  40438. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  40439. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40440. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  40441. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40442. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  40443. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  40444. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  40445. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  40446. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  40447. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  40448. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  40449. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  40450. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40451. /** @hidden */
  40452. var _forceSceneHelpersToBundle = true;
  40453. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  40454. if (replace === void 0) { replace = false; }
  40455. // Dispose existing light in replace mode.
  40456. if (replace) {
  40457. if (this.lights) {
  40458. for (var i = 0; i < this.lights.length; i++) {
  40459. this.lights[i].dispose();
  40460. }
  40461. }
  40462. }
  40463. // Light
  40464. if (this.lights.length === 0) {
  40465. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  40466. }
  40467. };
  40468. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  40469. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40470. if (replace === void 0) { replace = false; }
  40471. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40472. // Dispose existing camera in replace mode.
  40473. if (replace) {
  40474. if (this.activeCamera) {
  40475. this.activeCamera.dispose();
  40476. this.activeCamera = null;
  40477. }
  40478. }
  40479. // Camera
  40480. if (!this.activeCamera) {
  40481. var worldExtends = this.getWorldExtends();
  40482. var worldSize = worldExtends.max.subtract(worldExtends.min);
  40483. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  40484. var camera;
  40485. var radius = worldSize.length() * 1.5;
  40486. // empty scene scenario!
  40487. if (!isFinite(radius)) {
  40488. radius = 1;
  40489. worldCenter.copyFromFloats(0, 0, 0);
  40490. }
  40491. if (createArcRotateCamera) {
  40492. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  40493. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  40494. arcRotateCamera.wheelPrecision = 100 / radius;
  40495. camera = arcRotateCamera;
  40496. }
  40497. else {
  40498. 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);
  40499. freeCamera.setTarget(worldCenter);
  40500. camera = freeCamera;
  40501. }
  40502. camera.minZ = radius * 0.01;
  40503. camera.maxZ = radius * 1000;
  40504. camera.speed = radius * 0.2;
  40505. this.activeCamera = camera;
  40506. var canvas = this.getEngine().getRenderingCanvas();
  40507. if (attachCameraControls && canvas) {
  40508. camera.attachControl(canvas);
  40509. }
  40510. }
  40511. };
  40512. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  40513. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40514. if (replace === void 0) { replace = false; }
  40515. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40516. this.createDefaultLight(replace);
  40517. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  40518. };
  40519. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  40520. if (pbr === void 0) { pbr = false; }
  40521. if (scale === void 0) { scale = 1000; }
  40522. if (blur === void 0) { blur = 0; }
  40523. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  40524. if (!environmentTexture) {
  40525. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  40526. return null;
  40527. }
  40528. if (setGlobalEnvTexture) {
  40529. if (environmentTexture) {
  40530. this.environmentTexture = environmentTexture;
  40531. }
  40532. }
  40533. // Skybox
  40534. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  40535. if (pbr) {
  40536. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  40537. hdrSkyboxMaterial.backFaceCulling = false;
  40538. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  40539. if (hdrSkyboxMaterial.reflectionTexture) {
  40540. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40541. }
  40542. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  40543. hdrSkyboxMaterial.disableLighting = true;
  40544. hdrSkyboxMaterial.twoSidedLighting = true;
  40545. hdrSkybox.infiniteDistance = true;
  40546. hdrSkybox.material = hdrSkyboxMaterial;
  40547. }
  40548. else {
  40549. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  40550. skyboxMaterial.backFaceCulling = false;
  40551. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  40552. if (skyboxMaterial.reflectionTexture) {
  40553. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40554. }
  40555. skyboxMaterial.disableLighting = true;
  40556. hdrSkybox.infiniteDistance = true;
  40557. hdrSkybox.material = skyboxMaterial;
  40558. }
  40559. hdrSkybox.isPickable = false;
  40560. return hdrSkybox;
  40561. };
  40562. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  40563. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  40564. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  40565. }
  40566. return null;
  40567. };
  40568. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  40569. if (webVROptions === void 0) { webVROptions = {}; }
  40570. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  40571. };
  40572. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  40573. var _this = this;
  40574. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  40575. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  40576. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  40577. .then(function (ui) {
  40578. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  40579. return helper;
  40580. });
  40581. });
  40582. };
  40583. /***/ }),
  40584. /***/ "./Helpers/videoDome.ts":
  40585. /*!******************************!*\
  40586. !*** ./Helpers/videoDome.ts ***!
  40587. \******************************/
  40588. /*! exports provided: VideoDome */
  40589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40590. "use strict";
  40591. __webpack_require__.r(__webpack_exports__);
  40592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  40593. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40594. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40595. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40596. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40597. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  40598. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40599. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40600. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40601. /**
  40602. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  40603. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  40604. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  40605. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40606. */
  40607. var VideoDome = /** @class */ (function (_super) {
  40608. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  40609. /**
  40610. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  40611. * @param name Element's name, child elements will append suffixes for their own names.
  40612. * @param urlsOrVideo defines the url(s) or the video element to use
  40613. * @param options An object containing optional or exposed sub element properties
  40614. */
  40615. function VideoDome(name, urlsOrVideo, options, scene) {
  40616. var _this = _super.call(this, name, scene) || this;
  40617. _this._useDirectMapping = false;
  40618. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  40619. /**
  40620. * Oberserver used in Stereoscopic VR Mode.
  40621. */
  40622. _this._onBeforeCameraRenderObserver = null;
  40623. scene = _this.getScene();
  40624. // set defaults and manage values
  40625. name = name || "videoDome";
  40626. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40627. options.clickToPlay = Boolean(options.clickToPlay);
  40628. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  40629. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  40630. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40631. if (options.useDirectMapping === undefined) {
  40632. _this._useDirectMapping = true;
  40633. }
  40634. else {
  40635. _this._useDirectMapping = options.useDirectMapping;
  40636. }
  40637. if (options.faceForward === undefined) {
  40638. options.faceForward = true;
  40639. }
  40640. _this._setReady(false);
  40641. // create
  40642. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  40643. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40644. 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);
  40645. _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);
  40646. texture.onLoadObservable.addOnce(function () {
  40647. _this._setReady(true);
  40648. });
  40649. // configure material
  40650. material.useEquirectangularFOV = true;
  40651. material.fovMultiplier = 1.0;
  40652. material.opacityFresnel = false;
  40653. if (_this._useDirectMapping) {
  40654. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40655. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40656. material.diffuseTexture = texture;
  40657. }
  40658. else {
  40659. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40660. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40661. material.reflectionTexture = texture;
  40662. }
  40663. // configure mesh
  40664. _this._mesh.material = material;
  40665. _this._mesh.parent = _this;
  40666. // optional configuration
  40667. if (options.clickToPlay) {
  40668. scene.onPointerUp = function () {
  40669. _this._videoTexture.video.play();
  40670. };
  40671. }
  40672. // Initial rotation
  40673. if (options.faceForward && scene.activeCamera) {
  40674. var camera = scene.activeCamera;
  40675. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  40676. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  40677. direction.normalize();
  40678. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  40679. }
  40680. return _this;
  40681. }
  40682. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  40683. /**
  40684. * Gets the video texture being displayed on the sphere
  40685. */
  40686. get: function () {
  40687. return this._videoTexture;
  40688. },
  40689. enumerable: true,
  40690. configurable: true
  40691. });
  40692. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  40693. /**
  40694. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40695. * Also see the options.resolution property.
  40696. */
  40697. get: function () {
  40698. return this._material.fovMultiplier;
  40699. },
  40700. set: function (value) {
  40701. this._material.fovMultiplier = value;
  40702. },
  40703. enumerable: true,
  40704. configurable: true
  40705. });
  40706. Object.defineProperty(VideoDome.prototype, "videoMode", {
  40707. /**
  40708. * Gets or set the current video mode for the video. It can be:
  40709. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  40710. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  40711. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  40712. */
  40713. get: function () {
  40714. return this._videoMode;
  40715. },
  40716. set: function (value) {
  40717. if (this._videoMode === value) {
  40718. return;
  40719. }
  40720. this._changeVideoMode(value);
  40721. },
  40722. enumerable: true,
  40723. configurable: true
  40724. });
  40725. VideoDome.prototype._changeVideoMode = function (value) {
  40726. var _this = this;
  40727. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40728. this._videoMode = value;
  40729. // Default Setup and Reset.
  40730. this._videoTexture.uScale = 1;
  40731. this._videoTexture.vScale = 1;
  40732. this._videoTexture.uOffset = 0;
  40733. this._videoTexture.vOffset = 0;
  40734. switch (value) {
  40735. case VideoDome.MODE_SIDEBYSIDE:
  40736. this._videoTexture.uScale = 0.5;
  40737. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  40738. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  40739. });
  40740. break;
  40741. case VideoDome.MODE_TOPBOTTOM:
  40742. this._videoTexture.vScale = 0.5;
  40743. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  40744. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  40745. });
  40746. break;
  40747. }
  40748. };
  40749. /**
  40750. * Releases resources associated with this node.
  40751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40753. */
  40754. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40755. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40756. this._videoTexture.dispose();
  40757. this._mesh.dispose();
  40758. this._material.dispose();
  40759. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40760. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40761. };
  40762. /**
  40763. * Define the video source as a Monoscopic panoramic 360 video.
  40764. */
  40765. VideoDome.MODE_MONOSCOPIC = 0;
  40766. /**
  40767. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  40768. */
  40769. VideoDome.MODE_TOPBOTTOM = 1;
  40770. /**
  40771. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  40772. */
  40773. VideoDome.MODE_SIDEBYSIDE = 2;
  40774. return VideoDome;
  40775. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  40776. /***/ }),
  40777. /***/ "./Instrumentation/engineInstrumentation.ts":
  40778. /*!**************************************************!*\
  40779. !*** ./Instrumentation/engineInstrumentation.ts ***!
  40780. \**************************************************/
  40781. /*! exports provided: EngineInstrumentation */
  40782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40783. "use strict";
  40784. __webpack_require__.r(__webpack_exports__);
  40785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  40786. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40787. /**
  40788. * This class can be used to get instrumentation data from a Babylon engine
  40789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40790. */
  40791. var EngineInstrumentation = /** @class */ (function () {
  40792. /**
  40793. * Instantiates a new engine instrumentation.
  40794. * This class can be used to get instrumentation data from a Babylon engine
  40795. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40796. * @param engine Defines the engine to instrument
  40797. */
  40798. function EngineInstrumentation(
  40799. /**
  40800. * Define the instrumented engine.
  40801. */
  40802. engine) {
  40803. this.engine = engine;
  40804. this._captureGPUFrameTime = false;
  40805. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40806. this._captureShaderCompilationTime = false;
  40807. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40808. // Observers
  40809. this._onBeginFrameObserver = null;
  40810. this._onEndFrameObserver = null;
  40811. this._onBeforeShaderCompilationObserver = null;
  40812. this._onAfterShaderCompilationObserver = null;
  40813. }
  40814. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40815. // Properties
  40816. /**
  40817. * Gets the perf counter used for GPU frame time
  40818. */
  40819. get: function () {
  40820. return this._gpuFrameTime;
  40821. },
  40822. enumerable: true,
  40823. configurable: true
  40824. });
  40825. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40826. /**
  40827. * Gets the GPU frame time capture status
  40828. */
  40829. get: function () {
  40830. return this._captureGPUFrameTime;
  40831. },
  40832. /**
  40833. * Enable or disable the GPU frame time capture
  40834. */
  40835. set: function (value) {
  40836. var _this = this;
  40837. if (value === this._captureGPUFrameTime) {
  40838. return;
  40839. }
  40840. this._captureGPUFrameTime = value;
  40841. if (value) {
  40842. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40843. if (!_this._gpuFrameTimeToken) {
  40844. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40845. }
  40846. });
  40847. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40848. if (!_this._gpuFrameTimeToken) {
  40849. return;
  40850. }
  40851. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40852. if (time > -1) {
  40853. _this._gpuFrameTimeToken = null;
  40854. _this._gpuFrameTime.fetchNewFrame();
  40855. _this._gpuFrameTime.addCount(time, true);
  40856. }
  40857. });
  40858. }
  40859. else {
  40860. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40861. this._onBeginFrameObserver = null;
  40862. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40863. this._onEndFrameObserver = null;
  40864. }
  40865. },
  40866. enumerable: true,
  40867. configurable: true
  40868. });
  40869. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40870. /**
  40871. * Gets the perf counter used for shader compilation time
  40872. */
  40873. get: function () {
  40874. return this._shaderCompilationTime;
  40875. },
  40876. enumerable: true,
  40877. configurable: true
  40878. });
  40879. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  40880. /**
  40881. * Gets the shader compilation time capture status
  40882. */
  40883. get: function () {
  40884. return this._captureShaderCompilationTime;
  40885. },
  40886. /**
  40887. * Enable or disable the shader compilation time capture
  40888. */
  40889. set: function (value) {
  40890. var _this = this;
  40891. if (value === this._captureShaderCompilationTime) {
  40892. return;
  40893. }
  40894. this._captureShaderCompilationTime = value;
  40895. if (value) {
  40896. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  40897. _this._shaderCompilationTime.fetchNewFrame();
  40898. _this._shaderCompilationTime.beginMonitoring();
  40899. });
  40900. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  40901. _this._shaderCompilationTime.endMonitoring();
  40902. });
  40903. }
  40904. else {
  40905. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40906. this._onBeforeShaderCompilationObserver = null;
  40907. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40908. this._onAfterShaderCompilationObserver = null;
  40909. }
  40910. },
  40911. enumerable: true,
  40912. configurable: true
  40913. });
  40914. /**
  40915. * Dispose and release associated resources.
  40916. */
  40917. EngineInstrumentation.prototype.dispose = function () {
  40918. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40919. this._onBeginFrameObserver = null;
  40920. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40921. this._onEndFrameObserver = null;
  40922. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40923. this._onBeforeShaderCompilationObserver = null;
  40924. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40925. this._onAfterShaderCompilationObserver = null;
  40926. this.engine = null;
  40927. };
  40928. return EngineInstrumentation;
  40929. }());
  40930. /***/ }),
  40931. /***/ "./Instrumentation/index.ts":
  40932. /*!**********************************!*\
  40933. !*** ./Instrumentation/index.ts ***!
  40934. \**********************************/
  40935. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  40936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40937. "use strict";
  40938. __webpack_require__.r(__webpack_exports__);
  40939. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  40940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  40941. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  40942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  40943. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  40944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  40945. /***/ }),
  40946. /***/ "./Instrumentation/sceneInstrumentation.ts":
  40947. /*!*************************************************!*\
  40948. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  40949. \*************************************************/
  40950. /*! exports provided: SceneInstrumentation */
  40951. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40952. "use strict";
  40953. __webpack_require__.r(__webpack_exports__);
  40954. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  40955. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40956. /**
  40957. * This class can be used to get instrumentation data from a Babylon engine
  40958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40959. */
  40960. var SceneInstrumentation = /** @class */ (function () {
  40961. /**
  40962. * Instantiates a new scene instrumentation.
  40963. * This class can be used to get instrumentation data from a Babylon engine
  40964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40965. * @param scene Defines the scene to instrument
  40966. */
  40967. function SceneInstrumentation(
  40968. /**
  40969. * Defines the scene to instrument
  40970. */
  40971. scene) {
  40972. var _this = this;
  40973. this.scene = scene;
  40974. this._captureActiveMeshesEvaluationTime = false;
  40975. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40976. this._captureRenderTargetsRenderTime = false;
  40977. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40978. this._captureFrameTime = false;
  40979. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40980. this._captureRenderTime = false;
  40981. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40982. this._captureInterFrameTime = false;
  40983. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40984. this._captureParticlesRenderTime = false;
  40985. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40986. this._captureSpritesRenderTime = false;
  40987. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40988. this._capturePhysicsTime = false;
  40989. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40990. this._captureAnimationsTime = false;
  40991. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40992. this._captureCameraRenderTime = false;
  40993. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40994. // Observers
  40995. this._onBeforeActiveMeshesEvaluationObserver = null;
  40996. this._onAfterActiveMeshesEvaluationObserver = null;
  40997. this._onBeforeRenderTargetsRenderObserver = null;
  40998. this._onAfterRenderTargetsRenderObserver = null;
  40999. this._onAfterRenderObserver = null;
  41000. this._onBeforeDrawPhaseObserver = null;
  41001. this._onAfterDrawPhaseObserver = null;
  41002. this._onBeforeAnimationsObserver = null;
  41003. this._onBeforeParticlesRenderingObserver = null;
  41004. this._onAfterParticlesRenderingObserver = null;
  41005. this._onBeforeSpritesRenderingObserver = null;
  41006. this._onAfterSpritesRenderingObserver = null;
  41007. this._onBeforePhysicsObserver = null;
  41008. this._onAfterPhysicsObserver = null;
  41009. this._onAfterAnimationsObserver = null;
  41010. this._onBeforeCameraRenderObserver = null;
  41011. this._onAfterCameraRenderObserver = null;
  41012. // Before render
  41013. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  41014. if (_this._captureActiveMeshesEvaluationTime) {
  41015. _this._activeMeshesEvaluationTime.fetchNewFrame();
  41016. }
  41017. if (_this._captureRenderTargetsRenderTime) {
  41018. _this._renderTargetsRenderTime.fetchNewFrame();
  41019. }
  41020. if (_this._captureFrameTime) {
  41021. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  41022. _this._frameTime.beginMonitoring();
  41023. }
  41024. if (_this._captureInterFrameTime) {
  41025. _this._interFrameTime.endMonitoring();
  41026. }
  41027. if (_this._captureParticlesRenderTime) {
  41028. _this._particlesRenderTime.fetchNewFrame();
  41029. }
  41030. if (_this._captureSpritesRenderTime) {
  41031. _this._spritesRenderTime.fetchNewFrame();
  41032. }
  41033. if (_this._captureAnimationsTime) {
  41034. _this._animationsTime.beginMonitoring();
  41035. }
  41036. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  41037. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  41038. });
  41039. // After render
  41040. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  41041. if (_this._captureFrameTime) {
  41042. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  41043. _this._frameTime.endMonitoring();
  41044. }
  41045. if (_this._captureRenderTime) {
  41046. _this._renderTime.endMonitoring(false);
  41047. }
  41048. if (_this._captureInterFrameTime) {
  41049. _this._interFrameTime.beginMonitoring();
  41050. }
  41051. });
  41052. }
  41053. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  41054. // Properties
  41055. /**
  41056. * Gets the perf counter used for active meshes evaluation time
  41057. */
  41058. get: function () {
  41059. return this._activeMeshesEvaluationTime;
  41060. },
  41061. enumerable: true,
  41062. configurable: true
  41063. });
  41064. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  41065. /**
  41066. * Gets the active meshes evaluation time capture status
  41067. */
  41068. get: function () {
  41069. return this._captureActiveMeshesEvaluationTime;
  41070. },
  41071. /**
  41072. * Enable or disable the active meshes evaluation time capture
  41073. */
  41074. set: function (value) {
  41075. var _this = this;
  41076. if (value === this._captureActiveMeshesEvaluationTime) {
  41077. return;
  41078. }
  41079. this._captureActiveMeshesEvaluationTime = value;
  41080. if (value) {
  41081. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  41082. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  41083. _this._activeMeshesEvaluationTime.beginMonitoring();
  41084. });
  41085. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  41086. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  41087. _this._activeMeshesEvaluationTime.endMonitoring();
  41088. });
  41089. }
  41090. else {
  41091. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41092. this._onBeforeActiveMeshesEvaluationObserver = null;
  41093. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41094. this._onAfterActiveMeshesEvaluationObserver = null;
  41095. }
  41096. },
  41097. enumerable: true,
  41098. configurable: true
  41099. });
  41100. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  41101. /**
  41102. * Gets the perf counter used for render targets render time
  41103. */
  41104. get: function () {
  41105. return this._renderTargetsRenderTime;
  41106. },
  41107. enumerable: true,
  41108. configurable: true
  41109. });
  41110. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  41111. /**
  41112. * Gets the render targets render time capture status
  41113. */
  41114. get: function () {
  41115. return this._captureRenderTargetsRenderTime;
  41116. },
  41117. /**
  41118. * Enable or disable the render targets render time capture
  41119. */
  41120. set: function (value) {
  41121. var _this = this;
  41122. if (value === this._captureRenderTargetsRenderTime) {
  41123. return;
  41124. }
  41125. this._captureRenderTargetsRenderTime = value;
  41126. if (value) {
  41127. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  41128. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  41129. _this._renderTargetsRenderTime.beginMonitoring();
  41130. });
  41131. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  41132. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  41133. _this._renderTargetsRenderTime.endMonitoring(false);
  41134. });
  41135. }
  41136. else {
  41137. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41138. this._onBeforeRenderTargetsRenderObserver = null;
  41139. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41140. this._onAfterRenderTargetsRenderObserver = null;
  41141. }
  41142. },
  41143. enumerable: true,
  41144. configurable: true
  41145. });
  41146. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  41147. /**
  41148. * Gets the perf counter used for particles render time
  41149. */
  41150. get: function () {
  41151. return this._particlesRenderTime;
  41152. },
  41153. enumerable: true,
  41154. configurable: true
  41155. });
  41156. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  41157. /**
  41158. * Gets the particles render time capture status
  41159. */
  41160. get: function () {
  41161. return this._captureParticlesRenderTime;
  41162. },
  41163. /**
  41164. * Enable or disable the particles render time capture
  41165. */
  41166. set: function (value) {
  41167. var _this = this;
  41168. if (value === this._captureParticlesRenderTime) {
  41169. return;
  41170. }
  41171. this._captureParticlesRenderTime = value;
  41172. if (value) {
  41173. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  41174. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  41175. _this._particlesRenderTime.beginMonitoring();
  41176. });
  41177. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  41178. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  41179. _this._particlesRenderTime.endMonitoring(false);
  41180. });
  41181. }
  41182. else {
  41183. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41184. this._onBeforeParticlesRenderingObserver = null;
  41185. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41186. this._onAfterParticlesRenderingObserver = null;
  41187. }
  41188. },
  41189. enumerable: true,
  41190. configurable: true
  41191. });
  41192. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  41193. /**
  41194. * Gets the perf counter used for sprites render time
  41195. */
  41196. get: function () {
  41197. return this._spritesRenderTime;
  41198. },
  41199. enumerable: true,
  41200. configurable: true
  41201. });
  41202. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  41203. /**
  41204. * Gets the sprites render time capture status
  41205. */
  41206. get: function () {
  41207. return this._captureSpritesRenderTime;
  41208. },
  41209. /**
  41210. * Enable or disable the sprites render time capture
  41211. */
  41212. set: function (value) {
  41213. var _this = this;
  41214. if (value === this._captureSpritesRenderTime) {
  41215. return;
  41216. }
  41217. this._captureSpritesRenderTime = value;
  41218. if (!this.scene.spriteManagers) {
  41219. return;
  41220. }
  41221. if (value) {
  41222. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  41223. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  41224. _this._spritesRenderTime.beginMonitoring();
  41225. });
  41226. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  41227. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  41228. _this._spritesRenderTime.endMonitoring(false);
  41229. });
  41230. }
  41231. else {
  41232. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41233. this._onBeforeSpritesRenderingObserver = null;
  41234. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41235. this._onAfterSpritesRenderingObserver = null;
  41236. }
  41237. },
  41238. enumerable: true,
  41239. configurable: true
  41240. });
  41241. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  41242. /**
  41243. * Gets the perf counter used for physics time
  41244. */
  41245. get: function () {
  41246. return this._physicsTime;
  41247. },
  41248. enumerable: true,
  41249. configurable: true
  41250. });
  41251. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  41252. /**
  41253. * Gets the physics time capture status
  41254. */
  41255. get: function () {
  41256. return this._capturePhysicsTime;
  41257. },
  41258. /**
  41259. * Enable or disable the physics time capture
  41260. */
  41261. set: function (value) {
  41262. var _this = this;
  41263. if (value === this._capturePhysicsTime) {
  41264. return;
  41265. }
  41266. if (!this.scene.onBeforePhysicsObservable) {
  41267. return;
  41268. }
  41269. this._capturePhysicsTime = value;
  41270. if (value) {
  41271. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  41272. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  41273. _this._physicsTime.beginMonitoring();
  41274. });
  41275. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  41276. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  41277. _this._physicsTime.endMonitoring();
  41278. });
  41279. }
  41280. else {
  41281. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41282. this._onBeforePhysicsObserver = null;
  41283. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41284. this._onAfterPhysicsObserver = null;
  41285. }
  41286. },
  41287. enumerable: true,
  41288. configurable: true
  41289. });
  41290. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  41291. /**
  41292. * Gets the perf counter used for animations time
  41293. */
  41294. get: function () {
  41295. return this._animationsTime;
  41296. },
  41297. enumerable: true,
  41298. configurable: true
  41299. });
  41300. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  41301. /**
  41302. * Gets the animations time capture status
  41303. */
  41304. get: function () {
  41305. return this._captureAnimationsTime;
  41306. },
  41307. /**
  41308. * Enable or disable the animations time capture
  41309. */
  41310. set: function (value) {
  41311. var _this = this;
  41312. if (value === this._captureAnimationsTime) {
  41313. return;
  41314. }
  41315. this._captureAnimationsTime = value;
  41316. if (value) {
  41317. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  41318. _this._animationsTime.endMonitoring();
  41319. });
  41320. }
  41321. else {
  41322. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41323. this._onAfterAnimationsObserver = null;
  41324. }
  41325. },
  41326. enumerable: true,
  41327. configurable: true
  41328. });
  41329. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  41330. /**
  41331. * Gets the perf counter used for frame time capture
  41332. */
  41333. get: function () {
  41334. return this._frameTime;
  41335. },
  41336. enumerable: true,
  41337. configurable: true
  41338. });
  41339. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  41340. /**
  41341. * Gets the frame time capture status
  41342. */
  41343. get: function () {
  41344. return this._captureFrameTime;
  41345. },
  41346. /**
  41347. * Enable or disable the frame time capture
  41348. */
  41349. set: function (value) {
  41350. this._captureFrameTime = value;
  41351. },
  41352. enumerable: true,
  41353. configurable: true
  41354. });
  41355. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  41356. /**
  41357. * Gets the perf counter used for inter-frames time capture
  41358. */
  41359. get: function () {
  41360. return this._interFrameTime;
  41361. },
  41362. enumerable: true,
  41363. configurable: true
  41364. });
  41365. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  41366. /**
  41367. * Gets the inter-frames time capture status
  41368. */
  41369. get: function () {
  41370. return this._captureInterFrameTime;
  41371. },
  41372. /**
  41373. * Enable or disable the inter-frames time capture
  41374. */
  41375. set: function (value) {
  41376. this._captureInterFrameTime = value;
  41377. },
  41378. enumerable: true,
  41379. configurable: true
  41380. });
  41381. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  41382. /**
  41383. * Gets the perf counter used for render time capture
  41384. */
  41385. get: function () {
  41386. return this._renderTime;
  41387. },
  41388. enumerable: true,
  41389. configurable: true
  41390. });
  41391. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  41392. /**
  41393. * Gets the render time capture status
  41394. */
  41395. get: function () {
  41396. return this._captureRenderTime;
  41397. },
  41398. /**
  41399. * Enable or disable the render time capture
  41400. */
  41401. set: function (value) {
  41402. var _this = this;
  41403. if (value === this._captureRenderTime) {
  41404. return;
  41405. }
  41406. this._captureRenderTime = value;
  41407. if (value) {
  41408. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  41409. _this._renderTime.beginMonitoring();
  41410. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  41411. });
  41412. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  41413. _this._renderTime.endMonitoring(false);
  41414. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  41415. });
  41416. }
  41417. else {
  41418. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41419. this._onBeforeDrawPhaseObserver = null;
  41420. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41421. this._onAfterDrawPhaseObserver = null;
  41422. }
  41423. },
  41424. enumerable: true,
  41425. configurable: true
  41426. });
  41427. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  41428. /**
  41429. * Gets the perf counter used for camera render time capture
  41430. */
  41431. get: function () {
  41432. return this._cameraRenderTime;
  41433. },
  41434. enumerable: true,
  41435. configurable: true
  41436. });
  41437. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  41438. /**
  41439. * Gets the camera render time capture status
  41440. */
  41441. get: function () {
  41442. return this._captureCameraRenderTime;
  41443. },
  41444. /**
  41445. * Enable or disable the camera render time capture
  41446. */
  41447. set: function (value) {
  41448. var _this = this;
  41449. if (value === this._captureCameraRenderTime) {
  41450. return;
  41451. }
  41452. this._captureCameraRenderTime = value;
  41453. if (value) {
  41454. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  41455. _this._cameraRenderTime.beginMonitoring();
  41456. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  41457. });
  41458. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  41459. _this._cameraRenderTime.endMonitoring(false);
  41460. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  41461. });
  41462. }
  41463. else {
  41464. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41465. this._onBeforeCameraRenderObserver = null;
  41466. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41467. this._onAfterCameraRenderObserver = null;
  41468. }
  41469. },
  41470. enumerable: true,
  41471. configurable: true
  41472. });
  41473. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  41474. /**
  41475. * Gets the perf counter used for draw calls
  41476. */
  41477. get: function () {
  41478. return this.scene.getEngine()._drawCalls;
  41479. },
  41480. enumerable: true,
  41481. configurable: true
  41482. });
  41483. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  41484. /**
  41485. * Gets the perf counter used for texture collisions
  41486. */
  41487. get: function () {
  41488. return this.scene.getEngine()._textureCollisions;
  41489. },
  41490. enumerable: true,
  41491. configurable: true
  41492. });
  41493. /**
  41494. * Dispose and release associated resources.
  41495. */
  41496. SceneInstrumentation.prototype.dispose = function () {
  41497. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41498. this._onAfterRenderObserver = null;
  41499. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41500. this._onBeforeActiveMeshesEvaluationObserver = null;
  41501. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41502. this._onAfterActiveMeshesEvaluationObserver = null;
  41503. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41504. this._onBeforeRenderTargetsRenderObserver = null;
  41505. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41506. this._onAfterRenderTargetsRenderObserver = null;
  41507. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  41508. this._onBeforeAnimationsObserver = null;
  41509. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41510. this._onBeforeParticlesRenderingObserver = null;
  41511. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41512. this._onAfterParticlesRenderingObserver = null;
  41513. if (this._onBeforeSpritesRenderingObserver) {
  41514. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41515. this._onBeforeSpritesRenderingObserver = null;
  41516. }
  41517. if (this._onAfterSpritesRenderingObserver) {
  41518. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41519. this._onAfterSpritesRenderingObserver = null;
  41520. }
  41521. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41522. this._onBeforeDrawPhaseObserver = null;
  41523. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41524. this._onAfterDrawPhaseObserver = null;
  41525. if (this._onBeforePhysicsObserver) {
  41526. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41527. this._onBeforePhysicsObserver = null;
  41528. }
  41529. if (this._onAfterPhysicsObserver) {
  41530. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41531. this._onAfterPhysicsObserver = null;
  41532. }
  41533. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41534. this._onAfterAnimationsObserver = null;
  41535. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41536. this._onBeforeCameraRenderObserver = null;
  41537. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41538. this._onAfterCameraRenderObserver = null;
  41539. this.scene = null;
  41540. };
  41541. return SceneInstrumentation;
  41542. }());
  41543. /***/ }),
  41544. /***/ "./Instrumentation/timeToken.ts":
  41545. /*!**************************************!*\
  41546. !*** ./Instrumentation/timeToken.ts ***!
  41547. \**************************************/
  41548. /*! exports provided: _TimeToken */
  41549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41550. "use strict";
  41551. __webpack_require__.r(__webpack_exports__);
  41552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  41553. /**
  41554. * @hidden
  41555. **/
  41556. var _TimeToken = /** @class */ (function () {
  41557. function _TimeToken() {
  41558. this._timeElapsedQueryEnded = false;
  41559. }
  41560. return _TimeToken;
  41561. }());
  41562. /***/ }),
  41563. /***/ "./Layers/effectLayer.ts":
  41564. /*!*******************************!*\
  41565. !*** ./Layers/effectLayer.ts ***!
  41566. \*******************************/
  41567. /*! exports provided: EffectLayer */
  41568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41569. "use strict";
  41570. __webpack_require__.r(__webpack_exports__);
  41571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  41572. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41573. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41574. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41575. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41576. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41577. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  41578. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41579. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41580. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41581. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41582. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  41583. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41584. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  41585. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  41586. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  41587. /**
  41588. * The effect layer Helps adding post process effect blended with the main pass.
  41589. *
  41590. * This can be for instance use to generate glow or higlight effects on the scene.
  41591. *
  41592. * The effect layer class can not be used directly and is intented to inherited from to be
  41593. * customized per effects.
  41594. */
  41595. var EffectLayer = /** @class */ (function () {
  41596. /**
  41597. * Instantiates a new effect Layer and references it in the scene.
  41598. * @param name The name of the layer
  41599. * @param scene The scene to use the layer in
  41600. */
  41601. function EffectLayer(
  41602. /** The Friendly of the effect in the scene */
  41603. name, scene) {
  41604. this._vertexBuffers = {};
  41605. this._maxSize = 0;
  41606. this._mainTextureDesiredSize = { width: 0, height: 0 };
  41607. this._shouldRender = true;
  41608. this._postProcesses = [];
  41609. this._textures = [];
  41610. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  41611. /**
  41612. * The clear color of the texture used to generate the glow map.
  41613. */
  41614. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  41615. /**
  41616. * Specifies wether the highlight layer is enabled or not.
  41617. */
  41618. this.isEnabled = true;
  41619. /**
  41620. * An event triggered when the effect layer has been disposed.
  41621. */
  41622. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41623. /**
  41624. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  41625. */
  41626. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41627. /**
  41628. * An event triggered when the generated texture is being merged in the scene.
  41629. */
  41630. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41631. /**
  41632. * An event triggered when the generated texture has been merged in the scene.
  41633. */
  41634. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41635. /**
  41636. * An event triggered when the efffect layer changes its size.
  41637. */
  41638. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41639. this.name = name;
  41640. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  41641. EffectLayer._SceneComponentInitialization(this._scene);
  41642. this._engine = this._scene.getEngine();
  41643. this._maxSize = this._engine.getCaps().maxTextureSize;
  41644. this._scene.effectLayers.push(this);
  41645. // Generate Buffers
  41646. this._generateIndexBuffer();
  41647. this._genrateVertexBuffer();
  41648. }
  41649. Object.defineProperty(EffectLayer.prototype, "camera", {
  41650. /**
  41651. * Gets the camera attached to the layer.
  41652. */
  41653. get: function () {
  41654. return this._effectLayerOptions.camera;
  41655. },
  41656. enumerable: true,
  41657. configurable: true
  41658. });
  41659. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  41660. /**
  41661. * Gets the rendering group id the layer should render in.
  41662. */
  41663. get: function () {
  41664. return this._effectLayerOptions.renderingGroupId;
  41665. },
  41666. enumerable: true,
  41667. configurable: true
  41668. });
  41669. /**
  41670. * Initializes the effect layer with the required options.
  41671. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  41672. */
  41673. EffectLayer.prototype._init = function (options) {
  41674. // Adapt options
  41675. 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);
  41676. this._setMainTextureSize();
  41677. this._createMainTexture();
  41678. this._createTextureAndPostProcesses();
  41679. this._mergeEffect = this._createMergeEffect();
  41680. };
  41681. /**
  41682. * Generates the index buffer of the full screen quad blending to the main canvas.
  41683. */
  41684. EffectLayer.prototype._generateIndexBuffer = function () {
  41685. // Indices
  41686. var indices = [];
  41687. indices.push(0);
  41688. indices.push(1);
  41689. indices.push(2);
  41690. indices.push(0);
  41691. indices.push(2);
  41692. indices.push(3);
  41693. this._indexBuffer = this._engine.createIndexBuffer(indices);
  41694. };
  41695. /**
  41696. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  41697. */
  41698. EffectLayer.prototype._genrateVertexBuffer = function () {
  41699. // VBO
  41700. var vertices = [];
  41701. vertices.push(1, 1);
  41702. vertices.push(-1, 1);
  41703. vertices.push(-1, -1);
  41704. vertices.push(1, -1);
  41705. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  41706. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  41707. };
  41708. /**
  41709. * Sets the main texture desired size which is the closest power of two
  41710. * of the engine canvas size.
  41711. */
  41712. EffectLayer.prototype._setMainTextureSize = function () {
  41713. if (this._effectLayerOptions.mainTextureFixedSize) {
  41714. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  41715. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  41716. }
  41717. else {
  41718. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  41719. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  41720. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  41721. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  41722. }
  41723. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  41724. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  41725. };
  41726. /**
  41727. * Creates the main texture for the effect layer.
  41728. */
  41729. EffectLayer.prototype._createMainTexture = function () {
  41730. var _this = this;
  41731. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  41732. width: this._mainTextureDesiredSize.width,
  41733. height: this._mainTextureDesiredSize.height
  41734. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  41735. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  41736. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41737. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41738. this._mainTexture.anisotropicFilteringLevel = 1;
  41739. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  41740. this._mainTexture.renderParticles = false;
  41741. this._mainTexture.renderList = null;
  41742. this._mainTexture.ignoreCameraViewport = true;
  41743. // Custom render function
  41744. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  41745. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  41746. var index;
  41747. var engine = _this._scene.getEngine();
  41748. if (depthOnlySubMeshes.length) {
  41749. engine.setColorWrite(false);
  41750. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  41751. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  41752. }
  41753. engine.setColorWrite(true);
  41754. }
  41755. for (index = 0; index < opaqueSubMeshes.length; index++) {
  41756. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  41757. }
  41758. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  41759. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  41760. }
  41761. for (index = 0; index < transparentSubMeshes.length; index++) {
  41762. _this._renderSubMesh(transparentSubMeshes.data[index]);
  41763. }
  41764. };
  41765. this._mainTexture.onClearObservable.add(function (engine) {
  41766. engine.clear(_this.neutralColor, true, true, true);
  41767. });
  41768. };
  41769. /**
  41770. * Adds specific effects defines.
  41771. * @param defines The defines to add specifics to.
  41772. */
  41773. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  41774. // Nothing to add by default.
  41775. };
  41776. /**
  41777. * Checks for the readiness of the element composing the layer.
  41778. * @param subMesh the mesh to check for
  41779. * @param useInstances specify wether or not to use instances to render the mesh
  41780. * @param emissiveTexture the associated emissive texture used to generate the glow
  41781. * @return true if ready otherwise, false
  41782. */
  41783. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  41784. var material = subMesh.getMaterial();
  41785. if (!material) {
  41786. return false;
  41787. }
  41788. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  41789. return false;
  41790. }
  41791. var defines = [];
  41792. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41793. var mesh = subMesh.getMesh();
  41794. var uv1 = false;
  41795. var uv2 = false;
  41796. // Diffuse
  41797. if (material) {
  41798. var needAlphaTest = material.needAlphaTesting();
  41799. var diffuseTexture = material.getAlphaTestTexture();
  41800. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41801. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41802. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41803. defines.push("#define DIFFUSE");
  41804. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41805. diffuseTexture.coordinatesIndex === 1) {
  41806. defines.push("#define DIFFUSEUV2");
  41807. uv2 = true;
  41808. }
  41809. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41810. defines.push("#define DIFFUSEUV1");
  41811. uv1 = true;
  41812. }
  41813. if (needAlphaTest) {
  41814. defines.push("#define ALPHATEST");
  41815. defines.push("#define ALPHATESTVALUE 0.4");
  41816. }
  41817. }
  41818. var opacityTexture = material.opacityTexture;
  41819. if (opacityTexture) {
  41820. defines.push("#define OPACITY");
  41821. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41822. opacityTexture.coordinatesIndex === 1) {
  41823. defines.push("#define OPACITYUV2");
  41824. uv2 = true;
  41825. }
  41826. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41827. defines.push("#define OPACITYUV1");
  41828. uv1 = true;
  41829. }
  41830. }
  41831. }
  41832. // Emissive
  41833. if (emissiveTexture) {
  41834. defines.push("#define EMISSIVE");
  41835. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41836. emissiveTexture.coordinatesIndex === 1) {
  41837. defines.push("#define EMISSIVEUV2");
  41838. uv2 = true;
  41839. }
  41840. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41841. defines.push("#define EMISSIVEUV1");
  41842. uv1 = true;
  41843. }
  41844. }
  41845. // Vertex
  41846. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41847. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41848. defines.push("#define VERTEXALPHA");
  41849. }
  41850. if (uv1) {
  41851. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41852. defines.push("#define UV1");
  41853. }
  41854. if (uv2) {
  41855. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41856. defines.push("#define UV2");
  41857. }
  41858. // Bones
  41859. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41860. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41861. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41862. if (mesh.numBoneInfluencers > 4) {
  41863. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41864. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41865. }
  41866. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41867. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41868. }
  41869. else {
  41870. defines.push("#define NUM_BONE_INFLUENCERS 0");
  41871. }
  41872. // Morph targets
  41873. var manager = mesh.morphTargetManager;
  41874. var morphInfluencers = 0;
  41875. if (manager) {
  41876. if (manager.numInfluencers > 0) {
  41877. defines.push("#define MORPHTARGETS");
  41878. morphInfluencers = manager.numInfluencers;
  41879. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  41880. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  41881. }
  41882. }
  41883. // Instances
  41884. if (useInstances) {
  41885. defines.push("#define INSTANCES");
  41886. attribs.push("world0");
  41887. attribs.push("world1");
  41888. attribs.push("world2");
  41889. attribs.push("world3");
  41890. }
  41891. this._addCustomEffectDefines(defines);
  41892. // Get correct effect
  41893. var join = defines.join("\n");
  41894. if (this._cachedDefines !== join) {
  41895. this._cachedDefines = join;
  41896. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  41897. "color", "morphTargetInfluences",
  41898. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  41899. }
  41900. return this._effectLayerMapGenerationEffect.isReady();
  41901. };
  41902. /**
  41903. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  41904. */
  41905. EffectLayer.prototype.render = function () {
  41906. var currentEffect = this._mergeEffect;
  41907. // Check
  41908. if (!currentEffect.isReady()) {
  41909. return;
  41910. }
  41911. for (var i = 0; i < this._postProcesses.length; i++) {
  41912. if (!this._postProcesses[i].isReady()) {
  41913. return;
  41914. }
  41915. }
  41916. var engine = this._scene.getEngine();
  41917. this.onBeforeComposeObservable.notifyObservers(this);
  41918. // Render
  41919. engine.enableEffect(currentEffect);
  41920. engine.setState(false);
  41921. // VBOs
  41922. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41923. // Cache
  41924. var previousAlphaMode = engine.getAlphaMode();
  41925. // Go Blend.
  41926. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  41927. // Blends the map on the main canvas.
  41928. this._internalRender(currentEffect);
  41929. // Restore Alpha
  41930. engine.setAlphaMode(previousAlphaMode);
  41931. this.onAfterComposeObservable.notifyObservers(this);
  41932. // Handle size changes.
  41933. var size = this._mainTexture.getSize();
  41934. this._setMainTextureSize();
  41935. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  41936. // Recreate RTT and post processes on size change.
  41937. this.onSizeChangedObservable.notifyObservers(this);
  41938. this._disposeTextureAndPostProcesses();
  41939. this._createMainTexture();
  41940. this._createTextureAndPostProcesses();
  41941. }
  41942. };
  41943. /**
  41944. * Determine if a given mesh will be used in the current effect.
  41945. * @param mesh mesh to test
  41946. * @returns true if the mesh will be used
  41947. */
  41948. EffectLayer.prototype.hasMesh = function (mesh) {
  41949. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  41950. return true;
  41951. }
  41952. return false;
  41953. };
  41954. /**
  41955. * Returns true if the layer contains information to display, otherwise false.
  41956. * @returns true if the glow layer should be rendered
  41957. */
  41958. EffectLayer.prototype.shouldRender = function () {
  41959. return this.isEnabled && this._shouldRender;
  41960. };
  41961. /**
  41962. * Returns true if the mesh should render, otherwise false.
  41963. * @param mesh The mesh to render
  41964. * @returns true if it should render otherwise false
  41965. */
  41966. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  41967. return true;
  41968. };
  41969. /**
  41970. * Returns true if the mesh can be rendered, otherwise false.
  41971. * @param mesh The mesh to render
  41972. * @param material The material used on the mesh
  41973. * @returns true if it can be rendered otherwise false
  41974. */
  41975. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  41976. return !material.needAlphaBlendingForMesh(mesh);
  41977. };
  41978. /**
  41979. * Returns true if the mesh should render, otherwise false.
  41980. * @param mesh The mesh to render
  41981. * @returns true if it should render otherwise false
  41982. */
  41983. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41984. return true;
  41985. };
  41986. /**
  41987. * Renders the submesh passed in parameter to the generation map.
  41988. */
  41989. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41990. var _this = this;
  41991. if (!this.shouldRender()) {
  41992. return;
  41993. }
  41994. var material = subMesh.getMaterial();
  41995. var mesh = subMesh.getRenderingMesh();
  41996. var scene = this._scene;
  41997. var engine = scene.getEngine();
  41998. if (!material) {
  41999. return;
  42000. }
  42001. // Do not block in blend mode.
  42002. if (!this._canRenderMesh(mesh, material)) {
  42003. return;
  42004. }
  42005. // Culling
  42006. engine.setState(material.backFaceCulling);
  42007. // Managing instances
  42008. var batch = mesh._getInstancesRenderList(subMesh._id);
  42009. if (batch.mustReturn) {
  42010. return;
  42011. }
  42012. // Early Exit per mesh
  42013. if (!this._shouldRenderMesh(mesh)) {
  42014. return;
  42015. }
  42016. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  42017. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  42018. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  42019. engine.enableEffect(this._effectLayerMapGenerationEffect);
  42020. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  42021. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  42022. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  42023. var needAlphaTest = material.needAlphaTesting();
  42024. var diffuseTexture = material.getAlphaTestTexture();
  42025. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42026. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42027. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42028. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  42029. var textureMatrix = diffuseTexture.getTextureMatrix();
  42030. if (textureMatrix) {
  42031. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  42032. }
  42033. }
  42034. var opacityTexture = material.opacityTexture;
  42035. if (opacityTexture) {
  42036. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  42037. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  42038. var textureMatrix = opacityTexture.getTextureMatrix();
  42039. if (textureMatrix) {
  42040. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  42041. }
  42042. }
  42043. // Glow emissive only
  42044. if (this._emissiveTextureAndColor.texture) {
  42045. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  42046. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  42047. }
  42048. // Bones
  42049. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  42050. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  42051. }
  42052. // Morph targets
  42053. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  42054. // Draw
  42055. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  42056. }
  42057. else {
  42058. // Need to reset refresh rate of the main map
  42059. this._mainTexture.resetRefreshCounter();
  42060. }
  42061. };
  42062. /**
  42063. * Rebuild the required buffers.
  42064. * @hidden Internal use only.
  42065. */
  42066. EffectLayer.prototype._rebuild = function () {
  42067. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42068. if (vb) {
  42069. vb._rebuild();
  42070. }
  42071. this._generateIndexBuffer();
  42072. };
  42073. /**
  42074. * Dispose only the render target textures and post process.
  42075. */
  42076. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  42077. this._mainTexture.dispose();
  42078. for (var i = 0; i < this._postProcesses.length; i++) {
  42079. if (this._postProcesses[i]) {
  42080. this._postProcesses[i].dispose();
  42081. }
  42082. }
  42083. this._postProcesses = [];
  42084. for (var i = 0; i < this._textures.length; i++) {
  42085. if (this._textures[i]) {
  42086. this._textures[i].dispose();
  42087. }
  42088. }
  42089. this._textures = [];
  42090. };
  42091. /**
  42092. * Dispose the highlight layer and free resources.
  42093. */
  42094. EffectLayer.prototype.dispose = function () {
  42095. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42096. if (vertexBuffer) {
  42097. vertexBuffer.dispose();
  42098. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  42099. }
  42100. if (this._indexBuffer) {
  42101. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42102. this._indexBuffer = null;
  42103. }
  42104. // Clean textures and post processes
  42105. this._disposeTextureAndPostProcesses();
  42106. // Remove from scene
  42107. var index = this._scene.effectLayers.indexOf(this, 0);
  42108. if (index > -1) {
  42109. this._scene.effectLayers.splice(index, 1);
  42110. }
  42111. // Callback
  42112. this.onDisposeObservable.notifyObservers(this);
  42113. this.onDisposeObservable.clear();
  42114. this.onBeforeRenderMainTextureObservable.clear();
  42115. this.onBeforeComposeObservable.clear();
  42116. this.onAfterComposeObservable.clear();
  42117. this.onSizeChangedObservable.clear();
  42118. };
  42119. /**
  42120. * Gets the class name of the effect layer
  42121. * @returns the string with the class name of the effect layer
  42122. */
  42123. EffectLayer.prototype.getClassName = function () {
  42124. return "EffectLayer";
  42125. };
  42126. /**
  42127. * Creates an effect layer from parsed effect layer data
  42128. * @param parsedEffectLayer defines effect layer data
  42129. * @param scene defines the current scene
  42130. * @param rootUrl defines the root URL containing the effect layer information
  42131. * @returns a parsed effect Layer
  42132. */
  42133. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  42134. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  42135. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  42136. };
  42137. /** @hidden */
  42138. EffectLayer._SceneComponentInitialization = function (_) {
  42139. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  42140. };
  42141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42143. ], EffectLayer.prototype, "name", void 0);
  42144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  42146. ], EffectLayer.prototype, "neutralColor", void 0);
  42147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42149. ], EffectLayer.prototype, "isEnabled", void 0);
  42150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  42152. ], EffectLayer.prototype, "camera", null);
  42153. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42154. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42155. ], EffectLayer.prototype, "renderingGroupId", null);
  42156. return EffectLayer;
  42157. }());
  42158. /***/ }),
  42159. /***/ "./Layers/effectLayerSceneComponent.ts":
  42160. /*!*********************************************!*\
  42161. !*** ./Layers/effectLayerSceneComponent.ts ***!
  42162. \*********************************************/
  42163. /*! exports provided: EffectLayerSceneComponent */
  42164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42165. "use strict";
  42166. __webpack_require__.r(__webpack_exports__);
  42167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  42168. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  42169. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42170. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42171. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42172. // Adds the parser to the scene parsers.
  42173. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  42174. if (parsedData.effectLayers) {
  42175. if (!container.effectLayers) {
  42176. container.effectLayers = new Array();
  42177. }
  42178. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  42179. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  42180. container.effectLayers.push(effectLayer);
  42181. }
  42182. }
  42183. });
  42184. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  42185. var index = this.effectLayers.indexOf(toRemove);
  42186. if (index !== -1) {
  42187. this.effectLayers.splice(index, 1);
  42188. }
  42189. return index;
  42190. };
  42191. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  42192. this.effectLayers.push(newEffectLayer);
  42193. };
  42194. /**
  42195. * Defines the layer scene component responsible to manage any effect layers
  42196. * in a given scene.
  42197. */
  42198. var EffectLayerSceneComponent = /** @class */ (function () {
  42199. /**
  42200. * Creates a new instance of the component for the given scene
  42201. * @param scene Defines the scene to register the component in
  42202. */
  42203. function EffectLayerSceneComponent(scene) {
  42204. /**
  42205. * The component name helpfull to identify the component in the list of scene components.
  42206. */
  42207. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  42208. this._renderEffects = false;
  42209. this._needStencil = false;
  42210. this._previousStencilState = false;
  42211. this.scene = scene;
  42212. this._engine = scene.getEngine();
  42213. scene.effectLayers = new Array();
  42214. }
  42215. /**
  42216. * Registers the component in a given scene
  42217. */
  42218. EffectLayerSceneComponent.prototype.register = function () {
  42219. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  42220. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  42221. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  42222. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  42223. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  42224. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  42225. };
  42226. /**
  42227. * Rebuilds the elements related to this component in case of
  42228. * context lost for instance.
  42229. */
  42230. EffectLayerSceneComponent.prototype.rebuild = function () {
  42231. var layers = this.scene.effectLayers;
  42232. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42233. var effectLayer = layers_1[_i];
  42234. effectLayer._rebuild();
  42235. }
  42236. };
  42237. /**
  42238. * Serializes the component data to the specified json object
  42239. * @param serializationObject The object to serialize to
  42240. */
  42241. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  42242. // Effect layers
  42243. serializationObject.effectLayers = [];
  42244. var layers = this.scene.effectLayers;
  42245. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42246. var effectLayer = layers_2[_i];
  42247. if (effectLayer.serialize) {
  42248. serializationObject.effectLayers.push(effectLayer.serialize());
  42249. }
  42250. }
  42251. };
  42252. /**
  42253. * Adds all the element from the container to the scene
  42254. * @param container the container holding the elements
  42255. */
  42256. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  42257. var _this = this;
  42258. if (!container.effectLayers) {
  42259. return;
  42260. }
  42261. container.effectLayers.forEach(function (o) {
  42262. _this.scene.addEffectLayer(o);
  42263. });
  42264. };
  42265. /**
  42266. * Removes all the elements in the container from the scene
  42267. * @param container contains the elements to remove
  42268. */
  42269. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  42270. var _this = this;
  42271. if (!container.effectLayers) {
  42272. return;
  42273. }
  42274. container.effectLayers.forEach(function (o) {
  42275. _this.scene.removeEffectLayer(o);
  42276. });
  42277. };
  42278. /**
  42279. * Disposes the component and the associated ressources.
  42280. */
  42281. EffectLayerSceneComponent.prototype.dispose = function () {
  42282. var layers = this.scene.effectLayers;
  42283. while (layers.length) {
  42284. layers[0].dispose();
  42285. }
  42286. };
  42287. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  42288. var layers = this.scene.effectLayers;
  42289. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  42290. var layer = layers_3[_i];
  42291. if (!layer.hasMesh(mesh)) {
  42292. continue;
  42293. }
  42294. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  42295. var subMesh = _b[_a];
  42296. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  42297. return false;
  42298. }
  42299. }
  42300. }
  42301. return true;
  42302. };
  42303. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  42304. this._renderEffects = false;
  42305. this._needStencil = false;
  42306. var layers = this.scene.effectLayers;
  42307. if (layers && layers.length > 0) {
  42308. this._previousStencilState = this._engine.getStencilBuffer();
  42309. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  42310. var effectLayer = layers_4[_i];
  42311. if (effectLayer.shouldRender() &&
  42312. (!effectLayer.camera ||
  42313. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  42314. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  42315. this._renderEffects = true;
  42316. this._needStencil = this._needStencil || effectLayer.needStencil();
  42317. var renderTarget = effectLayer._mainTexture;
  42318. if (renderTarget._shouldRender()) {
  42319. this.scene.incrementRenderId();
  42320. renderTarget.render(false, false);
  42321. }
  42322. }
  42323. }
  42324. this.scene.incrementRenderId();
  42325. }
  42326. };
  42327. EffectLayerSceneComponent.prototype._setStencil = function () {
  42328. // Activate effect Layer stencil
  42329. if (this._needStencil) {
  42330. this._engine.setStencilBuffer(true);
  42331. }
  42332. };
  42333. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  42334. // Restore effect Layer stencil
  42335. if (this._needStencil) {
  42336. this._engine.setStencilBuffer(this._previousStencilState);
  42337. }
  42338. };
  42339. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  42340. if (this._renderEffects) {
  42341. this._engine.setDepthBuffer(false);
  42342. var layers = this.scene.effectLayers;
  42343. for (var i = 0; i < layers.length; i++) {
  42344. var effectLayer = layers[i];
  42345. if (effectLayer.renderingGroupId === renderingGroupId) {
  42346. if (effectLayer.shouldRender()) {
  42347. effectLayer.render();
  42348. }
  42349. }
  42350. }
  42351. this._engine.setDepthBuffer(true);
  42352. }
  42353. };
  42354. EffectLayerSceneComponent.prototype._drawCamera = function () {
  42355. if (this._renderEffects) {
  42356. this._draw(-1);
  42357. }
  42358. };
  42359. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  42360. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  42361. this._draw(index);
  42362. }
  42363. };
  42364. return EffectLayerSceneComponent;
  42365. }());
  42366. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  42367. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  42368. if (!component) {
  42369. component = new EffectLayerSceneComponent(scene);
  42370. scene._addComponent(component);
  42371. }
  42372. };
  42373. /***/ }),
  42374. /***/ "./Layers/glowLayer.ts":
  42375. /*!*****************************!*\
  42376. !*** ./Layers/glowLayer.ts ***!
  42377. \*****************************/
  42378. /*! exports provided: GlowLayer */
  42379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42380. "use strict";
  42381. __webpack_require__.r(__webpack_exports__);
  42382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  42383. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42384. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42385. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42386. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42387. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42388. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42389. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42390. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42391. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42392. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42393. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42394. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42395. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42396. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42397. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42398. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42399. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  42400. for (var index = 0; index < this.effectLayers.length; index++) {
  42401. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  42402. return this.effectLayers[index];
  42403. }
  42404. }
  42405. return null;
  42406. };
  42407. /**
  42408. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  42409. *
  42410. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42411. * glowy meshes to your scene.
  42412. *
  42413. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  42414. */
  42415. var GlowLayer = /** @class */ (function (_super) {
  42416. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  42417. /**
  42418. * Instantiates a new glow Layer and references it to the scene.
  42419. * @param name The name of the layer
  42420. * @param scene The scene to use the layer in
  42421. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  42422. */
  42423. function GlowLayer(name, scene, options) {
  42424. var _this = _super.call(this, name, scene) || this;
  42425. _this._intensity = 1.0;
  42426. _this._includedOnlyMeshes = [];
  42427. _this._excludedMeshes = [];
  42428. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  42429. // Adapt options
  42430. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  42431. // Initialize the layer
  42432. _this._init({
  42433. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  42434. camera: _this._options.camera,
  42435. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42436. mainTextureRatio: _this._options.mainTextureRatio,
  42437. renderingGroupId: _this._options.renderingGroupId
  42438. });
  42439. return _this;
  42440. }
  42441. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  42442. /**
  42443. * Gets the kernel size of the blur.
  42444. */
  42445. get: function () {
  42446. return this._horizontalBlurPostprocess1.kernel;
  42447. },
  42448. /**
  42449. * Sets the kernel size of the blur.
  42450. */
  42451. set: function (value) {
  42452. this._horizontalBlurPostprocess1.kernel = value;
  42453. this._verticalBlurPostprocess1.kernel = value;
  42454. this._horizontalBlurPostprocess2.kernel = value;
  42455. this._verticalBlurPostprocess2.kernel = value;
  42456. },
  42457. enumerable: true,
  42458. configurable: true
  42459. });
  42460. Object.defineProperty(GlowLayer.prototype, "intensity", {
  42461. /**
  42462. * Gets the glow intensity.
  42463. */
  42464. get: function () {
  42465. return this._intensity;
  42466. },
  42467. /**
  42468. * Sets the glow intensity.
  42469. */
  42470. set: function (value) {
  42471. this._intensity = value;
  42472. },
  42473. enumerable: true,
  42474. configurable: true
  42475. });
  42476. /**
  42477. * Get the effect name of the layer.
  42478. * @return The effect name
  42479. */
  42480. GlowLayer.prototype.getEffectName = function () {
  42481. return GlowLayer.EffectName;
  42482. };
  42483. /**
  42484. * Create the merge effect. This is the shader use to blit the information back
  42485. * to the main canvas at the end of the scene rendering.
  42486. */
  42487. GlowLayer.prototype._createMergeEffect = function () {
  42488. // Effect
  42489. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  42490. };
  42491. /**
  42492. * Creates the render target textures and post processes used in the glow layer.
  42493. */
  42494. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  42495. var _this = this;
  42496. var blurTextureWidth = this._mainTextureDesiredSize.width;
  42497. var blurTextureHeight = this._mainTextureDesiredSize.height;
  42498. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42499. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42500. var textureType = 0;
  42501. if (this._engine.getCaps().textureHalfFloatRender) {
  42502. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42503. }
  42504. else {
  42505. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42506. }
  42507. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  42508. width: blurTextureWidth,
  42509. height: blurTextureHeight
  42510. }, this._scene, false, true, textureType);
  42511. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42512. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42513. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42514. this._blurTexture1.renderParticles = false;
  42515. this._blurTexture1.ignoreCameraViewport = true;
  42516. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  42517. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  42518. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  42519. width: blurTextureWidth2,
  42520. height: blurTextureHeight2
  42521. }, this._scene, false, true, textureType);
  42522. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42523. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42524. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42525. this._blurTexture2.renderParticles = false;
  42526. this._blurTexture2.ignoreCameraViewport = true;
  42527. this._textures = [this._blurTexture1, this._blurTexture2];
  42528. 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, {
  42529. width: blurTextureWidth,
  42530. height: blurTextureHeight
  42531. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42532. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  42533. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  42534. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  42535. effect.setTexture("textureSampler", _this._mainTexture);
  42536. });
  42537. 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, {
  42538. width: blurTextureWidth,
  42539. height: blurTextureHeight
  42540. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42541. 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, {
  42542. width: blurTextureWidth2,
  42543. height: blurTextureHeight2
  42544. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42545. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  42546. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  42547. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  42548. effect.setTexture("textureSampler", _this._blurTexture1);
  42549. });
  42550. 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, {
  42551. width: blurTextureWidth2,
  42552. height: blurTextureHeight2
  42553. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42554. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  42555. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  42556. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  42557. this._mainTexture.samples = this._options.mainTextureSamples;
  42558. this._mainTexture.onAfterUnbindObservable.add(function () {
  42559. var internalTexture = _this._blurTexture1.getInternalTexture();
  42560. if (internalTexture) {
  42561. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  42562. internalTexture = _this._blurTexture2.getInternalTexture();
  42563. if (internalTexture) {
  42564. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  42565. }
  42566. }
  42567. });
  42568. // Prevent autoClear.
  42569. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42570. };
  42571. /**
  42572. * Checks for the readiness of the element composing the layer.
  42573. * @param subMesh the mesh to check for
  42574. * @param useInstances specify wether or not to use instances to render the mesh
  42575. * @param emissiveTexture the associated emissive texture used to generate the glow
  42576. * @return true if ready otherwise, false
  42577. */
  42578. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  42579. var material = subMesh.getMaterial();
  42580. var mesh = subMesh.getRenderingMesh();
  42581. if (!material || !mesh) {
  42582. return false;
  42583. }
  42584. var emissiveTexture = material.emissiveTexture;
  42585. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42586. };
  42587. /**
  42588. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42589. */
  42590. GlowLayer.prototype.needStencil = function () {
  42591. return false;
  42592. };
  42593. /**
  42594. * Returns true if the mesh can be rendered, otherwise false.
  42595. * @param mesh The mesh to render
  42596. * @param material The material used on the mesh
  42597. * @returns true if it can be rendered otherwise false
  42598. */
  42599. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  42600. return true;
  42601. };
  42602. /**
  42603. * Implementation specific of rendering the generating effect on the main canvas.
  42604. * @param effect The effect used to render through
  42605. */
  42606. GlowLayer.prototype._internalRender = function (effect) {
  42607. // Texture
  42608. effect.setTexture("textureSampler", this._blurTexture1);
  42609. effect.setTexture("textureSampler2", this._blurTexture2);
  42610. effect.setFloat("offset", this._intensity);
  42611. // Cache
  42612. var engine = this._engine;
  42613. var previousStencilBuffer = engine.getStencilBuffer();
  42614. // Draw order
  42615. engine.setStencilBuffer(false);
  42616. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  42617. // Draw order
  42618. engine.setStencilBuffer(previousStencilBuffer);
  42619. };
  42620. /**
  42621. * Sets the required values for both the emissive texture and and the main color.
  42622. */
  42623. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42624. var textureLevel = 1.0;
  42625. if (this.customEmissiveTextureSelector) {
  42626. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  42627. }
  42628. else {
  42629. if (material) {
  42630. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42631. if (this._emissiveTextureAndColor.texture) {
  42632. textureLevel = this._emissiveTextureAndColor.texture.level;
  42633. }
  42634. }
  42635. else {
  42636. this._emissiveTextureAndColor.texture = null;
  42637. }
  42638. }
  42639. if (this.customEmissiveColorSelector) {
  42640. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  42641. }
  42642. else {
  42643. if (material.emissiveColor) {
  42644. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  42645. }
  42646. else {
  42647. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42648. }
  42649. }
  42650. };
  42651. /**
  42652. * Returns true if the mesh should render, otherwise false.
  42653. * @param mesh The mesh to render
  42654. * @returns true if it should render otherwise false
  42655. */
  42656. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  42657. return this.hasMesh(mesh);
  42658. };
  42659. /**
  42660. * Adds specific effects defines.
  42661. * @param defines The defines to add specifics to.
  42662. */
  42663. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  42664. defines.push("#define GLOW");
  42665. };
  42666. /**
  42667. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  42668. * @param mesh The mesh to exclude from the glow layer
  42669. */
  42670. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  42671. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  42672. this._excludedMeshes.push(mesh.uniqueId);
  42673. }
  42674. };
  42675. /**
  42676. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  42677. * @param mesh The mesh to remove
  42678. */
  42679. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  42680. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  42681. if (index !== -1) {
  42682. this._excludedMeshes.splice(index, 1);
  42683. }
  42684. };
  42685. /**
  42686. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  42687. * @param mesh The mesh to include in the glow layer
  42688. */
  42689. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  42690. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  42691. this._includedOnlyMeshes.push(mesh.uniqueId);
  42692. }
  42693. };
  42694. /**
  42695. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  42696. * @param mesh The mesh to remove
  42697. */
  42698. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  42699. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  42700. if (index !== -1) {
  42701. this._includedOnlyMeshes.splice(index, 1);
  42702. }
  42703. };
  42704. /**
  42705. * Determine if a given mesh will be used in the glow layer
  42706. * @param mesh The mesh to test
  42707. * @returns true if the mesh will be highlighted by the current glow layer
  42708. */
  42709. GlowLayer.prototype.hasMesh = function (mesh) {
  42710. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42711. return false;
  42712. }
  42713. // Included Mesh
  42714. if (this._includedOnlyMeshes.length) {
  42715. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  42716. }
  42717. // Excluded Mesh
  42718. if (this._excludedMeshes.length) {
  42719. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  42720. }
  42721. return true;
  42722. };
  42723. /**
  42724. * Free any resources and references associated to a mesh.
  42725. * Internal use
  42726. * @param mesh The mesh to free.
  42727. * @hidden
  42728. */
  42729. GlowLayer.prototype._disposeMesh = function (mesh) {
  42730. this.removeIncludedOnlyMesh(mesh);
  42731. this.removeExcludedMesh(mesh);
  42732. };
  42733. /**
  42734. * Gets the class name of the effect layer
  42735. * @returns the string with the class name of the effect layer
  42736. */
  42737. GlowLayer.prototype.getClassName = function () {
  42738. return "GlowLayer";
  42739. };
  42740. /**
  42741. * Serializes this glow layer
  42742. * @returns a serialized glow layer object
  42743. */
  42744. GlowLayer.prototype.serialize = function () {
  42745. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42746. serializationObject.customType = "BABYLON.GlowLayer";
  42747. var index;
  42748. // Included meshes
  42749. serializationObject.includedMeshes = [];
  42750. if (this._includedOnlyMeshes.length) {
  42751. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  42752. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  42753. if (mesh) {
  42754. serializationObject.includedMeshes.push(mesh.id);
  42755. }
  42756. }
  42757. }
  42758. // Excluded meshes
  42759. serializationObject.excludedMeshes = [];
  42760. if (this._excludedMeshes.length) {
  42761. for (index = 0; index < this._excludedMeshes.length; index++) {
  42762. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  42763. if (mesh) {
  42764. serializationObject.excludedMeshes.push(mesh.id);
  42765. }
  42766. }
  42767. }
  42768. return serializationObject;
  42769. };
  42770. /**
  42771. * Creates a Glow Layer from parsed glow layer data
  42772. * @param parsedGlowLayer defines glow layer data
  42773. * @param scene defines the current scene
  42774. * @param rootUrl defines the root URL containing the glow layer information
  42775. * @returns a parsed Glow Layer
  42776. */
  42777. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  42778. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  42779. var index;
  42780. // Excluded meshes
  42781. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  42782. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  42783. if (mesh) {
  42784. gl.addExcludedMesh(mesh);
  42785. }
  42786. }
  42787. // Included meshes
  42788. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  42789. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  42790. if (mesh) {
  42791. gl.addIncludedOnlyMesh(mesh);
  42792. }
  42793. }
  42794. return gl;
  42795. };
  42796. /**
  42797. * Effect Name of the layer.
  42798. */
  42799. GlowLayer.EffectName = "GlowLayer";
  42800. /**
  42801. * The default blur kernel size used for the glow.
  42802. */
  42803. GlowLayer.DefaultBlurKernelSize = 32;
  42804. /**
  42805. * The default texture size ratio used for the glow.
  42806. */
  42807. GlowLayer.DefaultTextureRatio = 0.5;
  42808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42810. ], GlowLayer.prototype, "blurKernelSize", null);
  42811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42813. ], GlowLayer.prototype, "intensity", null);
  42814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42816. ], GlowLayer.prototype, "_options", void 0);
  42817. return GlowLayer;
  42818. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42819. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42820. /***/ }),
  42821. /***/ "./Layers/highlightLayer.ts":
  42822. /*!**********************************!*\
  42823. !*** ./Layers/highlightLayer.ts ***!
  42824. \**********************************/
  42825. /*! exports provided: HighlightLayer */
  42826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42827. "use strict";
  42828. __webpack_require__.r(__webpack_exports__);
  42829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42830. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42831. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42832. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42833. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42834. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42835. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42836. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42837. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42838. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42839. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42840. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42841. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42842. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42843. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42844. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42845. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42846. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42847. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42848. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42849. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42850. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42851. for (var index = 0; index < this.effectLayers.length; index++) {
  42852. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42853. return this.effectLayers[index];
  42854. }
  42855. }
  42856. return null;
  42857. };
  42858. /**
  42859. * Special Glow Blur post process only blurring the alpha channel
  42860. * It enforces keeping the most luminous color in the color channel.
  42861. */
  42862. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42863. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42864. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42865. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42866. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  42867. _this.direction = direction;
  42868. _this.kernel = kernel;
  42869. _this.onApplyObservable.add(function (effect) {
  42870. effect.setFloat2("screenSize", _this.width, _this.height);
  42871. effect.setVector2("direction", _this.direction);
  42872. effect.setFloat("blurWidth", _this.kernel);
  42873. });
  42874. return _this;
  42875. }
  42876. return GlowBlurPostProcess;
  42877. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  42878. /**
  42879. * The highlight layer Helps adding a glow effect around a mesh.
  42880. *
  42881. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42882. * glowy meshes to your scene.
  42883. *
  42884. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  42885. */
  42886. var HighlightLayer = /** @class */ (function (_super) {
  42887. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  42888. /**
  42889. * Instantiates a new highlight Layer and references it to the scene..
  42890. * @param name The name of the layer
  42891. * @param scene The scene to use the layer in
  42892. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  42893. */
  42894. function HighlightLayer(name, scene, options) {
  42895. var _this = _super.call(this, name, scene) || this;
  42896. _this.name = name;
  42897. /**
  42898. * Specifies whether or not the inner glow is ACTIVE in the layer.
  42899. */
  42900. _this.innerGlow = true;
  42901. /**
  42902. * Specifies whether or not the outer glow is ACTIVE in the layer.
  42903. */
  42904. _this.outerGlow = true;
  42905. /**
  42906. * An event triggered when the highlight layer is being blurred.
  42907. */
  42908. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42909. /**
  42910. * An event triggered when the highlight layer has been blurred.
  42911. */
  42912. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42913. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  42914. _this._meshes = {};
  42915. _this._excludedMeshes = {};
  42916. _this.neutralColor = HighlightLayer.NeutralColor;
  42917. // Warn on stencil
  42918. if (!_this._engine.isStencilEnable) {
  42919. _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 }");
  42920. }
  42921. // Adapt options
  42922. _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);
  42923. // Initialize the layer
  42924. _this._init({
  42925. alphaBlendingMode: _this._options.alphaBlendingMode,
  42926. camera: _this._options.camera,
  42927. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42928. mainTextureRatio: _this._options.mainTextureRatio,
  42929. renderingGroupId: _this._options.renderingGroupId
  42930. });
  42931. // Do not render as long as no meshes have been added
  42932. _this._shouldRender = false;
  42933. return _this;
  42934. }
  42935. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  42936. /**
  42937. * Gets the horizontal size of the blur.
  42938. */
  42939. get: function () {
  42940. return this._horizontalBlurPostprocess.kernel;
  42941. },
  42942. /**
  42943. * Specifies the horizontal size of the blur.
  42944. */
  42945. set: function (value) {
  42946. this._horizontalBlurPostprocess.kernel = value;
  42947. },
  42948. enumerable: true,
  42949. configurable: true
  42950. });
  42951. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  42952. /**
  42953. * Gets the vertical size of the blur.
  42954. */
  42955. get: function () {
  42956. return this._verticalBlurPostprocess.kernel;
  42957. },
  42958. /**
  42959. * Specifies the vertical size of the blur.
  42960. */
  42961. set: function (value) {
  42962. this._verticalBlurPostprocess.kernel = value;
  42963. },
  42964. enumerable: true,
  42965. configurable: true
  42966. });
  42967. /**
  42968. * Get the effect name of the layer.
  42969. * @return The effect name
  42970. */
  42971. HighlightLayer.prototype.getEffectName = function () {
  42972. return HighlightLayer.EffectName;
  42973. };
  42974. /**
  42975. * Create the merge effect. This is the shader use to blit the information back
  42976. * to the main canvas at the end of the scene rendering.
  42977. */
  42978. HighlightLayer.prototype._createMergeEffect = function () {
  42979. // Effect
  42980. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  42981. };
  42982. /**
  42983. * Creates the render target textures and post processes used in the highlight layer.
  42984. */
  42985. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42986. var _this = this;
  42987. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42988. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42989. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42990. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42991. var textureType = 0;
  42992. if (this._engine.getCaps().textureHalfFloatRender) {
  42993. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42994. }
  42995. else {
  42996. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42997. }
  42998. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42999. width: blurTextureWidth,
  43000. height: blurTextureHeight
  43001. }, this._scene, false, true, textureType);
  43002. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43003. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43004. this._blurTexture.anisotropicFilteringLevel = 16;
  43005. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  43006. this._blurTexture.renderParticles = false;
  43007. this._blurTexture.ignoreCameraViewport = true;
  43008. this._textures = [this._blurTexture];
  43009. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  43010. 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());
  43011. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  43012. effect.setTexture("textureSampler", _this._mainTexture);
  43013. });
  43014. 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());
  43015. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43016. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43017. });
  43018. 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());
  43019. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  43020. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43021. });
  43022. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43023. }
  43024. else {
  43025. 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, {
  43026. width: blurTextureWidth,
  43027. height: blurTextureHeight
  43028. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43029. this._horizontalBlurPostprocess.width = blurTextureWidth;
  43030. this._horizontalBlurPostprocess.height = blurTextureHeight;
  43031. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43032. effect.setTexture("textureSampler", _this._mainTexture);
  43033. });
  43034. 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, {
  43035. width: blurTextureWidth,
  43036. height: blurTextureHeight
  43037. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43038. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43039. }
  43040. this._mainTexture.onAfterUnbindObservable.add(function () {
  43041. _this.onBeforeBlurObservable.notifyObservers(_this);
  43042. var internalTexture = _this._blurTexture.getInternalTexture();
  43043. if (internalTexture) {
  43044. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  43045. }
  43046. _this.onAfterBlurObservable.notifyObservers(_this);
  43047. });
  43048. // Prevent autoClear.
  43049. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43050. };
  43051. /**
  43052. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43053. */
  43054. HighlightLayer.prototype.needStencil = function () {
  43055. return true;
  43056. };
  43057. /**
  43058. * Checks for the readiness of the element composing the layer.
  43059. * @param subMesh the mesh to check for
  43060. * @param useInstances specify wether or not to use instances to render the mesh
  43061. * @param emissiveTexture the associated emissive texture used to generate the glow
  43062. * @return true if ready otherwise, false
  43063. */
  43064. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  43065. var material = subMesh.getMaterial();
  43066. var mesh = subMesh.getRenderingMesh();
  43067. if (!material || !mesh || !this._meshes) {
  43068. return false;
  43069. }
  43070. var emissiveTexture = null;
  43071. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43072. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43073. emissiveTexture = material.emissiveTexture;
  43074. }
  43075. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43076. };
  43077. /**
  43078. * Implementation specific of rendering the generating effect on the main canvas.
  43079. * @param effect The effect used to render through
  43080. */
  43081. HighlightLayer.prototype._internalRender = function (effect) {
  43082. // Texture
  43083. effect.setTexture("textureSampler", this._blurTexture);
  43084. // Cache
  43085. var engine = this._engine;
  43086. engine.cacheStencilState();
  43087. // Stencil operations
  43088. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  43089. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43090. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43091. // Draw order
  43092. engine.setStencilMask(0x00);
  43093. engine.setStencilBuffer(true);
  43094. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  43095. // 2 passes inner outer
  43096. if (this.outerGlow) {
  43097. effect.setFloat("offset", 0);
  43098. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  43099. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43100. }
  43101. if (this.innerGlow) {
  43102. effect.setFloat("offset", 1);
  43103. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  43104. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43105. }
  43106. // Restore Cache
  43107. engine.restoreStencilState();
  43108. };
  43109. /**
  43110. * Returns true if the layer contains information to display, otherwise false.
  43111. */
  43112. HighlightLayer.prototype.shouldRender = function () {
  43113. if (_super.prototype.shouldRender.call(this)) {
  43114. return this._meshes ? true : false;
  43115. }
  43116. return false;
  43117. };
  43118. /**
  43119. * Returns true if the mesh should render, otherwise false.
  43120. * @param mesh The mesh to render
  43121. * @returns true if it should render otherwise false
  43122. */
  43123. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  43124. // Excluded Mesh
  43125. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  43126. return false;
  43127. }
  43128. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43129. return false;
  43130. }
  43131. return true;
  43132. };
  43133. /**
  43134. * Sets the required values for both the emissive texture and and the main color.
  43135. */
  43136. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43137. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43138. if (highlightLayerMesh) {
  43139. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  43140. }
  43141. else {
  43142. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43143. }
  43144. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43145. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43146. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  43147. }
  43148. else {
  43149. this._emissiveTextureAndColor.texture = null;
  43150. }
  43151. };
  43152. /**
  43153. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43154. * @param mesh The mesh to exclude from the highlight layer
  43155. */
  43156. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  43157. if (!this._excludedMeshes) {
  43158. return;
  43159. }
  43160. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43161. if (!meshExcluded) {
  43162. this._excludedMeshes[mesh.uniqueId] = {
  43163. mesh: mesh,
  43164. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  43165. mesh.getEngine().setStencilBuffer(false);
  43166. }),
  43167. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  43168. mesh.getEngine().setStencilBuffer(true);
  43169. }),
  43170. };
  43171. }
  43172. };
  43173. /**
  43174. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43175. * @param mesh The mesh to highlight
  43176. */
  43177. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  43178. if (!this._excludedMeshes) {
  43179. return;
  43180. }
  43181. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43182. if (meshExcluded) {
  43183. if (meshExcluded.beforeBind) {
  43184. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  43185. }
  43186. if (meshExcluded.afterRender) {
  43187. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  43188. }
  43189. }
  43190. this._excludedMeshes[mesh.uniqueId] = null;
  43191. };
  43192. /**
  43193. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43194. * @param mesh mesh to test
  43195. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43196. */
  43197. HighlightLayer.prototype.hasMesh = function (mesh) {
  43198. if (!this._meshes) {
  43199. return false;
  43200. }
  43201. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43202. return false;
  43203. }
  43204. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  43205. };
  43206. /**
  43207. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43208. * @param mesh The mesh to highlight
  43209. * @param color The color of the highlight
  43210. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43211. */
  43212. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  43213. var _this = this;
  43214. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  43215. if (!this._meshes) {
  43216. return;
  43217. }
  43218. var meshHighlight = this._meshes[mesh.uniqueId];
  43219. if (meshHighlight) {
  43220. meshHighlight.color = color;
  43221. }
  43222. else {
  43223. this._meshes[mesh.uniqueId] = {
  43224. mesh: mesh,
  43225. color: color,
  43226. // Lambda required for capture due to Observable this context
  43227. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  43228. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  43229. _this._defaultStencilReference(mesh);
  43230. }
  43231. else {
  43232. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  43233. }
  43234. }),
  43235. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  43236. glowEmissiveOnly: glowEmissiveOnly
  43237. };
  43238. mesh.onDisposeObservable.add(function () {
  43239. _this._disposeMesh(mesh);
  43240. });
  43241. }
  43242. this._shouldRender = true;
  43243. };
  43244. /**
  43245. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43246. * @param mesh The mesh to highlight
  43247. */
  43248. HighlightLayer.prototype.removeMesh = function (mesh) {
  43249. if (!this._meshes) {
  43250. return;
  43251. }
  43252. var meshHighlight = this._meshes[mesh.uniqueId];
  43253. if (meshHighlight) {
  43254. if (meshHighlight.observerHighlight) {
  43255. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43256. }
  43257. if (meshHighlight.observerDefault) {
  43258. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43259. }
  43260. delete this._meshes[mesh.uniqueId];
  43261. }
  43262. this._shouldRender = false;
  43263. for (var meshHighlightToCheck in this._meshes) {
  43264. if (this._meshes[meshHighlightToCheck]) {
  43265. this._shouldRender = true;
  43266. break;
  43267. }
  43268. }
  43269. };
  43270. /**
  43271. * Force the stencil to the normal expected value for none glowing parts
  43272. */
  43273. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  43274. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  43275. };
  43276. /**
  43277. * Free any resources and references associated to a mesh.
  43278. * Internal use
  43279. * @param mesh The mesh to free.
  43280. * @hidden
  43281. */
  43282. HighlightLayer.prototype._disposeMesh = function (mesh) {
  43283. this.removeMesh(mesh);
  43284. this.removeExcludedMesh(mesh);
  43285. };
  43286. /**
  43287. * Dispose the highlight layer and free resources.
  43288. */
  43289. HighlightLayer.prototype.dispose = function () {
  43290. if (this._meshes) {
  43291. // Clean mesh references
  43292. for (var id in this._meshes) {
  43293. var meshHighlight = this._meshes[id];
  43294. if (meshHighlight && meshHighlight.mesh) {
  43295. if (meshHighlight.observerHighlight) {
  43296. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43297. }
  43298. if (meshHighlight.observerDefault) {
  43299. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43300. }
  43301. }
  43302. }
  43303. this._meshes = null;
  43304. }
  43305. if (this._excludedMeshes) {
  43306. for (var id in this._excludedMeshes) {
  43307. var meshHighlight = this._excludedMeshes[id];
  43308. if (meshHighlight) {
  43309. if (meshHighlight.beforeBind) {
  43310. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  43311. }
  43312. if (meshHighlight.afterRender) {
  43313. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  43314. }
  43315. }
  43316. }
  43317. this._excludedMeshes = null;
  43318. }
  43319. _super.prototype.dispose.call(this);
  43320. };
  43321. /**
  43322. * Gets the class name of the effect layer
  43323. * @returns the string with the class name of the effect layer
  43324. */
  43325. HighlightLayer.prototype.getClassName = function () {
  43326. return "HighlightLayer";
  43327. };
  43328. /**
  43329. * Serializes this Highlight layer
  43330. * @returns a serialized Highlight layer object
  43331. */
  43332. HighlightLayer.prototype.serialize = function () {
  43333. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43334. serializationObject.customType = "BABYLON.HighlightLayer";
  43335. // Highlighted meshes
  43336. serializationObject.meshes = [];
  43337. if (this._meshes) {
  43338. for (var m in this._meshes) {
  43339. var mesh = this._meshes[m];
  43340. if (mesh) {
  43341. serializationObject.meshes.push({
  43342. glowEmissiveOnly: mesh.glowEmissiveOnly,
  43343. color: mesh.color.asArray(),
  43344. meshId: mesh.mesh.id
  43345. });
  43346. }
  43347. }
  43348. }
  43349. // Excluded meshes
  43350. serializationObject.excludedMeshes = [];
  43351. if (this._excludedMeshes) {
  43352. for (var e in this._excludedMeshes) {
  43353. var excludedMesh = this._excludedMeshes[e];
  43354. if (excludedMesh) {
  43355. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  43356. }
  43357. }
  43358. }
  43359. return serializationObject;
  43360. };
  43361. /**
  43362. * Creates a Highlight layer from parsed Highlight layer data
  43363. * @param parsedHightlightLayer defines the Highlight layer data
  43364. * @param scene defines the current scene
  43365. * @param rootUrl defines the root URL containing the Highlight layer information
  43366. * @returns a parsed Highlight layer
  43367. */
  43368. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  43369. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  43370. var index;
  43371. // Excluded meshes
  43372. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  43373. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  43374. if (mesh) {
  43375. hl.addExcludedMesh(mesh);
  43376. }
  43377. }
  43378. // Included meshes
  43379. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  43380. var highlightedMesh = parsedHightlightLayer.meshes[index];
  43381. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  43382. if (mesh) {
  43383. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  43384. }
  43385. }
  43386. return hl;
  43387. };
  43388. /**
  43389. * Effect Name of the highlight layer.
  43390. */
  43391. HighlightLayer.EffectName = "HighlightLayer";
  43392. /**
  43393. * The neutral color used during the preparation of the glow effect.
  43394. * This is black by default as the blend operation is a blend operation.
  43395. */
  43396. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  43397. /**
  43398. * Stencil value used for glowing meshes.
  43399. */
  43400. HighlightLayer.GlowingMeshStencilReference = 0x02;
  43401. /**
  43402. * Stencil value used for the other meshes in the scene.
  43403. */
  43404. HighlightLayer.NormalMeshStencilReference = 0x01;
  43405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43407. ], HighlightLayer.prototype, "innerGlow", void 0);
  43408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43410. ], HighlightLayer.prototype, "outerGlow", void 0);
  43411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43413. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  43414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43416. ], HighlightLayer.prototype, "blurVerticalSize", null);
  43417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43419. ], HighlightLayer.prototype, "_options", void 0);
  43420. return HighlightLayer;
  43421. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  43422. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  43423. /***/ }),
  43424. /***/ "./Layers/index.ts":
  43425. /*!*************************!*\
  43426. !*** ./Layers/index.ts ***!
  43427. \*************************/
  43428. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  43429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43430. "use strict";
  43431. __webpack_require__.r(__webpack_exports__);
  43432. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43434. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  43436. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  43437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  43438. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  43439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  43440. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  43441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  43442. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  43444. /***/ }),
  43445. /***/ "./Layers/layer.ts":
  43446. /*!*************************!*\
  43447. !*** ./Layers/layer.ts ***!
  43448. \*************************/
  43449. /*! exports provided: Layer */
  43450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43451. "use strict";
  43452. __webpack_require__.r(__webpack_exports__);
  43453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  43454. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43455. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43456. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43457. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43458. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43459. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43460. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43461. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43462. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43463. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  43464. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  43465. /**
  43466. * This represents a full screen 2d layer.
  43467. * This can be useful to display a picture in the background of your scene for instance.
  43468. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43469. */
  43470. var Layer = /** @class */ (function () {
  43471. /**
  43472. * Instantiates a new layer.
  43473. * This represents a full screen 2d layer.
  43474. * This can be useful to display a picture in the background of your scene for instance.
  43475. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43476. * @param name Define the name of the layer in the scene
  43477. * @param imgUrl Define the url of the texture to display in the layer
  43478. * @param scene Define the scene the layer belongs to
  43479. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  43480. * @param color Defines a color for the layer
  43481. */
  43482. function Layer(
  43483. /**
  43484. * Define the name of the layer.
  43485. */
  43486. name, imgUrl, scene, isBackground, color) {
  43487. this.name = name;
  43488. /**
  43489. * Define the scale of the layer in order to zoom in out of the texture.
  43490. */
  43491. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  43492. /**
  43493. * Define an offset for the layer in order to shift the texture.
  43494. */
  43495. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  43496. /**
  43497. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  43498. */
  43499. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  43500. /**
  43501. * Define a mask to restrict the layer to only some of the scene cameras.
  43502. */
  43503. this.layerMask = 0x0FFFFFFF;
  43504. /**
  43505. * Define the list of render target the layer is visible into.
  43506. */
  43507. this.renderTargetTextures = [];
  43508. /**
  43509. * Define if the layer is only used in renderTarget or if it also
  43510. * renders in the main frame buffer of the canvas.
  43511. */
  43512. this.renderOnlyInRenderTargetTextures = false;
  43513. this._vertexBuffers = {};
  43514. /**
  43515. * An event triggered when the layer is disposed.
  43516. */
  43517. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43518. /**
  43519. * An event triggered before rendering the scene
  43520. */
  43521. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43522. /**
  43523. * An event triggered after rendering the scene
  43524. */
  43525. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43526. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  43527. this.isBackground = isBackground === undefined ? true : isBackground;
  43528. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  43529. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  43530. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  43531. if (!layerComponent) {
  43532. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  43533. this._scene._addComponent(layerComponent);
  43534. }
  43535. this._scene.layers.push(this);
  43536. var engine = this._scene.getEngine();
  43537. // VBO
  43538. var vertices = [];
  43539. vertices.push(1, 1);
  43540. vertices.push(-1, 1);
  43541. vertices.push(-1, -1);
  43542. vertices.push(1, -1);
  43543. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  43544. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  43545. this._createIndexBuffer();
  43546. // Effects
  43547. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  43548. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  43549. }
  43550. Object.defineProperty(Layer.prototype, "onDispose", {
  43551. /**
  43552. * Back compatibility with callback before the onDisposeObservable existed.
  43553. * The set callback will be triggered when the layer has been disposed.
  43554. */
  43555. set: function (callback) {
  43556. if (this._onDisposeObserver) {
  43557. this.onDisposeObservable.remove(this._onDisposeObserver);
  43558. }
  43559. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  43560. },
  43561. enumerable: true,
  43562. configurable: true
  43563. });
  43564. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  43565. /**
  43566. * Back compatibility with callback before the onBeforeRenderObservable existed.
  43567. * The set callback will be triggered just before rendering the layer.
  43568. */
  43569. set: function (callback) {
  43570. if (this._onBeforeRenderObserver) {
  43571. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  43572. }
  43573. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  43574. },
  43575. enumerable: true,
  43576. configurable: true
  43577. });
  43578. Object.defineProperty(Layer.prototype, "onAfterRender", {
  43579. /**
  43580. * Back compatibility with callback before the onAfterRenderObservable existed.
  43581. * The set callback will be triggered just after rendering the layer.
  43582. */
  43583. set: function (callback) {
  43584. if (this._onAfterRenderObserver) {
  43585. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  43586. }
  43587. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  43588. },
  43589. enumerable: true,
  43590. configurable: true
  43591. });
  43592. Layer.prototype._createIndexBuffer = function () {
  43593. var engine = this._scene.getEngine();
  43594. // Indices
  43595. var indices = [];
  43596. indices.push(0);
  43597. indices.push(1);
  43598. indices.push(2);
  43599. indices.push(0);
  43600. indices.push(2);
  43601. indices.push(3);
  43602. this._indexBuffer = engine.createIndexBuffer(indices);
  43603. };
  43604. /** @hidden */
  43605. Layer.prototype._rebuild = function () {
  43606. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  43607. if (vb) {
  43608. vb._rebuild();
  43609. }
  43610. this._createIndexBuffer();
  43611. };
  43612. /**
  43613. * Renders the layer in the scene.
  43614. */
  43615. Layer.prototype.render = function () {
  43616. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  43617. // Check
  43618. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  43619. return;
  43620. }
  43621. var engine = this._scene.getEngine();
  43622. this.onBeforeRenderObservable.notifyObservers(this);
  43623. // Render
  43624. engine.enableEffect(currentEffect);
  43625. engine.setState(false);
  43626. // Texture
  43627. currentEffect.setTexture("textureSampler", this.texture);
  43628. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  43629. // Color
  43630. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  43631. // Scale / offset
  43632. currentEffect.setVector2("offset", this.offset);
  43633. currentEffect.setVector2("scale", this.scale);
  43634. // VBOs
  43635. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  43636. // Draw order
  43637. if (!this.alphaTest) {
  43638. engine.setAlphaMode(this.alphaBlendingMode);
  43639. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  43640. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  43641. }
  43642. else {
  43643. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  43644. }
  43645. this.onAfterRenderObservable.notifyObservers(this);
  43646. };
  43647. /**
  43648. * Disposes and releases the associated ressources.
  43649. */
  43650. Layer.prototype.dispose = function () {
  43651. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  43652. if (vertexBuffer) {
  43653. vertexBuffer.dispose();
  43654. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  43655. }
  43656. if (this._indexBuffer) {
  43657. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43658. this._indexBuffer = null;
  43659. }
  43660. if (this.texture) {
  43661. this.texture.dispose();
  43662. this.texture = null;
  43663. }
  43664. // Clean RTT list
  43665. this.renderTargetTextures = [];
  43666. // Remove from scene
  43667. var index = this._scene.layers.indexOf(this);
  43668. this._scene.layers.splice(index, 1);
  43669. // Callback
  43670. this.onDisposeObservable.notifyObservers(this);
  43671. this.onDisposeObservable.clear();
  43672. this.onAfterRenderObservable.clear();
  43673. this.onBeforeRenderObservable.clear();
  43674. };
  43675. return Layer;
  43676. }());
  43677. /***/ }),
  43678. /***/ "./Layers/layerSceneComponent.ts":
  43679. /*!***************************************!*\
  43680. !*** ./Layers/layerSceneComponent.ts ***!
  43681. \***************************************/
  43682. /*! exports provided: LayerSceneComponent */
  43683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43684. "use strict";
  43685. __webpack_require__.r(__webpack_exports__);
  43686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  43687. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43688. /**
  43689. * Defines the layer scene component responsible to manage any layers
  43690. * in a given scene.
  43691. */
  43692. var LayerSceneComponent = /** @class */ (function () {
  43693. /**
  43694. * Creates a new instance of the component for the given scene
  43695. * @param scene Defines the scene to register the component in
  43696. */
  43697. function LayerSceneComponent(scene) {
  43698. /**
  43699. * The component name helpfull to identify the component in the list of scene components.
  43700. */
  43701. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  43702. this.scene = scene;
  43703. this._engine = scene.getEngine();
  43704. scene.layers = new Array();
  43705. }
  43706. /**
  43707. * Registers the component in a given scene
  43708. */
  43709. LayerSceneComponent.prototype.register = function () {
  43710. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  43711. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  43712. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  43713. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  43714. };
  43715. /**
  43716. * Rebuilds the elements related to this component in case of
  43717. * context lost for instance.
  43718. */
  43719. LayerSceneComponent.prototype.rebuild = function () {
  43720. var layers = this.scene.layers;
  43721. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43722. var layer = layers_1[_i];
  43723. layer._rebuild();
  43724. }
  43725. };
  43726. /**
  43727. * Disposes the component and the associated ressources.
  43728. */
  43729. LayerSceneComponent.prototype.dispose = function () {
  43730. var layers = this.scene.layers;
  43731. while (layers.length) {
  43732. layers[0].dispose();
  43733. }
  43734. };
  43735. LayerSceneComponent.prototype._draw = function (predicate) {
  43736. var layers = this.scene.layers;
  43737. if (layers.length) {
  43738. this._engine.setDepthBuffer(false);
  43739. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43740. var layer = layers_2[_i];
  43741. if (predicate(layer)) {
  43742. layer.render();
  43743. }
  43744. }
  43745. this._engine.setDepthBuffer(true);
  43746. }
  43747. };
  43748. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  43749. return !layer.renderOnlyInRenderTargetTextures &&
  43750. layer.isBackground === isBackground &&
  43751. ((layer.layerMask & cameraLayerMask) !== 0);
  43752. };
  43753. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  43754. var _this = this;
  43755. this._draw(function (layer) {
  43756. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  43757. });
  43758. };
  43759. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  43760. var _this = this;
  43761. this._draw(function (layer) {
  43762. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  43763. });
  43764. };
  43765. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  43766. return (layer.renderTargetTextures.length > 0) &&
  43767. layer.isBackground === isBackground &&
  43768. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  43769. ((layer.layerMask & cameraLayerMask) !== 0);
  43770. };
  43771. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  43772. var _this = this;
  43773. this._draw(function (layer) {
  43774. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  43775. });
  43776. };
  43777. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  43778. var _this = this;
  43779. this._draw(function (layer) {
  43780. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  43781. });
  43782. };
  43783. return LayerSceneComponent;
  43784. }());
  43785. /***/ }),
  43786. /***/ "./Legacy/legacy.ts":
  43787. /*!**************************!*\
  43788. !*** ./Legacy/legacy.ts ***!
  43789. \**************************/
  43790. /*! exports provided: Debug, AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, 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, 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, PBRBaseMaterial, PBRMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, DynamicTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, VideoTexture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, 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, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, CubeMapToSphericalPolynomialTools, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseSimpleMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, EquiRectangularCubeTexture, HDRCubeTexture, DummyInternalTextureTracker, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, HDRTools, PanoramaToCubeMapTools, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  43791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43792. "use strict";
  43793. __webpack_require__.r(__webpack_exports__);
  43794. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  43795. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  43796. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  43797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  43798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  43799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  43800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  43801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  43802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  43867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  43868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  43869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  43870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  43871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  43872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  43873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  43874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  43875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  43876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  43877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  43878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  43879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  43880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  43881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  43882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  43883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  43884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  43885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  43886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  43887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  43888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  43889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  43890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  43891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  43892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  43893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  43894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  43895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  43896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  43897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  43898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  43899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  43900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  43901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  43902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  43903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  43904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  43905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  43906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  43907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  43908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  43909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  43910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  43911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  43912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  43913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  43914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  43915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  43916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  43917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  43918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  43919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  43920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  43921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  43922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  43924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  43925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  43926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  43927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  43928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  43929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  43931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  43932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  43933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  43934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  43935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  43937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  43938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  43939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  43940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  43941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  43942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  43943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  43944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  43945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  43946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  43947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  43948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  43949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  43950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  43951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  43952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  43953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  43954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  43955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  43956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  43957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  43958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  43959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  43960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  43961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  43962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  43963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  43964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  43965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  43966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  43968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  43971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  43974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  44000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  44001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  44002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  44003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  44004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  44005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  44006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  44007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  44008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  44009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  44010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  44011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  44012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  44013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  44014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  44015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  44016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  44017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  44018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  44019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  44020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  44021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  44022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  44023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  44024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  44025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  44026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  44027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  44028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  44029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  44030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  44031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  44032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  44033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  44034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  44035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  44036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  44037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  44038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  44039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  44040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  44041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  44042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  44043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  44044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  44045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  44046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  44047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  44048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  44049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  44050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  44051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  44052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  44053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  44054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  44055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  44056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEventOptions"]; });
  44057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEventOptions"]; });
  44058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEventOptions"]; });
  44059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  44060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  44061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  44062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  44063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  44064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  44065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  44066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  44067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  44068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  44069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  44070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  44071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  44072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  44073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  44074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  44075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  44076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  44077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  44078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  44079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  44080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  44081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  44082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  44083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  44084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  44085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  44086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  44087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  44088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  44089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  44090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  44091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  44092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  44093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  44094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  44095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  44096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  44097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  44098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  44099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  44100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  44101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  44102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  44103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  44104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  44105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  44106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  44107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  44108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  44109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  44110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  44111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  44112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  44113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  44114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  44115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  44116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  44117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  44118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  44119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  44120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  44121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  44122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  44123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  44124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  44125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  44126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  44127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  44128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  44129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  44130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  44131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  44132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  44133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  44134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  44135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  44136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  44137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  44138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  44139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  44140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  44141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  44142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  44143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  44144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMatrix"]; });
  44145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  44146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  44147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  44148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  44149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshExploder"]; });
  44150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  44151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  44152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  44153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  44154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  44155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  44156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  44157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  44158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  44159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  44160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  44161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  44162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  44163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  44164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  44165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  44166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  44167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  44168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  44169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  44170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  44171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  44172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  44173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  44174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  44175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  44176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  44177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  44178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  44179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  44180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  44181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  44182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  44183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  44184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  44185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  44186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  44187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  44188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  44189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  44190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  44191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  44192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  44193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  44194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  44195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  44196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  44197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  44198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  44199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]; });
  44200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InspectableType"]; });
  44201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  44202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  44203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  44204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  44205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  44206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  44207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  44208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  44209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  44210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  44211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  44212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  44213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  44214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  44215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  44216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  44217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  44218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  44219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  44220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  44221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  44222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  44223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  44224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  44225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  44226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  44227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  44228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  44229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  44230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  44231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  44232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  44233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  44234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  44235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  44236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  44237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  44238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  44239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  44240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  44241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  44242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  44243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  44244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  44245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  44246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  44247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  44248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  44249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  44250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  44251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  44252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  44253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  44254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  44255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  44256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  44257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  44258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  44259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  44260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  44261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  44262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  44263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  44264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  44265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  44267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  44268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  44269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  44270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  44271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  44272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  44273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTexture"]; });
  44274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  44275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  44276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  44277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  44278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  44279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  44280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  44281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  44282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  44283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  44284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  44285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  44286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  44287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  44288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  44289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  44290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  44291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  44292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  44293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  44294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  44295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  44296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  44297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  44298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  44299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  44300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  44301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  44302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  44303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  44304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  44305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  44306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  44307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  44308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  44309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  44310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  44311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  44312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  44313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  44314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  44315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  44316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  44317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  44318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  44319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  44320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  44321. /**
  44322. * Legacy support, defining window.BABYLON (global variable).
  44323. *
  44324. * This is the entry point for the UMD module.
  44325. * The entry point for a future ESM package should be index.ts
  44326. */
  44327. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  44328. if (typeof globalObject !== "undefined") {
  44329. globalObject.BABYLON = BABYLON;
  44330. globalObject.BABYLON = globalObject.BABYLON || {};
  44331. var BABYLON = globalObject.BABYLON;
  44332. BABYLON.Debug = BABYLON.Debug || {};
  44333. var keys = [];
  44334. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  44335. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  44336. keys.push(key);
  44337. }
  44338. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  44339. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  44340. }
  44341. }
  44342. var Debug = {
  44343. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  44344. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  44345. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  44346. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  44347. };
  44348. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  44349. /***/ }),
  44350. /***/ "./LensFlares/index.ts":
  44351. /*!*****************************!*\
  44352. !*** ./LensFlares/index.ts ***!
  44353. \*****************************/
  44354. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  44355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44356. "use strict";
  44357. __webpack_require__.r(__webpack_exports__);
  44358. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44360. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  44362. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  44363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  44364. /***/ }),
  44365. /***/ "./LensFlares/lensFlare.ts":
  44366. /*!*********************************!*\
  44367. !*** ./LensFlares/lensFlare.ts ***!
  44368. \*********************************/
  44369. /*! exports provided: LensFlare */
  44370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44371. "use strict";
  44372. __webpack_require__.r(__webpack_exports__);
  44373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  44374. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44375. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44376. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44377. /**
  44378. * This represents one of the lens effect in a `lensFlareSystem`.
  44379. * It controls one of the indiviual texture used in the effect.
  44380. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44381. */
  44382. var LensFlare = /** @class */ (function () {
  44383. /**
  44384. * Instantiates a new Lens Flare.
  44385. * This represents one of the lens effect in a `lensFlareSystem`.
  44386. * It controls one of the indiviual texture used in the effect.
  44387. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44388. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44389. * @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.
  44390. * @param color Define the lens color
  44391. * @param imgUrl Define the lens texture url
  44392. * @param system Define the `lensFlareSystem` this flare is part of
  44393. */
  44394. function LensFlare(
  44395. /**
  44396. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44397. */
  44398. size,
  44399. /**
  44400. * 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.
  44401. */
  44402. position, color, imgUrl, system) {
  44403. this.size = size;
  44404. this.position = position;
  44405. /**
  44406. * Define the alpha mode to render this particular lens.
  44407. */
  44408. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  44409. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  44410. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  44411. this._system = system;
  44412. system.lensFlares.push(this);
  44413. }
  44414. /**
  44415. * Creates a new Lens Flare.
  44416. * This represents one of the lens effect in a `lensFlareSystem`.
  44417. * It controls one of the indiviual texture used in the effect.
  44418. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44419. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44420. * @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.
  44421. * @param color Define the lens color
  44422. * @param imgUrl Define the lens texture url
  44423. * @param system Define the `lensFlareSystem` this flare is part of
  44424. * @returns The newly created Lens Flare
  44425. */
  44426. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  44427. return new LensFlare(size, position, color, imgUrl, system);
  44428. };
  44429. /**
  44430. * Dispose and release the lens flare with its associated resources.
  44431. */
  44432. LensFlare.prototype.dispose = function () {
  44433. if (this.texture) {
  44434. this.texture.dispose();
  44435. }
  44436. // Remove from scene
  44437. var index = this._system.lensFlares.indexOf(this);
  44438. this._system.lensFlares.splice(index, 1);
  44439. };
  44440. return LensFlare;
  44441. }());
  44442. /***/ }),
  44443. /***/ "./LensFlares/lensFlareSystem.ts":
  44444. /*!***************************************!*\
  44445. !*** ./LensFlares/lensFlareSystem.ts ***!
  44446. \***************************************/
  44447. /*! exports provided: LensFlareSystem */
  44448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44449. "use strict";
  44450. __webpack_require__.r(__webpack_exports__);
  44451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  44452. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44453. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44454. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  44455. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44456. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44457. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  44458. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44459. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44460. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44461. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  44462. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  44463. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  44464. /**
  44465. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44466. * It is usually composed of several `lensFlare`.
  44467. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44468. */
  44469. var LensFlareSystem = /** @class */ (function () {
  44470. /**
  44471. * Instantiates a lens flare system.
  44472. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44473. * It is usually composed of several `lensFlare`.
  44474. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44475. * @param name Define the name of the lens flare system in the scene
  44476. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44477. * @param scene Define the scene the lens flare system belongs to
  44478. */
  44479. function LensFlareSystem(
  44480. /**
  44481. * Define the name of the lens flare system
  44482. */
  44483. name, emitter, scene) {
  44484. this.name = name;
  44485. /**
  44486. * List of lens flares used in this system.
  44487. */
  44488. this.lensFlares = new Array();
  44489. /**
  44490. * Define a limit from the border the lens flare can be visible.
  44491. */
  44492. this.borderLimit = 300;
  44493. /**
  44494. * Define a viewport border we do not want to see the lens flare in.
  44495. */
  44496. this.viewportBorder = 0;
  44497. /**
  44498. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44499. */
  44500. this.layerMask = 0x0FFFFFFF;
  44501. this._vertexBuffers = {};
  44502. this._isEnabled = true;
  44503. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  44504. LensFlareSystem._SceneComponentInitialization(this._scene);
  44505. this._emitter = emitter;
  44506. this.id = name;
  44507. scene.lensFlareSystems.push(this);
  44508. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  44509. var engine = scene.getEngine();
  44510. // VBO
  44511. var vertices = [];
  44512. vertices.push(1, 1);
  44513. vertices.push(-1, 1);
  44514. vertices.push(-1, -1);
  44515. vertices.push(1, -1);
  44516. 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);
  44517. // Indices
  44518. var indices = [];
  44519. indices.push(0);
  44520. indices.push(1);
  44521. indices.push(2);
  44522. indices.push(0);
  44523. indices.push(2);
  44524. indices.push(3);
  44525. this._indexBuffer = engine.createIndexBuffer(indices);
  44526. // Effects
  44527. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  44528. }
  44529. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  44530. /**
  44531. * Define if the lens flare system is enabled.
  44532. */
  44533. get: function () {
  44534. return this._isEnabled;
  44535. },
  44536. set: function (value) {
  44537. this._isEnabled = value;
  44538. },
  44539. enumerable: true,
  44540. configurable: true
  44541. });
  44542. /**
  44543. * Get the scene the effects belongs to.
  44544. * @returns the scene holding the lens flare system
  44545. */
  44546. LensFlareSystem.prototype.getScene = function () {
  44547. return this._scene;
  44548. };
  44549. /**
  44550. * Get the emitter of the lens flare system.
  44551. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44552. * @returns the emitter of the lens flare system
  44553. */
  44554. LensFlareSystem.prototype.getEmitter = function () {
  44555. return this._emitter;
  44556. };
  44557. /**
  44558. * Set the emitter of the lens flare system.
  44559. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44560. * @param newEmitter Define the new emitter of the system
  44561. */
  44562. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  44563. this._emitter = newEmitter;
  44564. };
  44565. /**
  44566. * Get the lens flare system emitter position.
  44567. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  44568. * @returns the position
  44569. */
  44570. LensFlareSystem.prototype.getEmitterPosition = function () {
  44571. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  44572. };
  44573. /**
  44574. * @hidden
  44575. */
  44576. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  44577. var position = this.getEmitterPosition();
  44578. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  44579. this._positionX = position.x;
  44580. this._positionY = position.y;
  44581. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  44582. if (this.viewportBorder > 0) {
  44583. globalViewport.x -= this.viewportBorder;
  44584. globalViewport.y -= this.viewportBorder;
  44585. globalViewport.width += this.viewportBorder * 2;
  44586. globalViewport.height += this.viewportBorder * 2;
  44587. position.x += this.viewportBorder;
  44588. position.y += this.viewportBorder;
  44589. this._positionX += this.viewportBorder;
  44590. this._positionY += this.viewportBorder;
  44591. }
  44592. if (position.z > 0) {
  44593. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  44594. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  44595. return true;
  44596. }
  44597. }
  44598. return true;
  44599. }
  44600. return false;
  44601. };
  44602. /** @hidden */
  44603. LensFlareSystem.prototype._isVisible = function () {
  44604. if (!this._isEnabled || !this._scene.activeCamera) {
  44605. return false;
  44606. }
  44607. var emitterPosition = this.getEmitterPosition();
  44608. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  44609. var distance = direction.length();
  44610. direction.normalize();
  44611. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  44612. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  44613. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  44614. };
  44615. /**
  44616. * @hidden
  44617. */
  44618. LensFlareSystem.prototype.render = function () {
  44619. if (!this._effect.isReady() || !this._scene.activeCamera) {
  44620. return false;
  44621. }
  44622. var engine = this._scene.getEngine();
  44623. var viewport = this._scene.activeCamera.viewport;
  44624. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  44625. // Position
  44626. if (!this.computeEffectivePosition(globalViewport)) {
  44627. return false;
  44628. }
  44629. // Visibility
  44630. if (!this._isVisible()) {
  44631. return false;
  44632. }
  44633. // Intensity
  44634. var awayX;
  44635. var awayY;
  44636. if (this._positionX < this.borderLimit + globalViewport.x) {
  44637. awayX = this.borderLimit + globalViewport.x - this._positionX;
  44638. }
  44639. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  44640. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  44641. }
  44642. else {
  44643. awayX = 0;
  44644. }
  44645. if (this._positionY < this.borderLimit + globalViewport.y) {
  44646. awayY = this.borderLimit + globalViewport.y - this._positionY;
  44647. }
  44648. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  44649. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  44650. }
  44651. else {
  44652. awayY = 0;
  44653. }
  44654. var away = (awayX > awayY) ? awayX : awayY;
  44655. away -= this.viewportBorder;
  44656. if (away > this.borderLimit) {
  44657. away = this.borderLimit;
  44658. }
  44659. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  44660. if (intensity < 0) {
  44661. return false;
  44662. }
  44663. if (intensity > 1.0) {
  44664. intensity = 1.0;
  44665. }
  44666. if (this.viewportBorder > 0) {
  44667. globalViewport.x += this.viewportBorder;
  44668. globalViewport.y += this.viewportBorder;
  44669. globalViewport.width -= this.viewportBorder * 2;
  44670. globalViewport.height -= this.viewportBorder * 2;
  44671. this._positionX -= this.viewportBorder;
  44672. this._positionY -= this.viewportBorder;
  44673. }
  44674. // Position
  44675. var centerX = globalViewport.x + globalViewport.width / 2;
  44676. var centerY = globalViewport.y + globalViewport.height / 2;
  44677. var distX = centerX - this._positionX;
  44678. var distY = centerY - this._positionY;
  44679. // Effects
  44680. engine.enableEffect(this._effect);
  44681. engine.setState(false);
  44682. engine.setDepthBuffer(false);
  44683. // VBOs
  44684. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  44685. // Flares
  44686. for (var index = 0; index < this.lensFlares.length; index++) {
  44687. var flare = this.lensFlares[index];
  44688. engine.setAlphaMode(flare.alphaMode);
  44689. var x = centerX - (distX * flare.position);
  44690. var y = centerY - (distY * flare.position);
  44691. var cw = flare.size;
  44692. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  44693. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  44694. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  44695. 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);
  44696. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  44697. // Texture
  44698. this._effect.setTexture("textureSampler", flare.texture);
  44699. // Color
  44700. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  44701. // Draw order
  44702. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44703. }
  44704. engine.setDepthBuffer(true);
  44705. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44706. return true;
  44707. };
  44708. /**
  44709. * Dispose and release the lens flare with its associated resources.
  44710. */
  44711. LensFlareSystem.prototype.dispose = function () {
  44712. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  44713. if (vertexBuffer) {
  44714. vertexBuffer.dispose();
  44715. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  44716. }
  44717. if (this._indexBuffer) {
  44718. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44719. this._indexBuffer = null;
  44720. }
  44721. while (this.lensFlares.length) {
  44722. this.lensFlares[0].dispose();
  44723. }
  44724. // Remove from scene
  44725. var index = this._scene.lensFlareSystems.indexOf(this);
  44726. this._scene.lensFlareSystems.splice(index, 1);
  44727. };
  44728. /**
  44729. * Parse a lens flare system from a JSON repressentation
  44730. * @param parsedLensFlareSystem Define the JSON to parse
  44731. * @param scene Define the scene the parsed system should be instantiated in
  44732. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44733. * @returns the parsed system
  44734. */
  44735. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  44736. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  44737. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  44738. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  44739. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  44740. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  44741. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  44742. var parsedFlare = parsedLensFlareSystem.flares[index];
  44743. _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);
  44744. }
  44745. return lensFlareSystem;
  44746. };
  44747. /**
  44748. * Serialize the current Lens Flare System into a JSON representation.
  44749. * @returns the serialized JSON
  44750. */
  44751. LensFlareSystem.prototype.serialize = function () {
  44752. var serializationObject = {};
  44753. serializationObject.id = this.id;
  44754. serializationObject.name = this.name;
  44755. serializationObject.emitterId = this.getEmitter().id;
  44756. serializationObject.borderLimit = this.borderLimit;
  44757. serializationObject.flares = [];
  44758. for (var index = 0; index < this.lensFlares.length; index++) {
  44759. var flare = this.lensFlares[index];
  44760. serializationObject.flares.push({
  44761. size: flare.size,
  44762. position: flare.position,
  44763. color: flare.color.asArray(),
  44764. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  44765. });
  44766. }
  44767. return serializationObject;
  44768. };
  44769. /** @hidden */
  44770. LensFlareSystem._SceneComponentInitialization = function (_) {
  44771. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  44772. };
  44773. return LensFlareSystem;
  44774. }());
  44775. /***/ }),
  44776. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  44777. /*!*****************************************************!*\
  44778. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  44779. \*****************************************************/
  44780. /*! exports provided: LensFlareSystemSceneComponent */
  44781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44782. "use strict";
  44783. __webpack_require__.r(__webpack_exports__);
  44784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  44785. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44786. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44787. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44788. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44789. // Adds the parser to the scene parsers.
  44790. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  44791. // Lens flares
  44792. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  44793. if (!container.lensFlareSystems) {
  44794. container.lensFlareSystems = new Array();
  44795. }
  44796. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  44797. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  44798. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  44799. container.lensFlareSystems.push(lf);
  44800. }
  44801. }
  44802. });
  44803. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  44804. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44805. if (this.lensFlareSystems[index].name === name) {
  44806. return this.lensFlareSystems[index];
  44807. }
  44808. }
  44809. return null;
  44810. };
  44811. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  44812. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44813. if (this.lensFlareSystems[index].id === id) {
  44814. return this.lensFlareSystems[index];
  44815. }
  44816. }
  44817. return null;
  44818. };
  44819. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44820. var index = this.lensFlareSystems.indexOf(toRemove);
  44821. if (index !== -1) {
  44822. this.lensFlareSystems.splice(index, 1);
  44823. }
  44824. return index;
  44825. };
  44826. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44827. this.lensFlareSystems.push(newLensFlareSystem);
  44828. };
  44829. /**
  44830. * Defines the lens flare scene component responsible to manage any lens flares
  44831. * in a given scene.
  44832. */
  44833. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44834. /**
  44835. * Creates a new instance of the component for the given scene
  44836. * @param scene Defines the scene to register the component in
  44837. */
  44838. function LensFlareSystemSceneComponent(scene) {
  44839. /**
  44840. * The component name helpfull to identify the component in the list of scene components.
  44841. */
  44842. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44843. this.scene = scene;
  44844. scene.lensFlareSystems = new Array();
  44845. }
  44846. /**
  44847. * Registers the component in a given scene
  44848. */
  44849. LensFlareSystemSceneComponent.prototype.register = function () {
  44850. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44851. };
  44852. /**
  44853. * Rebuilds the elements related to this component in case of
  44854. * context lost for instance.
  44855. */
  44856. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44857. // Nothing to do for lens flare
  44858. };
  44859. /**
  44860. * Adds all the element from the container to the scene
  44861. * @param container the container holding the elements
  44862. */
  44863. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44864. var _this = this;
  44865. if (!container.lensFlareSystems) {
  44866. return;
  44867. }
  44868. container.lensFlareSystems.forEach(function (o) {
  44869. _this.scene.addLensFlareSystem(o);
  44870. });
  44871. };
  44872. /**
  44873. * Removes all the elements in the container from the scene
  44874. * @param container contains the elements to remove
  44875. */
  44876. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  44877. var _this = this;
  44878. if (!container.lensFlareSystems) {
  44879. return;
  44880. }
  44881. container.lensFlareSystems.forEach(function (o) {
  44882. _this.scene.removeLensFlareSystem(o);
  44883. });
  44884. };
  44885. /**
  44886. * Serializes the component data to the specified json object
  44887. * @param serializationObject The object to serialize to
  44888. */
  44889. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  44890. // Lens flares
  44891. serializationObject.lensFlareSystems = [];
  44892. var lensFlareSystems = this.scene.lensFlareSystems;
  44893. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  44894. var lensFlareSystem = lensFlareSystems_1[_i];
  44895. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  44896. }
  44897. };
  44898. /**
  44899. * Disposes the component and the associated ressources.
  44900. */
  44901. LensFlareSystemSceneComponent.prototype.dispose = function () {
  44902. var lensFlareSystems = this.scene.lensFlareSystems;
  44903. while (lensFlareSystems.length) {
  44904. lensFlareSystems[0].dispose();
  44905. }
  44906. };
  44907. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  44908. // Lens flares
  44909. if (this.scene.lensFlaresEnabled) {
  44910. var lensFlareSystems = this.scene.lensFlareSystems;
  44911. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44912. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  44913. var lensFlareSystem = lensFlareSystems_2[_i];
  44914. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  44915. lensFlareSystem.render();
  44916. }
  44917. }
  44918. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44919. }
  44920. };
  44921. return LensFlareSystemSceneComponent;
  44922. }());
  44923. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  44924. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  44925. if (!component) {
  44926. component = new LensFlareSystemSceneComponent(scene);
  44927. scene._addComponent(component);
  44928. }
  44929. };
  44930. /***/ }),
  44931. /***/ "./Lights/Shadows/index.ts":
  44932. /*!*********************************!*\
  44933. !*** ./Lights/Shadows/index.ts ***!
  44934. \*********************************/
  44935. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  44936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44937. "use strict";
  44938. __webpack_require__.r(__webpack_exports__);
  44939. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44941. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  44942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  44943. /***/ }),
  44944. /***/ "./Lights/Shadows/shadowGenerator.ts":
  44945. /*!*******************************************!*\
  44946. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  44947. \*******************************************/
  44948. /*! exports provided: ShadowGenerator */
  44949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44950. "use strict";
  44951. __webpack_require__.r(__webpack_exports__);
  44952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  44953. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44954. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  44955. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  44956. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  44957. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  44958. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  44959. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44960. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44961. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44962. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44963. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  44964. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  44965. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  44966. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  44967. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  44968. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  44969. /**
  44970. * Default implementation IShadowGenerator.
  44971. * This is the main object responsible of generating shadows in the framework.
  44972. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44973. */
  44974. var ShadowGenerator = /** @class */ (function () {
  44975. /**
  44976. * Creates a ShadowGenerator object.
  44977. * A ShadowGenerator is the required tool to use the shadows.
  44978. * Each light casting shadows needs to use its own ShadowGenerator.
  44979. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44980. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44981. * @param light The light object generating the shadows.
  44982. * @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.
  44983. */
  44984. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  44985. /**
  44986. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  44987. */
  44988. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44989. /**
  44990. * Observable triggered before a mesh is rendered in the shadow map.
  44991. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  44992. */
  44993. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44994. this._bias = 0.00005;
  44995. this._normalBias = 0;
  44996. this._blurBoxOffset = 1;
  44997. this._blurScale = 2;
  44998. this._blurKernel = 1;
  44999. this._useKernelBlur = false;
  45000. this._filter = ShadowGenerator.FILTER_NONE;
  45001. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  45002. this._contactHardeningLightSizeUVRatio = 0.1;
  45003. this._darkness = 0;
  45004. this._transparencyShadow = false;
  45005. /**
  45006. * Controls the extent to which the shadows fade out at the edge of the frustum
  45007. * Used only by directionals and spots
  45008. */
  45009. this.frustumEdgeFalloff = 0;
  45010. /**
  45011. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  45012. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  45013. * It might on the other hand introduce peter panning.
  45014. */
  45015. this.forceBackFacesOnly = false;
  45016. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  45017. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45018. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45019. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45020. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45021. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45022. this._currentFaceIndex = 0;
  45023. this._currentFaceIndexCache = 0;
  45024. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  45025. this._mapSize = mapSize;
  45026. this._light = light;
  45027. this._scene = light.getScene();
  45028. light._shadowGenerator = this;
  45029. ShadowGenerator._SceneComponentInitialization(this._scene);
  45030. // Texture type fallback from float to int if not supported.
  45031. var caps = this._scene.getEngine().getCaps();
  45032. if (!usefulFloatFirst) {
  45033. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45034. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45035. }
  45036. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45037. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45038. }
  45039. else {
  45040. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45041. }
  45042. }
  45043. else {
  45044. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45045. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45046. }
  45047. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45048. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45049. }
  45050. else {
  45051. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45052. }
  45053. }
  45054. this._initializeGenerator();
  45055. this._applyFilterValues();
  45056. }
  45057. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  45058. /**
  45059. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  45060. */
  45061. get: function () {
  45062. return this._bias;
  45063. },
  45064. /**
  45065. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  45066. */
  45067. set: function (bias) {
  45068. this._bias = bias;
  45069. },
  45070. enumerable: true,
  45071. configurable: true
  45072. });
  45073. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  45074. /**
  45075. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45076. */
  45077. get: function () {
  45078. return this._normalBias;
  45079. },
  45080. /**
  45081. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45082. */
  45083. set: function (normalBias) {
  45084. this._normalBias = normalBias;
  45085. },
  45086. enumerable: true,
  45087. configurable: true
  45088. });
  45089. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  45090. /**
  45091. * Gets the blur box offset: offset applied during the blur pass.
  45092. * Only useful if useKernelBlur = false
  45093. */
  45094. get: function () {
  45095. return this._blurBoxOffset;
  45096. },
  45097. /**
  45098. * Sets the blur box offset: offset applied during the blur pass.
  45099. * Only useful if useKernelBlur = false
  45100. */
  45101. set: function (value) {
  45102. if (this._blurBoxOffset === value) {
  45103. return;
  45104. }
  45105. this._blurBoxOffset = value;
  45106. this._disposeBlurPostProcesses();
  45107. },
  45108. enumerable: true,
  45109. configurable: true
  45110. });
  45111. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  45112. /**
  45113. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  45114. * 2 means half of the size.
  45115. */
  45116. get: function () {
  45117. return this._blurScale;
  45118. },
  45119. /**
  45120. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  45121. * 2 means half of the size.
  45122. */
  45123. set: function (value) {
  45124. if (this._blurScale === value) {
  45125. return;
  45126. }
  45127. this._blurScale = value;
  45128. this._disposeBlurPostProcesses();
  45129. },
  45130. enumerable: true,
  45131. configurable: true
  45132. });
  45133. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  45134. /**
  45135. * Gets the blur kernel: kernel size of the blur pass.
  45136. * Only useful if useKernelBlur = true
  45137. */
  45138. get: function () {
  45139. return this._blurKernel;
  45140. },
  45141. /**
  45142. * Sets the blur kernel: kernel size of the blur pass.
  45143. * Only useful if useKernelBlur = true
  45144. */
  45145. set: function (value) {
  45146. if (this._blurKernel === value) {
  45147. return;
  45148. }
  45149. this._blurKernel = value;
  45150. this._disposeBlurPostProcesses();
  45151. },
  45152. enumerable: true,
  45153. configurable: true
  45154. });
  45155. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  45156. /**
  45157. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  45158. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45159. */
  45160. get: function () {
  45161. return this._useKernelBlur;
  45162. },
  45163. /**
  45164. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  45165. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45166. */
  45167. set: function (value) {
  45168. if (this._useKernelBlur === value) {
  45169. return;
  45170. }
  45171. this._useKernelBlur = value;
  45172. this._disposeBlurPostProcesses();
  45173. },
  45174. enumerable: true,
  45175. configurable: true
  45176. });
  45177. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  45178. /**
  45179. * Gets the depth scale used in ESM mode.
  45180. */
  45181. get: function () {
  45182. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  45183. },
  45184. /**
  45185. * Sets the depth scale used in ESM mode.
  45186. * This can override the scale stored on the light.
  45187. */
  45188. set: function (value) {
  45189. this._depthScale = value;
  45190. },
  45191. enumerable: true,
  45192. configurable: true
  45193. });
  45194. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  45195. /**
  45196. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  45197. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45198. */
  45199. get: function () {
  45200. return this._filter;
  45201. },
  45202. /**
  45203. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  45204. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45205. */
  45206. set: function (value) {
  45207. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  45208. if (this._light.needCube()) {
  45209. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45210. this.useExponentialShadowMap = true;
  45211. return;
  45212. }
  45213. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45214. this.useCloseExponentialShadowMap = true;
  45215. return;
  45216. }
  45217. // PCF on cubemap would also be expensive
  45218. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45219. this.usePoissonSampling = true;
  45220. return;
  45221. }
  45222. }
  45223. // Weblg1 fallback for PCF.
  45224. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45225. if (this._scene.getEngine().webGLVersion === 1) {
  45226. this.usePoissonSampling = true;
  45227. return;
  45228. }
  45229. }
  45230. if (this._filter === value) {
  45231. return;
  45232. }
  45233. this._filter = value;
  45234. this._disposeBlurPostProcesses();
  45235. this._applyFilterValues();
  45236. this._light._markMeshesAsLightDirty();
  45237. },
  45238. enumerable: true,
  45239. configurable: true
  45240. });
  45241. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  45242. /**
  45243. * Gets if the current filter is set to Poisson Sampling.
  45244. */
  45245. get: function () {
  45246. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  45247. },
  45248. /**
  45249. * Sets the current filter to Poisson Sampling.
  45250. */
  45251. set: function (value) {
  45252. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  45253. return;
  45254. }
  45255. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  45256. },
  45257. enumerable: true,
  45258. configurable: true
  45259. });
  45260. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  45261. /**
  45262. * Gets if the current filter is set to ESM.
  45263. */
  45264. get: function () {
  45265. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  45266. },
  45267. /**
  45268. * Sets the current filter is to ESM.
  45269. */
  45270. set: function (value) {
  45271. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  45272. return;
  45273. }
  45274. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45275. },
  45276. enumerable: true,
  45277. configurable: true
  45278. });
  45279. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  45280. /**
  45281. * Gets if the current filter is set to filtered ESM.
  45282. */
  45283. get: function () {
  45284. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  45285. },
  45286. /**
  45287. * Gets if the current filter is set to filtered ESM.
  45288. */
  45289. set: function (value) {
  45290. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45291. return;
  45292. }
  45293. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45294. },
  45295. enumerable: true,
  45296. configurable: true
  45297. });
  45298. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  45299. /**
  45300. * Gets if the current filter is set to "close ESM" (using the inverse of the
  45301. * exponential to prevent steep falloff artifacts).
  45302. */
  45303. get: function () {
  45304. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  45305. },
  45306. /**
  45307. * Sets the current filter to "close ESM" (using the inverse of the
  45308. * exponential to prevent steep falloff artifacts).
  45309. */
  45310. set: function (value) {
  45311. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  45312. return;
  45313. }
  45314. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45315. },
  45316. enumerable: true,
  45317. configurable: true
  45318. });
  45319. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  45320. /**
  45321. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  45322. * exponential to prevent steep falloff artifacts).
  45323. */
  45324. get: function () {
  45325. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  45326. },
  45327. /**
  45328. * Sets the current filter to filtered "close ESM" (using the inverse of the
  45329. * exponential to prevent steep falloff artifacts).
  45330. */
  45331. set: function (value) {
  45332. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45333. return;
  45334. }
  45335. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45336. },
  45337. enumerable: true,
  45338. configurable: true
  45339. });
  45340. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  45341. /**
  45342. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  45343. */
  45344. get: function () {
  45345. return this.filter === ShadowGenerator.FILTER_PCF;
  45346. },
  45347. /**
  45348. * Sets the current filter to "PCF" (percentage closer filtering).
  45349. */
  45350. set: function (value) {
  45351. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  45352. return;
  45353. }
  45354. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  45355. },
  45356. enumerable: true,
  45357. configurable: true
  45358. });
  45359. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  45360. /**
  45361. * Gets the PCF or PCSS Quality.
  45362. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45363. */
  45364. get: function () {
  45365. return this._filteringQuality;
  45366. },
  45367. /**
  45368. * Sets the PCF or PCSS Quality.
  45369. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45370. */
  45371. set: function (filteringQuality) {
  45372. this._filteringQuality = filteringQuality;
  45373. },
  45374. enumerable: true,
  45375. configurable: true
  45376. });
  45377. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  45378. /**
  45379. * Gets if the current filter is set to "PCSS" (contact hardening).
  45380. */
  45381. get: function () {
  45382. return this.filter === ShadowGenerator.FILTER_PCSS;
  45383. },
  45384. /**
  45385. * Sets the current filter to "PCSS" (contact hardening).
  45386. */
  45387. set: function (value) {
  45388. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  45389. return;
  45390. }
  45391. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  45392. },
  45393. enumerable: true,
  45394. configurable: true
  45395. });
  45396. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  45397. /**
  45398. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45399. * Using a ratio helps keeping shape stability independently of the map size.
  45400. *
  45401. * It does not account for the light projection as it was having too much
  45402. * instability during the light setup or during light position changes.
  45403. *
  45404. * Only valid if useContactHardeningShadow is true.
  45405. */
  45406. get: function () {
  45407. return this._contactHardeningLightSizeUVRatio;
  45408. },
  45409. /**
  45410. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45411. * Using a ratio helps keeping shape stability independently of the map size.
  45412. *
  45413. * It does not account for the light projection as it was having too much
  45414. * instability during the light setup or during light position changes.
  45415. *
  45416. * Only valid if useContactHardeningShadow is true.
  45417. */
  45418. set: function (contactHardeningLightSizeUVRatio) {
  45419. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  45420. },
  45421. enumerable: true,
  45422. configurable: true
  45423. });
  45424. /**
  45425. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  45426. * 0 means strongest and 1 would means no shadow.
  45427. * @returns the darkness.
  45428. */
  45429. ShadowGenerator.prototype.getDarkness = function () {
  45430. return this._darkness;
  45431. };
  45432. /**
  45433. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  45434. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  45435. * @returns the shadow generator allowing fluent coding.
  45436. */
  45437. ShadowGenerator.prototype.setDarkness = function (darkness) {
  45438. if (darkness >= 1.0) {
  45439. this._darkness = 1.0;
  45440. }
  45441. else if (darkness <= 0.0) {
  45442. this._darkness = 0.0;
  45443. }
  45444. else {
  45445. this._darkness = darkness;
  45446. }
  45447. return this;
  45448. };
  45449. /**
  45450. * Sets the ability to have transparent shadow (boolean).
  45451. * @param transparent True if transparent else False
  45452. * @returns the shadow generator allowing fluent coding
  45453. */
  45454. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  45455. this._transparencyShadow = transparent;
  45456. return this;
  45457. };
  45458. /**
  45459. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  45460. * @returns The render target texture if present otherwise, null
  45461. */
  45462. ShadowGenerator.prototype.getShadowMap = function () {
  45463. return this._shadowMap;
  45464. };
  45465. /**
  45466. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  45467. * @returns The render target texture if the shadow map is present otherwise, null
  45468. */
  45469. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  45470. if (this._shadowMap2) {
  45471. return this._shadowMap2;
  45472. }
  45473. return this._shadowMap;
  45474. };
  45475. /**
  45476. * Helper function to add a mesh and its descendants to the list of shadow casters.
  45477. * @param mesh Mesh to add
  45478. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  45479. * @returns the Shadow Generator itself
  45480. */
  45481. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  45482. if (includeDescendants === void 0) { includeDescendants = true; }
  45483. var _a;
  45484. if (!this._shadowMap) {
  45485. return this;
  45486. }
  45487. if (!this._shadowMap.renderList) {
  45488. this._shadowMap.renderList = [];
  45489. }
  45490. this._shadowMap.renderList.push(mesh);
  45491. if (includeDescendants) {
  45492. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  45493. }
  45494. return this;
  45495. };
  45496. /**
  45497. * Helper function to remove a mesh and its descendants from the list of shadow casters
  45498. * @param mesh Mesh to remove
  45499. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  45500. * @returns the Shadow Generator itself
  45501. */
  45502. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  45503. if (includeDescendants === void 0) { includeDescendants = true; }
  45504. if (!this._shadowMap || !this._shadowMap.renderList) {
  45505. return this;
  45506. }
  45507. var index = this._shadowMap.renderList.indexOf(mesh);
  45508. if (index !== -1) {
  45509. this._shadowMap.renderList.splice(index, 1);
  45510. }
  45511. if (includeDescendants) {
  45512. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  45513. var child = _a[_i];
  45514. this.removeShadowCaster(child);
  45515. }
  45516. }
  45517. return this;
  45518. };
  45519. /**
  45520. * Returns the associated light object.
  45521. * @returns the light generating the shadow
  45522. */
  45523. ShadowGenerator.prototype.getLight = function () {
  45524. return this._light;
  45525. };
  45526. ShadowGenerator.prototype._initializeGenerator = function () {
  45527. this._light._markMeshesAsLightDirty();
  45528. this._initializeShadowMap();
  45529. };
  45530. ShadowGenerator.prototype._initializeShadowMap = function () {
  45531. var _this = this;
  45532. // Render target
  45533. var engine = this._scene.getEngine();
  45534. if (engine.webGLVersion > 1) {
  45535. 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);
  45536. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  45537. }
  45538. else {
  45539. 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());
  45540. }
  45541. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45542. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45543. this._shadowMap.anisotropicFilteringLevel = 1;
  45544. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45545. this._shadowMap.renderParticles = false;
  45546. this._shadowMap.ignoreCameraViewport = true;
  45547. // Record Face Index before render.
  45548. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  45549. _this._currentFaceIndex = faceIndex;
  45550. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45551. engine.setColorWrite(false);
  45552. }
  45553. });
  45554. // Custom render function.
  45555. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  45556. // Blur if required afer render.
  45557. this._shadowMap.onAfterUnbindObservable.add(function () {
  45558. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45559. engine.setColorWrite(true);
  45560. }
  45561. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  45562. return;
  45563. }
  45564. var shadowMap = _this.getShadowMapForRendering();
  45565. if (shadowMap) {
  45566. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  45567. }
  45568. });
  45569. // Clear according to the chosen filter.
  45570. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  45571. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  45572. this._shadowMap.onClearObservable.add(function (engine) {
  45573. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45574. engine.clear(clearOne, false, true, false);
  45575. }
  45576. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  45577. engine.clear(clearZero, true, true, false);
  45578. }
  45579. else {
  45580. engine.clear(clearOne, true, true, false);
  45581. }
  45582. });
  45583. };
  45584. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  45585. var _this = this;
  45586. var engine = this._scene.getEngine();
  45587. var targetSize = this._mapSize / this.blurScale;
  45588. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  45589. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  45590. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45591. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45592. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45593. }
  45594. if (this.useKernelBlur) {
  45595. 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);
  45596. this._kernelBlurXPostprocess.width = targetSize;
  45597. this._kernelBlurXPostprocess.height = targetSize;
  45598. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  45599. effect.setTexture("textureSampler", _this._shadowMap);
  45600. });
  45601. 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);
  45602. this._kernelBlurXPostprocess.autoClear = false;
  45603. this._kernelBlurYPostprocess.autoClear = false;
  45604. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45605. this._kernelBlurXPostprocess.packedFloat = true;
  45606. this._kernelBlurYPostprocess.packedFloat = true;
  45607. }
  45608. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  45609. }
  45610. else {
  45611. 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);
  45612. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  45613. effect.setFloat2("screenSize", targetSize, targetSize);
  45614. effect.setTexture("textureSampler", _this._shadowMap);
  45615. });
  45616. this._boxBlurPostprocess.autoClear = false;
  45617. this._blurPostProcesses = [this._boxBlurPostprocess];
  45618. }
  45619. };
  45620. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  45621. var index;
  45622. var engine = this._scene.getEngine();
  45623. if (depthOnlySubMeshes.length) {
  45624. engine.setColorWrite(false);
  45625. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  45626. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  45627. }
  45628. engine.setColorWrite(true);
  45629. }
  45630. for (index = 0; index < opaqueSubMeshes.length; index++) {
  45631. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  45632. }
  45633. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  45634. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  45635. }
  45636. if (this._transparencyShadow) {
  45637. for (index = 0; index < transparentSubMeshes.length; index++) {
  45638. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  45639. }
  45640. }
  45641. };
  45642. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  45643. var _this = this;
  45644. var mesh = subMesh.getRenderingMesh();
  45645. var scene = this._scene;
  45646. var engine = scene.getEngine();
  45647. var material = subMesh.getMaterial();
  45648. if (!material || subMesh.verticesCount === 0) {
  45649. return;
  45650. }
  45651. // Culling
  45652. engine.setState(material.backFaceCulling);
  45653. // Managing instances
  45654. var batch = mesh._getInstancesRenderList(subMesh._id);
  45655. if (batch.mustReturn) {
  45656. return;
  45657. }
  45658. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  45659. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  45660. engine.enableEffect(this._effect);
  45661. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  45662. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  45663. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  45664. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45665. this._effect.setVector3("lightData", this._cachedDirection);
  45666. }
  45667. else {
  45668. this._effect.setVector3("lightData", this._cachedPosition);
  45669. }
  45670. if (scene.activeCamera) {
  45671. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  45672. }
  45673. // Alpha test
  45674. if (material && material.needAlphaTesting()) {
  45675. var alphaTexture = material.getAlphaTestTexture();
  45676. if (alphaTexture) {
  45677. this._effect.setTexture("diffuseSampler", alphaTexture);
  45678. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  45679. }
  45680. }
  45681. // Bones
  45682. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45683. var skeleton = mesh.skeleton;
  45684. if (skeleton.isUsingTextureForMatrices) {
  45685. var boneTexture = skeleton.getTransformMatrixTexture();
  45686. if (!boneTexture) {
  45687. return;
  45688. }
  45689. this._effect.setTexture("boneSampler", boneTexture);
  45690. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  45691. }
  45692. else {
  45693. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  45694. }
  45695. }
  45696. // Morph targets
  45697. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  45698. if (this.forceBackFacesOnly) {
  45699. engine.setState(true, 0, false, true);
  45700. }
  45701. // Observables
  45702. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  45703. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  45704. // Draw
  45705. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  45706. if (this.forceBackFacesOnly) {
  45707. engine.setState(true, 0, false, false);
  45708. }
  45709. }
  45710. else {
  45711. // Need to reset refresh rate of the shadowMap
  45712. if (this._shadowMap) {
  45713. this._shadowMap.resetRefreshCounter();
  45714. }
  45715. }
  45716. };
  45717. ShadowGenerator.prototype._applyFilterValues = function () {
  45718. if (!this._shadowMap) {
  45719. return;
  45720. }
  45721. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  45722. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  45723. }
  45724. else {
  45725. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45726. }
  45727. };
  45728. /**
  45729. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45730. * @param onCompiled Callback triggered at the and of the effects compilation
  45731. * @param options Sets of optional options forcing the compilation with different modes
  45732. */
  45733. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  45734. var _this = this;
  45735. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  45736. var shadowMap = this.getShadowMap();
  45737. if (!shadowMap) {
  45738. if (onCompiled) {
  45739. onCompiled(this);
  45740. }
  45741. return;
  45742. }
  45743. var renderList = shadowMap.renderList;
  45744. if (!renderList) {
  45745. if (onCompiled) {
  45746. onCompiled(this);
  45747. }
  45748. return;
  45749. }
  45750. var subMeshes = new Array();
  45751. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  45752. var mesh = renderList_1[_i];
  45753. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  45754. }
  45755. if (subMeshes.length === 0) {
  45756. if (onCompiled) {
  45757. onCompiled(this);
  45758. }
  45759. return;
  45760. }
  45761. var currentIndex = 0;
  45762. var checkReady = function () {
  45763. if (!_this._scene || !_this._scene.getEngine()) {
  45764. return;
  45765. }
  45766. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  45767. currentIndex++;
  45768. if (currentIndex >= subMeshes.length) {
  45769. if (onCompiled) {
  45770. onCompiled(_this);
  45771. }
  45772. return;
  45773. }
  45774. }
  45775. setTimeout(checkReady, 16);
  45776. };
  45777. checkReady();
  45778. };
  45779. /**
  45780. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45781. * @param options Sets of optional options forcing the compilation with different modes
  45782. * @returns A promise that resolves when the compilation completes
  45783. */
  45784. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  45785. var _this = this;
  45786. return new Promise(function (resolve) {
  45787. _this.forceCompilation(function () {
  45788. resolve();
  45789. }, options);
  45790. });
  45791. };
  45792. /**
  45793. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  45794. * @param subMesh The submesh we want to render in the shadow map
  45795. * @param useInstances Defines wether will draw in the map using instances
  45796. * @returns true if ready otherwise, false
  45797. */
  45798. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  45799. var defines = [];
  45800. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45801. defines.push("#define FLOAT");
  45802. }
  45803. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45804. defines.push("#define ESM");
  45805. }
  45806. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  45807. defines.push("#define DEPTHTEXTURE");
  45808. }
  45809. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  45810. var mesh = subMesh.getMesh();
  45811. var material = subMesh.getMaterial();
  45812. // Normal bias.
  45813. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  45814. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  45815. defines.push("#define NORMAL");
  45816. if (mesh.nonUniformScaling) {
  45817. defines.push("#define NONUNIFORMSCALING");
  45818. }
  45819. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45820. defines.push("#define DIRECTIONINLIGHTDATA");
  45821. }
  45822. }
  45823. // Alpha test
  45824. if (material && material.needAlphaTesting()) {
  45825. var alphaTexture = material.getAlphaTestTexture();
  45826. if (alphaTexture) {
  45827. defines.push("#define ALPHATEST");
  45828. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45829. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45830. defines.push("#define UV1");
  45831. }
  45832. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45833. if (alphaTexture.coordinatesIndex === 1) {
  45834. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45835. defines.push("#define UV2");
  45836. }
  45837. }
  45838. }
  45839. }
  45840. // Bones
  45841. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45842. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45843. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45844. if (mesh.numBoneInfluencers > 4) {
  45845. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45846. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45847. }
  45848. var skeleton = mesh.skeleton;
  45849. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45850. if (skeleton.isUsingTextureForMatrices) {
  45851. defines.push("#define BONETEXTURE");
  45852. }
  45853. else {
  45854. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45855. }
  45856. }
  45857. else {
  45858. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45859. }
  45860. // Morph targets
  45861. var manager = mesh.morphTargetManager;
  45862. var morphInfluencers = 0;
  45863. if (manager) {
  45864. if (manager.numInfluencers > 0) {
  45865. defines.push("#define MORPHTARGETS");
  45866. morphInfluencers = manager.numInfluencers;
  45867. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45868. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  45869. }
  45870. }
  45871. // Instances
  45872. if (useInstances) {
  45873. defines.push("#define INSTANCES");
  45874. attribs.push("world0");
  45875. attribs.push("world1");
  45876. attribs.push("world2");
  45877. attribs.push("world3");
  45878. }
  45879. if (this.customShaderOptions) {
  45880. if (this.customShaderOptions.defines) {
  45881. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  45882. var define = _a[_i];
  45883. if (defines.indexOf(define) === -1) {
  45884. defines.push(define);
  45885. }
  45886. }
  45887. }
  45888. }
  45889. // Get correct effect
  45890. var join = defines.join("\n");
  45891. if (this._cachedDefines !== join) {
  45892. this._cachedDefines = join;
  45893. var shaderName = "shadowMap";
  45894. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  45895. var samplers = ["diffuseSampler", "boneSampler"];
  45896. // Custom shader?
  45897. if (this.customShaderOptions) {
  45898. shaderName = this.customShaderOptions.shaderName;
  45899. if (this.customShaderOptions.attributes) {
  45900. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  45901. var attrib = _c[_b];
  45902. if (attribs.indexOf(attrib) === -1) {
  45903. attribs.push(attrib);
  45904. }
  45905. }
  45906. }
  45907. if (this.customShaderOptions.uniforms) {
  45908. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  45909. var uniform = _e[_d];
  45910. if (uniforms.indexOf(uniform) === -1) {
  45911. uniforms.push(uniform);
  45912. }
  45913. }
  45914. }
  45915. if (this.customShaderOptions.samplers) {
  45916. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  45917. var sampler = _g[_f];
  45918. if (samplers.indexOf(sampler) === -1) {
  45919. samplers.push(sampler);
  45920. }
  45921. }
  45922. }
  45923. }
  45924. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45925. }
  45926. if (!this._effect.isReady()) {
  45927. return false;
  45928. }
  45929. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45930. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  45931. this._initializeBlurRTTAndPostProcesses();
  45932. }
  45933. }
  45934. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  45935. return false;
  45936. }
  45937. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  45938. return false;
  45939. }
  45940. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  45941. return false;
  45942. }
  45943. return true;
  45944. };
  45945. /**
  45946. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  45947. * @param defines Defines of the material we want to update
  45948. * @param lightIndex Index of the light in the enabled light list of the material
  45949. */
  45950. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  45951. var scene = this._scene;
  45952. var light = this._light;
  45953. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45954. return;
  45955. }
  45956. defines["SHADOW" + lightIndex] = true;
  45957. if (this.useContactHardeningShadow) {
  45958. defines["SHADOWPCSS" + lightIndex] = true;
  45959. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45960. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45961. }
  45962. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45963. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45964. }
  45965. // else default to high.
  45966. }
  45967. if (this.usePercentageCloserFiltering) {
  45968. defines["SHADOWPCF" + lightIndex] = true;
  45969. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45970. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45971. }
  45972. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45973. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45974. }
  45975. // else default to high.
  45976. }
  45977. else if (this.usePoissonSampling) {
  45978. defines["SHADOWPOISSON" + lightIndex] = true;
  45979. }
  45980. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45981. defines["SHADOWESM" + lightIndex] = true;
  45982. }
  45983. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45984. defines["SHADOWCLOSEESM" + lightIndex] = true;
  45985. }
  45986. if (light.needCube()) {
  45987. defines["SHADOWCUBE" + lightIndex] = true;
  45988. }
  45989. };
  45990. /**
  45991. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  45992. * defined in the generator but impacting the effect).
  45993. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45994. * @param effect The effect we are binfing the information for
  45995. */
  45996. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45997. var light = this._light;
  45998. var scene = this._scene;
  45999. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46000. return;
  46001. }
  46002. var camera = scene.activeCamera;
  46003. if (!camera) {
  46004. return;
  46005. }
  46006. var shadowMap = this.getShadowMap();
  46007. if (!shadowMap) {
  46008. return;
  46009. }
  46010. if (!light.needCube()) {
  46011. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  46012. }
  46013. // Only PCF uses depth stencil texture.
  46014. if (this._filter === ShadowGenerator.FILTER_PCF) {
  46015. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46016. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46017. }
  46018. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  46019. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46020. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  46021. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46022. }
  46023. else {
  46024. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46025. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  46026. }
  46027. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  46028. };
  46029. /**
  46030. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  46031. * (eq to shadow prjection matrix * light transform matrix)
  46032. * @returns The transform matrix used to create the shadow map
  46033. */
  46034. ShadowGenerator.prototype.getTransformMatrix = function () {
  46035. var scene = this._scene;
  46036. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  46037. return this._transformMatrix;
  46038. }
  46039. this._currentRenderID = scene.getRenderId();
  46040. this._currentFaceIndexCache = this._currentFaceIndex;
  46041. var lightPosition = this._light.position;
  46042. if (this._light.computeTransformedInformation()) {
  46043. lightPosition = this._light.transformedPosition;
  46044. }
  46045. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  46046. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  46047. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  46048. }
  46049. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  46050. this._cachedPosition.copyFrom(lightPosition);
  46051. this._cachedDirection.copyFrom(this._lightDirection);
  46052. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  46053. var shadowMap = this.getShadowMap();
  46054. if (shadowMap) {
  46055. var renderList = shadowMap.renderList;
  46056. if (renderList) {
  46057. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  46058. }
  46059. }
  46060. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  46061. }
  46062. return this._transformMatrix;
  46063. };
  46064. /**
  46065. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  46066. * Cube and 2D textures for instance.
  46067. */
  46068. ShadowGenerator.prototype.recreateShadowMap = function () {
  46069. var shadowMap = this._shadowMap;
  46070. if (!shadowMap) {
  46071. return;
  46072. }
  46073. // Track render list.
  46074. var renderList = shadowMap.renderList;
  46075. // Clean up existing data.
  46076. this._disposeRTTandPostProcesses();
  46077. // Reinitializes.
  46078. this._initializeGenerator();
  46079. // Reaffect the filter to ensure a correct fallback if necessary.
  46080. this.filter = this.filter;
  46081. // Reaffect the filter.
  46082. this._applyFilterValues();
  46083. // Reaffect Render List.
  46084. this._shadowMap.renderList = renderList;
  46085. };
  46086. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  46087. if (this._shadowMap2) {
  46088. this._shadowMap2.dispose();
  46089. this._shadowMap2 = null;
  46090. }
  46091. if (this._boxBlurPostprocess) {
  46092. this._boxBlurPostprocess.dispose();
  46093. this._boxBlurPostprocess = null;
  46094. }
  46095. if (this._kernelBlurXPostprocess) {
  46096. this._kernelBlurXPostprocess.dispose();
  46097. this._kernelBlurXPostprocess = null;
  46098. }
  46099. if (this._kernelBlurYPostprocess) {
  46100. this._kernelBlurYPostprocess.dispose();
  46101. this._kernelBlurYPostprocess = null;
  46102. }
  46103. this._blurPostProcesses = [];
  46104. };
  46105. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  46106. if (this._shadowMap) {
  46107. this._shadowMap.dispose();
  46108. this._shadowMap = null;
  46109. }
  46110. this._disposeBlurPostProcesses();
  46111. };
  46112. /**
  46113. * Disposes the ShadowGenerator.
  46114. * Returns nothing.
  46115. */
  46116. ShadowGenerator.prototype.dispose = function () {
  46117. this._disposeRTTandPostProcesses();
  46118. if (this._light) {
  46119. this._light._shadowGenerator = null;
  46120. this._light._markMeshesAsLightDirty();
  46121. }
  46122. };
  46123. /**
  46124. * Serializes the shadow generator setup to a json object.
  46125. * @returns The serialized JSON object
  46126. */
  46127. ShadowGenerator.prototype.serialize = function () {
  46128. var serializationObject = {};
  46129. var shadowMap = this.getShadowMap();
  46130. if (!shadowMap) {
  46131. return serializationObject;
  46132. }
  46133. serializationObject.lightId = this._light.id;
  46134. serializationObject.mapSize = shadowMap.getRenderSize();
  46135. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  46136. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  46137. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46138. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46139. serializationObject.usePoissonSampling = this.usePoissonSampling;
  46140. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  46141. serializationObject.depthScale = this.depthScale;
  46142. serializationObject.darkness = this.getDarkness();
  46143. serializationObject.blurBoxOffset = this.blurBoxOffset;
  46144. serializationObject.blurKernel = this.blurKernel;
  46145. serializationObject.blurScale = this.blurScale;
  46146. serializationObject.useKernelBlur = this.useKernelBlur;
  46147. serializationObject.transparencyShadow = this._transparencyShadow;
  46148. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  46149. serializationObject.bias = this.bias;
  46150. serializationObject.normalBias = this.normalBias;
  46151. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  46152. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  46153. serializationObject.filteringQuality = this.filteringQuality;
  46154. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  46155. serializationObject.renderList = [];
  46156. if (shadowMap.renderList) {
  46157. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  46158. var mesh = shadowMap.renderList[meshIndex];
  46159. serializationObject.renderList.push(mesh.id);
  46160. }
  46161. }
  46162. return serializationObject;
  46163. };
  46164. /**
  46165. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  46166. * @param parsedShadowGenerator The JSON object to parse
  46167. * @param scene The scene to create the shadow map for
  46168. * @returns The parsed shadow generator
  46169. */
  46170. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  46171. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  46172. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  46173. var shadowMap = shadowGenerator.getShadowMap();
  46174. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  46175. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  46176. meshes.forEach(function (mesh) {
  46177. if (!shadowMap) {
  46178. return;
  46179. }
  46180. if (!shadowMap.renderList) {
  46181. shadowMap.renderList = [];
  46182. }
  46183. shadowMap.renderList.push(mesh);
  46184. });
  46185. }
  46186. if (parsedShadowGenerator.usePoissonSampling) {
  46187. shadowGenerator.usePoissonSampling = true;
  46188. }
  46189. else if (parsedShadowGenerator.useExponentialShadowMap) {
  46190. shadowGenerator.useExponentialShadowMap = true;
  46191. }
  46192. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  46193. shadowGenerator.useBlurExponentialShadowMap = true;
  46194. }
  46195. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  46196. shadowGenerator.useCloseExponentialShadowMap = true;
  46197. }
  46198. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  46199. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  46200. }
  46201. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  46202. shadowGenerator.usePercentageCloserFiltering = true;
  46203. }
  46204. else if (parsedShadowGenerator.useContactHardeningShadow) {
  46205. shadowGenerator.useContactHardeningShadow = true;
  46206. }
  46207. if (parsedShadowGenerator.filteringQuality) {
  46208. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  46209. }
  46210. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  46211. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  46212. }
  46213. // Backward compat
  46214. else if (parsedShadowGenerator.useVarianceShadowMap) {
  46215. shadowGenerator.useExponentialShadowMap = true;
  46216. }
  46217. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  46218. shadowGenerator.useBlurExponentialShadowMap = true;
  46219. }
  46220. if (parsedShadowGenerator.depthScale) {
  46221. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  46222. }
  46223. if (parsedShadowGenerator.blurScale) {
  46224. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  46225. }
  46226. if (parsedShadowGenerator.blurBoxOffset) {
  46227. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  46228. }
  46229. if (parsedShadowGenerator.useKernelBlur) {
  46230. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  46231. }
  46232. if (parsedShadowGenerator.blurKernel) {
  46233. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  46234. }
  46235. if (parsedShadowGenerator.bias !== undefined) {
  46236. shadowGenerator.bias = parsedShadowGenerator.bias;
  46237. }
  46238. if (parsedShadowGenerator.normalBias !== undefined) {
  46239. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  46240. }
  46241. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  46242. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  46243. }
  46244. if (parsedShadowGenerator.darkness) {
  46245. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  46246. }
  46247. if (parsedShadowGenerator.transparencyShadow) {
  46248. shadowGenerator.setTransparencyShadow(true);
  46249. }
  46250. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  46251. return shadowGenerator;
  46252. };
  46253. /**
  46254. * Shadow generator mode None: no filtering applied.
  46255. */
  46256. ShadowGenerator.FILTER_NONE = 0;
  46257. /**
  46258. * Shadow generator mode ESM: Exponential Shadow Mapping.
  46259. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46260. */
  46261. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  46262. /**
  46263. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  46264. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  46265. */
  46266. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  46267. /**
  46268. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  46269. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46270. */
  46271. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  46272. /**
  46273. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  46274. * edge artifacts on steep falloff.
  46275. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46276. */
  46277. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  46278. /**
  46279. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  46280. * edge artifacts on steep falloff.
  46281. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46282. */
  46283. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  46284. /**
  46285. * Shadow generator mode PCF: Percentage Closer Filtering
  46286. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46287. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  46288. */
  46289. ShadowGenerator.FILTER_PCF = 6;
  46290. /**
  46291. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  46292. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46293. * Contact Hardening
  46294. */
  46295. ShadowGenerator.FILTER_PCSS = 7;
  46296. /**
  46297. * Reserved for PCF and PCSS
  46298. * Highest Quality.
  46299. *
  46300. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  46301. *
  46302. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  46303. */
  46304. ShadowGenerator.QUALITY_HIGH = 0;
  46305. /**
  46306. * Reserved for PCF and PCSS
  46307. * Good tradeoff for quality/perf cross devices
  46308. *
  46309. * Execute PCF on a 3*3 kernel.
  46310. *
  46311. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  46312. */
  46313. ShadowGenerator.QUALITY_MEDIUM = 1;
  46314. /**
  46315. * Reserved for PCF and PCSS
  46316. * The lowest quality but the fastest.
  46317. *
  46318. * Execute PCF on a 1*1 kernel.
  46319. *
  46320. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  46321. */
  46322. ShadowGenerator.QUALITY_LOW = 2;
  46323. /** @hidden */
  46324. ShadowGenerator._SceneComponentInitialization = function (_) {
  46325. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  46326. };
  46327. return ShadowGenerator;
  46328. }());
  46329. /***/ }),
  46330. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  46331. /*!*********************************************************!*\
  46332. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  46333. \*********************************************************/
  46334. /*! exports provided: ShadowGeneratorSceneComponent */
  46335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46336. "use strict";
  46337. __webpack_require__.r(__webpack_exports__);
  46338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  46339. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46340. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46341. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46342. // Adds the parser to the scene parsers.
  46343. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  46344. // Shadows
  46345. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  46346. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  46347. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  46348. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  46349. // SG would be available on their associated lights
  46350. }
  46351. }
  46352. });
  46353. /**
  46354. * Defines the shadow generator component responsible to manage any shadow generators
  46355. * in a given scene.
  46356. */
  46357. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  46358. /**
  46359. * Creates a new instance of the component for the given scene
  46360. * @param scene Defines the scene to register the component in
  46361. */
  46362. function ShadowGeneratorSceneComponent(scene) {
  46363. /**
  46364. * The component name helpfull to identify the component in the list of scene components.
  46365. */
  46366. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  46367. this.scene = scene;
  46368. }
  46369. /**
  46370. * Registers the component in a given scene
  46371. */
  46372. ShadowGeneratorSceneComponent.prototype.register = function () {
  46373. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  46374. };
  46375. /**
  46376. * Rebuilds the elements related to this component in case of
  46377. * context lost for instance.
  46378. */
  46379. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  46380. // Nothing To Do Here.
  46381. };
  46382. /**
  46383. * Serializes the component data to the specified json object
  46384. * @param serializationObject The object to serialize to
  46385. */
  46386. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  46387. // Shadows
  46388. serializationObject.shadowGenerators = [];
  46389. var lights = this.scene.lights;
  46390. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  46391. var light = lights_1[_i];
  46392. var shadowGenerator = light.getShadowGenerator();
  46393. if (shadowGenerator) {
  46394. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  46395. }
  46396. }
  46397. };
  46398. /**
  46399. * Adds all the element from the container to the scene
  46400. * @param container the container holding the elements
  46401. */
  46402. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  46403. // Nothing To Do Here. (directly attached to a light)
  46404. };
  46405. /**
  46406. * Removes all the elements in the container from the scene
  46407. * @param container contains the elements to remove
  46408. */
  46409. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  46410. // Nothing To Do Here. (directly attached to a light)
  46411. };
  46412. /**
  46413. * Rebuilds the elements related to this component in case of
  46414. * context lost for instance.
  46415. */
  46416. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  46417. // Nothing To Do Here.
  46418. };
  46419. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  46420. // Shadows
  46421. var scene = this.scene;
  46422. if (this.scene.shadowsEnabled) {
  46423. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  46424. var light = scene.lights[lightIndex];
  46425. var shadowGenerator = light.getShadowGenerator();
  46426. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  46427. var shadowMap = (shadowGenerator.getShadowMap());
  46428. if (scene.textures.indexOf(shadowMap) !== -1) {
  46429. renderTargets.push(shadowMap);
  46430. }
  46431. }
  46432. }
  46433. }
  46434. };
  46435. return ShadowGeneratorSceneComponent;
  46436. }());
  46437. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  46438. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  46439. if (!component) {
  46440. component = new ShadowGeneratorSceneComponent(scene);
  46441. scene._addComponent(component);
  46442. }
  46443. };
  46444. /***/ }),
  46445. /***/ "./Lights/directionalLight.ts":
  46446. /*!************************************!*\
  46447. !*** ./Lights/directionalLight.ts ***!
  46448. \************************************/
  46449. /*! exports provided: DirectionalLight */
  46450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46451. "use strict";
  46452. __webpack_require__.r(__webpack_exports__);
  46453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  46454. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46455. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46456. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46457. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46458. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46459. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46460. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  46461. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46462. });
  46463. /**
  46464. * A directional light is defined by a direction (what a surprise!).
  46465. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46466. * 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.
  46467. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46468. */
  46469. var DirectionalLight = /** @class */ (function (_super) {
  46470. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  46471. /**
  46472. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46473. * The directional light is emitted from everywhere in the given direction.
  46474. * It can cast shadows.
  46475. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46476. * @param name The friendly name of the light
  46477. * @param direction The direction of the light
  46478. * @param scene The scene the light belongs to
  46479. */
  46480. function DirectionalLight(name, direction, scene) {
  46481. var _this = _super.call(this, name, scene) || this;
  46482. _this._shadowFrustumSize = 0;
  46483. _this._shadowOrthoScale = 0.1;
  46484. /**
  46485. * Automatically compute the projection matrix to best fit (including all the casters)
  46486. * on each frame.
  46487. */
  46488. _this.autoUpdateExtends = true;
  46489. // Cache
  46490. _this._orthoLeft = Number.MAX_VALUE;
  46491. _this._orthoRight = Number.MIN_VALUE;
  46492. _this._orthoTop = Number.MIN_VALUE;
  46493. _this._orthoBottom = Number.MAX_VALUE;
  46494. _this.position = direction.scale(-1.0);
  46495. _this.direction = direction;
  46496. return _this;
  46497. }
  46498. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  46499. /**
  46500. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46501. */
  46502. get: function () {
  46503. return this._shadowFrustumSize;
  46504. },
  46505. /**
  46506. * Specifies a fix frustum size for the shadow generation.
  46507. */
  46508. set: function (value) {
  46509. this._shadowFrustumSize = value;
  46510. this.forceProjectionMatrixCompute();
  46511. },
  46512. enumerable: true,
  46513. configurable: true
  46514. });
  46515. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  46516. /**
  46517. * Gets the shadow projection scale against the optimal computed one.
  46518. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46519. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46520. */
  46521. get: function () {
  46522. return this._shadowOrthoScale;
  46523. },
  46524. /**
  46525. * Sets the shadow projection scale against the optimal computed one.
  46526. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46527. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46528. */
  46529. set: function (value) {
  46530. this._shadowOrthoScale = value;
  46531. this.forceProjectionMatrixCompute();
  46532. },
  46533. enumerable: true,
  46534. configurable: true
  46535. });
  46536. /**
  46537. * Returns the string "DirectionalLight".
  46538. * @return The class name
  46539. */
  46540. DirectionalLight.prototype.getClassName = function () {
  46541. return "DirectionalLight";
  46542. };
  46543. /**
  46544. * Returns the integer 1.
  46545. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46546. */
  46547. DirectionalLight.prototype.getTypeID = function () {
  46548. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  46549. };
  46550. /**
  46551. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46552. * Returns the DirectionalLight Shadow projection matrix.
  46553. */
  46554. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46555. if (this.shadowFrustumSize > 0) {
  46556. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  46557. }
  46558. else {
  46559. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  46560. }
  46561. };
  46562. /**
  46563. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46564. * Returns the DirectionalLight Shadow projection matrix.
  46565. */
  46566. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  46567. var activeCamera = this.getScene().activeCamera;
  46568. if (!activeCamera) {
  46569. return;
  46570. }
  46571. _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);
  46572. };
  46573. /**
  46574. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46575. * Returns the DirectionalLight Shadow projection matrix.
  46576. */
  46577. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46578. var activeCamera = this.getScene().activeCamera;
  46579. if (!activeCamera) {
  46580. return;
  46581. }
  46582. // Check extends
  46583. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  46584. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46585. this._orthoLeft = Number.MAX_VALUE;
  46586. this._orthoRight = Number.MIN_VALUE;
  46587. this._orthoTop = Number.MIN_VALUE;
  46588. this._orthoBottom = Number.MAX_VALUE;
  46589. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  46590. var mesh = renderList[meshIndex];
  46591. if (!mesh) {
  46592. continue;
  46593. }
  46594. var boundingInfo = mesh.getBoundingInfo();
  46595. var boundingBox = boundingInfo.boundingBox;
  46596. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  46597. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  46598. if (tempVector3.x < this._orthoLeft) {
  46599. this._orthoLeft = tempVector3.x;
  46600. }
  46601. if (tempVector3.y < this._orthoBottom) {
  46602. this._orthoBottom = tempVector3.y;
  46603. }
  46604. if (tempVector3.x > this._orthoRight) {
  46605. this._orthoRight = tempVector3.x;
  46606. }
  46607. if (tempVector3.y > this._orthoTop) {
  46608. this._orthoTop = tempVector3.y;
  46609. }
  46610. }
  46611. }
  46612. }
  46613. var xOffset = this._orthoRight - this._orthoLeft;
  46614. var yOffset = this._orthoTop - this._orthoBottom;
  46615. _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);
  46616. };
  46617. DirectionalLight.prototype._buildUniformLayout = function () {
  46618. this._uniformBuffer.addUniform("vLightData", 4);
  46619. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46620. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46621. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46622. this._uniformBuffer.addUniform("depthValues", 2);
  46623. this._uniformBuffer.create();
  46624. };
  46625. /**
  46626. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46627. * @param effect The effect to update
  46628. * @param lightIndex The index of the light in the effect to update
  46629. * @returns The directional light
  46630. */
  46631. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  46632. if (this.computeTransformedInformation()) {
  46633. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  46634. return this;
  46635. }
  46636. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  46637. return this;
  46638. };
  46639. /**
  46640. * Gets the minZ used for shadow according to both the scene and the light.
  46641. *
  46642. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46643. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46644. * @param activeCamera The camera we are returning the min for
  46645. * @returns the depth min z
  46646. */
  46647. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  46648. return 1;
  46649. };
  46650. /**
  46651. * Gets the maxZ used for shadow according to both the scene and the light.
  46652. *
  46653. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46654. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46655. * @param activeCamera The camera we are returning the max for
  46656. * @returns the depth max z
  46657. */
  46658. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  46659. return 1;
  46660. };
  46661. /**
  46662. * Prepares the list of defines specific to the light type.
  46663. * @param defines the list of defines
  46664. * @param lightIndex defines the index of the light for the effect
  46665. */
  46666. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46667. defines["DIRLIGHT" + lightIndex] = true;
  46668. };
  46669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46671. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  46672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46674. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  46675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46677. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  46678. return DirectionalLight;
  46679. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46680. /***/ }),
  46681. /***/ "./Lights/hemisphericLight.ts":
  46682. /*!************************************!*\
  46683. !*** ./Lights/hemisphericLight.ts ***!
  46684. \************************************/
  46685. /*! exports provided: HemisphericLight */
  46686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46687. "use strict";
  46688. __webpack_require__.r(__webpack_exports__);
  46689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  46690. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46691. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46692. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46693. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46694. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46695. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  46696. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46697. });
  46698. /**
  46699. * The HemisphericLight simulates the ambient environment light,
  46700. * so the passed direction is the light reflection direction, not the incoming direction.
  46701. */
  46702. var HemisphericLight = /** @class */ (function (_super) {
  46703. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  46704. /**
  46705. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  46706. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  46707. * The HemisphericLight can't cast shadows.
  46708. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46709. * @param name The friendly name of the light
  46710. * @param direction The direction of the light reflection
  46711. * @param scene The scene the light belongs to
  46712. */
  46713. function HemisphericLight(name, direction, scene) {
  46714. var _this = _super.call(this, name, scene) || this;
  46715. /**
  46716. * The groundColor is the light in the opposite direction to the one specified during creation.
  46717. * 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.
  46718. */
  46719. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  46720. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46721. return _this;
  46722. }
  46723. HemisphericLight.prototype._buildUniformLayout = function () {
  46724. this._uniformBuffer.addUniform("vLightData", 4);
  46725. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46726. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46727. this._uniformBuffer.addUniform("vLightGround", 3);
  46728. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46729. this._uniformBuffer.addUniform("depthValues", 2);
  46730. this._uniformBuffer.create();
  46731. };
  46732. /**
  46733. * Returns the string "HemisphericLight".
  46734. * @return The class name
  46735. */
  46736. HemisphericLight.prototype.getClassName = function () {
  46737. return "HemisphericLight";
  46738. };
  46739. /**
  46740. * Sets the HemisphericLight direction towards the passed target (Vector3).
  46741. * Returns the updated direction.
  46742. * @param target The target the direction should point to
  46743. * @return The computed direction
  46744. */
  46745. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  46746. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  46747. return this.direction;
  46748. };
  46749. /**
  46750. * Returns the shadow generator associated to the light.
  46751. * @returns Always null for hemispheric lights because it does not support shadows.
  46752. */
  46753. HemisphericLight.prototype.getShadowGenerator = function () {
  46754. return null;
  46755. };
  46756. /**
  46757. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  46758. * @param effect The effect to update
  46759. * @param lightIndex The index of the light in the effect to update
  46760. * @returns The hemispheric light
  46761. */
  46762. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  46763. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46764. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  46765. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  46766. return this;
  46767. };
  46768. /**
  46769. * Computes the world matrix of the node
  46770. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46771. * @param useWasUpdatedFlag defines a reserved property
  46772. * @returns the world matrix
  46773. */
  46774. HemisphericLight.prototype.computeWorldMatrix = function () {
  46775. if (!this._worldMatrix) {
  46776. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46777. }
  46778. return this._worldMatrix;
  46779. };
  46780. /**
  46781. * Returns the integer 3.
  46782. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46783. */
  46784. HemisphericLight.prototype.getTypeID = function () {
  46785. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  46786. };
  46787. /**
  46788. * Prepares the list of defines specific to the light type.
  46789. * @param defines the list of defines
  46790. * @param lightIndex defines the index of the light for the effect
  46791. */
  46792. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46793. defines["HEMILIGHT" + lightIndex] = true;
  46794. };
  46795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46797. ], HemisphericLight.prototype, "groundColor", void 0);
  46798. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46799. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46800. ], HemisphericLight.prototype, "direction", void 0);
  46801. return HemisphericLight;
  46802. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  46803. /***/ }),
  46804. /***/ "./Lights/index.ts":
  46805. /*!*************************!*\
  46806. !*** ./Lights/index.ts ***!
  46807. \*************************/
  46808. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  46809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46810. "use strict";
  46811. __webpack_require__.r(__webpack_exports__);
  46812. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  46814. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  46816. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  46817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  46818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  46819. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  46820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46821. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46823. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46825. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46827. /***/ }),
  46828. /***/ "./Lights/light.ts":
  46829. /*!*************************!*\
  46830. !*** ./Lights/light.ts ***!
  46831. \*************************/
  46832. /*! exports provided: Light */
  46833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46834. "use strict";
  46835. __webpack_require__.r(__webpack_exports__);
  46836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46837. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46838. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46839. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46840. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46841. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46842. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46843. /**
  46844. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46845. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46846. * 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.
  46847. */
  46848. var Light = /** @class */ (function (_super) {
  46849. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46850. /**
  46851. * Creates a Light object in the scene.
  46852. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46853. * @param name The firendly name of the light
  46854. * @param scene The scene the light belongs too
  46855. */
  46856. function Light(name, scene) {
  46857. var _this = _super.call(this, name, scene) || this;
  46858. /**
  46859. * Diffuse gives the basic color to an object.
  46860. */
  46861. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46862. /**
  46863. * Specular produces a highlight color on an object.
  46864. * Note: This is note affecting PBR materials.
  46865. */
  46866. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46867. /**
  46868. * Defines the falloff type for this light. This lets overrriding how punctual light are
  46869. * falling off base on range or angle.
  46870. * This can be set to any values in Light.FALLOFF_x.
  46871. *
  46872. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  46873. * other types of materials.
  46874. */
  46875. _this.falloffType = Light.FALLOFF_DEFAULT;
  46876. /**
  46877. * Strength of the light.
  46878. * Note: By default it is define in the framework own unit.
  46879. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  46880. */
  46881. _this.intensity = 1.0;
  46882. _this._range = Number.MAX_VALUE;
  46883. _this._inverseSquaredRange = 0;
  46884. /**
  46885. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  46886. * of light.
  46887. */
  46888. _this._photometricScale = 1.0;
  46889. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  46890. _this._radius = 0.00001;
  46891. /**
  46892. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  46893. * exceeding the number allowed of the materials.
  46894. */
  46895. _this.renderPriority = 0;
  46896. _this._shadowEnabled = true;
  46897. _this._excludeWithLayerMask = 0;
  46898. _this._includeOnlyWithLayerMask = 0;
  46899. _this._lightmapMode = 0;
  46900. /**
  46901. * @hidden Internal use only.
  46902. */
  46903. _this._excludedMeshesIds = new Array();
  46904. /**
  46905. * @hidden Internal use only.
  46906. */
  46907. _this._includedOnlyMeshesIds = new Array();
  46908. /** @hidden */
  46909. _this._isLight = true;
  46910. _this.getScene().addLight(_this);
  46911. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  46912. _this._buildUniformLayout();
  46913. _this.includedOnlyMeshes = new Array();
  46914. _this.excludedMeshes = new Array();
  46915. _this._resyncMeshes();
  46916. return _this;
  46917. }
  46918. Object.defineProperty(Light.prototype, "range", {
  46919. /**
  46920. * Defines how far from the source the light is impacting in scene units.
  46921. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46922. */
  46923. get: function () {
  46924. return this._range;
  46925. },
  46926. /**
  46927. * Defines how far from the source the light is impacting in scene units.
  46928. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46929. */
  46930. set: function (value) {
  46931. this._range = value;
  46932. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  46933. },
  46934. enumerable: true,
  46935. configurable: true
  46936. });
  46937. Object.defineProperty(Light.prototype, "intensityMode", {
  46938. /**
  46939. * Gets the photometric scale used to interpret the intensity.
  46940. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46941. */
  46942. get: function () {
  46943. return this._intensityMode;
  46944. },
  46945. /**
  46946. * Sets the photometric scale used to interpret the intensity.
  46947. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46948. */
  46949. set: function (value) {
  46950. this._intensityMode = value;
  46951. this._computePhotometricScale();
  46952. },
  46953. enumerable: true,
  46954. configurable: true
  46955. });
  46956. Object.defineProperty(Light.prototype, "radius", {
  46957. /**
  46958. * Gets the light radius used by PBR Materials to simulate soft area lights.
  46959. */
  46960. get: function () {
  46961. return this._radius;
  46962. },
  46963. /**
  46964. * sets the light radius used by PBR Materials to simulate soft area lights.
  46965. */
  46966. set: function (value) {
  46967. this._radius = value;
  46968. this._computePhotometricScale();
  46969. },
  46970. enumerable: true,
  46971. configurable: true
  46972. });
  46973. Object.defineProperty(Light.prototype, "shadowEnabled", {
  46974. /**
  46975. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46976. * the current shadow generator.
  46977. */
  46978. get: function () {
  46979. return this._shadowEnabled;
  46980. },
  46981. /**
  46982. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46983. * the current shadow generator.
  46984. */
  46985. set: function (value) {
  46986. if (this._shadowEnabled === value) {
  46987. return;
  46988. }
  46989. this._shadowEnabled = value;
  46990. this._markMeshesAsLightDirty();
  46991. },
  46992. enumerable: true,
  46993. configurable: true
  46994. });
  46995. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46996. /**
  46997. * Gets the only meshes impacted by this light.
  46998. */
  46999. get: function () {
  47000. return this._includedOnlyMeshes;
  47001. },
  47002. /**
  47003. * Sets the only meshes impacted by this light.
  47004. */
  47005. set: function (value) {
  47006. this._includedOnlyMeshes = value;
  47007. this._hookArrayForIncludedOnly(value);
  47008. },
  47009. enumerable: true,
  47010. configurable: true
  47011. });
  47012. Object.defineProperty(Light.prototype, "excludedMeshes", {
  47013. /**
  47014. * Gets the meshes not impacted by this light.
  47015. */
  47016. get: function () {
  47017. return this._excludedMeshes;
  47018. },
  47019. /**
  47020. * Sets the meshes not impacted by this light.
  47021. */
  47022. set: function (value) {
  47023. this._excludedMeshes = value;
  47024. this._hookArrayForExcluded(value);
  47025. },
  47026. enumerable: true,
  47027. configurable: true
  47028. });
  47029. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  47030. /**
  47031. * Gets the layer id use to find what meshes are not impacted by the light.
  47032. * Inactive if 0
  47033. */
  47034. get: function () {
  47035. return this._excludeWithLayerMask;
  47036. },
  47037. /**
  47038. * Sets the layer id use to find what meshes are not impacted by the light.
  47039. * Inactive if 0
  47040. */
  47041. set: function (value) {
  47042. this._excludeWithLayerMask = value;
  47043. this._resyncMeshes();
  47044. },
  47045. enumerable: true,
  47046. configurable: true
  47047. });
  47048. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  47049. /**
  47050. * Gets the layer id use to find what meshes are impacted by the light.
  47051. * Inactive if 0
  47052. */
  47053. get: function () {
  47054. return this._includeOnlyWithLayerMask;
  47055. },
  47056. /**
  47057. * Sets the layer id use to find what meshes are impacted by the light.
  47058. * Inactive if 0
  47059. */
  47060. set: function (value) {
  47061. this._includeOnlyWithLayerMask = value;
  47062. this._resyncMeshes();
  47063. },
  47064. enumerable: true,
  47065. configurable: true
  47066. });
  47067. Object.defineProperty(Light.prototype, "lightmapMode", {
  47068. /**
  47069. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47070. */
  47071. get: function () {
  47072. return this._lightmapMode;
  47073. },
  47074. /**
  47075. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47076. */
  47077. set: function (value) {
  47078. if (this._lightmapMode === value) {
  47079. return;
  47080. }
  47081. this._lightmapMode = value;
  47082. this._markMeshesAsLightDirty();
  47083. },
  47084. enumerable: true,
  47085. configurable: true
  47086. });
  47087. /**
  47088. * Returns the string "Light".
  47089. * @returns the class name
  47090. */
  47091. Light.prototype.getClassName = function () {
  47092. return "Light";
  47093. };
  47094. /**
  47095. * Converts the light information to a readable string for debug purpose.
  47096. * @param fullDetails Supports for multiple levels of logging within scene loading
  47097. * @returns the human readable light info
  47098. */
  47099. Light.prototype.toString = function (fullDetails) {
  47100. var ret = "Name: " + this.name;
  47101. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  47102. if (this.animations) {
  47103. for (var i = 0; i < this.animations.length; i++) {
  47104. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  47105. }
  47106. }
  47107. if (fullDetails) {
  47108. }
  47109. return ret;
  47110. };
  47111. /** @hidden */
  47112. Light.prototype._syncParentEnabledState = function () {
  47113. _super.prototype._syncParentEnabledState.call(this);
  47114. this._resyncMeshes();
  47115. };
  47116. /**
  47117. * Set the enabled state of this node.
  47118. * @param value - the new enabled state
  47119. */
  47120. Light.prototype.setEnabled = function (value) {
  47121. _super.prototype.setEnabled.call(this, value);
  47122. this._resyncMeshes();
  47123. };
  47124. /**
  47125. * Returns the Light associated shadow generator if any.
  47126. * @return the associated shadow generator.
  47127. */
  47128. Light.prototype.getShadowGenerator = function () {
  47129. return this._shadowGenerator;
  47130. };
  47131. /**
  47132. * Returns a Vector3, the absolute light position in the World.
  47133. * @returns the world space position of the light
  47134. */
  47135. Light.prototype.getAbsolutePosition = function () {
  47136. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47137. };
  47138. /**
  47139. * Specifies if the light will affect the passed mesh.
  47140. * @param mesh The mesh to test against the light
  47141. * @return true the mesh is affected otherwise, false.
  47142. */
  47143. Light.prototype.canAffectMesh = function (mesh) {
  47144. if (!mesh) {
  47145. return true;
  47146. }
  47147. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  47148. return false;
  47149. }
  47150. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  47151. return false;
  47152. }
  47153. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  47154. return false;
  47155. }
  47156. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  47157. return false;
  47158. }
  47159. return true;
  47160. };
  47161. /**
  47162. * Sort function to order lights for rendering.
  47163. * @param a First Light object to compare to second.
  47164. * @param b Second Light object to compare first.
  47165. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  47166. */
  47167. Light.CompareLightsPriority = function (a, b) {
  47168. //shadow-casting lights have priority over non-shadow-casting lights
  47169. //the renderPrioirty is a secondary sort criterion
  47170. if (a.shadowEnabled !== b.shadowEnabled) {
  47171. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  47172. }
  47173. return b.renderPriority - a.renderPriority;
  47174. };
  47175. /**
  47176. * Releases resources associated with this node.
  47177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47179. */
  47180. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  47181. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  47182. if (this._shadowGenerator) {
  47183. this._shadowGenerator.dispose();
  47184. this._shadowGenerator = null;
  47185. }
  47186. // Animations
  47187. this.getScene().stopAnimation(this);
  47188. // Remove from meshes
  47189. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47190. var mesh = _a[_i];
  47191. mesh._removeLightSource(this);
  47192. }
  47193. this._uniformBuffer.dispose();
  47194. // Remove from scene
  47195. this.getScene().removeLight(this);
  47196. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  47197. };
  47198. /**
  47199. * Returns the light type ID (integer).
  47200. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47201. */
  47202. Light.prototype.getTypeID = function () {
  47203. return 0;
  47204. };
  47205. /**
  47206. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  47207. * @returns the scaled intensity in intensity mode unit
  47208. */
  47209. Light.prototype.getScaledIntensity = function () {
  47210. return this._photometricScale * this.intensity;
  47211. };
  47212. /**
  47213. * Returns a new Light object, named "name", from the current one.
  47214. * @param name The name of the cloned light
  47215. * @returns the new created light
  47216. */
  47217. Light.prototype.clone = function (name) {
  47218. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  47219. if (!constructor) {
  47220. return null;
  47221. }
  47222. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  47223. };
  47224. /**
  47225. * Serializes the current light into a Serialization object.
  47226. * @returns the serialized object.
  47227. */
  47228. Light.prototype.serialize = function () {
  47229. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  47230. // Type
  47231. serializationObject.type = this.getTypeID();
  47232. // Parent
  47233. if (this.parent) {
  47234. serializationObject.parentId = this.parent.id;
  47235. }
  47236. // Inclusion / exclusions
  47237. if (this.excludedMeshes.length > 0) {
  47238. serializationObject.excludedMeshesIds = [];
  47239. this.excludedMeshes.forEach(function (mesh) {
  47240. serializationObject.excludedMeshesIds.push(mesh.id);
  47241. });
  47242. }
  47243. if (this.includedOnlyMeshes.length > 0) {
  47244. serializationObject.includedOnlyMeshesIds = [];
  47245. this.includedOnlyMeshes.forEach(function (mesh) {
  47246. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  47247. });
  47248. }
  47249. // Animations
  47250. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  47251. serializationObject.ranges = this.serializeAnimationRanges();
  47252. return serializationObject;
  47253. };
  47254. /**
  47255. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  47256. * This new light is named "name" and added to the passed scene.
  47257. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  47258. * @param name The friendly name of the light
  47259. * @param scene The scene the new light will belong to
  47260. * @returns the constructor function
  47261. */
  47262. Light.GetConstructorFromName = function (type, name, scene) {
  47263. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  47264. if (constructorFunc) {
  47265. return constructorFunc;
  47266. }
  47267. // Default to no light for none present once.
  47268. return null;
  47269. };
  47270. /**
  47271. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  47272. * @param parsedLight The JSON representation of the light
  47273. * @param scene The scene to create the parsed light in
  47274. * @returns the created light after parsing
  47275. */
  47276. Light.Parse = function (parsedLight, scene) {
  47277. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  47278. if (!constructor) {
  47279. return null;
  47280. }
  47281. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  47282. // Inclusion / exclusions
  47283. if (parsedLight.excludedMeshesIds) {
  47284. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  47285. }
  47286. if (parsedLight.includedOnlyMeshesIds) {
  47287. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  47288. }
  47289. // Parent
  47290. if (parsedLight.parentId) {
  47291. light._waitingParentId = parsedLight.parentId;
  47292. }
  47293. // Animations
  47294. if (parsedLight.animations) {
  47295. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  47296. var parsedAnimation = parsedLight.animations[animationIndex];
  47297. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  47298. if (internalClass) {
  47299. light.animations.push(internalClass.Parse(parsedAnimation));
  47300. }
  47301. }
  47302. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  47303. }
  47304. if (parsedLight.autoAnimate) {
  47305. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  47306. }
  47307. return light;
  47308. };
  47309. Light.prototype._hookArrayForExcluded = function (array) {
  47310. var _this = this;
  47311. var oldPush = array.push;
  47312. array.push = function () {
  47313. var items = [];
  47314. for (var _i = 0; _i < arguments.length; _i++) {
  47315. items[_i] = arguments[_i];
  47316. }
  47317. var result = oldPush.apply(array, items);
  47318. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  47319. var item = items_1[_a];
  47320. item._resyncLighSource(_this);
  47321. }
  47322. return result;
  47323. };
  47324. var oldSplice = array.splice;
  47325. array.splice = function (index, deleteCount) {
  47326. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47327. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  47328. var item = deleted_1[_i];
  47329. item._resyncLighSource(_this);
  47330. }
  47331. return deleted;
  47332. };
  47333. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  47334. var item = array_1[_i];
  47335. item._resyncLighSource(this);
  47336. }
  47337. };
  47338. Light.prototype._hookArrayForIncludedOnly = function (array) {
  47339. var _this = this;
  47340. var oldPush = array.push;
  47341. array.push = function () {
  47342. var items = [];
  47343. for (var _i = 0; _i < arguments.length; _i++) {
  47344. items[_i] = arguments[_i];
  47345. }
  47346. var result = oldPush.apply(array, items);
  47347. _this._resyncMeshes();
  47348. return result;
  47349. };
  47350. var oldSplice = array.splice;
  47351. array.splice = function (index, deleteCount) {
  47352. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47353. _this._resyncMeshes();
  47354. return deleted;
  47355. };
  47356. this._resyncMeshes();
  47357. };
  47358. Light.prototype._resyncMeshes = function () {
  47359. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47360. var mesh = _a[_i];
  47361. mesh._resyncLighSource(this);
  47362. }
  47363. };
  47364. /**
  47365. * Forces the meshes to update their light related information in their rendering used effects
  47366. * @hidden Internal Use Only
  47367. */
  47368. Light.prototype._markMeshesAsLightDirty = function () {
  47369. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47370. var mesh = _a[_i];
  47371. if (mesh._lightSources.indexOf(this) !== -1) {
  47372. mesh._markSubMeshesAsLightDirty();
  47373. }
  47374. }
  47375. };
  47376. /**
  47377. * Recomputes the cached photometric scale if needed.
  47378. */
  47379. Light.prototype._computePhotometricScale = function () {
  47380. this._photometricScale = this._getPhotometricScale();
  47381. this.getScene().resetCachedMaterial();
  47382. };
  47383. /**
  47384. * Returns the Photometric Scale according to the light type and intensity mode.
  47385. */
  47386. Light.prototype._getPhotometricScale = function () {
  47387. var photometricScale = 0.0;
  47388. var lightTypeID = this.getTypeID();
  47389. //get photometric mode
  47390. var photometricMode = this.intensityMode;
  47391. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  47392. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  47393. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  47394. }
  47395. else {
  47396. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  47397. }
  47398. }
  47399. //compute photometric scale
  47400. switch (lightTypeID) {
  47401. case Light.LIGHTTYPEID_POINTLIGHT:
  47402. case Light.LIGHTTYPEID_SPOTLIGHT:
  47403. switch (photometricMode) {
  47404. case Light.INTENSITYMODE_LUMINOUSPOWER:
  47405. photometricScale = 1.0 / (4.0 * Math.PI);
  47406. break;
  47407. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  47408. photometricScale = 1.0;
  47409. break;
  47410. case Light.INTENSITYMODE_LUMINANCE:
  47411. photometricScale = this.radius * this.radius;
  47412. break;
  47413. }
  47414. break;
  47415. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  47416. switch (photometricMode) {
  47417. case Light.INTENSITYMODE_ILLUMINANCE:
  47418. photometricScale = 1.0;
  47419. break;
  47420. case Light.INTENSITYMODE_LUMINANCE:
  47421. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  47422. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  47423. var apexAngleRadians = this.radius;
  47424. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  47425. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  47426. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  47427. photometricScale = solidAngle;
  47428. break;
  47429. }
  47430. break;
  47431. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  47432. // No fall off in hemisperic light.
  47433. photometricScale = 1.0;
  47434. break;
  47435. }
  47436. return photometricScale;
  47437. };
  47438. /**
  47439. * Reorder the light in the scene according to their defined priority.
  47440. * @hidden Internal Use Only
  47441. */
  47442. Light.prototype._reorderLightsInScene = function () {
  47443. var scene = this.getScene();
  47444. if (this._renderPriority != 0) {
  47445. scene.requireLightSorting = true;
  47446. }
  47447. this.getScene().sortLightsByPriority();
  47448. };
  47449. /**
  47450. * Falloff Default: light is falling off following the material specification:
  47451. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  47452. */
  47453. Light.FALLOFF_DEFAULT = 0;
  47454. /**
  47455. * Falloff Physical: light is falling off following the inverse squared distance law.
  47456. */
  47457. Light.FALLOFF_PHYSICAL = 1;
  47458. /**
  47459. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  47460. * to enhance interoperability with other engines.
  47461. */
  47462. Light.FALLOFF_GLTF = 2;
  47463. /**
  47464. * Falloff Standard: light is falling off like in the standard material
  47465. * to enhance interoperability with other materials.
  47466. */
  47467. Light.FALLOFF_STANDARD = 3;
  47468. //lightmapMode Consts
  47469. /**
  47470. * If every light affecting the material is in this lightmapMode,
  47471. * material.lightmapTexture adds or multiplies
  47472. * (depends on material.useLightmapAsShadowmap)
  47473. * after every other light calculations.
  47474. */
  47475. Light.LIGHTMAP_DEFAULT = 0;
  47476. /**
  47477. * material.lightmapTexture as only diffuse lighting from this light
  47478. * adds only specular lighting from this light
  47479. * adds dynamic shadows
  47480. */
  47481. Light.LIGHTMAP_SPECULAR = 1;
  47482. /**
  47483. * material.lightmapTexture as only lighting
  47484. * no light calculation from this light
  47485. * only adds dynamic shadows from this light
  47486. */
  47487. Light.LIGHTMAP_SHADOWSONLY = 2;
  47488. // Intensity Mode Consts
  47489. /**
  47490. * Each light type uses the default quantity according to its type:
  47491. * point/spot lights use luminous intensity
  47492. * directional lights use illuminance
  47493. */
  47494. Light.INTENSITYMODE_AUTOMATIC = 0;
  47495. /**
  47496. * lumen (lm)
  47497. */
  47498. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  47499. /**
  47500. * candela (lm/sr)
  47501. */
  47502. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  47503. /**
  47504. * lux (lm/m^2)
  47505. */
  47506. Light.INTENSITYMODE_ILLUMINANCE = 3;
  47507. /**
  47508. * nit (cd/m^2)
  47509. */
  47510. Light.INTENSITYMODE_LUMINANCE = 4;
  47511. // Light types ids const.
  47512. /**
  47513. * Light type const id of the point light.
  47514. */
  47515. Light.LIGHTTYPEID_POINTLIGHT = 0;
  47516. /**
  47517. * Light type const id of the directional light.
  47518. */
  47519. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  47520. /**
  47521. * Light type const id of the spot light.
  47522. */
  47523. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  47524. /**
  47525. * Light type const id of the hemispheric light.
  47526. */
  47527. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  47528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47530. ], Light.prototype, "diffuse", void 0);
  47531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47533. ], Light.prototype, "specular", void 0);
  47534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47536. ], Light.prototype, "falloffType", void 0);
  47537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47539. ], Light.prototype, "intensity", void 0);
  47540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47542. ], Light.prototype, "range", null);
  47543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47545. ], Light.prototype, "intensityMode", null);
  47546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47548. ], Light.prototype, "radius", null);
  47549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47551. ], Light.prototype, "_renderPriority", void 0);
  47552. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  47554. ], Light.prototype, "renderPriority", void 0);
  47555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  47557. ], Light.prototype, "_shadowEnabled", void 0);
  47558. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  47560. ], Light.prototype, "_excludeWithLayerMask", void 0);
  47561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  47563. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  47564. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47565. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  47566. ], Light.prototype, "_lightmapMode", void 0);
  47567. return Light;
  47568. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  47569. /***/ }),
  47570. /***/ "./Lights/pointLight.ts":
  47571. /*!******************************!*\
  47572. !*** ./Lights/pointLight.ts ***!
  47573. \******************************/
  47574. /*! exports provided: PointLight */
  47575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47576. "use strict";
  47577. __webpack_require__.r(__webpack_exports__);
  47578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  47579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47580. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47581. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47582. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47583. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47584. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47585. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  47586. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47587. });
  47588. /**
  47589. * A point light is a light defined by an unique point in world space.
  47590. * The light is emitted in every direction from this point.
  47591. * A good example of a point light is a standard light bulb.
  47592. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47593. */
  47594. var PointLight = /** @class */ (function (_super) {
  47595. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  47596. /**
  47597. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47598. * A PointLight emits the light in every direction.
  47599. * It can cast shadows.
  47600. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47601. * ```javascript
  47602. * var pointLight = new PointLight("pl", camera.position, scene);
  47603. * ```
  47604. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47605. * @param name The light friendly name
  47606. * @param position The position of the point light in the scene
  47607. * @param scene The scene the lights belongs to
  47608. */
  47609. function PointLight(name, position, scene) {
  47610. var _this = _super.call(this, name, scene) || this;
  47611. _this._shadowAngle = Math.PI / 2;
  47612. _this.position = position;
  47613. return _this;
  47614. }
  47615. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  47616. /**
  47617. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47618. * This specifies what angle the shadow will use to be created.
  47619. *
  47620. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47621. */
  47622. get: function () {
  47623. return this._shadowAngle;
  47624. },
  47625. /**
  47626. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47627. * This specifies what angle the shadow will use to be created.
  47628. *
  47629. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47630. */
  47631. set: function (value) {
  47632. this._shadowAngle = value;
  47633. this.forceProjectionMatrixCompute();
  47634. },
  47635. enumerable: true,
  47636. configurable: true
  47637. });
  47638. Object.defineProperty(PointLight.prototype, "direction", {
  47639. /**
  47640. * Gets the direction if it has been set.
  47641. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47642. */
  47643. get: function () {
  47644. return this._direction;
  47645. },
  47646. /**
  47647. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47648. */
  47649. set: function (value) {
  47650. var previousNeedCube = this.needCube();
  47651. this._direction = value;
  47652. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  47653. this._shadowGenerator.recreateShadowMap();
  47654. }
  47655. },
  47656. enumerable: true,
  47657. configurable: true
  47658. });
  47659. /**
  47660. * Returns the string "PointLight"
  47661. * @returns the class name
  47662. */
  47663. PointLight.prototype.getClassName = function () {
  47664. return "PointLight";
  47665. };
  47666. /**
  47667. * Returns the integer 0.
  47668. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47669. */
  47670. PointLight.prototype.getTypeID = function () {
  47671. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  47672. };
  47673. /**
  47674. * Specifies wether or not the shadowmap should be a cube texture.
  47675. * @returns true if the shadowmap needs to be a cube texture.
  47676. */
  47677. PointLight.prototype.needCube = function () {
  47678. return !this.direction;
  47679. };
  47680. /**
  47681. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47682. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47683. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47684. */
  47685. PointLight.prototype.getShadowDirection = function (faceIndex) {
  47686. if (this.direction) {
  47687. return _super.prototype.getShadowDirection.call(this, faceIndex);
  47688. }
  47689. else {
  47690. switch (faceIndex) {
  47691. case 0:
  47692. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  47693. case 1:
  47694. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  47695. case 2:
  47696. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  47697. case 3:
  47698. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  47699. case 4:
  47700. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  47701. case 5:
  47702. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  47703. }
  47704. }
  47705. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47706. };
  47707. /**
  47708. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47709. * - fov = PI / 2
  47710. * - aspect ratio : 1.0
  47711. * - z-near and far equal to the active camera minZ and maxZ.
  47712. * Returns the PointLight.
  47713. */
  47714. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47715. var activeCamera = this.getScene().activeCamera;
  47716. if (!activeCamera) {
  47717. return;
  47718. }
  47719. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47720. };
  47721. PointLight.prototype._buildUniformLayout = function () {
  47722. this._uniformBuffer.addUniform("vLightData", 4);
  47723. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47724. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47725. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47726. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47727. this._uniformBuffer.addUniform("depthValues", 2);
  47728. this._uniformBuffer.create();
  47729. };
  47730. /**
  47731. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47732. * @param effect The effect to update
  47733. * @param lightIndex The index of the light in the effect to update
  47734. * @returns The point light
  47735. */
  47736. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  47737. if (this.computeTransformedInformation()) {
  47738. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  47739. }
  47740. else {
  47741. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  47742. }
  47743. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  47744. return this;
  47745. };
  47746. /**
  47747. * Prepares the list of defines specific to the light type.
  47748. * @param defines the list of defines
  47749. * @param lightIndex defines the index of the light for the effect
  47750. */
  47751. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47752. defines["POINTLIGHT" + lightIndex] = true;
  47753. };
  47754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47756. ], PointLight.prototype, "shadowAngle", null);
  47757. return PointLight;
  47758. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47759. /***/ }),
  47760. /***/ "./Lights/shadowLight.ts":
  47761. /*!*******************************!*\
  47762. !*** ./Lights/shadowLight.ts ***!
  47763. \*******************************/
  47764. /*! exports provided: ShadowLight */
  47765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47766. "use strict";
  47767. __webpack_require__.r(__webpack_exports__);
  47768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  47769. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47770. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47771. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47772. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47773. /**
  47774. * Base implementation IShadowLight
  47775. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  47776. */
  47777. var ShadowLight = /** @class */ (function (_super) {
  47778. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  47779. function ShadowLight() {
  47780. var _this = _super !== null && _super.apply(this, arguments) || this;
  47781. _this._needProjectionMatrixCompute = true;
  47782. return _this;
  47783. }
  47784. ShadowLight.prototype._setPosition = function (value) {
  47785. this._position = value;
  47786. };
  47787. Object.defineProperty(ShadowLight.prototype, "position", {
  47788. /**
  47789. * Sets the position the shadow will be casted from. Also use as the light position for both
  47790. * point and spot lights.
  47791. */
  47792. get: function () {
  47793. return this._position;
  47794. },
  47795. /**
  47796. * Sets the position the shadow will be casted from. Also use as the light position for both
  47797. * point and spot lights.
  47798. */
  47799. set: function (value) {
  47800. this._setPosition(value);
  47801. },
  47802. enumerable: true,
  47803. configurable: true
  47804. });
  47805. ShadowLight.prototype._setDirection = function (value) {
  47806. this._direction = value;
  47807. };
  47808. Object.defineProperty(ShadowLight.prototype, "direction", {
  47809. /**
  47810. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  47811. * Also use as the light direction on spot and directional lights.
  47812. */
  47813. get: function () {
  47814. return this._direction;
  47815. },
  47816. /**
  47817. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  47818. * Also use as the light direction on spot and directional lights.
  47819. */
  47820. set: function (value) {
  47821. this._setDirection(value);
  47822. },
  47823. enumerable: true,
  47824. configurable: true
  47825. });
  47826. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47827. /**
  47828. * Gets the shadow projection clipping minimum z value.
  47829. */
  47830. get: function () {
  47831. return this._shadowMinZ;
  47832. },
  47833. /**
  47834. * Sets the shadow projection clipping minimum z value.
  47835. */
  47836. set: function (value) {
  47837. this._shadowMinZ = value;
  47838. this.forceProjectionMatrixCompute();
  47839. },
  47840. enumerable: true,
  47841. configurable: true
  47842. });
  47843. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47844. /**
  47845. * Sets the shadow projection clipping maximum z value.
  47846. */
  47847. get: function () {
  47848. return this._shadowMaxZ;
  47849. },
  47850. /**
  47851. * Gets the shadow projection clipping maximum z value.
  47852. */
  47853. set: function (value) {
  47854. this._shadowMaxZ = value;
  47855. this.forceProjectionMatrixCompute();
  47856. },
  47857. enumerable: true,
  47858. configurable: true
  47859. });
  47860. /**
  47861. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  47862. * @returns true if the information has been computed, false if it does not need to (no parenting)
  47863. */
  47864. ShadowLight.prototype.computeTransformedInformation = function () {
  47865. if (this.parent && this.parent.getWorldMatrix) {
  47866. if (!this.transformedPosition) {
  47867. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47868. }
  47869. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  47870. // In case the direction is present.
  47871. if (this.direction) {
  47872. if (!this.transformedDirection) {
  47873. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47874. }
  47875. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  47876. }
  47877. return true;
  47878. }
  47879. return false;
  47880. };
  47881. /**
  47882. * Return the depth scale used for the shadow map.
  47883. * @returns the depth scale.
  47884. */
  47885. ShadowLight.prototype.getDepthScale = function () {
  47886. return 50.0;
  47887. };
  47888. /**
  47889. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  47890. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47891. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47892. */
  47893. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  47894. return this.transformedDirection ? this.transformedDirection : this.direction;
  47895. };
  47896. /**
  47897. * Returns the ShadowLight absolute position in the World.
  47898. * @returns the position vector in world space
  47899. */
  47900. ShadowLight.prototype.getAbsolutePosition = function () {
  47901. return this.transformedPosition ? this.transformedPosition : this.position;
  47902. };
  47903. /**
  47904. * Sets the ShadowLight direction toward the passed target.
  47905. * @param target The point to target in local space
  47906. * @returns the updated ShadowLight direction
  47907. */
  47908. ShadowLight.prototype.setDirectionToTarget = function (target) {
  47909. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  47910. return this.direction;
  47911. };
  47912. /**
  47913. * Returns the light rotation in euler definition.
  47914. * @returns the x y z rotation in local space.
  47915. */
  47916. ShadowLight.prototype.getRotation = function () {
  47917. this.direction.normalize();
  47918. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  47919. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  47920. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  47921. };
  47922. /**
  47923. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  47924. * @returns true if a cube texture needs to be use
  47925. */
  47926. ShadowLight.prototype.needCube = function () {
  47927. return false;
  47928. };
  47929. /**
  47930. * Detects if the projection matrix requires to be recomputed this frame.
  47931. * @returns true if it requires to be recomputed otherwise, false.
  47932. */
  47933. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  47934. return this._needProjectionMatrixCompute;
  47935. };
  47936. /**
  47937. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  47938. */
  47939. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  47940. this._needProjectionMatrixCompute = true;
  47941. };
  47942. /** @hidden */
  47943. ShadowLight.prototype._initCache = function () {
  47944. _super.prototype._initCache.call(this);
  47945. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47946. };
  47947. /** @hidden */
  47948. ShadowLight.prototype._isSynchronized = function () {
  47949. if (!this._cache.position.equals(this.position)) {
  47950. return false;
  47951. }
  47952. return true;
  47953. };
  47954. /**
  47955. * Computes the world matrix of the node
  47956. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47957. * @returns the world matrix
  47958. */
  47959. ShadowLight.prototype.computeWorldMatrix = function (force) {
  47960. if (!force && this.isSynchronized()) {
  47961. this._currentRenderId = this.getScene().getRenderId();
  47962. return this._worldMatrix;
  47963. }
  47964. this._updateCache();
  47965. this._cache.position.copyFrom(this.position);
  47966. if (!this._worldMatrix) {
  47967. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47968. }
  47969. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  47970. if (this.parent && this.parent.getWorldMatrix) {
  47971. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  47972. this._markSyncedWithParent();
  47973. }
  47974. // Cache the determinant
  47975. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  47976. return this._worldMatrix;
  47977. };
  47978. /**
  47979. * Gets the minZ used for shadow according to both the scene and the light.
  47980. * @param activeCamera The camera we are returning the min for
  47981. * @returns the depth min z
  47982. */
  47983. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  47984. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  47985. };
  47986. /**
  47987. * Gets the maxZ used for shadow according to both the scene and the light.
  47988. * @param activeCamera The camera we are returning the max for
  47989. * @returns the depth max z
  47990. */
  47991. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  47992. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  47993. };
  47994. /**
  47995. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47996. * @param matrix The materix to updated with the projection information
  47997. * @param viewMatrix The transform matrix of the light
  47998. * @param renderList The list of mesh to render in the map
  47999. * @returns The current light
  48000. */
  48001. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48002. if (this.customProjectionMatrixBuilder) {
  48003. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  48004. }
  48005. else {
  48006. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  48007. }
  48008. return this;
  48009. };
  48010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48012. ], ShadowLight.prototype, "position", null);
  48013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48015. ], ShadowLight.prototype, "direction", null);
  48016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48018. ], ShadowLight.prototype, "shadowMinZ", null);
  48019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48021. ], ShadowLight.prototype, "shadowMaxZ", null);
  48022. return ShadowLight;
  48023. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  48024. /***/ }),
  48025. /***/ "./Lights/spotLight.ts":
  48026. /*!*****************************!*\
  48027. !*** ./Lights/spotLight.ts ***!
  48028. \*****************************/
  48029. /*! exports provided: SpotLight */
  48030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48031. "use strict";
  48032. __webpack_require__.r(__webpack_exports__);
  48033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  48034. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48035. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48037. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48038. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48039. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48040. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  48041. 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); };
  48042. });
  48043. /**
  48044. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48045. * These values define a cone of light starting from the position, emitting toward the direction.
  48046. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48047. * and the exponent defines the speed of the decay of the light with distance (reach).
  48048. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48049. */
  48050. var SpotLight = /** @class */ (function (_super) {
  48051. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  48052. /**
  48053. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48054. * It can cast shadows.
  48055. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48056. * @param name The light friendly name
  48057. * @param position The position of the spot light in the scene
  48058. * @param direction The direction of the light in the scene
  48059. * @param angle The cone angle of the light in Radians
  48060. * @param exponent The light decay speed with the distance from the emission spot
  48061. * @param scene The scene the lights belongs to
  48062. */
  48063. function SpotLight(name, position, direction, angle, exponent, scene) {
  48064. var _this = _super.call(this, name, scene) || this;
  48065. _this._innerAngle = 0;
  48066. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48067. _this._projectionTextureLightNear = 1e-6;
  48068. _this._projectionTextureLightFar = 1000.0;
  48069. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  48070. _this._projectionTextureViewLightDirty = true;
  48071. _this._projectionTextureProjectionLightDirty = true;
  48072. _this._projectionTextureDirty = true;
  48073. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48074. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48075. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48076. _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);
  48077. _this.position = position;
  48078. _this.direction = direction;
  48079. _this.angle = angle;
  48080. _this.exponent = exponent;
  48081. return _this;
  48082. }
  48083. Object.defineProperty(SpotLight.prototype, "angle", {
  48084. /**
  48085. * Gets the cone angle of the spot light in Radians.
  48086. */
  48087. get: function () {
  48088. return this._angle;
  48089. },
  48090. /**
  48091. * Sets the cone angle of the spot light in Radians.
  48092. */
  48093. set: function (value) {
  48094. this._angle = value;
  48095. this._cosHalfAngle = Math.cos(value * 0.5);
  48096. this._projectionTextureProjectionLightDirty = true;
  48097. this.forceProjectionMatrixCompute();
  48098. this._computeAngleValues();
  48099. },
  48100. enumerable: true,
  48101. configurable: true
  48102. });
  48103. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  48104. /**
  48105. * Only used in gltf falloff mode, this defines the angle where
  48106. * the directional falloff will start before cutting at angle which could be seen
  48107. * as outer angle.
  48108. */
  48109. get: function () {
  48110. return this._innerAngle;
  48111. },
  48112. /**
  48113. * Only used in gltf falloff mode, this defines the angle where
  48114. * the directional falloff will start before cutting at angle which could be seen
  48115. * as outer angle.
  48116. */
  48117. set: function (value) {
  48118. this._innerAngle = value;
  48119. this._computeAngleValues();
  48120. },
  48121. enumerable: true,
  48122. configurable: true
  48123. });
  48124. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  48125. /**
  48126. * Allows scaling the angle of the light for shadow generation only.
  48127. */
  48128. get: function () {
  48129. return this._shadowAngleScale;
  48130. },
  48131. /**
  48132. * Allows scaling the angle of the light for shadow generation only.
  48133. */
  48134. set: function (value) {
  48135. this._shadowAngleScale = value;
  48136. this.forceProjectionMatrixCompute();
  48137. },
  48138. enumerable: true,
  48139. configurable: true
  48140. });
  48141. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  48142. /**
  48143. * Allows reading the projecton texture
  48144. */
  48145. get: function () {
  48146. return this._projectionTextureMatrix;
  48147. },
  48148. enumerable: true,
  48149. configurable: true
  48150. });
  48151. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  48152. /**
  48153. * Gets the near clip of the Spotlight for texture projection.
  48154. */
  48155. get: function () {
  48156. return this._projectionTextureLightNear;
  48157. },
  48158. /**
  48159. * Sets the near clip of the Spotlight for texture projection.
  48160. */
  48161. set: function (value) {
  48162. this._projectionTextureLightNear = value;
  48163. this._projectionTextureProjectionLightDirty = true;
  48164. },
  48165. enumerable: true,
  48166. configurable: true
  48167. });
  48168. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  48169. /**
  48170. * Gets the far clip of the Spotlight for texture projection.
  48171. */
  48172. get: function () {
  48173. return this._projectionTextureLightFar;
  48174. },
  48175. /**
  48176. * Sets the far clip of the Spotlight for texture projection.
  48177. */
  48178. set: function (value) {
  48179. this._projectionTextureLightFar = value;
  48180. this._projectionTextureProjectionLightDirty = true;
  48181. },
  48182. enumerable: true,
  48183. configurable: true
  48184. });
  48185. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  48186. /**
  48187. * Gets the Up vector of the Spotlight for texture projection.
  48188. */
  48189. get: function () {
  48190. return this._projectionTextureUpDirection;
  48191. },
  48192. /**
  48193. * Sets the Up vector of the Spotlight for texture projection.
  48194. */
  48195. set: function (value) {
  48196. this._projectionTextureUpDirection = value;
  48197. this._projectionTextureProjectionLightDirty = true;
  48198. },
  48199. enumerable: true,
  48200. configurable: true
  48201. });
  48202. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  48203. /**
  48204. * Gets the projection texture of the light.
  48205. */
  48206. get: function () {
  48207. return this._projectionTexture;
  48208. },
  48209. /**
  48210. * Sets the projection texture of the light.
  48211. */
  48212. set: function (value) {
  48213. this._projectionTexture = value;
  48214. this._projectionTextureDirty = true;
  48215. },
  48216. enumerable: true,
  48217. configurable: true
  48218. });
  48219. /**
  48220. * Returns the string "SpotLight".
  48221. * @returns the class name
  48222. */
  48223. SpotLight.prototype.getClassName = function () {
  48224. return "SpotLight";
  48225. };
  48226. /**
  48227. * Returns the integer 2.
  48228. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48229. */
  48230. SpotLight.prototype.getTypeID = function () {
  48231. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  48232. };
  48233. /**
  48234. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48235. */
  48236. SpotLight.prototype._setDirection = function (value) {
  48237. _super.prototype._setDirection.call(this, value);
  48238. this._projectionTextureViewLightDirty = true;
  48239. };
  48240. /**
  48241. * Overrides the position setter to recompute the projection texture view light Matrix.
  48242. */
  48243. SpotLight.prototype._setPosition = function (value) {
  48244. _super.prototype._setPosition.call(this, value);
  48245. this._projectionTextureViewLightDirty = true;
  48246. };
  48247. /**
  48248. * 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.
  48249. * Returns the SpotLight.
  48250. */
  48251. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48252. var activeCamera = this.getScene().activeCamera;
  48253. if (!activeCamera) {
  48254. return;
  48255. }
  48256. this._shadowAngleScale = this._shadowAngleScale || 1;
  48257. var angle = this._shadowAngleScale * this._angle;
  48258. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48259. };
  48260. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  48261. this._projectionTextureViewLightDirty = false;
  48262. this._projectionTextureDirty = true;
  48263. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  48264. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  48265. };
  48266. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  48267. this._projectionTextureProjectionLightDirty = false;
  48268. this._projectionTextureDirty = true;
  48269. var light_far = this.projectionTextureLightFar;
  48270. var light_near = this.projectionTextureLightNear;
  48271. var P = light_far / (light_far - light_near);
  48272. var Q = -P * light_near;
  48273. var S = 1.0 / Math.tan(this._angle / 2.0);
  48274. var A = 1.0;
  48275. _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);
  48276. };
  48277. /**
  48278. * Main function for light texture projection matrix computing.
  48279. */
  48280. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  48281. this._projectionTextureDirty = false;
  48282. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  48283. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  48284. };
  48285. SpotLight.prototype._buildUniformLayout = function () {
  48286. this._uniformBuffer.addUniform("vLightData", 4);
  48287. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48288. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48289. this._uniformBuffer.addUniform("vLightDirection", 3);
  48290. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48291. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48292. this._uniformBuffer.addUniform("depthValues", 2);
  48293. this._uniformBuffer.create();
  48294. };
  48295. SpotLight.prototype._computeAngleValues = function () {
  48296. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  48297. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  48298. };
  48299. /**
  48300. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48301. * @param effect The effect to update
  48302. * @param lightIndex The index of the light in the effect to update
  48303. * @returns The spot light
  48304. */
  48305. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  48306. var normalizeDirection;
  48307. if (this.computeTransformedInformation()) {
  48308. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  48309. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  48310. }
  48311. else {
  48312. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  48313. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48314. }
  48315. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  48316. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  48317. if (this.projectionTexture && this.projectionTexture.isReady()) {
  48318. if (this._projectionTextureViewLightDirty) {
  48319. this._computeProjectionTextureViewLightMatrix();
  48320. }
  48321. if (this._projectionTextureProjectionLightDirty) {
  48322. this._computeProjectionTextureProjectionLightMatrix();
  48323. }
  48324. if (this._projectionTextureDirty) {
  48325. this._computeProjectionTextureMatrix();
  48326. }
  48327. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  48328. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  48329. }
  48330. return this;
  48331. };
  48332. /**
  48333. * Disposes the light and the associated resources.
  48334. */
  48335. SpotLight.prototype.dispose = function () {
  48336. _super.prototype.dispose.call(this);
  48337. if (this._projectionTexture) {
  48338. this._projectionTexture.dispose();
  48339. }
  48340. };
  48341. /**
  48342. * Prepares the list of defines specific to the light type.
  48343. * @param defines the list of defines
  48344. * @param lightIndex defines the index of the light for the effect
  48345. */
  48346. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48347. defines["SPOTLIGHT" + lightIndex] = true;
  48348. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  48349. };
  48350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48352. ], SpotLight.prototype, "angle", null);
  48353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48355. ], SpotLight.prototype, "innerAngle", null);
  48356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48358. ], SpotLight.prototype, "shadowAngleScale", null);
  48359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48361. ], SpotLight.prototype, "exponent", void 0);
  48362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48364. ], SpotLight.prototype, "projectionTextureLightNear", null);
  48365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48367. ], SpotLight.prototype, "projectionTextureLightFar", null);
  48368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48370. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  48371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  48373. ], SpotLight.prototype, "_projectionTexture", void 0);
  48374. return SpotLight;
  48375. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48376. /***/ }),
  48377. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  48378. /*!**********************************************!*\
  48379. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  48380. \**********************************************/
  48381. /*! exports provided: _BabylonLoaderRegistered */
  48382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48383. "use strict";
  48384. __webpack_require__.r(__webpack_exports__);
  48385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  48386. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48387. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  48388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48389. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  48390. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  48391. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  48392. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48393. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  48394. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  48395. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  48396. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  48397. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48398. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  48399. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  48400. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  48401. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  48402. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  48403. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  48404. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  48405. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  48406. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  48407. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  48408. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48409. /** @hidden */
  48410. var _BabylonLoaderRegistered = true;
  48411. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  48412. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48413. var parsedMaterial = parsedData.materials[index];
  48414. if (parsedMaterial.id === id) {
  48415. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48416. }
  48417. }
  48418. return null;
  48419. };
  48420. var isDescendantOf = function (mesh, names, hierarchyIds) {
  48421. for (var i in names) {
  48422. if (mesh.name === names[i]) {
  48423. hierarchyIds.push(mesh.id);
  48424. return true;
  48425. }
  48426. }
  48427. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  48428. hierarchyIds.push(mesh.id);
  48429. return true;
  48430. }
  48431. return false;
  48432. };
  48433. var logOperation = function (operation, producer) {
  48434. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  48435. };
  48436. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  48437. if (addToScene === void 0) { addToScene = false; }
  48438. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  48439. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48440. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48441. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48442. // and avoid problems with multiple concurrent .babylon loads.
  48443. var log = "importScene has failed JSON parse";
  48444. try {
  48445. var parsedData = JSON.parse(data);
  48446. log = "";
  48447. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48448. var index;
  48449. var cache;
  48450. // Lights
  48451. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  48452. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  48453. var parsedLight = parsedData.lights[index];
  48454. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  48455. if (light) {
  48456. container.lights.push(light);
  48457. log += (index === 0 ? "\n\tLights:" : "");
  48458. log += "\n\t\t" + light.toString(fullDetails);
  48459. }
  48460. }
  48461. }
  48462. // Reflection probes
  48463. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  48464. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  48465. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  48466. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  48467. if (reflectionProbe) {
  48468. container.reflectionProbes.push(reflectionProbe);
  48469. log += (index === 0 ? "\n\tReflection Probes:" : "");
  48470. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  48471. }
  48472. }
  48473. }
  48474. // Animations
  48475. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  48476. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  48477. var parsedAnimation = parsedData.animations[index];
  48478. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  48479. if (internalClass) {
  48480. var animation = internalClass.Parse(parsedAnimation);
  48481. scene.animations.push(animation);
  48482. container.animations.push(animation);
  48483. log += (index === 0 ? "\n\tAnimations:" : "");
  48484. log += "\n\t\t" + animation.toString(fullDetails);
  48485. }
  48486. }
  48487. }
  48488. // Materials
  48489. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  48490. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48491. var parsedMaterial = parsedData.materials[index];
  48492. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48493. container.materials.push(mat);
  48494. log += (index === 0 ? "\n\tMaterials:" : "");
  48495. log += "\n\t\t" + mat.toString(fullDetails);
  48496. }
  48497. }
  48498. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48499. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  48500. var parsedMultiMaterial = parsedData.multiMaterials[index];
  48501. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48502. container.multiMaterials.push(mmat);
  48503. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  48504. log += "\n\t\t" + mmat.toString(fullDetails);
  48505. }
  48506. }
  48507. // Morph targets
  48508. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48509. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48510. var managerData = _a[_i];
  48511. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  48512. }
  48513. }
  48514. // Skeletons
  48515. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48516. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  48517. var parsedSkeleton = parsedData.skeletons[index];
  48518. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48519. container.skeletons.push(skeleton);
  48520. log += (index === 0 ? "\n\tSkeletons:" : "");
  48521. log += "\n\t\t" + skeleton.toString(fullDetails);
  48522. }
  48523. }
  48524. // Geometries
  48525. var geometries = parsedData.geometries;
  48526. if (geometries !== undefined && geometries !== null) {
  48527. var addedGeometry = new Array();
  48528. // VertexData
  48529. var vertexData = geometries.vertexData;
  48530. if (vertexData !== undefined && vertexData !== null) {
  48531. for (index = 0, cache = vertexData.length; index < cache; index++) {
  48532. var parsedVertexData = vertexData[index];
  48533. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  48534. }
  48535. }
  48536. addedGeometry.forEach(function (g) {
  48537. if (g) {
  48538. container.geometries.push(g);
  48539. }
  48540. });
  48541. }
  48542. // Transform nodes
  48543. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  48544. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  48545. var parsedTransformNode = parsedData.transformNodes[index];
  48546. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  48547. container.transformNodes.push(node);
  48548. }
  48549. }
  48550. // Meshes
  48551. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48552. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48553. var parsedMesh = parsedData.meshes[index];
  48554. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48555. container.meshes.push(mesh);
  48556. log += (index === 0 ? "\n\tMeshes:" : "");
  48557. log += "\n\t\t" + mesh.toString(fullDetails);
  48558. }
  48559. }
  48560. // Cameras
  48561. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  48562. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  48563. var parsedCamera = parsedData.cameras[index];
  48564. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  48565. container.cameras.push(camera);
  48566. log += (index === 0 ? "\n\tCameras:" : "");
  48567. log += "\n\t\t" + camera.toString(fullDetails);
  48568. }
  48569. }
  48570. // Animation Groups
  48571. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  48572. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  48573. var parsedAnimationGroup = parsedData.animationGroups[index];
  48574. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  48575. container.animationGroups.push(animationGroup);
  48576. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  48577. log += "\n\t\t" + animationGroup.toString(fullDetails);
  48578. }
  48579. }
  48580. // Browsing all the graph to connect the dots
  48581. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  48582. var camera = scene.cameras[index];
  48583. if (camera._waitingParentId) {
  48584. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  48585. camera._waitingParentId = null;
  48586. }
  48587. }
  48588. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  48589. var light_1 = scene.lights[index];
  48590. if (light_1 && light_1._waitingParentId) {
  48591. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  48592. light_1._waitingParentId = null;
  48593. }
  48594. }
  48595. // Connect parents & children and parse actions
  48596. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  48597. var transformNode = scene.transformNodes[index];
  48598. if (transformNode._waitingParentId) {
  48599. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  48600. transformNode._waitingParentId = null;
  48601. }
  48602. }
  48603. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48604. var mesh = scene.meshes[index];
  48605. if (mesh._waitingParentId) {
  48606. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  48607. mesh._waitingParentId = null;
  48608. }
  48609. }
  48610. // freeze world matrix application
  48611. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48612. var currentMesh = scene.meshes[index];
  48613. if (currentMesh._waitingFreezeWorldMatrix) {
  48614. currentMesh.freezeWorldMatrix();
  48615. currentMesh._waitingFreezeWorldMatrix = null;
  48616. }
  48617. else {
  48618. currentMesh.computeWorldMatrix(true);
  48619. }
  48620. }
  48621. // Lights exclusions / inclusions
  48622. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  48623. var light_2 = scene.lights[index];
  48624. // Excluded check
  48625. if (light_2._excludedMeshesIds.length > 0) {
  48626. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  48627. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  48628. if (excludedMesh) {
  48629. light_2.excludedMeshes.push(excludedMesh);
  48630. }
  48631. }
  48632. light_2._excludedMeshesIds = [];
  48633. }
  48634. // Included check
  48635. if (light_2._includedOnlyMeshesIds.length > 0) {
  48636. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  48637. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  48638. if (includedOnlyMesh) {
  48639. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  48640. }
  48641. }
  48642. light_2._includedOnlyMeshesIds = [];
  48643. }
  48644. }
  48645. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  48646. // Actions (scene) Done last as it can access other objects.
  48647. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48648. var mesh = scene.meshes[index];
  48649. if (mesh._waitingActions) {
  48650. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  48651. mesh._waitingActions = null;
  48652. }
  48653. }
  48654. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  48655. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  48656. }
  48657. if (!addToScene) {
  48658. container.removeAllFromScene();
  48659. }
  48660. }
  48661. catch (err) {
  48662. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  48663. if (onError) {
  48664. onError(msg, err);
  48665. }
  48666. else {
  48667. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48668. throw err;
  48669. }
  48670. }
  48671. finally {
  48672. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48673. _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 : ""));
  48674. }
  48675. }
  48676. return container;
  48677. };
  48678. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  48679. name: "babylon.js",
  48680. extensions: ".babylon",
  48681. canDirectLoad: function (data) {
  48682. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  48683. return true;
  48684. }
  48685. return false;
  48686. },
  48687. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  48688. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48689. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48690. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48691. // and avoid problems with multiple concurrent .babylon loads.
  48692. var log = "importMesh has failed JSON parse";
  48693. try {
  48694. var parsedData = JSON.parse(data);
  48695. log = "";
  48696. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48697. if (!meshesNames) {
  48698. meshesNames = null;
  48699. }
  48700. else if (!Array.isArray(meshesNames)) {
  48701. meshesNames = [meshesNames];
  48702. }
  48703. var hierarchyIds = new Array();
  48704. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48705. var loadedSkeletonsIds = [];
  48706. var loadedMaterialsIds = [];
  48707. var index;
  48708. var cache;
  48709. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48710. var parsedMesh = parsedData.meshes[index];
  48711. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  48712. if (meshesNames !== null) {
  48713. // Remove found mesh name from list.
  48714. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  48715. }
  48716. //Geometry?
  48717. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  48718. //does the file contain geometries?
  48719. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  48720. //find the correct geometry and add it to the scene
  48721. var found = false;
  48722. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  48723. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  48724. return;
  48725. }
  48726. else {
  48727. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  48728. if (parsedGeometryData.id === parsedMesh.geometryId) {
  48729. switch (geometryType) {
  48730. case "vertexData":
  48731. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  48732. break;
  48733. }
  48734. found = true;
  48735. }
  48736. });
  48737. }
  48738. });
  48739. if (found === false) {
  48740. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  48741. }
  48742. }
  48743. }
  48744. // Material ?
  48745. if (parsedMesh.materialId) {
  48746. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  48747. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48748. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  48749. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  48750. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  48751. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  48752. var subMatId = parsedMultiMaterial.materials[matIndex];
  48753. loadedMaterialsIds.push(subMatId);
  48754. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  48755. if (mat) {
  48756. log += "\n\tMaterial " + mat.toString(fullDetails);
  48757. }
  48758. }
  48759. loadedMaterialsIds.push(parsedMultiMaterial.id);
  48760. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48761. if (mmat) {
  48762. materialFound = true;
  48763. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  48764. }
  48765. break;
  48766. }
  48767. }
  48768. }
  48769. if (materialFound === false) {
  48770. loadedMaterialsIds.push(parsedMesh.materialId);
  48771. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  48772. if (!mat) {
  48773. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  48774. }
  48775. else {
  48776. log += "\n\tMaterial " + mat.toString(fullDetails);
  48777. }
  48778. }
  48779. }
  48780. // Skeleton ?
  48781. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48782. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  48783. if (skeletonAlreadyLoaded === false) {
  48784. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  48785. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  48786. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  48787. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48788. skeletons.push(skeleton);
  48789. loadedSkeletonsIds.push(parsedSkeleton.id);
  48790. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  48791. }
  48792. }
  48793. }
  48794. }
  48795. // Morph targets ?
  48796. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48797. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48798. var managerData = _a[_i];
  48799. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  48800. }
  48801. }
  48802. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48803. meshes.push(mesh);
  48804. log += "\n\tMesh " + mesh.toString(fullDetails);
  48805. }
  48806. }
  48807. // Connecting parents
  48808. var currentMesh;
  48809. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48810. currentMesh = scene.meshes[index];
  48811. if (currentMesh._waitingParentId) {
  48812. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  48813. currentMesh._waitingParentId = null;
  48814. }
  48815. }
  48816. // freeze and compute world matrix application
  48817. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48818. currentMesh = scene.meshes[index];
  48819. if (currentMesh._waitingFreezeWorldMatrix) {
  48820. currentMesh.freezeWorldMatrix();
  48821. currentMesh._waitingFreezeWorldMatrix = null;
  48822. }
  48823. else {
  48824. currentMesh.computeWorldMatrix(true);
  48825. }
  48826. }
  48827. }
  48828. // Particles
  48829. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48830. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48831. if (parser) {
  48832. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48833. var parsedParticleSystem = parsedData.particleSystems[index];
  48834. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  48835. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  48836. }
  48837. }
  48838. }
  48839. }
  48840. return true;
  48841. }
  48842. catch (err) {
  48843. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  48844. if (onError) {
  48845. onError(msg, err);
  48846. }
  48847. else {
  48848. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48849. throw err;
  48850. }
  48851. }
  48852. finally {
  48853. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48854. _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 : ""));
  48855. }
  48856. }
  48857. return false;
  48858. },
  48859. load: function (scene, data, rootUrl, onError) {
  48860. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48861. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48862. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48863. // and avoid problems with multiple concurrent .babylon loads.
  48864. var log = "importScene has failed JSON parse";
  48865. try {
  48866. var parsedData = JSON.parse(data);
  48867. log = "";
  48868. // Scene
  48869. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  48870. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  48871. }
  48872. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  48873. scene.autoClear = parsedData.autoClear;
  48874. }
  48875. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  48876. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  48877. }
  48878. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  48879. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  48880. }
  48881. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  48882. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  48883. }
  48884. // Fog
  48885. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  48886. scene.fogMode = parsedData.fogMode;
  48887. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  48888. scene.fogStart = parsedData.fogStart;
  48889. scene.fogEnd = parsedData.fogEnd;
  48890. scene.fogDensity = parsedData.fogDensity;
  48891. log += "\tFog mode for scene: ";
  48892. switch (scene.fogMode) {
  48893. // getters not compiling, so using hardcoded
  48894. case 1:
  48895. log += "exp\n";
  48896. break;
  48897. case 2:
  48898. log += "exp2\n";
  48899. break;
  48900. case 3:
  48901. log += "linear\n";
  48902. break;
  48903. }
  48904. }
  48905. //Physics
  48906. if (parsedData.physicsEnabled) {
  48907. var physicsPlugin;
  48908. if (parsedData.physicsEngine === "cannon") {
  48909. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  48910. }
  48911. else if (parsedData.physicsEngine === "oimo") {
  48912. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  48913. }
  48914. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  48915. //else - default engine, which is currently oimo
  48916. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  48917. scene.enablePhysics(physicsGravity, physicsPlugin);
  48918. }
  48919. // Metadata
  48920. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  48921. scene.metadata = parsedData.metadata;
  48922. }
  48923. //collisions, if defined. otherwise, default is true
  48924. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  48925. scene.collisionsEnabled = parsedData.collisionsEnabled;
  48926. }
  48927. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  48928. if (!container) {
  48929. return false;
  48930. }
  48931. if (parsedData.autoAnimate) {
  48932. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  48933. }
  48934. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  48935. scene.setActiveCameraByID(parsedData.activeCameraID);
  48936. }
  48937. // Environment texture
  48938. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48939. // PBR needed for both HDR texture (gamma space) & a sky box
  48940. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48941. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48942. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48943. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48944. if (parsedData.environmentTextureRotationY) {
  48945. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48946. }
  48947. scene.environmentTexture = hdrTexture;
  48948. }
  48949. else {
  48950. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  48951. if (parsedData.environmentTextureRotationY) {
  48952. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48953. }
  48954. scene.environmentTexture = cubeTexture;
  48955. }
  48956. if (parsedData.createDefaultSkybox === true) {
  48957. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48958. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48959. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48960. }
  48961. }
  48962. // Finish
  48963. return true;
  48964. }
  48965. catch (err) {
  48966. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  48967. if (onError) {
  48968. onError(msg, err);
  48969. }
  48970. else {
  48971. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48972. throw err;
  48973. }
  48974. }
  48975. finally {
  48976. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48977. _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 : ""));
  48978. }
  48979. }
  48980. return false;
  48981. },
  48982. loadAssetContainer: function (scene, data, rootUrl, onError) {
  48983. var container = loadAssetContainer(scene, data, rootUrl, onError);
  48984. return container;
  48985. }
  48986. });
  48987. /***/ }),
  48988. /***/ "./Loading/Plugins/index.ts":
  48989. /*!**********************************!*\
  48990. !*** ./Loading/Plugins/index.ts ***!
  48991. \**********************************/
  48992. /*! exports provided: _BabylonLoaderRegistered */
  48993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48994. "use strict";
  48995. __webpack_require__.r(__webpack_exports__);
  48996. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48998. /***/ }),
  48999. /***/ "./Loading/index.ts":
  49000. /*!**************************!*\
  49001. !*** ./Loading/index.ts ***!
  49002. \**************************/
  49003. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  49004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49005. "use strict";
  49006. __webpack_require__.r(__webpack_exports__);
  49007. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  49008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  49009. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  49010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  49011. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  49012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  49013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  49014. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  49016. /***/ }),
  49017. /***/ "./Loading/loadingScreen.ts":
  49018. /*!**********************************!*\
  49019. !*** ./Loading/loadingScreen.ts ***!
  49020. \**********************************/
  49021. /*! exports provided: DefaultLoadingScreen */
  49022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49023. "use strict";
  49024. __webpack_require__.r(__webpack_exports__);
  49025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  49026. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49027. /**
  49028. * Class used for the default loading screen
  49029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  49030. */
  49031. var DefaultLoadingScreen = /** @class */ (function () {
  49032. /**
  49033. * Creates a new default loading screen
  49034. * @param _renderingCanvas defines the canvas used to render the scene
  49035. * @param _loadingText defines the default text to display
  49036. * @param _loadingDivBackgroundColor defines the default background color
  49037. */
  49038. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  49039. if (_loadingText === void 0) { _loadingText = ""; }
  49040. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  49041. var _this = this;
  49042. this._renderingCanvas = _renderingCanvas;
  49043. this._loadingText = _loadingText;
  49044. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  49045. // Resize
  49046. this._resizeLoadingUI = function () {
  49047. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  49048. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  49049. if (!_this._loadingDiv) {
  49050. return;
  49051. }
  49052. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  49053. _this._loadingDiv.style.left = canvasRect.left + "px";
  49054. _this._loadingDiv.style.top = canvasRect.top + "px";
  49055. _this._loadingDiv.style.width = canvasRect.width + "px";
  49056. _this._loadingDiv.style.height = canvasRect.height + "px";
  49057. };
  49058. }
  49059. /**
  49060. * Function called to display the loading screen
  49061. */
  49062. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  49063. if (this._loadingDiv) {
  49064. // Do not add a loading screen if there is already one
  49065. return;
  49066. }
  49067. this._loadingDiv = document.createElement("div");
  49068. this._loadingDiv.id = "babylonjsLoadingDiv";
  49069. this._loadingDiv.style.opacity = "0";
  49070. this._loadingDiv.style.transition = "opacity 1.5s ease";
  49071. this._loadingDiv.style.pointerEvents = "none";
  49072. // Loading text
  49073. this._loadingTextDiv = document.createElement("div");
  49074. this._loadingTextDiv.style.position = "absolute";
  49075. this._loadingTextDiv.style.left = "0";
  49076. this._loadingTextDiv.style.top = "50%";
  49077. this._loadingTextDiv.style.marginTop = "80px";
  49078. this._loadingTextDiv.style.width = "100%";
  49079. this._loadingTextDiv.style.height = "20px";
  49080. this._loadingTextDiv.style.fontFamily = "Arial";
  49081. this._loadingTextDiv.style.fontSize = "14px";
  49082. this._loadingTextDiv.style.color = "white";
  49083. this._loadingTextDiv.style.textAlign = "center";
  49084. this._loadingTextDiv.innerHTML = "Loading";
  49085. this._loadingDiv.appendChild(this._loadingTextDiv);
  49086. //set the predefined text
  49087. this._loadingTextDiv.innerHTML = this._loadingText;
  49088. // Generating keyframes
  49089. var style = document.createElement('style');
  49090. style.type = 'text/css';
  49091. 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 }";
  49092. style.innerHTML = keyFrames;
  49093. document.getElementsByTagName('head')[0].appendChild(style);
  49094. // Loading img
  49095. var imgBack = new Image();
  49096. 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";
  49097. imgBack.style.position = "absolute";
  49098. imgBack.style.left = "50%";
  49099. imgBack.style.top = "50%";
  49100. imgBack.style.marginLeft = "-60px";
  49101. imgBack.style.marginTop = "-60px";
  49102. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  49103. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  49104. imgBack.style.transformOrigin = "50% 50%";
  49105. imgBack.style.webkitTransformOrigin = "50% 50%";
  49106. this._loadingDiv.appendChild(imgBack);
  49107. this._resizeLoadingUI();
  49108. window.addEventListener("resize", this._resizeLoadingUI);
  49109. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49110. document.body.appendChild(this._loadingDiv);
  49111. this._loadingDiv.style.opacity = "1";
  49112. };
  49113. /**
  49114. * Function called to hide the loading screen
  49115. */
  49116. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  49117. var _this = this;
  49118. if (!this._loadingDiv) {
  49119. return;
  49120. }
  49121. var onTransitionEnd = function () {
  49122. if (!_this._loadingDiv) {
  49123. return;
  49124. }
  49125. if (_this._loadingDiv.parentElement) {
  49126. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  49127. }
  49128. window.removeEventListener("resize", _this._resizeLoadingUI);
  49129. _this._loadingDiv = null;
  49130. };
  49131. this._loadingDiv.style.opacity = "0";
  49132. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  49133. };
  49134. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  49135. get: function () {
  49136. return this._loadingText;
  49137. },
  49138. /**
  49139. * Gets or sets the text to display while loading
  49140. */
  49141. set: function (text) {
  49142. this._loadingText = text;
  49143. if (this._loadingTextDiv) {
  49144. this._loadingTextDiv.innerHTML = this._loadingText;
  49145. }
  49146. },
  49147. enumerable: true,
  49148. configurable: true
  49149. });
  49150. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  49151. /**
  49152. * Gets or sets the color to use for the background
  49153. */
  49154. get: function () {
  49155. return this._loadingDivBackgroundColor;
  49156. },
  49157. set: function (color) {
  49158. this._loadingDivBackgroundColor = color;
  49159. if (!this._loadingDiv) {
  49160. return;
  49161. }
  49162. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49163. },
  49164. enumerable: true,
  49165. configurable: true
  49166. });
  49167. return DefaultLoadingScreen;
  49168. }());
  49169. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  49170. /***/ }),
  49171. /***/ "./Loading/sceneLoader.ts":
  49172. /*!********************************!*\
  49173. !*** ./Loading/sceneLoader.ts ***!
  49174. \********************************/
  49175. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  49176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49177. "use strict";
  49178. __webpack_require__.r(__webpack_exports__);
  49179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  49180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  49181. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  49182. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  49183. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  49184. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  49185. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49186. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  49187. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  49188. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49189. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49190. /**
  49191. * Class used to represent data loading progression
  49192. */
  49193. var SceneLoaderProgressEvent = /** @class */ (function () {
  49194. /**
  49195. * Create a new progress event
  49196. * @param lengthComputable defines if data length to load can be evaluated
  49197. * @param loaded defines the loaded data length
  49198. * @param total defines the data length to load
  49199. */
  49200. function SceneLoaderProgressEvent(
  49201. /** defines if data length to load can be evaluated */
  49202. lengthComputable,
  49203. /** defines the loaded data length */
  49204. loaded,
  49205. /** defines the data length to load */
  49206. total) {
  49207. this.lengthComputable = lengthComputable;
  49208. this.loaded = loaded;
  49209. this.total = total;
  49210. }
  49211. /**
  49212. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  49213. * @param event defines the source event
  49214. * @returns a new SceneLoaderProgressEvent
  49215. */
  49216. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  49217. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  49218. };
  49219. return SceneLoaderProgressEvent;
  49220. }());
  49221. /**
  49222. * Class used to load scene from various file formats using registered plugins
  49223. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  49224. */
  49225. var SceneLoader = /** @class */ (function () {
  49226. function SceneLoader() {
  49227. }
  49228. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  49229. /**
  49230. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49231. */
  49232. get: function () {
  49233. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  49234. },
  49235. set: function (value) {
  49236. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  49237. },
  49238. enumerable: true,
  49239. configurable: true
  49240. });
  49241. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  49242. /**
  49243. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49244. */
  49245. get: function () {
  49246. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  49247. },
  49248. set: function (value) {
  49249. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  49250. },
  49251. enumerable: true,
  49252. configurable: true
  49253. });
  49254. Object.defineProperty(SceneLoader, "loggingLevel", {
  49255. /**
  49256. * Defines the current logging level (while loading the scene)
  49257. * @ignorenaming
  49258. */
  49259. get: function () {
  49260. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  49261. },
  49262. set: function (value) {
  49263. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  49264. },
  49265. enumerable: true,
  49266. configurable: true
  49267. });
  49268. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  49269. /**
  49270. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49271. */
  49272. get: function () {
  49273. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  49274. },
  49275. set: function (value) {
  49276. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  49277. },
  49278. enumerable: true,
  49279. configurable: true
  49280. });
  49281. SceneLoader._getDefaultPlugin = function () {
  49282. return SceneLoader._registeredPlugins[".babylon"];
  49283. };
  49284. SceneLoader._getPluginForExtension = function (extension) {
  49285. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  49286. if (registeredPlugin) {
  49287. return registeredPlugin;
  49288. }
  49289. _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");
  49290. return SceneLoader._getDefaultPlugin();
  49291. };
  49292. SceneLoader._getPluginForDirectLoad = function (data) {
  49293. for (var extension in SceneLoader._registeredPlugins) {
  49294. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  49295. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  49296. return SceneLoader._registeredPlugins[extension];
  49297. }
  49298. }
  49299. return SceneLoader._getDefaultPlugin();
  49300. };
  49301. SceneLoader._getPluginForFilename = function (sceneFilename) {
  49302. var queryStringPosition = sceneFilename.indexOf("?");
  49303. if (queryStringPosition !== -1) {
  49304. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  49305. }
  49306. var dotPosition = sceneFilename.lastIndexOf(".");
  49307. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  49308. return SceneLoader._getPluginForExtension(extension);
  49309. };
  49310. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  49311. SceneLoader._getDirectLoad = function (sceneFilename) {
  49312. if (sceneFilename.substr(0, 5) === "data:") {
  49313. return sceneFilename.substr(5);
  49314. }
  49315. return null;
  49316. };
  49317. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  49318. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  49319. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  49320. var plugin;
  49321. if (registeredPlugin.plugin.createPlugin) {
  49322. plugin = registeredPlugin.plugin.createPlugin();
  49323. }
  49324. else {
  49325. plugin = registeredPlugin.plugin;
  49326. }
  49327. if (!plugin) {
  49328. 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.";
  49329. }
  49330. var useArrayBuffer = registeredPlugin.isBinary;
  49331. var offlineProvider;
  49332. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  49333. var dataCallback = function (data, responseURL) {
  49334. if (scene.isDisposed) {
  49335. onError("Scene has been disposed");
  49336. return;
  49337. }
  49338. scene.offlineProvider = offlineProvider;
  49339. onSuccess(plugin, data, responseURL);
  49340. };
  49341. var request = null;
  49342. var pluginDisposed = false;
  49343. var onDisposeObservable = plugin.onDisposeObservable;
  49344. if (onDisposeObservable) {
  49345. onDisposeObservable.add(function () {
  49346. pluginDisposed = true;
  49347. if (request) {
  49348. request.abort();
  49349. request = null;
  49350. }
  49351. onDispose();
  49352. });
  49353. }
  49354. var manifestChecked = function () {
  49355. if (pluginDisposed) {
  49356. return;
  49357. }
  49358. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  49359. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  49360. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  49361. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  49362. });
  49363. };
  49364. if (directLoad) {
  49365. dataCallback(directLoad);
  49366. return plugin;
  49367. }
  49368. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  49369. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  49370. var engine = scene.getEngine();
  49371. var canUseOfflineSupport = engine.enableOfflineSupport;
  49372. if (canUseOfflineSupport) {
  49373. // Also check for exceptions
  49374. var exceptionFound = false;
  49375. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  49376. var regex = _a[_i];
  49377. if (regex.test(fileInfo.url)) {
  49378. exceptionFound = true;
  49379. break;
  49380. }
  49381. }
  49382. canUseOfflineSupport = !exceptionFound;
  49383. }
  49384. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  49385. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  49386. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  49387. }
  49388. else {
  49389. manifestChecked();
  49390. }
  49391. }
  49392. // Loading file from disk via input file or drag'n'drop
  49393. else {
  49394. if (file) {
  49395. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  49396. }
  49397. else {
  49398. onError("Unable to find file named " + fileInfo.name);
  49399. }
  49400. }
  49401. return plugin;
  49402. };
  49403. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  49404. var url;
  49405. var name;
  49406. var file = null;
  49407. if (!sceneFilename) {
  49408. url = rootUrl;
  49409. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  49410. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  49411. }
  49412. else if (sceneFilename.name) {
  49413. var sceneFile = sceneFilename;
  49414. url = rootUrl + sceneFile.name;
  49415. name = sceneFile.name;
  49416. file = sceneFile;
  49417. }
  49418. else {
  49419. var filename = sceneFilename;
  49420. if (filename.substr(0, 1) === "/") {
  49421. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  49422. return null;
  49423. }
  49424. url = rootUrl + filename;
  49425. name = filename;
  49426. }
  49427. return {
  49428. url: url,
  49429. rootUrl: rootUrl,
  49430. name: name,
  49431. file: file
  49432. };
  49433. };
  49434. // Public functions
  49435. /**
  49436. * Gets a plugin that can load the given extension
  49437. * @param extension defines the extension to load
  49438. * @returns a plugin or null if none works
  49439. */
  49440. SceneLoader.GetPluginForExtension = function (extension) {
  49441. return SceneLoader._getPluginForExtension(extension).plugin;
  49442. };
  49443. /**
  49444. * Gets a boolean indicating that the given extension can be loaded
  49445. * @param extension defines the extension to load
  49446. * @returns true if the extension is supported
  49447. */
  49448. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  49449. return !!SceneLoader._registeredPlugins[extension];
  49450. };
  49451. /**
  49452. * Adds a new plugin to the list of registered plugins
  49453. * @param plugin defines the plugin to add
  49454. */
  49455. SceneLoader.RegisterPlugin = function (plugin) {
  49456. if (typeof plugin.extensions === "string") {
  49457. var extension = plugin.extensions;
  49458. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49459. plugin: plugin,
  49460. isBinary: false
  49461. };
  49462. }
  49463. else {
  49464. var extensions = plugin.extensions;
  49465. Object.keys(extensions).forEach(function (extension) {
  49466. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49467. plugin: plugin,
  49468. isBinary: extensions[extension].isBinary
  49469. };
  49470. });
  49471. }
  49472. };
  49473. /**
  49474. * Import meshes into a scene
  49475. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49476. * @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)
  49477. * @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)
  49478. * @param scene the instance of BABYLON.Scene to append to
  49479. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49480. * @param onProgress a callback with a progress event for each file being loaded
  49481. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49482. * @param pluginExtension the extension used to determine the plugin
  49483. * @returns The loaded plugin
  49484. */
  49485. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49486. if (sceneFilename === void 0) { sceneFilename = ""; }
  49487. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49488. if (onSuccess === void 0) { onSuccess = null; }
  49489. if (onProgress === void 0) { onProgress = null; }
  49490. if (onError === void 0) { onError = null; }
  49491. if (pluginExtension === void 0) { pluginExtension = null; }
  49492. if (!scene) {
  49493. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  49494. return null;
  49495. }
  49496. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49497. if (!fileInfo) {
  49498. return null;
  49499. }
  49500. var loadingToken = {};
  49501. scene._addPendingData(loadingToken);
  49502. var disposeHandler = function () {
  49503. scene._removePendingData(loadingToken);
  49504. };
  49505. var errorHandler = function (message, exception) {
  49506. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  49507. if (onError) {
  49508. onError(scene, errorMessage, exception);
  49509. }
  49510. else {
  49511. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49512. // should the exception be thrown?
  49513. }
  49514. disposeHandler();
  49515. };
  49516. var progressHandler = onProgress ? function (event) {
  49517. try {
  49518. onProgress(event);
  49519. }
  49520. catch (e) {
  49521. errorHandler("Error in onProgress callback", e);
  49522. }
  49523. } : undefined;
  49524. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  49525. scene.importedMeshesFiles.push(fileInfo.url);
  49526. if (onSuccess) {
  49527. try {
  49528. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  49529. }
  49530. catch (e) {
  49531. errorHandler("Error in onSuccess callback", e);
  49532. }
  49533. }
  49534. scene._removePendingData(loadingToken);
  49535. };
  49536. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  49537. if (plugin.rewriteRootURL) {
  49538. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  49539. }
  49540. if (plugin.importMesh) {
  49541. var syncedPlugin = plugin;
  49542. var meshes = new Array();
  49543. var particleSystems = new Array();
  49544. var skeletons = new Array();
  49545. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  49546. return;
  49547. }
  49548. scene.loadingPluginName = plugin.name;
  49549. successHandler(meshes, particleSystems, skeletons, []);
  49550. }
  49551. else {
  49552. var asyncedPlugin = plugin;
  49553. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  49554. scene.loadingPluginName = plugin.name;
  49555. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  49556. }).catch(function (error) {
  49557. errorHandler(error.message, error);
  49558. });
  49559. }
  49560. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49561. };
  49562. /**
  49563. * Import meshes into a scene
  49564. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49565. * @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)
  49566. * @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)
  49567. * @param scene the instance of BABYLON.Scene to append to
  49568. * @param onProgress a callback with a progress event for each file being loaded
  49569. * @param pluginExtension the extension used to determine the plugin
  49570. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49571. */
  49572. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49573. if (sceneFilename === void 0) { sceneFilename = ""; }
  49574. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49575. if (onProgress === void 0) { onProgress = null; }
  49576. if (pluginExtension === void 0) { pluginExtension = null; }
  49577. return new Promise(function (resolve, reject) {
  49578. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  49579. resolve({
  49580. meshes: meshes,
  49581. particleSystems: particleSystems,
  49582. skeletons: skeletons,
  49583. animationGroups: animationGroups
  49584. });
  49585. }, onProgress, function (scene, message, exception) {
  49586. reject(exception || new Error(message));
  49587. }, pluginExtension);
  49588. });
  49589. };
  49590. /**
  49591. * Load a scene
  49592. * @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)
  49593. * @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)
  49594. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49595. * @param onSuccess a callback with the scene when import succeeds
  49596. * @param onProgress a callback with a progress event for each file being loaded
  49597. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49598. * @param pluginExtension the extension used to determine the plugin
  49599. * @returns The loaded plugin
  49600. */
  49601. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  49602. if (sceneFilename === void 0) { sceneFilename = ""; }
  49603. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  49604. if (onSuccess === void 0) { onSuccess = null; }
  49605. if (onProgress === void 0) { onProgress = null; }
  49606. if (onError === void 0) { onError = null; }
  49607. if (pluginExtension === void 0) { pluginExtension = null; }
  49608. if (!engine) {
  49609. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  49610. return null;
  49611. }
  49612. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  49613. };
  49614. /**
  49615. * Load a scene
  49616. * @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)
  49617. * @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)
  49618. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49619. * @param onProgress a callback with a progress event for each file being loaded
  49620. * @param pluginExtension the extension used to determine the plugin
  49621. * @returns The loaded scene
  49622. */
  49623. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  49624. if (sceneFilename === void 0) { sceneFilename = ""; }
  49625. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  49626. if (onProgress === void 0) { onProgress = null; }
  49627. if (pluginExtension === void 0) { pluginExtension = null; }
  49628. return new Promise(function (resolve, reject) {
  49629. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  49630. resolve(scene);
  49631. }, onProgress, function (scene, message, exception) {
  49632. reject(exception || new Error(message));
  49633. }, pluginExtension);
  49634. });
  49635. };
  49636. /**
  49637. * Append a scene
  49638. * @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)
  49639. * @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)
  49640. * @param scene is the instance of BABYLON.Scene to append to
  49641. * @param onSuccess a callback with the scene when import succeeds
  49642. * @param onProgress a callback with a progress event for each file being loaded
  49643. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49644. * @param pluginExtension the extension used to determine the plugin
  49645. * @returns The loaded plugin
  49646. */
  49647. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49648. if (sceneFilename === void 0) { sceneFilename = ""; }
  49649. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49650. if (onSuccess === void 0) { onSuccess = null; }
  49651. if (onProgress === void 0) { onProgress = null; }
  49652. if (onError === void 0) { onError = null; }
  49653. if (pluginExtension === void 0) { pluginExtension = null; }
  49654. if (!scene) {
  49655. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  49656. return null;
  49657. }
  49658. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49659. if (!fileInfo) {
  49660. return null;
  49661. }
  49662. if (SceneLoader.ShowLoadingScreen) {
  49663. scene.getEngine().displayLoadingUI();
  49664. }
  49665. var loadingToken = {};
  49666. scene._addPendingData(loadingToken);
  49667. var disposeHandler = function () {
  49668. scene._removePendingData(loadingToken);
  49669. scene.getEngine().hideLoadingUI();
  49670. };
  49671. var errorHandler = function (message, exception) {
  49672. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  49673. if (onError) {
  49674. onError(scene, errorMessage, exception);
  49675. }
  49676. else {
  49677. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49678. // should the exception be thrown?
  49679. }
  49680. disposeHandler();
  49681. };
  49682. var progressHandler = onProgress ? function (event) {
  49683. try {
  49684. onProgress(event);
  49685. }
  49686. catch (e) {
  49687. errorHandler("Error in onProgress callback", e);
  49688. }
  49689. } : undefined;
  49690. var successHandler = function () {
  49691. if (onSuccess) {
  49692. try {
  49693. onSuccess(scene);
  49694. }
  49695. catch (e) {
  49696. errorHandler("Error in onSuccess callback", e);
  49697. }
  49698. }
  49699. scene._removePendingData(loadingToken);
  49700. };
  49701. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49702. if (plugin.load) {
  49703. var syncedPlugin = plugin;
  49704. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  49705. return;
  49706. }
  49707. scene.loadingPluginName = plugin.name;
  49708. successHandler();
  49709. }
  49710. else {
  49711. var asyncedPlugin = plugin;
  49712. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  49713. scene.loadingPluginName = plugin.name;
  49714. successHandler();
  49715. }).catch(function (error) {
  49716. errorHandler(error.message, error);
  49717. });
  49718. }
  49719. if (SceneLoader.ShowLoadingScreen) {
  49720. scene.executeWhenReady(function () {
  49721. scene.getEngine().hideLoadingUI();
  49722. });
  49723. }
  49724. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49725. };
  49726. /**
  49727. * Append a scene
  49728. * @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)
  49729. * @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)
  49730. * @param scene is the instance of BABYLON.Scene to append to
  49731. * @param onProgress a callback with a progress event for each file being loaded
  49732. * @param pluginExtension the extension used to determine the plugin
  49733. * @returns The given scene
  49734. */
  49735. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49736. if (sceneFilename === void 0) { sceneFilename = ""; }
  49737. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49738. if (onProgress === void 0) { onProgress = null; }
  49739. if (pluginExtension === void 0) { pluginExtension = null; }
  49740. return new Promise(function (resolve, reject) {
  49741. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  49742. resolve(scene);
  49743. }, onProgress, function (scene, message, exception) {
  49744. reject(exception || new Error(message));
  49745. }, pluginExtension);
  49746. });
  49747. };
  49748. /**
  49749. * Load a scene into an asset container
  49750. * @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)
  49751. * @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)
  49752. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49753. * @param onSuccess a callback with the scene when import succeeds
  49754. * @param onProgress a callback with a progress event for each file being loaded
  49755. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49756. * @param pluginExtension the extension used to determine the plugin
  49757. * @returns The loaded plugin
  49758. */
  49759. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49760. if (sceneFilename === void 0) { sceneFilename = ""; }
  49761. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49762. if (onSuccess === void 0) { onSuccess = null; }
  49763. if (onProgress === void 0) { onProgress = null; }
  49764. if (onError === void 0) { onError = null; }
  49765. if (pluginExtension === void 0) { pluginExtension = null; }
  49766. if (!scene) {
  49767. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  49768. return null;
  49769. }
  49770. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49771. if (!fileInfo) {
  49772. return null;
  49773. }
  49774. var loadingToken = {};
  49775. scene._addPendingData(loadingToken);
  49776. var disposeHandler = function () {
  49777. scene._removePendingData(loadingToken);
  49778. };
  49779. var errorHandler = function (message, exception) {
  49780. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  49781. if (onError) {
  49782. onError(scene, errorMessage, exception);
  49783. }
  49784. else {
  49785. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49786. // should the exception be thrown?
  49787. }
  49788. disposeHandler();
  49789. };
  49790. var progressHandler = onProgress ? function (event) {
  49791. try {
  49792. onProgress(event);
  49793. }
  49794. catch (e) {
  49795. errorHandler("Error in onProgress callback", e);
  49796. }
  49797. } : undefined;
  49798. var successHandler = function (assets) {
  49799. if (onSuccess) {
  49800. try {
  49801. onSuccess(assets);
  49802. }
  49803. catch (e) {
  49804. errorHandler("Error in onSuccess callback", e);
  49805. }
  49806. }
  49807. scene._removePendingData(loadingToken);
  49808. };
  49809. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49810. if (plugin.loadAssetContainer) {
  49811. var syncedPlugin = plugin;
  49812. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  49813. if (!assetContainer) {
  49814. return;
  49815. }
  49816. scene.loadingPluginName = plugin.name;
  49817. successHandler(assetContainer);
  49818. }
  49819. else if (plugin.loadAssetContainerAsync) {
  49820. var asyncedPlugin = plugin;
  49821. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49822. scene.loadingPluginName = plugin.name;
  49823. successHandler(assetContainer);
  49824. }).catch(function (error) {
  49825. errorHandler(error.message, error);
  49826. });
  49827. }
  49828. else {
  49829. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49830. }
  49831. if (SceneLoader.ShowLoadingScreen) {
  49832. scene.executeWhenReady(function () {
  49833. scene.getEngine().hideLoadingUI();
  49834. });
  49835. }
  49836. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49837. };
  49838. /**
  49839. * Load a scene into an asset container
  49840. * @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)
  49841. * @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)
  49842. * @param scene is the instance of Scene to append to
  49843. * @param onProgress a callback with a progress event for each file being loaded
  49844. * @param pluginExtension the extension used to determine the plugin
  49845. * @returns The loaded asset container
  49846. */
  49847. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49848. if (sceneFilename === void 0) { sceneFilename = ""; }
  49849. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49850. if (onProgress === void 0) { onProgress = null; }
  49851. if (pluginExtension === void 0) { pluginExtension = null; }
  49852. return new Promise(function (resolve, reject) {
  49853. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  49854. resolve(assetContainer);
  49855. }, onProgress, function (scene, message, exception) {
  49856. reject(exception || new Error(message));
  49857. }, pluginExtension);
  49858. });
  49859. };
  49860. /**
  49861. * No logging while loading
  49862. */
  49863. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  49864. /**
  49865. * Minimal logging while loading
  49866. */
  49867. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  49868. /**
  49869. * Summary logging while loading
  49870. */
  49871. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  49872. /**
  49873. * Detailled logging while loading
  49874. */
  49875. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  49876. // Members
  49877. /**
  49878. * Event raised when a plugin is used to load a scene
  49879. */
  49880. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  49881. SceneLoader._registeredPlugins = {};
  49882. return SceneLoader;
  49883. }());
  49884. /***/ }),
  49885. /***/ "./Loading/sceneLoaderFlags.ts":
  49886. /*!*************************************!*\
  49887. !*** ./Loading/sceneLoaderFlags.ts ***!
  49888. \*************************************/
  49889. /*! exports provided: SceneLoaderFlags */
  49890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49891. "use strict";
  49892. __webpack_require__.r(__webpack_exports__);
  49893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  49894. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49895. /**
  49896. * Class used to represent data loading progression
  49897. */
  49898. var SceneLoaderFlags = /** @class */ (function () {
  49899. function SceneLoaderFlags() {
  49900. }
  49901. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  49902. /**
  49903. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49904. */
  49905. get: function () {
  49906. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  49907. },
  49908. set: function (value) {
  49909. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  49910. },
  49911. enumerable: true,
  49912. configurable: true
  49913. });
  49914. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  49915. /**
  49916. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49917. */
  49918. get: function () {
  49919. return SceneLoaderFlags._ShowLoadingScreen;
  49920. },
  49921. set: function (value) {
  49922. SceneLoaderFlags._ShowLoadingScreen = value;
  49923. },
  49924. enumerable: true,
  49925. configurable: true
  49926. });
  49927. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  49928. /**
  49929. * Defines the current logging level (while loading the scene)
  49930. * @ignorenaming
  49931. */
  49932. get: function () {
  49933. return SceneLoaderFlags._loggingLevel;
  49934. },
  49935. set: function (value) {
  49936. SceneLoaderFlags._loggingLevel = value;
  49937. },
  49938. enumerable: true,
  49939. configurable: true
  49940. });
  49941. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  49942. /**
  49943. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49944. */
  49945. get: function () {
  49946. return SceneLoaderFlags._CleanBoneMatrixWeights;
  49947. },
  49948. set: function (value) {
  49949. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  49950. },
  49951. enumerable: true,
  49952. configurable: true
  49953. });
  49954. // Flags
  49955. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  49956. SceneLoaderFlags._ShowLoadingScreen = true;
  49957. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  49958. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  49959. return SceneLoaderFlags;
  49960. }());
  49961. /***/ }),
  49962. /***/ "./Materials/Background/backgroundMaterial.ts":
  49963. /*!****************************************************!*\
  49964. !*** ./Materials/Background/backgroundMaterial.ts ***!
  49965. \****************************************************/
  49966. /*! exports provided: BackgroundMaterial */
  49967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49968. "use strict";
  49969. __webpack_require__.r(__webpack_exports__);
  49970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  49971. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49972. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49973. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49974. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49975. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49976. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49977. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49978. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49979. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49980. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49981. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49982. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49983. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49984. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49985. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49986. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  49987. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  49988. /**
  49989. * Background material defines definition.
  49990. * @hidden Mainly internal Use
  49991. */
  49992. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  49993. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49994. /**
  49995. * Constructor of the defines.
  49996. */
  49997. function BackgroundMaterialDefines() {
  49998. var _this = _super.call(this) || this;
  49999. /**
  50000. * True if the diffuse texture is in use.
  50001. */
  50002. _this.DIFFUSE = false;
  50003. /**
  50004. * The direct UV channel to use.
  50005. */
  50006. _this.DIFFUSEDIRECTUV = 0;
  50007. /**
  50008. * True if the diffuse texture is in gamma space.
  50009. */
  50010. _this.GAMMADIFFUSE = false;
  50011. /**
  50012. * True if the diffuse texture has opacity in the alpha channel.
  50013. */
  50014. _this.DIFFUSEHASALPHA = false;
  50015. /**
  50016. * True if you want the material to fade to transparent at grazing angle.
  50017. */
  50018. _this.OPACITYFRESNEL = false;
  50019. /**
  50020. * True if an extra blur needs to be added in the reflection.
  50021. */
  50022. _this.REFLECTIONBLUR = false;
  50023. /**
  50024. * True if you want the material to fade to reflection at grazing angle.
  50025. */
  50026. _this.REFLECTIONFRESNEL = false;
  50027. /**
  50028. * True if you want the material to falloff as far as you move away from the scene center.
  50029. */
  50030. _this.REFLECTIONFALLOFF = false;
  50031. /**
  50032. * False if the current Webgl implementation does not support the texture lod extension.
  50033. */
  50034. _this.TEXTURELODSUPPORT = false;
  50035. /**
  50036. * True to ensure the data are premultiplied.
  50037. */
  50038. _this.PREMULTIPLYALPHA = false;
  50039. /**
  50040. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  50041. */
  50042. _this.USERGBCOLOR = false;
  50043. /**
  50044. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  50045. * stays aligned with the desired configuration.
  50046. */
  50047. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  50048. /**
  50049. * True to add noise in order to reduce the banding effect.
  50050. */
  50051. _this.NOISE = false;
  50052. /**
  50053. * is the reflection texture in BGR color scheme?
  50054. * Mainly used to solve a bug in ios10 video tag
  50055. */
  50056. _this.REFLECTIONBGR = false;
  50057. _this.IMAGEPROCESSING = false;
  50058. _this.VIGNETTE = false;
  50059. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50060. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50061. _this.TONEMAPPING = false;
  50062. _this.TONEMAPPING_ACES = false;
  50063. _this.CONTRAST = false;
  50064. _this.COLORCURVES = false;
  50065. _this.COLORGRADING = false;
  50066. _this.COLORGRADING3D = false;
  50067. _this.SAMPLER3DGREENDEPTH = false;
  50068. _this.SAMPLER3DBGRMAP = false;
  50069. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50070. _this.EXPOSURE = false;
  50071. // Reflection.
  50072. _this.REFLECTION = false;
  50073. _this.REFLECTIONMAP_3D = false;
  50074. _this.REFLECTIONMAP_SPHERICAL = false;
  50075. _this.REFLECTIONMAP_PLANAR = false;
  50076. _this.REFLECTIONMAP_CUBIC = false;
  50077. _this.REFLECTIONMAP_PROJECTION = false;
  50078. _this.REFLECTIONMAP_SKYBOX = false;
  50079. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50080. _this.REFLECTIONMAP_EXPLICIT = false;
  50081. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50082. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50083. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50084. _this.INVERTCUBICMAP = false;
  50085. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50086. _this.LODINREFLECTIONALPHA = false;
  50087. _this.GAMMAREFLECTION = false;
  50088. _this.RGBDREFLECTION = false;
  50089. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  50090. // Default BJS.
  50091. _this.MAINUV1 = false;
  50092. _this.MAINUV2 = false;
  50093. _this.UV1 = false;
  50094. _this.UV2 = false;
  50095. _this.CLIPPLANE = false;
  50096. _this.CLIPPLANE2 = false;
  50097. _this.CLIPPLANE3 = false;
  50098. _this.CLIPPLANE4 = false;
  50099. _this.POINTSIZE = false;
  50100. _this.FOG = false;
  50101. _this.NORMAL = false;
  50102. _this.NUM_BONE_INFLUENCERS = 0;
  50103. _this.BonesPerMesh = 0;
  50104. _this.INSTANCES = false;
  50105. _this.SHADOWFLOAT = false;
  50106. _this.rebuild();
  50107. return _this;
  50108. }
  50109. return BackgroundMaterialDefines;
  50110. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  50111. /**
  50112. * Background material used to create an efficient environement around your scene.
  50113. */
  50114. var BackgroundMaterial = /** @class */ (function (_super) {
  50115. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  50116. /**
  50117. * Instantiates a Background Material in the given scene
  50118. * @param name The friendly name of the material
  50119. * @param scene The scene to add the material to
  50120. */
  50121. function BackgroundMaterial(name, scene) {
  50122. var _this = _super.call(this, name, scene) || this;
  50123. /**
  50124. * Key light Color (multiply against the environement texture)
  50125. */
  50126. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50127. _this._primaryColorShadowLevel = 0;
  50128. _this._primaryColorHighlightLevel = 0;
  50129. /**
  50130. * Reflection Texture used in the material.
  50131. * Should be author in a specific way for the best result (refer to the documentation).
  50132. */
  50133. _this.reflectionTexture = null;
  50134. /**
  50135. * Reflection Texture level of blur.
  50136. *
  50137. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50138. * texture twice.
  50139. */
  50140. _this.reflectionBlur = 0;
  50141. /**
  50142. * Diffuse Texture used in the material.
  50143. * Should be author in a specific way for the best result (refer to the documentation).
  50144. */
  50145. _this.diffuseTexture = null;
  50146. _this._shadowLights = null;
  50147. /**
  50148. * Specify the list of lights casting shadow on the material.
  50149. * All scene shadow lights will be included if null.
  50150. */
  50151. _this.shadowLights = null;
  50152. /**
  50153. * Helps adjusting the shadow to a softer level if required.
  50154. * 0 means black shadows and 1 means no shadows.
  50155. */
  50156. _this.shadowLevel = 0;
  50157. /**
  50158. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50159. * It is usually zero but might be interesting to modify according to your setup.
  50160. */
  50161. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  50162. /**
  50163. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50164. * This helps ensuring a nice transition when the camera goes under the ground.
  50165. */
  50166. _this.opacityFresnel = true;
  50167. /**
  50168. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50169. * This helps adding a mirror texture on the ground.
  50170. */
  50171. _this.reflectionFresnel = false;
  50172. /**
  50173. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50174. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50175. */
  50176. _this.reflectionFalloffDistance = 0.0;
  50177. /**
  50178. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50179. */
  50180. _this.reflectionAmount = 1.0;
  50181. /**
  50182. * This specifies the weight of the reflection at grazing angle.
  50183. */
  50184. _this.reflectionReflectance0 = 0.05;
  50185. /**
  50186. * This specifies the weight of the reflection at a perpendicular point of view.
  50187. */
  50188. _this.reflectionReflectance90 = 0.5;
  50189. /**
  50190. * Helps to directly use the maps channels instead of their level.
  50191. */
  50192. _this.useRGBColor = true;
  50193. /**
  50194. * This helps reducing the banding effect that could occur on the background.
  50195. */
  50196. _this.enableNoise = false;
  50197. _this._fovMultiplier = 1.0;
  50198. /**
  50199. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50200. */
  50201. _this.useEquirectangularFOV = false;
  50202. _this._maxSimultaneousLights = 4;
  50203. /**
  50204. * Number of Simultaneous lights allowed on the material.
  50205. */
  50206. _this.maxSimultaneousLights = 4;
  50207. /**
  50208. * Keep track of the image processing observer to allow dispose and replace.
  50209. */
  50210. _this._imageProcessingObserver = null;
  50211. /**
  50212. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50213. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50214. */
  50215. _this.switchToBGR = false;
  50216. // Temp values kept as cache in the material.
  50217. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  50218. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  50219. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50220. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50221. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50222. // Setup the default processing configuration to the scene.
  50223. _this._attachImageProcessingConfiguration(null);
  50224. _this.getRenderTargetTextures = function () {
  50225. _this._renderTargets.reset();
  50226. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  50227. _this._renderTargets.push(_this._diffuseTexture);
  50228. }
  50229. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50230. _this._renderTargets.push(_this._reflectionTexture);
  50231. }
  50232. return _this._renderTargets;
  50233. };
  50234. return _this;
  50235. }
  50236. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  50237. /**
  50238. * Experimental Internal Use Only.
  50239. *
  50240. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50241. * This acts as a helper to set the primary color to a more "human friendly" value.
  50242. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50243. * output color as close as possible from the chosen value.
  50244. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50245. * part of lighting setup.)
  50246. */
  50247. get: function () {
  50248. return this.__perceptualColor;
  50249. },
  50250. set: function (value) {
  50251. this.__perceptualColor = value;
  50252. this._computePrimaryColorFromPerceptualColor();
  50253. this._markAllSubMeshesAsLightsDirty();
  50254. },
  50255. enumerable: true,
  50256. configurable: true
  50257. });
  50258. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  50259. /**
  50260. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50261. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50262. */
  50263. get: function () {
  50264. return this._primaryColorShadowLevel;
  50265. },
  50266. set: function (value) {
  50267. this._primaryColorShadowLevel = value;
  50268. this._computePrimaryColors();
  50269. this._markAllSubMeshesAsLightsDirty();
  50270. },
  50271. enumerable: true,
  50272. configurable: true
  50273. });
  50274. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  50275. /**
  50276. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50277. * The primary color is used at the level chosen to define what the white area would look.
  50278. */
  50279. get: function () {
  50280. return this._primaryColorHighlightLevel;
  50281. },
  50282. set: function (value) {
  50283. this._primaryColorHighlightLevel = value;
  50284. this._computePrimaryColors();
  50285. this._markAllSubMeshesAsLightsDirty();
  50286. },
  50287. enumerable: true,
  50288. configurable: true
  50289. });
  50290. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  50291. /**
  50292. * Sets the reflection reflectance fresnel values according to the default standard
  50293. * empirically know to work well :-)
  50294. */
  50295. set: function (value) {
  50296. var reflectionWeight = value;
  50297. if (reflectionWeight < 0.5) {
  50298. reflectionWeight = reflectionWeight * 2.0;
  50299. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  50300. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  50301. }
  50302. else {
  50303. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  50304. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  50305. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  50306. }
  50307. },
  50308. enumerable: true,
  50309. configurable: true
  50310. });
  50311. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  50312. /**
  50313. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50314. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50315. * Recommended to be keep at 1.0 except for special cases.
  50316. */
  50317. get: function () {
  50318. return this._fovMultiplier;
  50319. },
  50320. set: function (value) {
  50321. if (isNaN(value)) {
  50322. value = 1.0;
  50323. }
  50324. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  50325. },
  50326. enumerable: true,
  50327. configurable: true
  50328. });
  50329. /**
  50330. * Attaches a new image processing configuration to the PBR Material.
  50331. * @param configuration (if null the scene configuration will be use)
  50332. */
  50333. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50334. var _this = this;
  50335. if (configuration === this._imageProcessingConfiguration) {
  50336. return;
  50337. }
  50338. // Detaches observer.
  50339. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50340. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50341. }
  50342. // Pick the scene configuration if needed.
  50343. if (!configuration) {
  50344. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50345. }
  50346. else {
  50347. this._imageProcessingConfiguration = configuration;
  50348. }
  50349. // Attaches observer.
  50350. if (this._imageProcessingConfiguration) {
  50351. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50352. _this._computePrimaryColorFromPerceptualColor();
  50353. _this._markAllSubMeshesAsImageProcessingDirty();
  50354. });
  50355. }
  50356. };
  50357. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  50358. /**
  50359. * Gets the image processing configuration used either in this material.
  50360. */
  50361. get: function () {
  50362. return this._imageProcessingConfiguration;
  50363. },
  50364. /**
  50365. * Sets the Default image processing configuration used either in the this material.
  50366. *
  50367. * If sets to null, the scene one is in use.
  50368. */
  50369. set: function (value) {
  50370. this._attachImageProcessingConfiguration(value);
  50371. // Ensure the effect will be rebuilt.
  50372. this._markAllSubMeshesAsTexturesDirty();
  50373. },
  50374. enumerable: true,
  50375. configurable: true
  50376. });
  50377. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  50378. /**
  50379. * Gets wether the color curves effect is enabled.
  50380. */
  50381. get: function () {
  50382. return this.imageProcessingConfiguration.colorCurvesEnabled;
  50383. },
  50384. /**
  50385. * Sets wether the color curves effect is enabled.
  50386. */
  50387. set: function (value) {
  50388. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  50389. },
  50390. enumerable: true,
  50391. configurable: true
  50392. });
  50393. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  50394. /**
  50395. * Gets wether the color grading effect is enabled.
  50396. */
  50397. get: function () {
  50398. return this.imageProcessingConfiguration.colorGradingEnabled;
  50399. },
  50400. /**
  50401. * Gets wether the color grading effect is enabled.
  50402. */
  50403. set: function (value) {
  50404. this.imageProcessingConfiguration.colorGradingEnabled = value;
  50405. },
  50406. enumerable: true,
  50407. configurable: true
  50408. });
  50409. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  50410. /**
  50411. * Gets wether tonemapping is enabled or not.
  50412. */
  50413. get: function () {
  50414. return this._imageProcessingConfiguration.toneMappingEnabled;
  50415. },
  50416. /**
  50417. * Sets wether tonemapping is enabled or not
  50418. */
  50419. set: function (value) {
  50420. this._imageProcessingConfiguration.toneMappingEnabled = value;
  50421. },
  50422. enumerable: true,
  50423. configurable: true
  50424. });
  50425. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  50426. /**
  50427. * The camera exposure used on this material.
  50428. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50429. * This corresponds to a photographic exposure.
  50430. */
  50431. get: function () {
  50432. return this._imageProcessingConfiguration.exposure;
  50433. },
  50434. /**
  50435. * The camera exposure used on this material.
  50436. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50437. * This corresponds to a photographic exposure.
  50438. */
  50439. set: function (value) {
  50440. this._imageProcessingConfiguration.exposure = value;
  50441. },
  50442. enumerable: true,
  50443. configurable: true
  50444. });
  50445. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  50446. /**
  50447. * Gets The camera contrast used on this material.
  50448. */
  50449. get: function () {
  50450. return this._imageProcessingConfiguration.contrast;
  50451. },
  50452. /**
  50453. * Sets The camera contrast used on this material.
  50454. */
  50455. set: function (value) {
  50456. this._imageProcessingConfiguration.contrast = value;
  50457. },
  50458. enumerable: true,
  50459. configurable: true
  50460. });
  50461. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  50462. /**
  50463. * Gets the Color Grading 2D Lookup Texture.
  50464. */
  50465. get: function () {
  50466. return this._imageProcessingConfiguration.colorGradingTexture;
  50467. },
  50468. /**
  50469. * Sets the Color Grading 2D Lookup Texture.
  50470. */
  50471. set: function (value) {
  50472. this.imageProcessingConfiguration.colorGradingTexture = value;
  50473. },
  50474. enumerable: true,
  50475. configurable: true
  50476. });
  50477. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  50478. /**
  50479. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50480. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50481. * 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;
  50482. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50483. */
  50484. get: function () {
  50485. return this.imageProcessingConfiguration.colorCurves;
  50486. },
  50487. /**
  50488. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50489. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50490. * 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;
  50491. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50492. */
  50493. set: function (value) {
  50494. this.imageProcessingConfiguration.colorCurves = value;
  50495. },
  50496. enumerable: true,
  50497. configurable: true
  50498. });
  50499. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  50500. /**
  50501. * Gets a boolean indicating that current material needs to register RTT
  50502. */
  50503. get: function () {
  50504. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50505. return true;
  50506. }
  50507. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50508. return true;
  50509. }
  50510. return false;
  50511. },
  50512. enumerable: true,
  50513. configurable: true
  50514. });
  50515. /**
  50516. * The entire material has been created in order to prevent overdraw.
  50517. * @returns false
  50518. */
  50519. BackgroundMaterial.prototype.needAlphaTesting = function () {
  50520. return true;
  50521. };
  50522. /**
  50523. * The entire material has been created in order to prevent overdraw.
  50524. * @returns true if blending is enable
  50525. */
  50526. BackgroundMaterial.prototype.needAlphaBlending = function () {
  50527. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  50528. };
  50529. /**
  50530. * Checks wether the material is ready to be rendered for a given mesh.
  50531. * @param mesh The mesh to render
  50532. * @param subMesh The submesh to check against
  50533. * @param useInstances Specify wether or not the material is used with instances
  50534. * @returns true if all the dependencies are ready (Textures, Effects...)
  50535. */
  50536. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50537. var _this = this;
  50538. if (useInstances === void 0) { useInstances = false; }
  50539. if (subMesh.effect && this.isFrozen) {
  50540. if (this._wasPreviouslyReady) {
  50541. return true;
  50542. }
  50543. }
  50544. if (!subMesh._materialDefines) {
  50545. subMesh._materialDefines = new BackgroundMaterialDefines();
  50546. }
  50547. var scene = this.getScene();
  50548. var defines = subMesh._materialDefines;
  50549. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50550. if (defines._renderId === scene.getRenderId()) {
  50551. return true;
  50552. }
  50553. }
  50554. var engine = scene.getEngine();
  50555. // Lights
  50556. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  50557. defines._needNormals = true;
  50558. // Textures
  50559. if (defines._areTexturesDirty) {
  50560. defines._needUVs = false;
  50561. if (scene.texturesEnabled) {
  50562. if (scene.getEngine().getCaps().textureLOD) {
  50563. defines.TEXTURELODSUPPORT = true;
  50564. }
  50565. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50566. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  50567. return false;
  50568. }
  50569. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  50570. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  50571. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  50572. defines.OPACITYFRESNEL = this._opacityFresnel;
  50573. }
  50574. else {
  50575. defines.DIFFUSE = false;
  50576. defines.DIFFUSEHASALPHA = false;
  50577. defines.GAMMADIFFUSE = false;
  50578. defines.OPACITYFRESNEL = false;
  50579. }
  50580. var reflectionTexture = this._reflectionTexture;
  50581. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50582. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50583. return false;
  50584. }
  50585. defines.REFLECTION = true;
  50586. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  50587. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  50588. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  50589. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  50590. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  50591. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  50592. defines.REFLECTIONBGR = this.switchToBGR;
  50593. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  50594. defines.INVERTCUBICMAP = true;
  50595. }
  50596. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  50597. switch (reflectionTexture.coordinatesMode) {
  50598. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  50599. defines.REFLECTIONMAP_EXPLICIT = true;
  50600. break;
  50601. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  50602. defines.REFLECTIONMAP_PLANAR = true;
  50603. break;
  50604. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  50605. defines.REFLECTIONMAP_PROJECTION = true;
  50606. break;
  50607. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  50608. defines.REFLECTIONMAP_SKYBOX = true;
  50609. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  50610. break;
  50611. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  50612. defines.REFLECTIONMAP_SPHERICAL = true;
  50613. break;
  50614. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  50615. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  50616. break;
  50617. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  50618. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  50619. break;
  50620. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  50621. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  50622. break;
  50623. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  50624. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  50625. default:
  50626. defines.REFLECTIONMAP_CUBIC = true;
  50627. break;
  50628. }
  50629. if (this.reflectionFresnel) {
  50630. defines.REFLECTIONFRESNEL = true;
  50631. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  50632. this._reflectionControls.x = this.reflectionAmount;
  50633. this._reflectionControls.y = this.reflectionReflectance0;
  50634. this._reflectionControls.z = this.reflectionReflectance90;
  50635. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  50636. }
  50637. else {
  50638. defines.REFLECTIONFRESNEL = false;
  50639. defines.REFLECTIONFALLOFF = false;
  50640. }
  50641. }
  50642. else {
  50643. defines.REFLECTION = false;
  50644. defines.REFLECTIONFRESNEL = false;
  50645. defines.REFLECTIONFALLOFF = false;
  50646. defines.REFLECTIONBLUR = false;
  50647. defines.REFLECTIONMAP_3D = false;
  50648. defines.REFLECTIONMAP_SPHERICAL = false;
  50649. defines.REFLECTIONMAP_PLANAR = false;
  50650. defines.REFLECTIONMAP_CUBIC = false;
  50651. defines.REFLECTIONMAP_PROJECTION = false;
  50652. defines.REFLECTIONMAP_SKYBOX = false;
  50653. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50654. defines.REFLECTIONMAP_EXPLICIT = false;
  50655. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50656. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50657. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50658. defines.INVERTCUBICMAP = false;
  50659. defines.REFLECTIONMAP_OPPOSITEZ = false;
  50660. defines.LODINREFLECTIONALPHA = false;
  50661. defines.GAMMAREFLECTION = false;
  50662. defines.RGBDREFLECTION = false;
  50663. }
  50664. }
  50665. 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);
  50666. defines.USERGBCOLOR = this._useRGBColor;
  50667. defines.NOISE = this._enableNoise;
  50668. }
  50669. if (defines._areLightsDirty) {
  50670. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  50671. }
  50672. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50673. if (!this._imageProcessingConfiguration.isReady()) {
  50674. return false;
  50675. }
  50676. this._imageProcessingConfiguration.prepareDefines(defines);
  50677. }
  50678. // Misc.
  50679. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  50680. // Values that need to be evaluated on every frame
  50681. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  50682. // Attribs
  50683. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  50684. if (mesh) {
  50685. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  50686. mesh.createNormals(true);
  50687. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  50688. }
  50689. }
  50690. }
  50691. // Get correct effect
  50692. if (defines.isDirty) {
  50693. defines.markAsProcessed();
  50694. scene.resetCachedMaterial();
  50695. // Fallbacks
  50696. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  50697. if (defines.FOG) {
  50698. fallbacks.addFallback(0, "FOG");
  50699. }
  50700. if (defines.POINTSIZE) {
  50701. fallbacks.addFallback(1, "POINTSIZE");
  50702. }
  50703. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  50704. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50705. fallbacks.addCPUSkinningFallback(0, mesh);
  50706. }
  50707. //Attributes
  50708. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  50709. if (defines.NORMAL) {
  50710. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  50711. }
  50712. if (defines.UV1) {
  50713. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  50714. }
  50715. if (defines.UV2) {
  50716. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  50717. }
  50718. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50719. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50720. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  50721. "vFogInfos", "vFogColor", "pointSize",
  50722. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  50723. "vPrimaryColor", "vPrimaryColorShadow",
  50724. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  50725. "shadowLevel", "alpha",
  50726. "vBackgroundCenter", "vReflectionControl",
  50727. "vDiffuseInfos", "diffuseMatrix",
  50728. ];
  50729. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  50730. var uniformBuffers = ["Material", "Scene"];
  50731. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  50732. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50733. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50734. }
  50735. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50736. uniformsNames: uniforms,
  50737. uniformBuffersNames: uniformBuffers,
  50738. samplers: samplers,
  50739. defines: defines,
  50740. maxSimultaneousLights: this._maxSimultaneousLights
  50741. });
  50742. var onCompiled = function (effect) {
  50743. if (_this.onCompiled) {
  50744. _this.onCompiled(effect);
  50745. }
  50746. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  50747. };
  50748. var join = defines.toString();
  50749. subMesh.setEffect(scene.getEngine().createEffect("background", {
  50750. attributes: attribs,
  50751. uniformsNames: uniforms,
  50752. uniformBuffersNames: uniformBuffers,
  50753. samplers: samplers,
  50754. defines: join,
  50755. fallbacks: fallbacks,
  50756. onCompiled: onCompiled,
  50757. onError: this.onError,
  50758. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  50759. }, engine), defines);
  50760. this.buildUniformLayout();
  50761. }
  50762. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50763. return false;
  50764. }
  50765. defines._renderId = scene.getRenderId();
  50766. this._wasPreviouslyReady = true;
  50767. return true;
  50768. };
  50769. /**
  50770. * Compute the primary color according to the chosen perceptual color.
  50771. */
  50772. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  50773. if (!this.__perceptualColor) {
  50774. return;
  50775. }
  50776. this._primaryColor.copyFrom(this.__perceptualColor);
  50777. // Revert gamma space.
  50778. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  50779. // Revert image processing configuration.
  50780. if (this._imageProcessingConfiguration) {
  50781. // Revert Exposure.
  50782. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  50783. }
  50784. this._computePrimaryColors();
  50785. };
  50786. /**
  50787. * Compute the highlights and shadow colors according to their chosen levels.
  50788. */
  50789. BackgroundMaterial.prototype._computePrimaryColors = function () {
  50790. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  50791. return;
  50792. }
  50793. // Find the highlight color based on the configuration.
  50794. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  50795. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  50796. // Find the shadow color based on the configuration.
  50797. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  50798. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  50799. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  50800. };
  50801. /**
  50802. * Build the uniform buffer used in the material.
  50803. */
  50804. BackgroundMaterial.prototype.buildUniformLayout = function () {
  50805. // Order is important !
  50806. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  50807. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  50808. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  50809. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50810. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  50811. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50812. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50813. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  50814. this._uniformBuffer.addUniform("pointSize", 1);
  50815. this._uniformBuffer.addUniform("shadowLevel", 1);
  50816. this._uniformBuffer.addUniform("alpha", 1);
  50817. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  50818. this._uniformBuffer.addUniform("vReflectionControl", 4);
  50819. this._uniformBuffer.create();
  50820. };
  50821. /**
  50822. * Unbind the material.
  50823. */
  50824. BackgroundMaterial.prototype.unbind = function () {
  50825. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50826. this._uniformBuffer.setTexture("diffuseSampler", null);
  50827. }
  50828. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50829. this._uniformBuffer.setTexture("reflectionSampler", null);
  50830. }
  50831. _super.prototype.unbind.call(this);
  50832. };
  50833. /**
  50834. * Bind only the world matrix to the material.
  50835. * @param world The world matrix to bind.
  50836. */
  50837. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  50838. this._activeEffect.setMatrix("world", world);
  50839. };
  50840. /**
  50841. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50842. * @param world The world matrix to bind.
  50843. * @param subMesh The submesh to bind for.
  50844. */
  50845. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50846. var scene = this.getScene();
  50847. var defines = subMesh._materialDefines;
  50848. if (!defines) {
  50849. return;
  50850. }
  50851. var effect = subMesh.effect;
  50852. if (!effect) {
  50853. return;
  50854. }
  50855. this._activeEffect = effect;
  50856. // Matrices
  50857. this.bindOnlyWorldMatrix(world);
  50858. // Bones
  50859. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50860. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50861. if (mustRebind) {
  50862. this._uniformBuffer.bindToEffect(effect, "Material");
  50863. this.bindViewProjection(effect);
  50864. var reflectionTexture = this._reflectionTexture;
  50865. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50866. // Texture uniforms
  50867. if (scene.texturesEnabled) {
  50868. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50869. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  50870. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  50871. }
  50872. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50873. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50874. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  50875. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50876. }
  50877. }
  50878. if (this.shadowLevel > 0) {
  50879. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  50880. }
  50881. this._uniformBuffer.updateFloat("alpha", this.alpha);
  50882. // Point size
  50883. if (this.pointsCloud) {
  50884. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50885. }
  50886. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  50887. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  50888. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  50889. }
  50890. else {
  50891. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  50892. }
  50893. }
  50894. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  50895. // Textures
  50896. if (scene.texturesEnabled) {
  50897. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50898. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  50899. }
  50900. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50901. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  50902. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50903. }
  50904. else if (!defines.REFLECTIONBLUR) {
  50905. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50906. }
  50907. else {
  50908. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50909. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50910. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50911. }
  50912. if (defines.REFLECTIONFRESNEL) {
  50913. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  50914. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  50915. }
  50916. }
  50917. }
  50918. // Clip plane
  50919. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50920. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  50921. }
  50922. if (mustRebind || !this.isFrozen) {
  50923. if (scene.lightsEnabled) {
  50924. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  50925. }
  50926. // View
  50927. this.bindView(effect);
  50928. // Fog
  50929. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50930. // image processing
  50931. if (this._imageProcessingConfiguration) {
  50932. this._imageProcessingConfiguration.bind(this._activeEffect);
  50933. }
  50934. }
  50935. this._uniformBuffer.update();
  50936. this._afterBind(mesh, this._activeEffect);
  50937. };
  50938. /**
  50939. * Dispose the material.
  50940. * @param forceDisposeEffect Force disposal of the associated effect.
  50941. * @param forceDisposeTextures Force disposal of the associated textures.
  50942. */
  50943. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50944. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  50945. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  50946. if (forceDisposeTextures) {
  50947. if (this.diffuseTexture) {
  50948. this.diffuseTexture.dispose();
  50949. }
  50950. if (this.reflectionTexture) {
  50951. this.reflectionTexture.dispose();
  50952. }
  50953. }
  50954. this._renderTargets.dispose();
  50955. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50956. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50957. }
  50958. _super.prototype.dispose.call(this, forceDisposeEffect);
  50959. };
  50960. /**
  50961. * Clones the material.
  50962. * @param name The cloned name.
  50963. * @returns The cloned material.
  50964. */
  50965. BackgroundMaterial.prototype.clone = function (name) {
  50966. var _this = this;
  50967. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  50968. };
  50969. /**
  50970. * Serializes the current material to its JSON representation.
  50971. * @returns The JSON representation.
  50972. */
  50973. BackgroundMaterial.prototype.serialize = function () {
  50974. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50975. serializationObject.customType = "BABYLON.BackgroundMaterial";
  50976. return serializationObject;
  50977. };
  50978. /**
  50979. * Gets the class name of the material
  50980. * @returns "BackgroundMaterial"
  50981. */
  50982. BackgroundMaterial.prototype.getClassName = function () {
  50983. return "BackgroundMaterial";
  50984. };
  50985. /**
  50986. * Parse a JSON input to create back a background material.
  50987. * @param source The JSON data to parse
  50988. * @param scene The scene to create the parsed material in
  50989. * @param rootUrl The root url of the assets the material depends upon
  50990. * @returns the instantiated BackgroundMaterial.
  50991. */
  50992. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  50993. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50994. };
  50995. /**
  50996. * Standard reflectance value at parallel view angle.
  50997. */
  50998. BackgroundMaterial.StandardReflectance0 = 0.05;
  50999. /**
  51000. * Standard reflectance value at grazing angle.
  51001. */
  51002. BackgroundMaterial.StandardReflectance90 = 0.5;
  51003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51005. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  51006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51008. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  51009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51011. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  51012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51014. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  51015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51017. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  51018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51020. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  51021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51023. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  51024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51026. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  51027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51029. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  51030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51032. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  51033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51035. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  51036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51038. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  51039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51041. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  51042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51044. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  51045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51047. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  51048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  51050. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  51051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51053. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  51054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51056. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  51057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51059. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  51060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51062. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  51063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51065. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  51066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51068. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  51069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51071. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  51072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51074. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  51075. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51077. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  51078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51080. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  51081. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51083. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  51084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51086. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  51087. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51089. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  51090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51092. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  51093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51095. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  51096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51098. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  51099. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51101. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  51102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51104. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  51105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51107. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  51108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51110. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51111. return BackgroundMaterial;
  51112. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  51113. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  51114. /***/ }),
  51115. /***/ "./Materials/Background/index.ts":
  51116. /*!***************************************!*\
  51117. !*** ./Materials/Background/index.ts ***!
  51118. \***************************************/
  51119. /*! exports provided: BackgroundMaterial */
  51120. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51121. "use strict";
  51122. __webpack_require__.r(__webpack_exports__);
  51123. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  51124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  51125. /***/ }),
  51126. /***/ "./Materials/PBR/index.ts":
  51127. /*!********************************!*\
  51128. !*** ./Materials/PBR/index.ts ***!
  51129. \********************************/
  51130. /*! exports provided: PBRBaseMaterial, PBRMaterial, PBRBaseSimpleMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  51131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51132. "use strict";
  51133. __webpack_require__.r(__webpack_exports__);
  51134. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  51136. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  51137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  51138. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  51139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  51140. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  51141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  51142. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  51143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  51144. /***/ }),
  51145. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  51146. /*!******************************************************!*\
  51147. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  51148. \******************************************************/
  51149. /*! exports provided: PBRAnisotropicConfiguration */
  51150. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51151. "use strict";
  51152. __webpack_require__.r(__webpack_exports__);
  51153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  51154. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51155. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51156. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51157. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51158. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  51159. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51160. /**
  51161. * Define the code related to the anisotropic parameters of the pbr material.
  51162. */
  51163. var PBRAnisotropicConfiguration = /** @class */ (function () {
  51164. /**
  51165. * Instantiate a new istance of anisotropy configuration.
  51166. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51167. */
  51168. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  51169. this._isEnabled = false;
  51170. /**
  51171. * Defines if the anisotropy is enabled in the material.
  51172. */
  51173. this.isEnabled = false;
  51174. /**
  51175. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51176. */
  51177. this.intensity = 1;
  51178. /**
  51179. * Defines if the effect is along the tangents, bitangents or in between.
  51180. * By default, the effect is "strectching" the highlights along the tangents.
  51181. */
  51182. this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  51183. this._texture = null;
  51184. /**
  51185. * Stores the anisotropy values in a texture.
  51186. * rg is direction (like normal from -1 to 1)
  51187. * b is a intensity
  51188. */
  51189. this.texture = null;
  51190. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  51191. }
  51192. /** @hidden */
  51193. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  51194. this._internalMarkAllSubMeshesAsTexturesDirty();
  51195. };
  51196. /**
  51197. * Specifies that the submesh is ready to be used.
  51198. * @param defines the list of "defines" to update.
  51199. * @param scene defines the scene the material belongs to.
  51200. * @returns - boolean indicating that the submesh is ready or not.
  51201. */
  51202. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  51203. if (defines._areTexturesDirty) {
  51204. if (scene.texturesEnabled) {
  51205. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51206. if (!this._texture.isReadyOrNotBlocking()) {
  51207. return false;
  51208. }
  51209. }
  51210. }
  51211. }
  51212. return true;
  51213. };
  51214. /**
  51215. * Checks to see if a texture is used in the material.
  51216. * @param defines the list of "defines" to update.
  51217. * @param mesh the mesh we are preparing the defines for.
  51218. * @param scene defines the scene the material belongs to.
  51219. */
  51220. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  51221. if (this._isEnabled) {
  51222. defines.ANISOTROPIC = this._isEnabled;
  51223. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  51224. defines._needUVs = true;
  51225. defines.MAINUV1 = true;
  51226. }
  51227. if (defines._areTexturesDirty) {
  51228. if (scene.texturesEnabled) {
  51229. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51230. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  51231. }
  51232. else {
  51233. defines.ANISOTROPIC_TEXTURE = false;
  51234. }
  51235. }
  51236. }
  51237. }
  51238. else {
  51239. defines.ANISOTROPIC = false;
  51240. defines.ANISOTROPIC_TEXTURE = false;
  51241. }
  51242. };
  51243. /**
  51244. * Binds the material data.
  51245. * @param uniformBuffer defines the Uniform buffer to fill in.
  51246. * @param scene defines the scene the material belongs to.
  51247. * @param isFrozen defines wether the material is frozen or not.
  51248. */
  51249. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  51250. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  51251. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51252. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  51253. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  51254. }
  51255. // Anisotropy
  51256. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  51257. }
  51258. // Textures
  51259. if (scene.texturesEnabled) {
  51260. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51261. uniformBuffer.setTexture("anisotropySampler", this._texture);
  51262. }
  51263. }
  51264. };
  51265. /**
  51266. * Checks to see if a texture is used in the material.
  51267. * @param texture - Base texture to use.
  51268. * @returns - Boolean specifying if a texture is used in the material.
  51269. */
  51270. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  51271. if (this._texture === texture) {
  51272. return true;
  51273. }
  51274. return false;
  51275. };
  51276. /**
  51277. * Returns an array of the actively used textures.
  51278. * @param activeTextures Array of BaseTextures
  51279. */
  51280. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  51281. if (this._texture) {
  51282. activeTextures.push(this._texture);
  51283. }
  51284. };
  51285. /**
  51286. * Returns the animatable textures.
  51287. * @param animatables Array of animatable textures.
  51288. */
  51289. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  51290. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  51291. animatables.push(this._texture);
  51292. }
  51293. };
  51294. /**
  51295. * Disposes the resources of the material.
  51296. * @param forceDisposeTextures - Forces the disposal of all textures.
  51297. */
  51298. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  51299. if (forceDisposeTextures) {
  51300. if (this._texture) {
  51301. this._texture.dispose();
  51302. }
  51303. }
  51304. };
  51305. /**
  51306. * Get the current class name of the texture useful for serialization or dynamic coding.
  51307. * @returns "PBRAnisotropicConfiguration"
  51308. */
  51309. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  51310. return "PBRAnisotropicConfiguration";
  51311. };
  51312. /**
  51313. * Add fallbacks to the effect fallbacks list.
  51314. * @param defines defines the Base texture to use.
  51315. * @param fallbacks defines the current fallback list.
  51316. * @param currentRank defines the current fallback rank.
  51317. * @returns the new fallback rank.
  51318. */
  51319. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  51320. if (defines.ANISOTROPIC) {
  51321. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  51322. }
  51323. return currentRank;
  51324. };
  51325. /**
  51326. * Add the required uniforms to the current list.
  51327. * @param uniforms defines the current uniform list.
  51328. */
  51329. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  51330. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  51331. };
  51332. /**
  51333. * Add the required uniforms to the current buffer.
  51334. * @param uniformBuffer defines the current uniform buffer.
  51335. */
  51336. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  51337. uniformBuffer.addUniform("vAnisotropy", 3);
  51338. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  51339. uniformBuffer.addUniform("anisotropyMatrix", 16);
  51340. };
  51341. /**
  51342. * Add the required samplers to the current list.
  51343. * @param samplers defines the current sampler list.
  51344. */
  51345. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  51346. samplers.push("anisotropySampler");
  51347. };
  51348. /**
  51349. * Makes a duplicate of the current configuration into another one.
  51350. * @param anisotropicConfiguration define the config where to copy the info
  51351. */
  51352. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  51353. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  51354. };
  51355. /**
  51356. * Serializes this anisotropy configuration.
  51357. * @returns - An object with the serialized config.
  51358. */
  51359. PBRAnisotropicConfiguration.prototype.serialize = function () {
  51360. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51361. };
  51362. /**
  51363. * Parses a anisotropy Configuration from a serialized object.
  51364. * @param source - Serialized object.
  51365. */
  51366. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  51367. var _this = this;
  51368. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51369. };
  51370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51372. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  51373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51375. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  51376. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51377. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51378. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  51379. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  51381. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  51382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51384. ], PBRAnisotropicConfiguration.prototype, "_texture", void 0);
  51385. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51386. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51387. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  51388. return PBRAnisotropicConfiguration;
  51389. }());
  51390. /***/ }),
  51391. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  51392. /*!***********************************************!*\
  51393. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  51394. \***********************************************/
  51395. /*! exports provided: PBRBRDFConfiguration */
  51396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51397. "use strict";
  51398. __webpack_require__.r(__webpack_exports__);
  51399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  51400. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51401. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51402. /**
  51403. * Define the code related to the BRDF parameters of the pbr material.
  51404. */
  51405. var PBRBRDFConfiguration = /** @class */ (function () {
  51406. /**
  51407. * Instantiate a new istance of clear coat configuration.
  51408. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51409. */
  51410. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  51411. this._useEnergyConservation = true;
  51412. /**
  51413. * Defines if the material uses energy conservation.
  51414. */
  51415. this.useEnergyConservation = true;
  51416. this._useSmithVisibilityHeightCorrelated = true;
  51417. /**
  51418. * LEGACY Mode set to false
  51419. * Defines if the material uses height smith correlated visibility term.
  51420. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51421. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51422. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51423. * Not relying on height correlated will also disable energy conservation.
  51424. */
  51425. this.useSmithVisibilityHeightCorrelated = true;
  51426. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51427. }
  51428. /** @hidden */
  51429. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51430. this._internalMarkAllSubMeshesAsMiscDirty();
  51431. };
  51432. /**
  51433. * Checks to see if a texture is used in the material.
  51434. * @param defines the list of "defines" to update.
  51435. */
  51436. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  51437. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  51438. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  51439. };
  51440. /**
  51441. * Get the current class name of the texture useful for serialization or dynamic coding.
  51442. * @returns "PBRClearCoatConfiguration"
  51443. */
  51444. PBRBRDFConfiguration.prototype.getClassName = function () {
  51445. return "PBRClearCoatConfiguration";
  51446. };
  51447. /**
  51448. * Makes a duplicate of the current configuration into another one.
  51449. * @param brdfConfiguration define the config where to copy the info
  51450. */
  51451. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  51452. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  51453. };
  51454. /**
  51455. * Serializes this BRDF configuration.
  51456. * @returns - An object with the serialized config.
  51457. */
  51458. PBRBRDFConfiguration.prototype.serialize = function () {
  51459. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51460. };
  51461. /**
  51462. * Parses a BRDF Configuration from a serialized object.
  51463. * @param source - Serialized object.
  51464. */
  51465. PBRBRDFConfiguration.prototype.parse = function (source) {
  51466. var _this = this;
  51467. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51468. };
  51469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51471. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  51472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51474. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  51475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51476. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51477. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  51478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51480. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  51481. return PBRBRDFConfiguration;
  51482. }());
  51483. /***/ }),
  51484. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  51485. /*!******************************************!*\
  51486. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  51487. \******************************************/
  51488. /*! exports provided: PBRBaseMaterial */
  51489. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51490. "use strict";
  51491. __webpack_require__.r(__webpack_exports__);
  51492. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  51493. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51494. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51495. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  51496. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  51497. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  51498. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  51499. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51500. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51501. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  51502. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  51503. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  51504. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  51505. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  51506. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  51507. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  51508. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  51509. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51510. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  51511. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  51512. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  51513. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  51514. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  51515. /**
  51516. * Manages the defines for the PBR Material.
  51517. * @hiddenChildren
  51518. */
  51519. var PBRMaterialDefines = /** @class */ (function (_super) {
  51520. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  51521. /**
  51522. * Initializes the PBR Material defines.
  51523. */
  51524. function PBRMaterialDefines() {
  51525. var _this = _super.call(this) || this;
  51526. _this.PBR = true;
  51527. _this.MAINUV1 = false;
  51528. _this.MAINUV2 = false;
  51529. _this.UV1 = false;
  51530. _this.UV2 = false;
  51531. _this.ALBEDO = false;
  51532. _this.ALBEDODIRECTUV = 0;
  51533. _this.VERTEXCOLOR = false;
  51534. _this.AMBIENT = false;
  51535. _this.AMBIENTDIRECTUV = 0;
  51536. _this.AMBIENTINGRAYSCALE = false;
  51537. _this.OPACITY = false;
  51538. _this.VERTEXALPHA = false;
  51539. _this.OPACITYDIRECTUV = 0;
  51540. _this.OPACITYRGB = false;
  51541. _this.ALPHATEST = false;
  51542. _this.DEPTHPREPASS = false;
  51543. _this.ALPHABLEND = false;
  51544. _this.ALPHAFROMALBEDO = false;
  51545. _this.ALPHATESTVALUE = "0.5";
  51546. _this.SPECULAROVERALPHA = false;
  51547. _this.RADIANCEOVERALPHA = false;
  51548. _this.ALPHAFRESNEL = false;
  51549. _this.LINEARALPHAFRESNEL = false;
  51550. _this.PREMULTIPLYALPHA = false;
  51551. _this.EMISSIVE = false;
  51552. _this.EMISSIVEDIRECTUV = 0;
  51553. _this.REFLECTIVITY = false;
  51554. _this.REFLECTIVITYDIRECTUV = 0;
  51555. _this.SPECULARTERM = false;
  51556. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  51557. _this.MICROSURFACEAUTOMATIC = false;
  51558. _this.LODBASEDMICROSFURACE = false;
  51559. _this.MICROSURFACEMAP = false;
  51560. _this.MICROSURFACEMAPDIRECTUV = 0;
  51561. _this.METALLICWORKFLOW = false;
  51562. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  51563. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  51564. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  51565. _this.AOSTOREINMETALMAPRED = false;
  51566. _this.ENVIRONMENTBRDF = false;
  51567. _this.NORMAL = false;
  51568. _this.TANGENT = false;
  51569. _this.BUMP = false;
  51570. _this.BUMPDIRECTUV = 0;
  51571. _this.OBJECTSPACE_NORMALMAP = false;
  51572. _this.PARALLAX = false;
  51573. _this.PARALLAXOCCLUSION = false;
  51574. _this.NORMALXYSCALE = true;
  51575. _this.LIGHTMAP = false;
  51576. _this.LIGHTMAPDIRECTUV = 0;
  51577. _this.USELIGHTMAPASSHADOWMAP = false;
  51578. _this.GAMMALIGHTMAP = false;
  51579. _this.REFLECTION = false;
  51580. _this.REFLECTIONMAP_3D = false;
  51581. _this.REFLECTIONMAP_SPHERICAL = false;
  51582. _this.REFLECTIONMAP_PLANAR = false;
  51583. _this.REFLECTIONMAP_CUBIC = false;
  51584. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51585. _this.REFLECTIONMAP_PROJECTION = false;
  51586. _this.REFLECTIONMAP_SKYBOX = false;
  51587. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51588. _this.REFLECTIONMAP_EXPLICIT = false;
  51589. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51590. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51591. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51592. _this.INVERTCUBICMAP = false;
  51593. _this.USESPHERICALFROMREFLECTIONMAP = false;
  51594. _this.USESPHERICALINVERTEX = false;
  51595. _this.REFLECTIONMAP_OPPOSITEZ = false;
  51596. _this.LODINREFLECTIONALPHA = false;
  51597. _this.GAMMAREFLECTION = false;
  51598. _this.RGBDREFLECTION = false;
  51599. _this.RADIANCEOCCLUSION = false;
  51600. _this.HORIZONOCCLUSION = false;
  51601. _this.REFRACTION = false;
  51602. _this.REFRACTIONMAP_3D = false;
  51603. _this.REFRACTIONMAP_OPPOSITEZ = false;
  51604. _this.LODINREFRACTIONALPHA = false;
  51605. _this.GAMMAREFRACTION = false;
  51606. _this.RGBDREFRACTION = false;
  51607. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  51608. _this.INSTANCES = false;
  51609. _this.NUM_BONE_INFLUENCERS = 0;
  51610. _this.BonesPerMesh = 0;
  51611. _this.BONETEXTURE = false;
  51612. _this.NONUNIFORMSCALING = false;
  51613. _this.MORPHTARGETS = false;
  51614. _this.MORPHTARGETS_NORMAL = false;
  51615. _this.MORPHTARGETS_TANGENT = false;
  51616. _this.NUM_MORPH_INFLUENCERS = 0;
  51617. _this.IMAGEPROCESSING = false;
  51618. _this.VIGNETTE = false;
  51619. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  51620. _this.VIGNETTEBLENDMODEOPAQUE = false;
  51621. _this.TONEMAPPING = false;
  51622. _this.TONEMAPPING_ACES = false;
  51623. _this.CONTRAST = false;
  51624. _this.COLORCURVES = false;
  51625. _this.COLORGRADING = false;
  51626. _this.COLORGRADING3D = false;
  51627. _this.SAMPLER3DGREENDEPTH = false;
  51628. _this.SAMPLER3DBGRMAP = false;
  51629. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  51630. _this.EXPOSURE = false;
  51631. _this.USEPHYSICALLIGHTFALLOFF = false;
  51632. _this.USEGLTFLIGHTFALLOFF = false;
  51633. _this.TWOSIDEDLIGHTING = false;
  51634. _this.SHADOWFLOAT = false;
  51635. _this.CLIPPLANE = false;
  51636. _this.CLIPPLANE2 = false;
  51637. _this.CLIPPLANE3 = false;
  51638. _this.CLIPPLANE4 = false;
  51639. _this.POINTSIZE = false;
  51640. _this.FOG = false;
  51641. _this.LOGARITHMICDEPTH = false;
  51642. _this.FORCENORMALFORWARD = false;
  51643. _this.SPECULARAA = false;
  51644. _this.CLEARCOAT = false;
  51645. _this.CLEARCOAT_DEFAULTIOR = false;
  51646. _this.CLEARCOAT_TEXTURE = false;
  51647. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  51648. _this.CLEARCOAT_BUMP = false;
  51649. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  51650. _this.CLEARCOAT_TINT = false;
  51651. _this.CLEARCOAT_TINT_TEXTURE = false;
  51652. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  51653. _this.ANISOTROPIC = false;
  51654. _this.ANISOTROPIC_TEXTURE = false;
  51655. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  51656. _this.BRDF_V_HEIGHT_CORRELATED = false;
  51657. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  51658. _this.SHEEN = false;
  51659. _this.SHEEN_TEXTURE = false;
  51660. _this.SHEEN_TEXTUREDIRECTUV = 0;
  51661. _this.SHEEN_LINKWITHALBEDO = false;
  51662. _this.UNLIT = false;
  51663. _this.DEBUGMODE = 0;
  51664. _this.rebuild();
  51665. return _this;
  51666. }
  51667. /**
  51668. * Resets the PBR Material defines.
  51669. */
  51670. PBRMaterialDefines.prototype.reset = function () {
  51671. _super.prototype.reset.call(this);
  51672. this.ALPHATESTVALUE = "0.5";
  51673. this.PBR = true;
  51674. };
  51675. return PBRMaterialDefines;
  51676. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_14__["MaterialDefines"]));
  51677. /**
  51678. * The Physically based material base class of BJS.
  51679. *
  51680. * This offers the main features of a standard PBR material.
  51681. * For more information, please refer to the documentation :
  51682. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  51683. */
  51684. var PBRBaseMaterial = /** @class */ (function (_super) {
  51685. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  51686. /**
  51687. * Instantiates a new PBRMaterial instance.
  51688. *
  51689. * @param name The material name
  51690. * @param scene The scene the material will be use in.
  51691. */
  51692. function PBRBaseMaterial(name, scene) {
  51693. var _this = _super.call(this, name, scene) || this;
  51694. /**
  51695. * Intensity of the direct lights e.g. the four lights available in your scene.
  51696. * This impacts both the direct diffuse and specular highlights.
  51697. */
  51698. _this._directIntensity = 1.0;
  51699. /**
  51700. * Intensity of the emissive part of the material.
  51701. * This helps controlling the emissive effect without modifying the emissive color.
  51702. */
  51703. _this._emissiveIntensity = 1.0;
  51704. /**
  51705. * Intensity of the environment e.g. how much the environment will light the object
  51706. * either through harmonics for rough material or through the refelction for shiny ones.
  51707. */
  51708. _this._environmentIntensity = 1.0;
  51709. /**
  51710. * This is a special control allowing the reduction of the specular highlights coming from the
  51711. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51712. */
  51713. _this._specularIntensity = 1.0;
  51714. /**
  51715. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51716. */
  51717. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  51718. /**
  51719. * Debug Control allowing disabling the bump map on this material.
  51720. */
  51721. _this._disableBumpMap = false;
  51722. /**
  51723. * AKA Occlusion Texture Intensity in other nomenclature.
  51724. */
  51725. _this._ambientTextureStrength = 1.0;
  51726. /**
  51727. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51728. * 1 means it completely occludes it
  51729. * 0 mean it has no impact
  51730. */
  51731. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51732. /**
  51733. * The color of a material in ambient lighting.
  51734. */
  51735. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51736. /**
  51737. * AKA Diffuse Color in other nomenclature.
  51738. */
  51739. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51740. /**
  51741. * AKA Specular Color in other nomenclature.
  51742. */
  51743. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51744. /**
  51745. * The color applied when light is reflected from a material.
  51746. */
  51747. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51748. /**
  51749. * The color applied when light is emitted from a material.
  51750. */
  51751. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51752. /**
  51753. * AKA Glossiness in other nomenclature.
  51754. */
  51755. _this._microSurface = 0.9;
  51756. /**
  51757. * source material index of refraction (IOR)' / 'destination material IOR.
  51758. */
  51759. _this._indexOfRefraction = 0.66;
  51760. /**
  51761. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51762. */
  51763. _this._invertRefractionY = false;
  51764. /**
  51765. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51766. * Materials half opaque for instance using refraction could benefit from this control.
  51767. */
  51768. _this._linkRefractionWithTransparency = false;
  51769. /**
  51770. * Specifies that the material will use the light map as a show map.
  51771. */
  51772. _this._useLightmapAsShadowmap = false;
  51773. /**
  51774. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51775. * makes the reflect vector face the model (under horizon).
  51776. */
  51777. _this._useHorizonOcclusion = true;
  51778. /**
  51779. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51780. * too much the area relying on ambient texture to define their ambient occlusion.
  51781. */
  51782. _this._useRadianceOcclusion = true;
  51783. /**
  51784. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51785. */
  51786. _this._useAlphaFromAlbedoTexture = false;
  51787. /**
  51788. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51789. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51790. */
  51791. _this._useSpecularOverAlpha = true;
  51792. /**
  51793. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51794. */
  51795. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  51796. /**
  51797. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51798. */
  51799. _this._useRoughnessFromMetallicTextureAlpha = true;
  51800. /**
  51801. * Specifies if the metallic texture contains the roughness information in its green channel.
  51802. */
  51803. _this._useRoughnessFromMetallicTextureGreen = false;
  51804. /**
  51805. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51806. */
  51807. _this._useMetallnessFromMetallicTextureBlue = false;
  51808. /**
  51809. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51810. */
  51811. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  51812. /**
  51813. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51814. */
  51815. _this._useAmbientInGrayScale = false;
  51816. /**
  51817. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51818. * The material will try to infer what glossiness each pixel should be.
  51819. */
  51820. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  51821. /**
  51822. * Defines the falloff type used in this material.
  51823. * It by default is Physical.
  51824. */
  51825. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  51826. /**
  51827. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51828. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51829. */
  51830. _this._useRadianceOverAlpha = true;
  51831. /**
  51832. * Allows using an object space normal map (instead of tangent space).
  51833. */
  51834. _this._useObjectSpaceNormalMap = false;
  51835. /**
  51836. * Allows using the bump map in parallax mode.
  51837. */
  51838. _this._useParallax = false;
  51839. /**
  51840. * Allows using the bump map in parallax occlusion mode.
  51841. */
  51842. _this._useParallaxOcclusion = false;
  51843. /**
  51844. * Controls the scale bias of the parallax mode.
  51845. */
  51846. _this._parallaxScaleBias = 0.05;
  51847. /**
  51848. * If sets to true, disables all the lights affecting the material.
  51849. */
  51850. _this._disableLighting = false;
  51851. /**
  51852. * Number of Simultaneous lights allowed on the material.
  51853. */
  51854. _this._maxSimultaneousLights = 4;
  51855. /**
  51856. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51857. */
  51858. _this._invertNormalMapX = false;
  51859. /**
  51860. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51861. */
  51862. _this._invertNormalMapY = false;
  51863. /**
  51864. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51865. */
  51866. _this._twoSidedLighting = false;
  51867. /**
  51868. * Defines the alpha limits in alpha test mode.
  51869. */
  51870. _this._alphaCutOff = 0.4;
  51871. /**
  51872. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51873. */
  51874. _this._forceAlphaTest = false;
  51875. /**
  51876. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51877. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51878. */
  51879. _this._useAlphaFresnel = false;
  51880. /**
  51881. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51882. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51883. */
  51884. _this._useLinearAlphaFresnel = false;
  51885. /**
  51886. * The transparency mode of the material.
  51887. */
  51888. _this._transparencyMode = null;
  51889. /**
  51890. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51891. * from cos thetav and roughness:
  51892. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51893. */
  51894. _this._environmentBRDFTexture = null;
  51895. /**
  51896. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51897. */
  51898. _this._forceIrradianceInFragment = false;
  51899. /**
  51900. * Force normal to face away from face.
  51901. */
  51902. _this._forceNormalForward = false;
  51903. /**
  51904. * Enables specular anti aliasing in the PBR shader.
  51905. * It will both interacts on the Geometry for analytical and IBL lighting.
  51906. * It also prefilter the roughness map based on the bump values.
  51907. */
  51908. _this._enableSpecularAntiAliasing = false;
  51909. /**
  51910. * Stores the available render targets.
  51911. */
  51912. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  51913. /**
  51914. * Sets the global ambient color for the material used in lighting calculations.
  51915. */
  51916. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51917. /**
  51918. * If set to true, no lighting calculations will be applied.
  51919. */
  51920. _this._unlit = false;
  51921. _this._debugMode = 0;
  51922. /**
  51923. * @hidden
  51924. * This is reserved for the inspector.
  51925. * Defines the material debug mode.
  51926. * It helps seeing only some components of the material while troubleshooting.
  51927. */
  51928. _this.debugMode = 0;
  51929. /**
  51930. * @hidden
  51931. * This is reserved for the inspector.
  51932. * Specify from where on screen the debug mode should start.
  51933. * The value goes from -1 (full screen) to 1 (not visible)
  51934. * It helps with side by side comparison against the final render
  51935. * This defaults to -1
  51936. */
  51937. _this.debugLimit = -1;
  51938. /**
  51939. * @hidden
  51940. * This is reserved for the inspector.
  51941. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51942. * You can use the factor to better multiply the final value.
  51943. */
  51944. _this.debugFactor = 1;
  51945. /**
  51946. * Defines the clear coat layer parameters for the material.
  51947. */
  51948. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  51949. /**
  51950. * Defines the anisotropic parameters for the material.
  51951. */
  51952. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  51953. /**
  51954. * Defines the BRDF parameters for the material.
  51955. */
  51956. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  51957. /**
  51958. * Defines the Sheen parameters for the material.
  51959. */
  51960. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  51961. // Setup the default processing configuration to the scene.
  51962. _this._attachImageProcessingConfiguration(null);
  51963. _this.getRenderTargetTextures = function () {
  51964. _this._renderTargets.reset();
  51965. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  51966. _this._renderTargets.push(_this._reflectionTexture);
  51967. }
  51968. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  51969. _this._renderTargets.push(_this._refractionTexture);
  51970. }
  51971. return _this._renderTargets;
  51972. };
  51973. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  51974. return _this;
  51975. }
  51976. /**
  51977. * Attaches a new image processing configuration to the PBR Material.
  51978. * @param configuration
  51979. */
  51980. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  51981. var _this = this;
  51982. if (configuration === this._imageProcessingConfiguration) {
  51983. return;
  51984. }
  51985. // Detaches observer.
  51986. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51987. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51988. }
  51989. // Pick the scene configuration if needed.
  51990. if (!configuration) {
  51991. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  51992. }
  51993. else {
  51994. this._imageProcessingConfiguration = configuration;
  51995. }
  51996. // Attaches observer.
  51997. if (this._imageProcessingConfiguration) {
  51998. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  51999. _this._markAllSubMeshesAsImageProcessingDirty();
  52000. });
  52001. }
  52002. };
  52003. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  52004. /**
  52005. * Gets a boolean indicating that current material needs to register RTT
  52006. */
  52007. get: function () {
  52008. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52009. return true;
  52010. }
  52011. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  52012. return true;
  52013. }
  52014. return false;
  52015. },
  52016. enumerable: true,
  52017. configurable: true
  52018. });
  52019. /**
  52020. * Gets the name of the material class.
  52021. */
  52022. PBRBaseMaterial.prototype.getClassName = function () {
  52023. return "PBRBaseMaterial";
  52024. };
  52025. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  52026. /**
  52027. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52028. */
  52029. get: function () {
  52030. return this._useLogarithmicDepth;
  52031. },
  52032. /**
  52033. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52034. */
  52035. set: function (value) {
  52036. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  52037. },
  52038. enumerable: true,
  52039. configurable: true
  52040. });
  52041. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  52042. /**
  52043. * Gets the current transparency mode.
  52044. */
  52045. get: function () {
  52046. return this._transparencyMode;
  52047. },
  52048. /**
  52049. * Sets the transparency mode of the material.
  52050. *
  52051. * | Value | Type | Description |
  52052. * | ----- | ----------------------------------- | ----------- |
  52053. * | 0 | OPAQUE | |
  52054. * | 1 | ALPHATEST | |
  52055. * | 2 | ALPHABLEND | |
  52056. * | 3 | ALPHATESTANDBLEND | |
  52057. *
  52058. */
  52059. set: function (value) {
  52060. if (this._transparencyMode === value) {
  52061. return;
  52062. }
  52063. this._transparencyMode = value;
  52064. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  52065. this._markAllSubMeshesAsTexturesAndMiscDirty();
  52066. },
  52067. enumerable: true,
  52068. configurable: true
  52069. });
  52070. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  52071. /**
  52072. * Returns true if alpha blending should be disabled.
  52073. */
  52074. get: function () {
  52075. return (this._linkRefractionWithTransparency ||
  52076. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  52077. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52078. },
  52079. enumerable: true,
  52080. configurable: true
  52081. });
  52082. /**
  52083. * Specifies whether or not this material should be rendered in alpha blend mode.
  52084. */
  52085. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  52086. if (this._disableAlphaBlending) {
  52087. return false;
  52088. }
  52089. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  52090. };
  52091. /**
  52092. * Specifies if the mesh will require alpha blending.
  52093. * @param mesh - BJS mesh.
  52094. */
  52095. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  52096. if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
  52097. return false;
  52098. }
  52099. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  52100. };
  52101. /**
  52102. * Specifies whether or not this material should be rendered in alpha test mode.
  52103. */
  52104. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  52105. if (this._forceAlphaTest) {
  52106. return true;
  52107. }
  52108. if (this._linkRefractionWithTransparency) {
  52109. return false;
  52110. }
  52111. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52112. };
  52113. /**
  52114. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52115. */
  52116. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  52117. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  52118. };
  52119. /**
  52120. * Gets the texture used for the alpha test.
  52121. */
  52122. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  52123. return this._albedoTexture;
  52124. };
  52125. /**
  52126. * Specifies that the submesh is ready to be used.
  52127. * @param mesh - BJS mesh.
  52128. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52129. * @param useInstances - Specifies that instances should be used.
  52130. * @returns - boolean indicating that the submesh is ready or not.
  52131. */
  52132. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  52133. if (subMesh.effect && this.isFrozen) {
  52134. if (this._wasPreviouslyReady) {
  52135. return true;
  52136. }
  52137. }
  52138. if (!subMesh._materialDefines) {
  52139. subMesh._materialDefines = new PBRMaterialDefines();
  52140. }
  52141. var defines = subMesh._materialDefines;
  52142. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  52143. if (defines._renderId === this.getScene().getRenderId()) {
  52144. return true;
  52145. }
  52146. }
  52147. var scene = this.getScene();
  52148. var engine = scene.getEngine();
  52149. if (defines._areTexturesDirty) {
  52150. if (scene.texturesEnabled) {
  52151. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52152. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  52153. return false;
  52154. }
  52155. }
  52156. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52157. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  52158. return false;
  52159. }
  52160. }
  52161. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52162. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  52163. return false;
  52164. }
  52165. }
  52166. var reflectionTexture = this._getReflectionTexture();
  52167. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52168. if (!reflectionTexture.isReadyOrNotBlocking()) {
  52169. return false;
  52170. }
  52171. }
  52172. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52173. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  52174. return false;
  52175. }
  52176. }
  52177. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52178. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  52179. return false;
  52180. }
  52181. }
  52182. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52183. if (this._metallicTexture) {
  52184. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  52185. return false;
  52186. }
  52187. }
  52188. else if (this._reflectivityTexture) {
  52189. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  52190. return false;
  52191. }
  52192. }
  52193. if (this._microSurfaceTexture) {
  52194. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  52195. return false;
  52196. }
  52197. }
  52198. }
  52199. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52200. // Bump texture cannot be not blocking.
  52201. if (!this._bumpTexture.isReady()) {
  52202. return false;
  52203. }
  52204. }
  52205. var refractionTexture = this._getRefractionTexture();
  52206. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52207. if (!refractionTexture.isReadyOrNotBlocking()) {
  52208. return false;
  52209. }
  52210. }
  52211. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52212. // This is blocking.
  52213. if (!this._environmentBRDFTexture.isReady()) {
  52214. return false;
  52215. }
  52216. }
  52217. }
  52218. }
  52219. if (!this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap)) {
  52220. return false;
  52221. }
  52222. if (!this.sheen.isReadyForSubMesh(defines, scene)) {
  52223. return false;
  52224. }
  52225. if (!this.anisotropy.isReadyForSubMesh(defines, scene)) {
  52226. return false;
  52227. }
  52228. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52229. if (!this._imageProcessingConfiguration.isReady()) {
  52230. return false;
  52231. }
  52232. }
  52233. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  52234. mesh.createNormals(true);
  52235. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  52236. }
  52237. var previousEffect = subMesh.effect;
  52238. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  52239. if (effect) {
  52240. // Use previous effect while new one is compiling
  52241. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  52242. effect = previousEffect;
  52243. defines.markAsUnprocessed();
  52244. }
  52245. else {
  52246. scene.resetCachedMaterial();
  52247. subMesh.setEffect(effect, defines);
  52248. this.buildUniformLayout();
  52249. }
  52250. }
  52251. if (!subMesh.effect || !subMesh.effect.isReady()) {
  52252. return false;
  52253. }
  52254. defines._renderId = scene.getRenderId();
  52255. this._wasPreviouslyReady = true;
  52256. return true;
  52257. };
  52258. /**
  52259. * Specifies if the material uses metallic roughness workflow.
  52260. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52261. */
  52262. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  52263. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  52264. return true;
  52265. }
  52266. return false;
  52267. };
  52268. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  52269. if (onCompiled === void 0) { onCompiled = null; }
  52270. if (onError === void 0) { onError = null; }
  52271. if (useInstances === void 0) { useInstances = null; }
  52272. if (useClipPlane === void 0) { useClipPlane = null; }
  52273. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  52274. if (!defines.isDirty) {
  52275. return null;
  52276. }
  52277. defines.markAsProcessed();
  52278. var scene = this.getScene();
  52279. var engine = scene.getEngine();
  52280. // Fallbacks
  52281. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_13__["EffectFallbacks"]();
  52282. var fallbackRank = 0;
  52283. if (defines.USESPHERICALINVERTEX) {
  52284. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  52285. }
  52286. if (defines.FOG) {
  52287. fallbacks.addFallback(fallbackRank, "FOG");
  52288. }
  52289. if (defines.SPECULARAA) {
  52290. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  52291. }
  52292. if (defines.POINTSIZE) {
  52293. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  52294. }
  52295. if (defines.LOGARITHMICDEPTH) {
  52296. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  52297. }
  52298. if (defines.PARALLAX) {
  52299. fallbacks.addFallback(fallbackRank, "PARALLAX");
  52300. }
  52301. if (defines.PARALLAXOCCLUSION) {
  52302. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  52303. }
  52304. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52305. fallbackRank = _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52306. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52307. if (defines.ENVIRONMENTBRDF) {
  52308. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  52309. }
  52310. if (defines.TANGENT) {
  52311. fallbacks.addFallback(fallbackRank++, "TANGENT");
  52312. }
  52313. if (defines.BUMP) {
  52314. fallbacks.addFallback(fallbackRank++, "BUMP");
  52315. }
  52316. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  52317. if (defines.SPECULARTERM) {
  52318. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  52319. }
  52320. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  52321. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  52322. }
  52323. if (defines.LIGHTMAP) {
  52324. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  52325. }
  52326. if (defines.NORMAL) {
  52327. fallbacks.addFallback(fallbackRank++, "NORMAL");
  52328. }
  52329. if (defines.AMBIENT) {
  52330. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  52331. }
  52332. if (defines.EMISSIVE) {
  52333. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  52334. }
  52335. if (defines.VERTEXCOLOR) {
  52336. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  52337. }
  52338. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52339. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  52340. }
  52341. if (defines.MORPHTARGETS) {
  52342. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  52343. }
  52344. //Attributes
  52345. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  52346. if (defines.NORMAL) {
  52347. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  52348. }
  52349. if (defines.TANGENT) {
  52350. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  52351. }
  52352. if (defines.UV1) {
  52353. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  52354. }
  52355. if (defines.UV2) {
  52356. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  52357. }
  52358. if (defines.VERTEXCOLOR) {
  52359. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  52360. }
  52361. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52362. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52363. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  52364. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  52365. "vFogInfos", "vFogColor", "pointSize",
  52366. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  52367. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  52368. "mBones",
  52369. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  52370. "vLightingIntensity",
  52371. "logarithmicDepthConstant",
  52372. "vSphericalX", "vSphericalY", "vSphericalZ",
  52373. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  52374. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  52375. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  52376. "vTangentSpaceParams", "boneTextureWidth",
  52377. "vDebugMode"
  52378. ];
  52379. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  52380. "bumpSampler", "lightmapSampler", "opacitySampler",
  52381. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  52382. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  52383. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  52384. var uniformBuffers = ["Material", "Scene"];
  52385. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  52386. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  52387. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  52388. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  52389. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  52390. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  52391. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  52392. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  52393. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  52394. }
  52395. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareUniformsAndSamplersList({
  52396. uniformsNames: uniforms,
  52397. uniformBuffersNames: uniformBuffers,
  52398. samplers: samplers,
  52399. defines: defines,
  52400. maxSimultaneousLights: this._maxSimultaneousLights
  52401. });
  52402. var join = defines.toString();
  52403. return engine.createEffect("pbr", {
  52404. attributes: attribs,
  52405. uniformsNames: uniforms,
  52406. uniformBuffersNames: uniformBuffers,
  52407. samplers: samplers,
  52408. defines: join,
  52409. fallbacks: fallbacks,
  52410. onCompiled: onCompiled,
  52411. onError: onError,
  52412. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  52413. }, engine);
  52414. };
  52415. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  52416. if (useInstances === void 0) { useInstances = null; }
  52417. if (useClipPlane === void 0) { useClipPlane = null; }
  52418. var scene = this.getScene();
  52419. var engine = scene.getEngine();
  52420. // Lights
  52421. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  52422. defines._needNormals = true;
  52423. // Textures
  52424. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  52425. if (defines._areTexturesDirty) {
  52426. defines._needUVs = false;
  52427. if (scene.texturesEnabled) {
  52428. if (scene.getEngine().getCaps().textureLOD) {
  52429. defines.LODBASEDMICROSFURACE = true;
  52430. }
  52431. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52432. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  52433. }
  52434. else {
  52435. defines.ALBEDO = false;
  52436. }
  52437. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52438. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  52439. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  52440. }
  52441. else {
  52442. defines.AMBIENT = false;
  52443. }
  52444. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52445. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  52446. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  52447. }
  52448. else {
  52449. defines.OPACITY = false;
  52450. }
  52451. var reflectionTexture = this._getReflectionTexture();
  52452. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52453. defines.REFLECTION = true;
  52454. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  52455. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  52456. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  52457. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  52458. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].INVCUBIC_MODE) {
  52459. defines.INVERTCUBICMAP = true;
  52460. }
  52461. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  52462. defines.REFLECTIONMAP_CUBIC = false;
  52463. defines.REFLECTIONMAP_EXPLICIT = false;
  52464. defines.REFLECTIONMAP_PLANAR = false;
  52465. defines.REFLECTIONMAP_PROJECTION = false;
  52466. defines.REFLECTIONMAP_SKYBOX = false;
  52467. defines.REFLECTIONMAP_SPHERICAL = false;
  52468. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52469. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52470. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52471. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52472. switch (reflectionTexture.coordinatesMode) {
  52473. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].EXPLICIT_MODE:
  52474. defines.REFLECTIONMAP_EXPLICIT = true;
  52475. break;
  52476. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].PLANAR_MODE:
  52477. defines.REFLECTIONMAP_PLANAR = true;
  52478. break;
  52479. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].PROJECTION_MODE:
  52480. defines.REFLECTIONMAP_PROJECTION = true;
  52481. break;
  52482. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SKYBOX_MODE:
  52483. defines.REFLECTIONMAP_SKYBOX = true;
  52484. break;
  52485. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SPHERICAL_MODE:
  52486. defines.REFLECTIONMAP_SPHERICAL = true;
  52487. break;
  52488. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].EQUIRECTANGULAR_MODE:
  52489. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  52490. break;
  52491. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  52492. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  52493. break;
  52494. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  52495. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  52496. break;
  52497. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].CUBIC_MODE:
  52498. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].INVCUBIC_MODE:
  52499. default:
  52500. defines.REFLECTIONMAP_CUBIC = true;
  52501. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  52502. break;
  52503. }
  52504. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SKYBOX_MODE) {
  52505. if (reflectionTexture.sphericalPolynomial) {
  52506. defines.USESPHERICALFROMREFLECTIONMAP = true;
  52507. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  52508. defines.USESPHERICALINVERTEX = false;
  52509. }
  52510. else {
  52511. defines.USESPHERICALINVERTEX = true;
  52512. }
  52513. }
  52514. }
  52515. else {
  52516. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  52517. }
  52518. }
  52519. else {
  52520. defines.REFLECTION = false;
  52521. defines.REFLECTIONMAP_3D = false;
  52522. defines.REFLECTIONMAP_SPHERICAL = false;
  52523. defines.REFLECTIONMAP_PLANAR = false;
  52524. defines.REFLECTIONMAP_CUBIC = false;
  52525. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  52526. defines.REFLECTIONMAP_PROJECTION = false;
  52527. defines.REFLECTIONMAP_SKYBOX = false;
  52528. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52529. defines.REFLECTIONMAP_EXPLICIT = false;
  52530. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52531. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52532. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52533. defines.INVERTCUBICMAP = false;
  52534. defines.USESPHERICALFROMREFLECTIONMAP = false;
  52535. defines.USESPHERICALINVERTEX = false;
  52536. defines.REFLECTIONMAP_OPPOSITEZ = false;
  52537. defines.LODINREFLECTIONALPHA = false;
  52538. defines.GAMMAREFLECTION = false;
  52539. defines.RGBDREFLECTION = false;
  52540. }
  52541. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52542. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  52543. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  52544. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  52545. }
  52546. else {
  52547. defines.LIGHTMAP = false;
  52548. }
  52549. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52550. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  52551. }
  52552. else {
  52553. defines.EMISSIVE = false;
  52554. }
  52555. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52556. if (this._metallicTexture) {
  52557. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  52558. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  52559. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  52560. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  52561. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  52562. }
  52563. else if (this._reflectivityTexture) {
  52564. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  52565. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  52566. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  52567. }
  52568. else {
  52569. defines.REFLECTIVITY = false;
  52570. }
  52571. if (this._microSurfaceTexture) {
  52572. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  52573. }
  52574. else {
  52575. defines.MICROSURFACEMAP = false;
  52576. }
  52577. }
  52578. else {
  52579. defines.REFLECTIVITY = false;
  52580. defines.MICROSURFACEMAP = false;
  52581. }
  52582. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52583. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  52584. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52585. defines.PARALLAX = true;
  52586. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  52587. }
  52588. else {
  52589. defines.PARALLAX = false;
  52590. }
  52591. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  52592. }
  52593. else {
  52594. defines.BUMP = false;
  52595. }
  52596. var refractionTexture = this._getRefractionTexture();
  52597. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52598. defines.REFRACTION = true;
  52599. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  52600. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  52601. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  52602. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  52603. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  52604. if (this._linkRefractionWithTransparency) {
  52605. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  52606. }
  52607. }
  52608. else {
  52609. defines.REFRACTION = false;
  52610. }
  52611. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52612. defines.ENVIRONMENTBRDF = true;
  52613. }
  52614. else {
  52615. defines.ENVIRONMENTBRDF = false;
  52616. }
  52617. if (this._shouldUseAlphaFromAlbedoTexture()) {
  52618. defines.ALPHAFROMALBEDO = true;
  52619. }
  52620. else {
  52621. defines.ALPHAFROMALBEDO = false;
  52622. }
  52623. }
  52624. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  52625. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  52626. defines.USEPHYSICALLIGHTFALLOFF = false;
  52627. defines.USEGLTFLIGHTFALLOFF = false;
  52628. }
  52629. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  52630. defines.USEPHYSICALLIGHTFALLOFF = false;
  52631. defines.USEGLTFLIGHTFALLOFF = true;
  52632. }
  52633. else {
  52634. defines.USEPHYSICALLIGHTFALLOFF = true;
  52635. defines.USEGLTFLIGHTFALLOFF = false;
  52636. }
  52637. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  52638. if (!this.backFaceCulling && this._twoSidedLighting) {
  52639. defines.TWOSIDEDLIGHTING = true;
  52640. }
  52641. else {
  52642. defines.TWOSIDEDLIGHTING = false;
  52643. }
  52644. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  52645. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  52646. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  52647. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  52648. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  52649. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  52650. }
  52651. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52652. this._imageProcessingConfiguration.prepareDefines(defines);
  52653. }
  52654. defines.FORCENORMALFORWARD = this._forceNormalForward;
  52655. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  52656. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  52657. // Misc.
  52658. if (defines._areMiscDirty) {
  52659. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  52660. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  52661. defines.DEBUGMODE = this._debugMode;
  52662. }
  52663. // External config
  52664. this.clearCoat.prepareDefines(defines, scene);
  52665. this.anisotropy.prepareDefines(defines, mesh, scene);
  52666. this.brdf.prepareDefines(defines);
  52667. this.sheen.prepareDefines(defines, scene);
  52668. // Values that need to be evaluated on every frame
  52669. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  52670. // Attribs
  52671. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  52672. };
  52673. /**
  52674. * Force shader compilation
  52675. */
  52676. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  52677. var _this = this;
  52678. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  52679. var defines = new PBRMaterialDefines();
  52680. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  52681. if (effect.isReady()) {
  52682. if (onCompiled) {
  52683. onCompiled(this);
  52684. }
  52685. }
  52686. else {
  52687. effect.onCompileObservable.add(function () {
  52688. if (onCompiled) {
  52689. onCompiled(_this);
  52690. }
  52691. });
  52692. }
  52693. };
  52694. /**
  52695. * Initializes the uniform buffer layout for the shader.
  52696. */
  52697. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  52698. // Order is important !
  52699. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  52700. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  52701. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  52702. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  52703. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  52704. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  52705. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  52706. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  52707. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  52708. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  52709. this._uniformBuffer.addUniform("vReflectionSize", 3);
  52710. this._uniformBuffer.addUniform("vBumpInfos", 3);
  52711. this._uniformBuffer.addUniform("albedoMatrix", 16);
  52712. this._uniformBuffer.addUniform("ambientMatrix", 16);
  52713. this._uniformBuffer.addUniform("opacityMatrix", 16);
  52714. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  52715. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  52716. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  52717. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  52718. this._uniformBuffer.addUniform("bumpMatrix", 16);
  52719. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  52720. this._uniformBuffer.addUniform("refractionMatrix", 16);
  52721. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  52722. this._uniformBuffer.addUniform("vReflectionColor", 3);
  52723. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  52724. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  52725. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  52726. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  52727. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  52728. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  52729. this._uniformBuffer.addUniform("pointSize", 1);
  52730. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52731. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52732. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52733. this._uniformBuffer.create();
  52734. };
  52735. /**
  52736. * Unbinds the textures.
  52737. */
  52738. PBRBaseMaterial.prototype.unbind = function () {
  52739. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52740. this._uniformBuffer.setTexture("reflectionSampler", null);
  52741. }
  52742. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  52743. this._uniformBuffer.setTexture("refractionSampler", null);
  52744. }
  52745. _super.prototype.unbind.call(this);
  52746. };
  52747. /**
  52748. * Binds the submesh data.
  52749. * @param world - The world matrix.
  52750. * @param mesh - The BJS mesh.
  52751. * @param subMesh - A submesh of the BJS mesh.
  52752. */
  52753. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  52754. var scene = this.getScene();
  52755. var defines = subMesh._materialDefines;
  52756. if (!defines) {
  52757. return;
  52758. }
  52759. var effect = subMesh.effect;
  52760. if (!effect) {
  52761. return;
  52762. }
  52763. this._activeEffect = effect;
  52764. // Matrices
  52765. this.bindOnlyWorldMatrix(world);
  52766. // Normal Matrix
  52767. if (defines.OBJECTSPACE_NORMALMAP) {
  52768. world.toNormalMatrix(this._normalMatrix);
  52769. this.bindOnlyNormalMatrix(this._normalMatrix);
  52770. }
  52771. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  52772. // Bones
  52773. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  52774. var reflectionTexture = null;
  52775. if (mustRebind) {
  52776. var engine = scene.getEngine();
  52777. this._uniformBuffer.bindToEffect(effect, "Material");
  52778. this.bindViewProjection(effect);
  52779. reflectionTexture = this._getReflectionTexture();
  52780. var refractionTexture = this._getRefractionTexture();
  52781. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  52782. // Texture uniforms
  52783. if (scene.texturesEnabled) {
  52784. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52785. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  52786. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  52787. }
  52788. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52789. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  52790. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  52791. }
  52792. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52793. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  52794. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  52795. }
  52796. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52797. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  52798. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  52799. if (reflectionTexture.boundingBoxSize) {
  52800. var cubeTexture = reflectionTexture;
  52801. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  52802. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  52803. }
  52804. var polynomials = reflectionTexture.sphericalPolynomial;
  52805. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  52806. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  52807. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  52808. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  52809. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  52810. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  52811. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  52812. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  52813. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  52814. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  52815. }
  52816. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  52817. }
  52818. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52819. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  52820. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  52821. }
  52822. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52823. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  52824. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  52825. }
  52826. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52827. if (this._metallicTexture) {
  52828. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  52829. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  52830. }
  52831. else if (this._reflectivityTexture) {
  52832. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  52833. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  52834. }
  52835. if (this._microSurfaceTexture) {
  52836. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  52837. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  52838. }
  52839. }
  52840. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52841. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  52842. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  52843. if (scene._mirroredCameraPosition) {
  52844. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  52845. }
  52846. else {
  52847. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  52848. }
  52849. }
  52850. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52851. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  52852. var depth = 1.0;
  52853. if (!refractionTexture.isCube) {
  52854. if (refractionTexture.depth) {
  52855. depth = refractionTexture.depth;
  52856. }
  52857. }
  52858. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  52859. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  52860. }
  52861. }
  52862. // Point size
  52863. if (this.pointsCloud) {
  52864. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  52865. }
  52866. // Colors
  52867. if (defines.METALLICWORKFLOW) {
  52868. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  52869. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  52870. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  52871. }
  52872. else {
  52873. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  52874. }
  52875. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  52876. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  52877. var alpha = this._disableAlphaBlending ? mesh.visibility : this.alpha * mesh.visibility;
  52878. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, alpha);
  52879. // Misc
  52880. this._lightingInfos.x = this._directIntensity;
  52881. this._lightingInfos.y = this._emissiveIntensity;
  52882. this._lightingInfos.z = this._environmentIntensity;
  52883. this._lightingInfos.w = this._specularIntensity;
  52884. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  52885. }
  52886. // Textures
  52887. if (scene.texturesEnabled) {
  52888. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52889. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  52890. }
  52891. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52892. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  52893. }
  52894. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52895. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  52896. }
  52897. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52898. if (defines.LODBASEDMICROSFURACE) {
  52899. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  52900. }
  52901. else {
  52902. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  52903. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  52904. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  52905. }
  52906. }
  52907. if (defines.ENVIRONMENTBRDF) {
  52908. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  52909. }
  52910. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52911. if (defines.LODBASEDMICROSFURACE) {
  52912. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  52913. }
  52914. else {
  52915. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  52916. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  52917. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  52918. }
  52919. }
  52920. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52921. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  52922. }
  52923. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52924. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  52925. }
  52926. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52927. if (this._metallicTexture) {
  52928. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  52929. }
  52930. else if (this._reflectivityTexture) {
  52931. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  52932. }
  52933. if (this._microSurfaceTexture) {
  52934. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  52935. }
  52936. }
  52937. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52938. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  52939. }
  52940. }
  52941. this.clearCoat.bindForSubMesh(this._uniformBuffer, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  52942. this.anisotropy.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  52943. this.sheen.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  52944. // Clip plane
  52945. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  52946. // Colors
  52947. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  52948. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  52949. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  52950. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  52951. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  52952. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  52953. }
  52954. if (mustRebind || !this.isFrozen) {
  52955. // Lights
  52956. if (scene.lightsEnabled && !this._disableLighting) {
  52957. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  52958. }
  52959. // View
  52960. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  52961. this.bindView(effect);
  52962. }
  52963. // Fog
  52964. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  52965. // Morph targets
  52966. if (defines.NUM_MORPH_INFLUENCERS) {
  52967. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  52968. }
  52969. // image processing
  52970. this._imageProcessingConfiguration.bind(this._activeEffect);
  52971. // Log. depth
  52972. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  52973. }
  52974. this._uniformBuffer.update();
  52975. this._afterBind(mesh, this._activeEffect);
  52976. };
  52977. /**
  52978. * Returns the animatable textures.
  52979. * @returns - Array of animatable textures.
  52980. */
  52981. PBRBaseMaterial.prototype.getAnimatables = function () {
  52982. var results = [];
  52983. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  52984. results.push(this._albedoTexture);
  52985. }
  52986. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  52987. results.push(this._ambientTexture);
  52988. }
  52989. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  52990. results.push(this._opacityTexture);
  52991. }
  52992. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  52993. results.push(this._reflectionTexture);
  52994. }
  52995. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  52996. results.push(this._emissiveTexture);
  52997. }
  52998. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  52999. results.push(this._metallicTexture);
  53000. }
  53001. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  53002. results.push(this._reflectivityTexture);
  53003. }
  53004. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53005. results.push(this._bumpTexture);
  53006. }
  53007. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  53008. results.push(this._lightmapTexture);
  53009. }
  53010. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  53011. results.push(this._refractionTexture);
  53012. }
  53013. this.clearCoat.getAnimatables(results);
  53014. this.sheen.getAnimatables(results);
  53015. this.anisotropy.getAnimatables(results);
  53016. return results;
  53017. };
  53018. /**
  53019. * Returns the texture used for reflections.
  53020. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53021. */
  53022. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  53023. if (this._reflectionTexture) {
  53024. return this._reflectionTexture;
  53025. }
  53026. return this.getScene().environmentTexture;
  53027. };
  53028. /**
  53029. * Returns the texture used for refraction or null if none is used.
  53030. * @returns - Refection texture if present. If no refraction texture and refraction
  53031. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53032. */
  53033. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  53034. if (this._refractionTexture) {
  53035. return this._refractionTexture;
  53036. }
  53037. if (this._linkRefractionWithTransparency) {
  53038. return this.getScene().environmentTexture;
  53039. }
  53040. return null;
  53041. };
  53042. /**
  53043. * Returns an array of the actively used textures.
  53044. * @returns - Array of BaseTextures
  53045. */
  53046. PBRBaseMaterial.prototype.getActiveTextures = function () {
  53047. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53048. if (this._albedoTexture) {
  53049. activeTextures.push(this._albedoTexture);
  53050. }
  53051. if (this._ambientTexture) {
  53052. activeTextures.push(this._ambientTexture);
  53053. }
  53054. if (this._opacityTexture) {
  53055. activeTextures.push(this._opacityTexture);
  53056. }
  53057. if (this._reflectionTexture) {
  53058. activeTextures.push(this._reflectionTexture);
  53059. }
  53060. if (this._emissiveTexture) {
  53061. activeTextures.push(this._emissiveTexture);
  53062. }
  53063. if (this._reflectivityTexture) {
  53064. activeTextures.push(this._reflectivityTexture);
  53065. }
  53066. if (this._metallicTexture) {
  53067. activeTextures.push(this._metallicTexture);
  53068. }
  53069. if (this._microSurfaceTexture) {
  53070. activeTextures.push(this._microSurfaceTexture);
  53071. }
  53072. if (this._bumpTexture) {
  53073. activeTextures.push(this._bumpTexture);
  53074. }
  53075. if (this._lightmapTexture) {
  53076. activeTextures.push(this._lightmapTexture);
  53077. }
  53078. if (this._refractionTexture) {
  53079. activeTextures.push(this._refractionTexture);
  53080. }
  53081. this.clearCoat.getActiveTextures(activeTextures);
  53082. this.sheen.getActiveTextures(activeTextures);
  53083. this.anisotropy.getActiveTextures(activeTextures);
  53084. return activeTextures;
  53085. };
  53086. /**
  53087. * Checks to see if a texture is used in the material.
  53088. * @param texture - Base texture to use.
  53089. * @returns - Boolean specifying if a texture is used in the material.
  53090. */
  53091. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  53092. if (_super.prototype.hasTexture.call(this, texture)) {
  53093. return true;
  53094. }
  53095. if (this._albedoTexture === texture) {
  53096. return true;
  53097. }
  53098. if (this._ambientTexture === texture) {
  53099. return true;
  53100. }
  53101. if (this._opacityTexture === texture) {
  53102. return true;
  53103. }
  53104. if (this._reflectionTexture === texture) {
  53105. return true;
  53106. }
  53107. if (this._reflectivityTexture === texture) {
  53108. return true;
  53109. }
  53110. if (this._metallicTexture === texture) {
  53111. return true;
  53112. }
  53113. if (this._microSurfaceTexture === texture) {
  53114. return true;
  53115. }
  53116. if (this._bumpTexture === texture) {
  53117. return true;
  53118. }
  53119. if (this._lightmapTexture === texture) {
  53120. return true;
  53121. }
  53122. return this.clearCoat.hasTexture(texture) ||
  53123. this.sheen.hasTexture(texture) ||
  53124. this.anisotropy.hasTexture(texture);
  53125. };
  53126. /**
  53127. * Disposes the resources of the material.
  53128. * @param forceDisposeEffect - Forces the disposal of effects.
  53129. * @param forceDisposeTextures - Forces the disposal of all textures.
  53130. */
  53131. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  53132. if (forceDisposeTextures) {
  53133. if (this._albedoTexture) {
  53134. this._albedoTexture.dispose();
  53135. }
  53136. if (this._ambientTexture) {
  53137. this._ambientTexture.dispose();
  53138. }
  53139. if (this._opacityTexture) {
  53140. this._opacityTexture.dispose();
  53141. }
  53142. if (this._reflectionTexture) {
  53143. this._reflectionTexture.dispose();
  53144. }
  53145. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  53146. this._environmentBRDFTexture.dispose();
  53147. }
  53148. if (this._emissiveTexture) {
  53149. this._emissiveTexture.dispose();
  53150. }
  53151. if (this._metallicTexture) {
  53152. this._metallicTexture.dispose();
  53153. }
  53154. if (this._reflectivityTexture) {
  53155. this._reflectivityTexture.dispose();
  53156. }
  53157. if (this._bumpTexture) {
  53158. this._bumpTexture.dispose();
  53159. }
  53160. if (this._lightmapTexture) {
  53161. this._lightmapTexture.dispose();
  53162. }
  53163. if (this._refractionTexture) {
  53164. this._refractionTexture.dispose();
  53165. }
  53166. }
  53167. this.clearCoat.dispose(forceDisposeTextures);
  53168. this.sheen.dispose(forceDisposeTextures);
  53169. this.anisotropy.dispose(forceDisposeTextures);
  53170. this._renderTargets.dispose();
  53171. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  53172. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  53173. }
  53174. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  53175. };
  53176. /**
  53177. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53178. */
  53179. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  53180. /**
  53181. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53182. */
  53183. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  53184. /**
  53185. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53186. */
  53187. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  53188. /**
  53189. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53190. * They are also discarded below the alpha cutoff threshold to improve performances.
  53191. */
  53192. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  53193. /**
  53194. * Defines the default value of how much AO map is occluding the analytical lights
  53195. * (point spot...).
  53196. */
  53197. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  53198. /**
  53199. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53200. */
  53201. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  53202. /**
  53203. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53204. * to enhance interoperability with other engines.
  53205. */
  53206. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  53207. /**
  53208. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53209. * to enhance interoperability with other materials.
  53210. */
  53211. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  53212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  53214. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  53215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53217. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  53218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53220. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  53221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53223. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  53224. return PBRBaseMaterial;
  53225. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_15__["PushMaterial"]));
  53226. /***/ }),
  53227. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  53228. /*!************************************************!*\
  53229. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  53230. \************************************************/
  53231. /*! exports provided: PBRBaseSimpleMaterial */
  53232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53233. "use strict";
  53234. __webpack_require__.r(__webpack_exports__);
  53235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  53236. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53237. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53238. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53239. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53240. /**
  53241. * The Physically based simple base material of BJS.
  53242. *
  53243. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53244. * It is used as the base class for both the specGloss and metalRough conventions.
  53245. */
  53246. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  53247. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  53248. /**
  53249. * Instantiates a new PBRMaterial instance.
  53250. *
  53251. * @param name The material name
  53252. * @param scene The scene the material will be use in.
  53253. */
  53254. function PBRBaseSimpleMaterial(name, scene) {
  53255. var _this = _super.call(this, name, scene) || this;
  53256. /**
  53257. * Number of Simultaneous lights allowed on the material.
  53258. */
  53259. _this.maxSimultaneousLights = 4;
  53260. /**
  53261. * If sets to true, disables all the lights affecting the material.
  53262. */
  53263. _this.disableLighting = false;
  53264. /**
  53265. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53266. */
  53267. _this.invertNormalMapX = false;
  53268. /**
  53269. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53270. */
  53271. _this.invertNormalMapY = false;
  53272. /**
  53273. * Emissivie color used to self-illuminate the model.
  53274. */
  53275. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  53276. /**
  53277. * Occlusion Channel Strenght.
  53278. */
  53279. _this.occlusionStrength = 1.0;
  53280. /**
  53281. * If true, the light map contains occlusion information instead of lighting info.
  53282. */
  53283. _this.useLightmapAsShadowmap = false;
  53284. _this._useAlphaFromAlbedoTexture = true;
  53285. _this._useAmbientInGrayScale = true;
  53286. return _this;
  53287. }
  53288. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  53289. /**
  53290. * Gets the current double sided mode.
  53291. */
  53292. get: function () {
  53293. return this._twoSidedLighting;
  53294. },
  53295. /**
  53296. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53297. */
  53298. set: function (value) {
  53299. if (this._twoSidedLighting === value) {
  53300. return;
  53301. }
  53302. this._twoSidedLighting = value;
  53303. this.backFaceCulling = !value;
  53304. this._markAllSubMeshesAsTexturesDirty();
  53305. },
  53306. enumerable: true,
  53307. configurable: true
  53308. });
  53309. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  53310. return "PBRBaseSimpleMaterial";
  53311. };
  53312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53315. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  53316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53319. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  53320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  53323. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  53324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53327. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  53328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53331. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  53332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  53335. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  53336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53339. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  53340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53343. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  53344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  53347. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  53348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  53351. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  53352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  53355. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  53356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53358. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  53359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  53362. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  53363. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53364. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53366. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53367. return PBRBaseSimpleMaterial;
  53368. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  53369. /***/ }),
  53370. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  53371. /*!****************************************************!*\
  53372. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  53373. \****************************************************/
  53374. /*! exports provided: PBRClearCoatConfiguration */
  53375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53376. "use strict";
  53377. __webpack_require__.r(__webpack_exports__);
  53378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  53379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53380. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53381. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53382. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53383. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53384. /**
  53385. * Define the code related to the clear coat parameters of the pbr material.
  53386. */
  53387. var PBRClearCoatConfiguration = /** @class */ (function () {
  53388. /**
  53389. * Instantiate a new istance of clear coat configuration.
  53390. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53391. */
  53392. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  53393. this._isEnabled = false;
  53394. /**
  53395. * Defines if the clear coat is enabled in the material.
  53396. */
  53397. this.isEnabled = false;
  53398. /**
  53399. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53400. */
  53401. this.intensity = 1;
  53402. /**
  53403. * Defines the clear coat layer roughness.
  53404. */
  53405. this.roughness = 0;
  53406. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53407. /**
  53408. * Defines the indice of refraction of the clear coat.
  53409. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53410. * The default fits with a polyurethane material.
  53411. * Changing the default value is more performance intensive.
  53412. */
  53413. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53414. this._texture = null;
  53415. /**
  53416. * Stores the clear coat values in a texture.
  53417. */
  53418. this.texture = null;
  53419. this._bumpTexture = null;
  53420. /**
  53421. * Define the clear coat specific bump texture.
  53422. */
  53423. this.bumpTexture = null;
  53424. this._isTintEnabled = false;
  53425. /**
  53426. * Defines if the clear coat tint is enabled in the material.
  53427. */
  53428. this.isTintEnabled = false;
  53429. /**
  53430. * Defines if the clear coat tint is enabled in the material.
  53431. * This is only use if tint is enabled
  53432. */
  53433. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  53434. /**
  53435. * Defines if the distance at which the tint color should be found in the
  53436. * clear coat media.
  53437. * This is only use if tint is enabled
  53438. */
  53439. this.tintColorAtDistance = 1;
  53440. /**
  53441. * Defines the clear coat layer thickness.
  53442. * This is only use if tint is enabled
  53443. */
  53444. this.tintThickness = 1;
  53445. this._tintTexture = null;
  53446. /**
  53447. * Stores the clear tint values in a texture.
  53448. * rgb is tint
  53449. * a is a thickness factor
  53450. */
  53451. this.tintTexture = null;
  53452. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  53453. }
  53454. /** @hidden */
  53455. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  53456. this._internalMarkAllSubMeshesAsTexturesDirty();
  53457. };
  53458. /**
  53459. * Specifies that the submesh is ready to be used.
  53460. * @param defines the list of "defines" to update.
  53461. * @param scene defines the scene the material belongs to.
  53462. * @param engine defines the engine the material belongs to.
  53463. * @param disableBumpMap defines wether the material disables bump or not.
  53464. * @returns - boolean indicating that the submesh is ready or not.
  53465. */
  53466. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  53467. if (defines._areTexturesDirty) {
  53468. if (scene.texturesEnabled) {
  53469. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53470. if (!this._texture.isReadyOrNotBlocking()) {
  53471. return false;
  53472. }
  53473. }
  53474. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53475. // Bump texture cannot be not blocking.
  53476. if (!this._bumpTexture.isReady()) {
  53477. return false;
  53478. }
  53479. }
  53480. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53481. if (!this._tintTexture.isReadyOrNotBlocking()) {
  53482. return false;
  53483. }
  53484. }
  53485. }
  53486. }
  53487. return true;
  53488. };
  53489. /**
  53490. * Checks to see if a texture is used in the material.
  53491. * @param defines the list of "defines" to update.
  53492. * @param scene defines the scene to the material belongs to.
  53493. */
  53494. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  53495. if (this._isEnabled) {
  53496. defines.CLEARCOAT = true;
  53497. if (defines._areTexturesDirty) {
  53498. if (scene.texturesEnabled) {
  53499. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53500. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  53501. }
  53502. else {
  53503. defines.CLEARCOAT_TEXTURE = false;
  53504. }
  53505. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  53506. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  53507. }
  53508. else {
  53509. defines.CLEARCOAT_BUMP = false;
  53510. }
  53511. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53512. if (this._isTintEnabled) {
  53513. defines.CLEARCOAT_TINT = true;
  53514. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53515. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  53516. }
  53517. else {
  53518. defines.CLEARCOAT_TINT_TEXTURE = false;
  53519. }
  53520. }
  53521. else {
  53522. defines.CLEARCOAT_TINT = false;
  53523. defines.CLEARCOAT_TINT_TEXTURE = false;
  53524. }
  53525. }
  53526. }
  53527. }
  53528. else {
  53529. defines.CLEARCOAT = false;
  53530. defines.CLEARCOAT_TEXTURE = false;
  53531. defines.CLEARCOAT_BUMP = false;
  53532. defines.CLEARCOAT_TINT = false;
  53533. defines.CLEARCOAT_TINT_TEXTURE = false;
  53534. }
  53535. };
  53536. /**
  53537. * Binds the material data.
  53538. * @param uniformBuffer defines the Uniform buffer to fill in.
  53539. * @param scene defines the scene the material belongs to.
  53540. * @param engine defines the engine the material belongs to.
  53541. * @param disableBumpMap defines wether the material disables bump or not.
  53542. * @param isFrozen defines wether the material is frozen or not.
  53543. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53544. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53545. */
  53546. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  53547. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  53548. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53549. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  53550. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  53551. }
  53552. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  53553. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  53554. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  53555. if (scene._mirroredCameraPosition) {
  53556. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  53557. }
  53558. else {
  53559. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  53560. }
  53561. }
  53562. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53563. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  53564. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  53565. }
  53566. // Clear Coat General params
  53567. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  53568. // Clear Coat Refraction params
  53569. var a = 1 - this._indiceOfRefraction;
  53570. var b = 1 + this._indiceOfRefraction;
  53571. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  53572. var eta = 1 / this._indiceOfRefraction;
  53573. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  53574. if (this._isTintEnabled) {
  53575. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  53576. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  53577. }
  53578. }
  53579. // Textures
  53580. if (scene.texturesEnabled) {
  53581. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53582. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  53583. }
  53584. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53585. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  53586. }
  53587. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53588. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  53589. }
  53590. }
  53591. };
  53592. /**
  53593. * Checks to see if a texture is used in the material.
  53594. * @param texture - Base texture to use.
  53595. * @returns - Boolean specifying if a texture is used in the material.
  53596. */
  53597. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  53598. if (this._texture === texture) {
  53599. return true;
  53600. }
  53601. if (this._bumpTexture === texture) {
  53602. return true;
  53603. }
  53604. if (this._tintTexture === texture) {
  53605. return true;
  53606. }
  53607. return false;
  53608. };
  53609. /**
  53610. * Returns an array of the actively used textures.
  53611. * @param activeTextures Array of BaseTextures
  53612. */
  53613. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  53614. if (this._texture) {
  53615. activeTextures.push(this._texture);
  53616. }
  53617. if (this._bumpTexture) {
  53618. activeTextures.push(this._bumpTexture);
  53619. }
  53620. if (this._tintTexture) {
  53621. activeTextures.push(this._tintTexture);
  53622. }
  53623. };
  53624. /**
  53625. * Returns the animatable textures.
  53626. * @param animatables Array of animatable textures.
  53627. */
  53628. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  53629. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  53630. animatables.push(this._texture);
  53631. }
  53632. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53633. animatables.push(this._bumpTexture);
  53634. }
  53635. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  53636. animatables.push(this._tintTexture);
  53637. }
  53638. };
  53639. /**
  53640. * Disposes the resources of the material.
  53641. * @param forceDisposeTextures - Forces the disposal of all textures.
  53642. */
  53643. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  53644. if (forceDisposeTextures) {
  53645. if (this._texture) {
  53646. this._texture.dispose();
  53647. }
  53648. if (this._bumpTexture) {
  53649. this._bumpTexture.dispose();
  53650. }
  53651. if (this._tintTexture) {
  53652. this._tintTexture.dispose();
  53653. }
  53654. }
  53655. };
  53656. /**
  53657. * Get the current class name of the texture useful for serialization or dynamic coding.
  53658. * @returns "PBRClearCoatConfiguration"
  53659. */
  53660. PBRClearCoatConfiguration.prototype.getClassName = function () {
  53661. return "PBRClearCoatConfiguration";
  53662. };
  53663. /**
  53664. * Add fallbacks to the effect fallbacks list.
  53665. * @param defines defines the Base texture to use.
  53666. * @param fallbacks defines the current fallback list.
  53667. * @param currentRank defines the current fallback rank.
  53668. * @returns the new fallback rank.
  53669. */
  53670. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  53671. if (defines.CLEARCOAT_BUMP) {
  53672. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  53673. }
  53674. if (defines.CLEARCOAT_TINT) {
  53675. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  53676. }
  53677. if (defines.CLEARCOAT) {
  53678. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  53679. }
  53680. return currentRank;
  53681. };
  53682. /**
  53683. * Add the required uniforms to the current list.
  53684. * @param uniforms defines the current uniform list.
  53685. */
  53686. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  53687. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  53688. };
  53689. /**
  53690. * Add the required samplers to the current list.
  53691. * @param samplers defines the current sampler list.
  53692. */
  53693. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  53694. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  53695. };
  53696. /**
  53697. * Add the required uniforms to the current buffer.
  53698. * @param uniformBuffer defines the current uniform buffer.
  53699. */
  53700. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  53701. uniformBuffer.addUniform("vClearCoatParams", 2);
  53702. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  53703. uniformBuffer.addUniform("vClearCoatInfos", 2);
  53704. uniformBuffer.addUniform("clearCoatMatrix", 16);
  53705. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  53706. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  53707. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  53708. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  53709. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  53710. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  53711. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  53712. };
  53713. /**
  53714. * Makes a duplicate of the current configuration into another one.
  53715. * @param clearCoatConfiguration define the config where to copy the info
  53716. */
  53717. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  53718. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  53719. };
  53720. /**
  53721. * Serializes this clear coat configuration.
  53722. * @returns - An object with the serialized config.
  53723. */
  53724. PBRClearCoatConfiguration.prototype.serialize = function () {
  53725. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53726. };
  53727. /**
  53728. * Parses a Clear Coat Configuration from a serialized object.
  53729. * @param source - Serialized object.
  53730. */
  53731. PBRClearCoatConfiguration.prototype.parse = function (source) {
  53732. var _this = this;
  53733. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  53734. };
  53735. /**
  53736. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53737. * The default fits with a polyurethane material.
  53738. */
  53739. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  53740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53742. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  53743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53745. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  53746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53748. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  53749. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53750. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53751. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  53752. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53754. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  53755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53757. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  53758. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53759. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53760. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  53761. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53762. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53763. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  53764. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53765. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53766. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  53767. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53769. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  53770. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53771. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53772. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  53773. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53774. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53775. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  53776. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53777. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  53778. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  53779. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53780. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53781. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  53782. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53783. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53784. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  53785. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53786. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53787. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  53788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53790. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  53791. return PBRClearCoatConfiguration;
  53792. }());
  53793. /***/ }),
  53794. /***/ "./Materials/PBR/pbrMaterial.ts":
  53795. /*!**************************************!*\
  53796. !*** ./Materials/PBR/pbrMaterial.ts ***!
  53797. \**************************************/
  53798. /*! exports provided: PBRMaterial */
  53799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53800. "use strict";
  53801. __webpack_require__.r(__webpack_exports__);
  53802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  53803. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53804. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53805. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  53806. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53807. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53808. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53809. /**
  53810. * The Physically based material of BJS.
  53811. *
  53812. * This offers the main features of a standard PBR material.
  53813. * For more information, please refer to the documentation :
  53814. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  53815. */
  53816. var PBRMaterial = /** @class */ (function (_super) {
  53817. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  53818. /**
  53819. * Instantiates a new PBRMaterial instance.
  53820. *
  53821. * @param name The material name
  53822. * @param scene The scene the material will be use in.
  53823. */
  53824. function PBRMaterial(name, scene) {
  53825. var _this = _super.call(this, name, scene) || this;
  53826. /**
  53827. * Intensity of the direct lights e.g. the four lights available in your scene.
  53828. * This impacts both the direct diffuse and specular highlights.
  53829. */
  53830. _this.directIntensity = 1.0;
  53831. /**
  53832. * Intensity of the emissive part of the material.
  53833. * This helps controlling the emissive effect without modifying the emissive color.
  53834. */
  53835. _this.emissiveIntensity = 1.0;
  53836. /**
  53837. * Intensity of the environment e.g. how much the environment will light the object
  53838. * either through harmonics for rough material or through the refelction for shiny ones.
  53839. */
  53840. _this.environmentIntensity = 1.0;
  53841. /**
  53842. * This is a special control allowing the reduction of the specular highlights coming from the
  53843. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53844. */
  53845. _this.specularIntensity = 1.0;
  53846. /**
  53847. * Debug Control allowing disabling the bump map on this material.
  53848. */
  53849. _this.disableBumpMap = false;
  53850. /**
  53851. * AKA Occlusion Texture Intensity in other nomenclature.
  53852. */
  53853. _this.ambientTextureStrength = 1.0;
  53854. /**
  53855. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53856. * 1 means it completely occludes it
  53857. * 0 mean it has no impact
  53858. */
  53859. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  53860. /**
  53861. * The color of a material in ambient lighting.
  53862. */
  53863. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  53864. /**
  53865. * AKA Diffuse Color in other nomenclature.
  53866. */
  53867. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  53868. /**
  53869. * AKA Specular Color in other nomenclature.
  53870. */
  53871. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  53872. /**
  53873. * The color reflected from the material.
  53874. */
  53875. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  53876. /**
  53877. * The color emitted from the material.
  53878. */
  53879. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  53880. /**
  53881. * AKA Glossiness in other nomenclature.
  53882. */
  53883. _this.microSurface = 1.0;
  53884. /**
  53885. * source material index of refraction (IOR)' / 'destination material IOR.
  53886. */
  53887. _this.indexOfRefraction = 0.66;
  53888. /**
  53889. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53890. */
  53891. _this.invertRefractionY = false;
  53892. /**
  53893. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53894. * Materials half opaque for instance using refraction could benefit from this control.
  53895. */
  53896. _this.linkRefractionWithTransparency = false;
  53897. /**
  53898. * If true, the light map contains occlusion information instead of lighting info.
  53899. */
  53900. _this.useLightmapAsShadowmap = false;
  53901. /**
  53902. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53903. */
  53904. _this.useAlphaFromAlbedoTexture = false;
  53905. /**
  53906. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53907. */
  53908. _this.forceAlphaTest = false;
  53909. /**
  53910. * Defines the alpha limits in alpha test mode.
  53911. */
  53912. _this.alphaCutOff = 0.4;
  53913. /**
  53914. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53915. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53916. */
  53917. _this.useSpecularOverAlpha = true;
  53918. /**
  53919. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53920. */
  53921. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  53922. /**
  53923. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53924. */
  53925. _this.useRoughnessFromMetallicTextureAlpha = true;
  53926. /**
  53927. * Specifies if the metallic texture contains the roughness information in its green channel.
  53928. */
  53929. _this.useRoughnessFromMetallicTextureGreen = false;
  53930. /**
  53931. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53932. */
  53933. _this.useMetallnessFromMetallicTextureBlue = false;
  53934. /**
  53935. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53936. */
  53937. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  53938. /**
  53939. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53940. */
  53941. _this.useAmbientInGrayScale = false;
  53942. /**
  53943. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53944. * The material will try to infer what glossiness each pixel should be.
  53945. */
  53946. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  53947. /**
  53948. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53949. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53950. */
  53951. _this.useRadianceOverAlpha = true;
  53952. /**
  53953. * Allows using an object space normal map (instead of tangent space).
  53954. */
  53955. _this.useObjectSpaceNormalMap = false;
  53956. /**
  53957. * Allows using the bump map in parallax mode.
  53958. */
  53959. _this.useParallax = false;
  53960. /**
  53961. * Allows using the bump map in parallax occlusion mode.
  53962. */
  53963. _this.useParallaxOcclusion = false;
  53964. /**
  53965. * Controls the scale bias of the parallax mode.
  53966. */
  53967. _this.parallaxScaleBias = 0.05;
  53968. /**
  53969. * If sets to true, disables all the lights affecting the material.
  53970. */
  53971. _this.disableLighting = false;
  53972. /**
  53973. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53974. */
  53975. _this.forceIrradianceInFragment = false;
  53976. /**
  53977. * Number of Simultaneous lights allowed on the material.
  53978. */
  53979. _this.maxSimultaneousLights = 4;
  53980. /**
  53981. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53982. */
  53983. _this.invertNormalMapX = false;
  53984. /**
  53985. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53986. */
  53987. _this.invertNormalMapY = false;
  53988. /**
  53989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53990. */
  53991. _this.twoSidedLighting = false;
  53992. /**
  53993. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53994. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53995. */
  53996. _this.useAlphaFresnel = false;
  53997. /**
  53998. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53999. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54000. */
  54001. _this.useLinearAlphaFresnel = false;
  54002. /**
  54003. * Let user defines the brdf lookup texture used for IBL.
  54004. * A default 8bit version is embedded but you could point at :
  54005. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  54006. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54007. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54008. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54009. */
  54010. _this.environmentBRDFTexture = null;
  54011. /**
  54012. * Force normal to face away from face.
  54013. */
  54014. _this.forceNormalForward = false;
  54015. /**
  54016. * Enables specular anti aliasing in the PBR shader.
  54017. * It will both interacts on the Geometry for analytical and IBL lighting.
  54018. * It also prefilter the roughness map based on the bump values.
  54019. */
  54020. _this.enableSpecularAntiAliasing = false;
  54021. /**
  54022. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54023. * makes the reflect vector face the model (under horizon).
  54024. */
  54025. _this.useHorizonOcclusion = true;
  54026. /**
  54027. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54028. * too much the area relying on ambient texture to define their ambient occlusion.
  54029. */
  54030. _this.useRadianceOcclusion = true;
  54031. /**
  54032. * If set to true, no lighting calculations will be applied.
  54033. */
  54034. _this.unlit = false;
  54035. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  54036. return _this;
  54037. }
  54038. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  54039. /**
  54040. * BJS is using an harcoded light falloff based on a manually sets up range.
  54041. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54042. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54043. */
  54044. get: function () {
  54045. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54046. },
  54047. /**
  54048. * BJS is using an harcoded light falloff based on a manually sets up range.
  54049. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54050. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54051. */
  54052. set: function (value) {
  54053. if (value !== this.usePhysicalLightFalloff) {
  54054. // Ensure the effect will be rebuilt.
  54055. this._markAllSubMeshesAsTexturesDirty();
  54056. if (value) {
  54057. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54058. }
  54059. else {
  54060. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54061. }
  54062. }
  54063. },
  54064. enumerable: true,
  54065. configurable: true
  54066. });
  54067. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  54068. /**
  54069. * In order to support the falloff compatibility with gltf, a special mode has been added
  54070. * to reproduce the gltf light falloff.
  54071. */
  54072. get: function () {
  54073. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54074. },
  54075. /**
  54076. * In order to support the falloff compatibility with gltf, a special mode has been added
  54077. * to reproduce the gltf light falloff.
  54078. */
  54079. set: function (value) {
  54080. if (value !== this.useGLTFLightFalloff) {
  54081. // Ensure the effect will be rebuilt.
  54082. this._markAllSubMeshesAsTexturesDirty();
  54083. if (value) {
  54084. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54085. }
  54086. else {
  54087. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54088. }
  54089. }
  54090. },
  54091. enumerable: true,
  54092. configurable: true
  54093. });
  54094. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  54095. /**
  54096. * Gets the image processing configuration used either in this material.
  54097. */
  54098. get: function () {
  54099. return this._imageProcessingConfiguration;
  54100. },
  54101. /**
  54102. * Sets the Default image processing configuration used either in the this material.
  54103. *
  54104. * If sets to null, the scene one is in use.
  54105. */
  54106. set: function (value) {
  54107. this._attachImageProcessingConfiguration(value);
  54108. // Ensure the effect will be rebuilt.
  54109. this._markAllSubMeshesAsTexturesDirty();
  54110. },
  54111. enumerable: true,
  54112. configurable: true
  54113. });
  54114. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  54115. /**
  54116. * Gets wether the color curves effect is enabled.
  54117. */
  54118. get: function () {
  54119. return this.imageProcessingConfiguration.colorCurvesEnabled;
  54120. },
  54121. /**
  54122. * Sets wether the color curves effect is enabled.
  54123. */
  54124. set: function (value) {
  54125. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  54126. },
  54127. enumerable: true,
  54128. configurable: true
  54129. });
  54130. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  54131. /**
  54132. * Gets wether the color grading effect is enabled.
  54133. */
  54134. get: function () {
  54135. return this.imageProcessingConfiguration.colorGradingEnabled;
  54136. },
  54137. /**
  54138. * Gets wether the color grading effect is enabled.
  54139. */
  54140. set: function (value) {
  54141. this.imageProcessingConfiguration.colorGradingEnabled = value;
  54142. },
  54143. enumerable: true,
  54144. configurable: true
  54145. });
  54146. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  54147. /**
  54148. * Gets wether tonemapping is enabled or not.
  54149. */
  54150. get: function () {
  54151. return this._imageProcessingConfiguration.toneMappingEnabled;
  54152. },
  54153. /**
  54154. * Sets wether tonemapping is enabled or not
  54155. */
  54156. set: function (value) {
  54157. this._imageProcessingConfiguration.toneMappingEnabled = value;
  54158. },
  54159. enumerable: true,
  54160. configurable: true
  54161. });
  54162. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  54163. /**
  54164. * The camera exposure used on this material.
  54165. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54166. * This corresponds to a photographic exposure.
  54167. */
  54168. get: function () {
  54169. return this._imageProcessingConfiguration.exposure;
  54170. },
  54171. /**
  54172. * The camera exposure used on this material.
  54173. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54174. * This corresponds to a photographic exposure.
  54175. */
  54176. set: function (value) {
  54177. this._imageProcessingConfiguration.exposure = value;
  54178. },
  54179. enumerable: true,
  54180. configurable: true
  54181. });
  54182. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  54183. /**
  54184. * Gets The camera contrast used on this material.
  54185. */
  54186. get: function () {
  54187. return this._imageProcessingConfiguration.contrast;
  54188. },
  54189. /**
  54190. * Sets The camera contrast used on this material.
  54191. */
  54192. set: function (value) {
  54193. this._imageProcessingConfiguration.contrast = value;
  54194. },
  54195. enumerable: true,
  54196. configurable: true
  54197. });
  54198. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  54199. /**
  54200. * Gets the Color Grading 2D Lookup Texture.
  54201. */
  54202. get: function () {
  54203. return this._imageProcessingConfiguration.colorGradingTexture;
  54204. },
  54205. /**
  54206. * Sets the Color Grading 2D Lookup Texture.
  54207. */
  54208. set: function (value) {
  54209. this._imageProcessingConfiguration.colorGradingTexture = value;
  54210. },
  54211. enumerable: true,
  54212. configurable: true
  54213. });
  54214. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  54215. /**
  54216. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54217. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54218. * 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;
  54219. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54220. */
  54221. get: function () {
  54222. return this._imageProcessingConfiguration.colorCurves;
  54223. },
  54224. /**
  54225. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54226. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54227. * 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;
  54228. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54229. */
  54230. set: function (value) {
  54231. this._imageProcessingConfiguration.colorCurves = value;
  54232. },
  54233. enumerable: true,
  54234. configurable: true
  54235. });
  54236. /**
  54237. * Returns the name of this material class.
  54238. */
  54239. PBRMaterial.prototype.getClassName = function () {
  54240. return "PBRMaterial";
  54241. };
  54242. /**
  54243. * Makes a duplicate of the current material.
  54244. * @param name - name to use for the new material.
  54245. */
  54246. PBRMaterial.prototype.clone = function (name) {
  54247. var _this = this;
  54248. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  54249. clone.id = name;
  54250. clone.name = name;
  54251. this.clearCoat.copyTo(clone.clearCoat);
  54252. this.anisotropy.copyTo(clone.anisotropy);
  54253. this.brdf.copyTo(clone.brdf);
  54254. this.sheen.copyTo(clone.sheen);
  54255. return clone;
  54256. };
  54257. /**
  54258. * Serializes this PBR Material.
  54259. * @returns - An object with the serialized material.
  54260. */
  54261. PBRMaterial.prototype.serialize = function () {
  54262. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54263. serializationObject.customType = "BABYLON.PBRMaterial";
  54264. serializationObject.clearCoat = this.clearCoat.serialize();
  54265. serializationObject.anisotropy = this.anisotropy.serialize();
  54266. serializationObject.brdf = this.brdf.serialize();
  54267. serializationObject.sheen = this.sheen.serialize();
  54268. return serializationObject;
  54269. };
  54270. // Statics
  54271. /**
  54272. * Parses a PBR Material from a serialized object.
  54273. * @param source - Serialized object.
  54274. * @param scene - BJS scene instance.
  54275. * @param rootUrl - url for the scene object
  54276. * @returns - PBRMaterial
  54277. */
  54278. PBRMaterial.Parse = function (source, scene, rootUrl) {
  54279. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  54280. if (source.clearCoat) {
  54281. material.clearCoat.parse(source.clearCoat);
  54282. }
  54283. if (source.anisotropy) {
  54284. material.anisotropy.parse(source.anisotropy);
  54285. }
  54286. if (source.brdf) {
  54287. material.brdf.parse(source.brdf);
  54288. }
  54289. if (source.sheen) {
  54290. material.sheen.parse(source.brdf);
  54291. }
  54292. return material;
  54293. };
  54294. /**
  54295. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54296. */
  54297. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  54298. /**
  54299. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54300. */
  54301. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  54302. /**
  54303. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54304. */
  54305. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  54306. /**
  54307. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54308. * They are also discarded below the alpha cutoff threshold to improve performances.
  54309. */
  54310. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  54311. /**
  54312. * Defines the default value of how much AO map is occluding the analytical lights
  54313. * (point spot...).
  54314. */
  54315. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54319. ], PBRMaterial.prototype, "directIntensity", void 0);
  54320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54323. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  54324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54327. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  54328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54331. ], PBRMaterial.prototype, "specularIntensity", void 0);
  54332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54335. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  54336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54339. ], PBRMaterial.prototype, "albedoTexture", void 0);
  54340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54343. ], PBRMaterial.prototype, "ambientTexture", void 0);
  54344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54347. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  54348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54351. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  54352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54355. ], PBRMaterial.prototype, "opacityTexture", void 0);
  54356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54359. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  54360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54363. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  54364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54367. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  54368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54371. ], PBRMaterial.prototype, "metallicTexture", void 0);
  54372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54375. ], PBRMaterial.prototype, "metallic", void 0);
  54376. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54377. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54379. ], PBRMaterial.prototype, "roughness", void 0);
  54380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54383. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  54384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54386. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54387. ], PBRMaterial.prototype, "bumpTexture", void 0);
  54388. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54389. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54390. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  54391. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  54392. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54395. ], PBRMaterial.prototype, "refractionTexture", void 0);
  54396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  54398. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54399. ], PBRMaterial.prototype, "ambientColor", void 0);
  54400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  54402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54403. ], PBRMaterial.prototype, "albedoColor", void 0);
  54404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  54406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54407. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  54408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  54410. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54411. ], PBRMaterial.prototype, "reflectionColor", void 0);
  54412. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54413. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  54414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54415. ], PBRMaterial.prototype, "emissiveColor", void 0);
  54416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54419. ], PBRMaterial.prototype, "microSurface", void 0);
  54420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54423. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  54424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54427. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  54428. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54431. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  54432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54435. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  54436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54439. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  54440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54443. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  54444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54447. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  54448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54451. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  54452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54455. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  54456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54459. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  54460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54463. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  54464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54467. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  54468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54471. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  54472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54475. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  54476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54479. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  54480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54482. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  54483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54485. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  54486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54488. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54489. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  54490. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54491. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54493. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  54494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54496. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54497. ], PBRMaterial.prototype, "useParallax", void 0);
  54498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54500. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54501. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  54502. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54503. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54505. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  54506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54508. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54509. ], PBRMaterial.prototype, "disableLighting", void 0);
  54510. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54511. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54512. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54513. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  54514. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54515. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54517. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  54518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54520. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54521. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  54522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54524. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54525. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  54526. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54527. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54529. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  54530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54533. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  54534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54537. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  54538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54541. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  54542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54545. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  54546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54549. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  54550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54553. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  54554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54557. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  54558. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  54561. ], PBRMaterial.prototype, "unlit", void 0);
  54562. return PBRMaterial;
  54563. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  54564. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  54565. /***/ }),
  54566. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  54567. /*!*******************************************************!*\
  54568. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  54569. \*******************************************************/
  54570. /*! exports provided: PBRMetallicRoughnessMaterial */
  54571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54572. "use strict";
  54573. __webpack_require__.r(__webpack_exports__);
  54574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  54575. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54576. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54577. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  54578. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54579. /**
  54580. * The PBR material of BJS following the metal roughness convention.
  54581. *
  54582. * This fits to the PBR convention in the GLTF definition:
  54583. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54584. */
  54585. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  54586. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  54587. /**
  54588. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54589. *
  54590. * @param name The material name
  54591. * @param scene The scene the material will be use in.
  54592. */
  54593. function PBRMetallicRoughnessMaterial(name, scene) {
  54594. var _this = _super.call(this, name, scene) || this;
  54595. _this._useRoughnessFromMetallicTextureAlpha = false;
  54596. _this._useRoughnessFromMetallicTextureGreen = true;
  54597. _this._useMetallnessFromMetallicTextureBlue = true;
  54598. _this.metallic = 1.0;
  54599. _this.roughness = 1.0;
  54600. return _this;
  54601. }
  54602. /**
  54603. * Return the currrent class name of the material.
  54604. */
  54605. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  54606. return "PBRMetallicRoughnessMaterial";
  54607. };
  54608. /**
  54609. * Makes a duplicate of the current material.
  54610. * @param name - name to use for the new material.
  54611. */
  54612. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  54613. var _this = this;
  54614. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  54615. clone.id = name;
  54616. clone.name = name;
  54617. this.clearCoat.copyTo(clone.clearCoat);
  54618. this.anisotropy.copyTo(clone.anisotropy);
  54619. this.brdf.copyTo(clone.brdf);
  54620. this.sheen.copyTo(clone.sheen);
  54621. return clone;
  54622. };
  54623. /**
  54624. * Serialize the material to a parsable JSON object.
  54625. */
  54626. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  54627. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54628. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  54629. serializationObject.clearCoat = this.clearCoat.serialize();
  54630. serializationObject.anisotropy = this.anisotropy.serialize();
  54631. serializationObject.brdf = this.brdf.serialize();
  54632. serializationObject.sheen = this.sheen.serialize();
  54633. return serializationObject;
  54634. };
  54635. /**
  54636. * Parses a JSON object correponding to the serialize function.
  54637. */
  54638. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  54639. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  54640. if (source.clearCoat) {
  54641. material.clearCoat.parse(source.clearCoat);
  54642. }
  54643. if (source.anisotropy) {
  54644. material.anisotropy.parse(source.anisotropy);
  54645. }
  54646. if (source.brdf) {
  54647. material.brdf.parse(source.brdf);
  54648. }
  54649. if (source.sheen) {
  54650. material.sheen.parse(source.brdf);
  54651. }
  54652. return material;
  54653. };
  54654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  54656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  54657. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  54658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  54661. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  54662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54665. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  54666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54669. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  54670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  54673. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  54674. return PBRMetallicRoughnessMaterial;
  54675. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  54676. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  54677. /***/ }),
  54678. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  54679. /*!************************************************!*\
  54680. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  54681. \************************************************/
  54682. /*! exports provided: PBRSheenConfiguration */
  54683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54684. "use strict";
  54685. __webpack_require__.r(__webpack_exports__);
  54686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  54687. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54688. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54689. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54690. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  54691. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  54692. /**
  54693. * Define the code related to the Sheen parameters of the pbr material.
  54694. */
  54695. var PBRSheenConfiguration = /** @class */ (function () {
  54696. /**
  54697. * Instantiate a new istance of clear coat configuration.
  54698. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54699. */
  54700. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  54701. this._isEnabled = false;
  54702. /**
  54703. * Defines if the material uses sheen.
  54704. */
  54705. this.isEnabled = false;
  54706. this._linkSheenWithAlbedo = false;
  54707. /**
  54708. * Defines if the sheen is linked to the sheen color.
  54709. */
  54710. this.linkSheenWithAlbedo = false;
  54711. /**
  54712. * Defines the sheen intensity.
  54713. */
  54714. this.intensity = 1;
  54715. /**
  54716. * Defines the sheen color.
  54717. */
  54718. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  54719. this._texture = null;
  54720. /**
  54721. * Stores the sheen tint values in a texture.
  54722. * rgb is tint
  54723. * a is a intensity
  54724. */
  54725. this.texture = null;
  54726. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  54727. }
  54728. /** @hidden */
  54729. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  54730. this._internalMarkAllSubMeshesAsTexturesDirty();
  54731. };
  54732. /**
  54733. * Specifies that the submesh is ready to be used.
  54734. * @param defines the list of "defines" to update.
  54735. * @param scene defines the scene the material belongs to.
  54736. * @returns - boolean indicating that the submesh is ready or not.
  54737. */
  54738. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  54739. if (defines._areTexturesDirty) {
  54740. if (scene.texturesEnabled) {
  54741. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54742. if (!this._texture.isReadyOrNotBlocking()) {
  54743. return false;
  54744. }
  54745. }
  54746. }
  54747. }
  54748. return true;
  54749. };
  54750. /**
  54751. * Checks to see if a texture is used in the material.
  54752. * @param defines the list of "defines" to update.
  54753. * @param scene defines the scene the material belongs to.
  54754. */
  54755. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  54756. if (this._isEnabled) {
  54757. defines.SHEEN = this._isEnabled;
  54758. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  54759. if (defines._areTexturesDirty) {
  54760. if (scene.texturesEnabled) {
  54761. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54762. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  54763. }
  54764. else {
  54765. defines.SHEEN_TEXTURE = false;
  54766. }
  54767. }
  54768. }
  54769. }
  54770. else {
  54771. defines.SHEEN = false;
  54772. defines.SHEEN_TEXTURE = false;
  54773. defines.SHEEN_LINKWITHALBEDO = false;
  54774. }
  54775. };
  54776. /**
  54777. * Binds the material data.
  54778. * @param uniformBuffer defines the Uniform buffer to fill in.
  54779. * @param scene defines the scene the material belongs to.
  54780. * @param isFrozen defines wether the material is frozen or not.
  54781. */
  54782. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  54783. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  54784. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54785. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  54786. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  54787. }
  54788. // Sheen
  54789. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  54790. }
  54791. // Textures
  54792. if (scene.texturesEnabled) {
  54793. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54794. uniformBuffer.setTexture("sheenSampler", this._texture);
  54795. }
  54796. }
  54797. };
  54798. /**
  54799. * Checks to see if a texture is used in the material.
  54800. * @param texture - Base texture to use.
  54801. * @returns - Boolean specifying if a texture is used in the material.
  54802. */
  54803. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  54804. if (this._texture === texture) {
  54805. return true;
  54806. }
  54807. return false;
  54808. };
  54809. /**
  54810. * Returns an array of the actively used textures.
  54811. * @param activeTextures Array of BaseTextures
  54812. */
  54813. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  54814. if (this._texture) {
  54815. activeTextures.push(this._texture);
  54816. }
  54817. };
  54818. /**
  54819. * Returns the animatable textures.
  54820. * @param animatables Array of animatable textures.
  54821. */
  54822. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  54823. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  54824. animatables.push(this._texture);
  54825. }
  54826. };
  54827. /**
  54828. * Disposes the resources of the material.
  54829. * @param forceDisposeTextures - Forces the disposal of all textures.
  54830. */
  54831. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  54832. if (forceDisposeTextures) {
  54833. if (this._texture) {
  54834. this._texture.dispose();
  54835. }
  54836. }
  54837. };
  54838. /**
  54839. * Get the current class name of the texture useful for serialization or dynamic coding.
  54840. * @returns "PBRSheenConfiguration"
  54841. */
  54842. PBRSheenConfiguration.prototype.getClassName = function () {
  54843. return "PBRSheenConfiguration";
  54844. };
  54845. /**
  54846. * Add fallbacks to the effect fallbacks list.
  54847. * @param defines defines the Base texture to use.
  54848. * @param fallbacks defines the current fallback list.
  54849. * @param currentRank defines the current fallback rank.
  54850. * @returns the new fallback rank.
  54851. */
  54852. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  54853. if (defines.SHEEN) {
  54854. fallbacks.addFallback(currentRank++, "SHEEN");
  54855. }
  54856. return currentRank;
  54857. };
  54858. /**
  54859. * Add the required uniforms to the current list.
  54860. * @param uniforms defines the current uniform list.
  54861. */
  54862. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  54863. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  54864. };
  54865. /**
  54866. * Add the required uniforms to the current buffer.
  54867. * @param uniformBuffer defines the current uniform buffer.
  54868. */
  54869. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  54870. uniformBuffer.addUniform("vSheenColor", 4);
  54871. uniformBuffer.addUniform("vSheenInfos", 2);
  54872. uniformBuffer.addUniform("sheenMatrix", 16);
  54873. };
  54874. /**
  54875. * Add the required samplers to the current list.
  54876. * @param samplers defines the current sampler list.
  54877. */
  54878. PBRSheenConfiguration.AddSamplers = function (samplers) {
  54879. samplers.push("sheenSampler");
  54880. };
  54881. /**
  54882. * Makes a duplicate of the current configuration into another one.
  54883. * @param sheenConfiguration define the config where to copy the info
  54884. */
  54885. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  54886. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  54887. };
  54888. /**
  54889. * Serializes this BRDF configuration.
  54890. * @returns - An object with the serialized config.
  54891. */
  54892. PBRSheenConfiguration.prototype.serialize = function () {
  54893. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54894. };
  54895. /**
  54896. * Parses a Sheen Configuration from a serialized object.
  54897. * @param source - Serialized object.
  54898. */
  54899. PBRSheenConfiguration.prototype.parse = function (source) {
  54900. var _this = this;
  54901. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  54902. };
  54903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54905. ], PBRSheenConfiguration.prototype, "_isEnabled", void 0);
  54906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54908. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  54909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54911. ], PBRSheenConfiguration.prototype, "_linkSheenWithAlbedo", void 0);
  54912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54914. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  54915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54917. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  54918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  54920. ], PBRSheenConfiguration.prototype, "color", void 0);
  54921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54923. ], PBRSheenConfiguration.prototype, "_texture", void 0);
  54924. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54926. ], PBRSheenConfiguration.prototype, "texture", void 0);
  54927. return PBRSheenConfiguration;
  54928. }());
  54929. /***/ }),
  54930. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  54931. /*!********************************************************!*\
  54932. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  54933. \********************************************************/
  54934. /*! exports provided: PBRSpecularGlossinessMaterial */
  54935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54936. "use strict";
  54937. __webpack_require__.r(__webpack_exports__);
  54938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  54939. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54940. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54941. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  54942. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54943. /**
  54944. * The PBR material of BJS following the specular glossiness convention.
  54945. *
  54946. * This fits to the PBR convention in the GLTF definition:
  54947. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54948. */
  54949. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  54950. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  54951. /**
  54952. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54953. *
  54954. * @param name The material name
  54955. * @param scene The scene the material will be use in.
  54956. */
  54957. function PBRSpecularGlossinessMaterial(name, scene) {
  54958. var _this = _super.call(this, name, scene) || this;
  54959. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  54960. return _this;
  54961. }
  54962. /**
  54963. * Return the currrent class name of the material.
  54964. */
  54965. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  54966. return "PBRSpecularGlossinessMaterial";
  54967. };
  54968. /**
  54969. * Makes a duplicate of the current material.
  54970. * @param name - name to use for the new material.
  54971. */
  54972. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  54973. var _this = this;
  54974. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  54975. clone.id = name;
  54976. clone.name = name;
  54977. this.clearCoat.copyTo(clone.clearCoat);
  54978. this.anisotropy.copyTo(clone.anisotropy);
  54979. this.brdf.copyTo(clone.brdf);
  54980. this.sheen.copyTo(clone.sheen);
  54981. return clone;
  54982. };
  54983. /**
  54984. * Serialize the material to a parsable JSON object.
  54985. */
  54986. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  54987. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54988. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  54989. serializationObject.clearCoat = this.clearCoat.serialize();
  54990. serializationObject.anisotropy = this.anisotropy.serialize();
  54991. serializationObject.brdf = this.brdf.serialize();
  54992. serializationObject.sheen = this.sheen.serialize();
  54993. return serializationObject;
  54994. };
  54995. /**
  54996. * Parses a JSON object correponding to the serialize function.
  54997. */
  54998. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  54999. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  55000. if (source.clearCoat) {
  55001. material.clearCoat.parse(source.clearCoat);
  55002. }
  55003. if (source.anisotropy) {
  55004. material.anisotropy.parse(source.anisotropy);
  55005. }
  55006. if (source.brdf) {
  55007. material.brdf.parse(source.brdf);
  55008. }
  55009. if (source.sheen) {
  55010. material.sheen.parse(source.brdf);
  55011. }
  55012. return material;
  55013. };
  55014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  55016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55017. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  55018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55021. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  55022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  55024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  55025. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  55026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  55029. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  55030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  55033. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  55034. return PBRSpecularGlossinessMaterial;
  55035. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55036. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  55037. /***/ }),
  55038. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  55039. /*!********************************************************!*\
  55040. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  55041. \********************************************************/
  55042. /*! exports provided: _DDSTextureLoader */
  55043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55044. "use strict";
  55045. __webpack_require__.r(__webpack_exports__);
  55046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  55047. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  55048. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55049. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  55050. /**
  55051. * Implementation of the DDS Texture Loader.
  55052. * @hidden
  55053. */
  55054. var _DDSTextureLoader = /** @class */ (function () {
  55055. function _DDSTextureLoader() {
  55056. /**
  55057. * Defines wether the loader supports cascade loading the different faces.
  55058. */
  55059. this.supportCascades = true;
  55060. }
  55061. /**
  55062. * This returns if the loader support the current file information.
  55063. * @param extension defines the file extension of the file being loaded
  55064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55065. * @param fallback defines the fallback internal texture if any
  55066. * @param isBase64 defines whether the texture is encoded as a base64
  55067. * @param isBuffer defines whether the texture data are stored as a buffer
  55068. * @returns true if the loader can load the specified file
  55069. */
  55070. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55071. return extension.indexOf(".dds") === 0;
  55072. };
  55073. /**
  55074. * Transform the url before loading if required.
  55075. * @param rootUrl the url of the texture
  55076. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55077. * @returns the transformed texture
  55078. */
  55079. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55080. return rootUrl;
  55081. };
  55082. /**
  55083. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55084. * @param rootUrl the url of the texture
  55085. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55086. * @returns the fallback texture
  55087. */
  55088. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55089. return null;
  55090. };
  55091. /**
  55092. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55093. * @param data contains the texture data
  55094. * @param texture defines the BabylonJS internal texture
  55095. * @param createPolynomials will be true if polynomials have been requested
  55096. * @param onLoad defines the callback to trigger once the texture is ready
  55097. * @param onError defines the callback to trigger in case of error
  55098. */
  55099. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  55100. var engine = texture.getEngine();
  55101. var info;
  55102. var loadMipmap = false;
  55103. if (Array.isArray(imgs)) {
  55104. for (var index = 0; index < imgs.length; index++) {
  55105. var data_1 = imgs[index];
  55106. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  55107. texture.width = info.width;
  55108. texture.height = info.height;
  55109. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  55110. engine._unpackFlipY(info.isCompressed);
  55111. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  55112. if (!info.isFourCC && info.mipmapCount === 1) {
  55113. engine.generateMipMapsForCubemap(texture);
  55114. }
  55115. }
  55116. }
  55117. else {
  55118. var data = imgs;
  55119. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  55120. texture.width = info.width;
  55121. texture.height = info.height;
  55122. if (createPolynomials) {
  55123. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  55124. }
  55125. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  55126. engine._unpackFlipY(info.isCompressed);
  55127. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  55128. if (!info.isFourCC && info.mipmapCount === 1) {
  55129. engine.generateMipMapsForCubemap(texture);
  55130. }
  55131. }
  55132. engine._setCubeMapTextureParams(loadMipmap);
  55133. texture.isReady = true;
  55134. if (onLoad) {
  55135. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  55136. }
  55137. };
  55138. /**
  55139. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55140. * @param data contains the texture data
  55141. * @param texture defines the BabylonJS internal texture
  55142. * @param callback defines the method to call once ready to upload
  55143. */
  55144. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  55145. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  55146. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  55147. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  55148. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  55149. });
  55150. };
  55151. return _DDSTextureLoader;
  55152. }());
  55153. // Register the loader.
  55154. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  55155. /***/ }),
  55156. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  55157. /*!********************************************************!*\
  55158. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  55159. \********************************************************/
  55160. /*! exports provided: _ENVTextureLoader */
  55161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55162. "use strict";
  55163. __webpack_require__.r(__webpack_exports__);
  55164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  55165. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  55166. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55167. /**
  55168. * Implementation of the ENV Texture Loader.
  55169. * @hidden
  55170. */
  55171. var _ENVTextureLoader = /** @class */ (function () {
  55172. function _ENVTextureLoader() {
  55173. /**
  55174. * Defines wether the loader supports cascade loading the different faces.
  55175. */
  55176. this.supportCascades = false;
  55177. }
  55178. /**
  55179. * This returns if the loader support the current file information.
  55180. * @param extension defines the file extension of the file being loaded
  55181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55182. * @param fallback defines the fallback internal texture if any
  55183. * @param isBase64 defines whether the texture is encoded as a base64
  55184. * @param isBuffer defines whether the texture data are stored as a buffer
  55185. * @returns true if the loader can load the specified file
  55186. */
  55187. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55188. return extension.indexOf(".env") === 0;
  55189. };
  55190. /**
  55191. * Transform the url before loading if required.
  55192. * @param rootUrl the url of the texture
  55193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55194. * @returns the transformed texture
  55195. */
  55196. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55197. return rootUrl;
  55198. };
  55199. /**
  55200. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55201. * @param rootUrl the url of the texture
  55202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55203. * @returns the fallback texture
  55204. */
  55205. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55206. return null;
  55207. };
  55208. /**
  55209. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55210. * @param data contains the texture data
  55211. * @param texture defines the BabylonJS internal texture
  55212. * @param createPolynomials will be true if polynomials have been requested
  55213. * @param onLoad defines the callback to trigger once the texture is ready
  55214. * @param onError defines the callback to trigger in case of error
  55215. */
  55216. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55217. if (Array.isArray(data)) {
  55218. return;
  55219. }
  55220. data = data;
  55221. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  55222. if (info) {
  55223. texture.width = info.width;
  55224. texture.height = info.width;
  55225. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  55226. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  55227. texture.isReady = true;
  55228. if (onLoad) {
  55229. onLoad();
  55230. }
  55231. });
  55232. }
  55233. else if (onError) {
  55234. onError("Can not parse the environment file", null);
  55235. }
  55236. };
  55237. /**
  55238. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55239. * @param data contains the texture data
  55240. * @param texture defines the BabylonJS internal texture
  55241. * @param callback defines the method to call once ready to upload
  55242. */
  55243. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  55244. throw ".env not supported in 2d.";
  55245. };
  55246. return _ENVTextureLoader;
  55247. }());
  55248. // Register the loader.
  55249. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  55250. /***/ }),
  55251. /***/ "./Materials/Textures/Loaders/index.ts":
  55252. /*!*********************************************!*\
  55253. !*** ./Materials/Textures/Loaders/index.ts ***!
  55254. \*********************************************/
  55255. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  55256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55257. "use strict";
  55258. __webpack_require__.r(__webpack_exports__);
  55259. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  55260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  55261. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  55262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  55263. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  55264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  55265. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  55266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  55267. /***/ }),
  55268. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  55269. /*!********************************************************!*\
  55270. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  55271. \********************************************************/
  55272. /*! exports provided: _KTXTextureLoader */
  55273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55274. "use strict";
  55275. __webpack_require__.r(__webpack_exports__);
  55276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  55277. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  55278. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55279. /**
  55280. * Implementation of the KTX Texture Loader.
  55281. * @hidden
  55282. */
  55283. var _KTXTextureLoader = /** @class */ (function () {
  55284. function _KTXTextureLoader() {
  55285. /**
  55286. * Defines wether the loader supports cascade loading the different faces.
  55287. */
  55288. this.supportCascades = false;
  55289. }
  55290. /**
  55291. * This returns if the loader support the current file information.
  55292. * @param extension defines the file extension of the file being loaded
  55293. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55294. * @param fallback defines the fallback internal texture if any
  55295. * @param isBase64 defines whether the texture is encoded as a base64
  55296. * @param isBuffer defines whether the texture data are stored as a buffer
  55297. * @returns true if the loader can load the specified file
  55298. */
  55299. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55300. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  55301. return true;
  55302. }
  55303. return false;
  55304. };
  55305. /**
  55306. * Transform the url before loading if required.
  55307. * @param rootUrl the url of the texture
  55308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55309. * @returns the transformed texture
  55310. */
  55311. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55312. var lastDot = rootUrl.lastIndexOf('.');
  55313. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  55314. // Already transformed
  55315. return rootUrl;
  55316. }
  55317. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  55318. };
  55319. /**
  55320. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55321. * @param rootUrl the url of the texture
  55322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55323. * @returns the fallback texture
  55324. */
  55325. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55326. // remove the format appended to the rootUrl in the original createCubeTexture call.
  55327. var exp = new RegExp("" + textureFormatInUse + "$");
  55328. return rootUrl.replace(exp, "");
  55329. };
  55330. /**
  55331. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55332. * @param data contains the texture data
  55333. * @param texture defines the BabylonJS internal texture
  55334. * @param createPolynomials will be true if polynomials have been requested
  55335. * @param onLoad defines the callback to trigger once the texture is ready
  55336. * @param onError defines the callback to trigger in case of error
  55337. */
  55338. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55339. if (Array.isArray(data)) {
  55340. return;
  55341. }
  55342. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  55343. texture._invertVScale = !texture.invertY;
  55344. var engine = texture.getEngine();
  55345. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  55346. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  55347. engine._unpackFlipY(true);
  55348. ktx.uploadLevels(texture, texture.generateMipMaps);
  55349. texture.width = ktx.pixelWidth;
  55350. texture.height = ktx.pixelHeight;
  55351. engine._setCubeMapTextureParams(loadMipmap);
  55352. texture.isReady = true;
  55353. };
  55354. /**
  55355. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55356. * @param data contains the texture data
  55357. * @param texture defines the BabylonJS internal texture
  55358. * @param callback defines the method to call once ready to upload
  55359. */
  55360. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  55361. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  55362. texture._invertVScale = !texture.invertY;
  55363. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  55364. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  55365. ktx.uploadLevels(texture, texture.generateMipMaps);
  55366. }, ktx.isInvalid);
  55367. };
  55368. return _KTXTextureLoader;
  55369. }());
  55370. // Register the loader.
  55371. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  55372. /***/ }),
  55373. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  55374. /*!********************************************************!*\
  55375. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  55376. \********************************************************/
  55377. /*! exports provided: _TGATextureLoader */
  55378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55379. "use strict";
  55380. __webpack_require__.r(__webpack_exports__);
  55381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  55382. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  55383. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55384. /**
  55385. * Implementation of the TGA Texture Loader.
  55386. * @hidden
  55387. */
  55388. var _TGATextureLoader = /** @class */ (function () {
  55389. function _TGATextureLoader() {
  55390. /**
  55391. * Defines wether the loader supports cascade loading the different faces.
  55392. */
  55393. this.supportCascades = false;
  55394. }
  55395. /**
  55396. * This returns if the loader support the current file information.
  55397. * @param extension defines the file extension of the file being loaded
  55398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55399. * @param fallback defines the fallback internal texture if any
  55400. * @param isBase64 defines whether the texture is encoded as a base64
  55401. * @param isBuffer defines whether the texture data are stored as a buffer
  55402. * @returns true if the loader can load the specified file
  55403. */
  55404. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55405. return extension.indexOf(".tga") === 0;
  55406. };
  55407. /**
  55408. * Transform the url before loading if required.
  55409. * @param rootUrl the url of the texture
  55410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55411. * @returns the transformed texture
  55412. */
  55413. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55414. return rootUrl;
  55415. };
  55416. /**
  55417. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55418. * @param rootUrl the url of the texture
  55419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55420. * @returns the fallback texture
  55421. */
  55422. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55423. return null;
  55424. };
  55425. /**
  55426. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55427. * @param data contains the texture data
  55428. * @param texture defines the BabylonJS internal texture
  55429. * @param createPolynomials will be true if polynomials have been requested
  55430. * @param onLoad defines the callback to trigger once the texture is ready
  55431. * @param onError defines the callback to trigger in case of error
  55432. */
  55433. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55434. throw ".env not supported in Cube.";
  55435. };
  55436. /**
  55437. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55438. * @param data contains the texture data
  55439. * @param texture defines the BabylonJS internal texture
  55440. * @param callback defines the method to call once ready to upload
  55441. */
  55442. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  55443. var uintData = new Uint8Array(data);
  55444. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  55445. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  55446. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  55447. });
  55448. };
  55449. return _TGATextureLoader;
  55450. }());
  55451. // Register the loader.
  55452. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  55453. /***/ }),
  55454. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  55455. /*!*******************************************************************!*\
  55456. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  55457. \*******************************************************************/
  55458. /*! exports provided: CustomProceduralTexture */
  55459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55460. "use strict";
  55461. __webpack_require__.r(__webpack_exports__);
  55462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  55463. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55464. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  55465. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  55466. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55467. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55468. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Misc/webRequest */ "./Misc/webRequest.ts");
  55469. /**
  55470. * 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.
  55471. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55472. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55473. */
  55474. var CustomProceduralTexture = /** @class */ (function (_super) {
  55475. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  55476. /**
  55477. * Instantiates a new Custom Procedural Texture.
  55478. * 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.
  55479. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55480. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55481. * @param name Define the name of the texture
  55482. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55483. * @param size Define the size of the texture to create
  55484. * @param scene Define the scene the texture belongs to
  55485. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55486. * @param generateMipMaps Define if the texture should creates mip maps or not
  55487. */
  55488. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  55489. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  55490. _this._animate = true;
  55491. _this._time = 0;
  55492. _this._texturePath = texturePath;
  55493. //Try to load json
  55494. _this._loadJson(texturePath);
  55495. _this.refreshRate = 1;
  55496. return _this;
  55497. }
  55498. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  55499. var _this = this;
  55500. var noConfigFile = function () {
  55501. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  55502. try {
  55503. _this.setFragment(_this._texturePath);
  55504. }
  55505. catch (ex) {
  55506. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  55507. }
  55508. };
  55509. var configFileUrl = jsonUrl + "/config.json";
  55510. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__["WebRequest"]();
  55511. xhr.open("GET", configFileUrl);
  55512. xhr.addEventListener("load", function () {
  55513. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  55514. try {
  55515. _this._config = JSON.parse(xhr.response);
  55516. _this.updateShaderUniforms();
  55517. _this.updateTextures();
  55518. _this.setFragment(_this._texturePath + "/custom");
  55519. _this._animate = _this._config.animate;
  55520. _this.refreshRate = _this._config.refreshrate;
  55521. }
  55522. catch (ex) {
  55523. noConfigFile();
  55524. }
  55525. }
  55526. else {
  55527. noConfigFile();
  55528. }
  55529. }, false);
  55530. xhr.addEventListener("error", function () {
  55531. noConfigFile();
  55532. }, false);
  55533. try {
  55534. xhr.send();
  55535. }
  55536. catch (ex) {
  55537. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  55538. }
  55539. };
  55540. /**
  55541. * Is the texture ready to be used ? (rendered at least once)
  55542. * @returns true if ready, otherwise, false.
  55543. */
  55544. CustomProceduralTexture.prototype.isReady = function () {
  55545. if (!_super.prototype.isReady.call(this)) {
  55546. return false;
  55547. }
  55548. for (var name in this._textures) {
  55549. var texture = this._textures[name];
  55550. if (!texture.isReady()) {
  55551. return false;
  55552. }
  55553. }
  55554. return true;
  55555. };
  55556. /**
  55557. * Render the texture to its associated render target.
  55558. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55559. */
  55560. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55561. var scene = this.getScene();
  55562. if (this._animate && scene) {
  55563. this._time += scene.getAnimationRatio() * 0.03;
  55564. this.updateShaderUniforms();
  55565. }
  55566. _super.prototype.render.call(this, useCameraPostProcess);
  55567. };
  55568. /**
  55569. * Update the list of dependant textures samplers in the shader.
  55570. */
  55571. CustomProceduralTexture.prototype.updateTextures = function () {
  55572. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  55573. this.setTexture(this._config.sampler2Ds[i].sample2Dname, new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"](this._texturePath + "/" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));
  55574. }
  55575. };
  55576. /**
  55577. * Update the uniform values of the procedural texture in the shader.
  55578. */
  55579. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  55580. if (this._config) {
  55581. for (var j = 0; j < this._config.uniforms.length; j++) {
  55582. var uniform = this._config.uniforms[j];
  55583. switch (uniform.type) {
  55584. case "float":
  55585. this.setFloat(uniform.name, uniform.value);
  55586. break;
  55587. case "color3":
  55588. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](uniform.r, uniform.g, uniform.b));
  55589. break;
  55590. case "color4":
  55591. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  55592. break;
  55593. case "vector2":
  55594. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](uniform.x, uniform.y));
  55595. break;
  55596. case "vector3":
  55597. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](uniform.x, uniform.y, uniform.z));
  55598. break;
  55599. }
  55600. }
  55601. }
  55602. this.setFloat("time", this._time);
  55603. };
  55604. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  55605. /**
  55606. * Define if the texture animates or not.
  55607. */
  55608. get: function () {
  55609. return this._animate;
  55610. },
  55611. set: function (value) {
  55612. this._animate = value;
  55613. },
  55614. enumerable: true,
  55615. configurable: true
  55616. });
  55617. return CustomProceduralTexture;
  55618. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_4__["ProceduralTexture"]));
  55619. /***/ }),
  55620. /***/ "./Materials/Textures/Procedurals/index.ts":
  55621. /*!*************************************************!*\
  55622. !*** ./Materials/Textures/Procedurals/index.ts ***!
  55623. \*************************************************/
  55624. /*! exports provided: CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  55625. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55626. "use strict";
  55627. __webpack_require__.r(__webpack_exports__);
  55628. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  55629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  55630. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  55631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  55632. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  55634. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  55635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  55636. /***/ }),
  55637. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  55638. /*!******************************************************************!*\
  55639. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  55640. \******************************************************************/
  55641. /*! exports provided: NoiseProceduralTexture */
  55642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55643. "use strict";
  55644. __webpack_require__.r(__webpack_exports__);
  55645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  55646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55647. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  55648. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55649. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55650. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  55651. /**
  55652. * Class used to generate noise procedural textures
  55653. */
  55654. var NoiseProceduralTexture = /** @class */ (function (_super) {
  55655. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  55656. /**
  55657. * Creates a new NoiseProceduralTexture
  55658. * @param name defines the name fo the texture
  55659. * @param size defines the size of the texture (default is 256)
  55660. * @param scene defines the hosting scene
  55661. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55662. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55663. */
  55664. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  55665. if (size === void 0) { size = 256; }
  55666. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  55667. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  55668. _this._time = 0;
  55669. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55670. _this.brightness = 0.2;
  55671. /** Defines the number of octaves to process */
  55672. _this.octaves = 3;
  55673. /** Defines the level of persistence (0.8 by default) */
  55674. _this.persistence = 0.8;
  55675. /** Gets or sets animation speed factor (default is 1) */
  55676. _this.animationSpeedFactor = 1;
  55677. _this.autoClear = false;
  55678. _this._updateShaderUniforms();
  55679. return _this;
  55680. }
  55681. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  55682. var scene = this.getScene();
  55683. if (!scene) {
  55684. return;
  55685. }
  55686. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  55687. this.setFloat("brightness", this.brightness);
  55688. this.setFloat("persistence", this.persistence);
  55689. this.setFloat("timeScale", this._time);
  55690. };
  55691. NoiseProceduralTexture.prototype._getDefines = function () {
  55692. return "#define OCTAVES " + (this.octaves | 0);
  55693. };
  55694. /** Generate the current state of the procedural texture */
  55695. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55696. this._updateShaderUniforms();
  55697. _super.prototype.render.call(this, useCameraPostProcess);
  55698. };
  55699. /**
  55700. * Serializes this noise procedural texture
  55701. * @returns a serialized noise procedural texture object
  55702. */
  55703. NoiseProceduralTexture.prototype.serialize = function () {
  55704. var serializationObject = {};
  55705. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  55706. serializationObject.brightness = this.brightness;
  55707. serializationObject.octaves = this.octaves;
  55708. serializationObject.persistence = this.persistence;
  55709. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  55710. serializationObject.size = this.getSize().width;
  55711. serializationObject.generateMipMaps = this._generateMipMaps;
  55712. return serializationObject;
  55713. };
  55714. /**
  55715. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55716. * @param parsedTexture defines parsed texture data
  55717. * @param scene defines the current scene
  55718. * @param rootUrl defines the root URL containing noise procedural texture information
  55719. * @returns a parsed NoiseProceduralTexture
  55720. */
  55721. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  55722. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  55723. texture.brightness = parsedTexture.brightness;
  55724. texture.octaves = parsedTexture.octaves;
  55725. texture.persistence = parsedTexture.persistence;
  55726. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  55727. return texture;
  55728. };
  55729. return NoiseProceduralTexture;
  55730. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  55731. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  55732. /***/ }),
  55733. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  55734. /*!*************************************************************!*\
  55735. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  55736. \*************************************************************/
  55737. /*! exports provided: ProceduralTexture */
  55738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55739. "use strict";
  55740. __webpack_require__.r(__webpack_exports__);
  55741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  55742. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55743. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  55744. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  55745. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  55746. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  55747. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  55748. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55749. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55750. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  55751. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  55752. /**
  55753. * 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.
  55754. * This is the base class of any Procedural texture and contains most of the shareable code.
  55755. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  55756. */
  55757. var ProceduralTexture = /** @class */ (function (_super) {
  55758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  55759. /**
  55760. * Instantiates a new procedural texture.
  55761. * 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.
  55762. * This is the base class of any Procedural texture and contains most of the shareable code.
  55763. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  55764. * @param name Define the name of the texture
  55765. * @param size Define the size of the texture to create
  55766. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  55767. * @param scene Define the scene the texture belongs to
  55768. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55769. * @param generateMipMaps Define if the texture should creates mip maps or not
  55770. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  55771. */
  55772. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  55773. if (fallbackTexture === void 0) { fallbackTexture = null; }
  55774. if (generateMipMaps === void 0) { generateMipMaps = true; }
  55775. if (isCube === void 0) { isCube = false; }
  55776. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  55777. _this.isCube = isCube;
  55778. /**
  55779. * Define if the texture is enabled or not (disabled texture will not render)
  55780. */
  55781. _this.isEnabled = true;
  55782. /**
  55783. * Define if the texture must be cleared before rendering (default is true)
  55784. */
  55785. _this.autoClear = true;
  55786. /**
  55787. * Event raised when the texture is generated
  55788. */
  55789. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  55790. /** @hidden */
  55791. _this._textures = {};
  55792. _this._currentRefreshId = -1;
  55793. _this._refreshRate = 1;
  55794. _this._vertexBuffers = {};
  55795. _this._uniforms = new Array();
  55796. _this._samplers = new Array();
  55797. _this._floats = {};
  55798. _this._ints = {};
  55799. _this._floatsArrays = {};
  55800. _this._colors3 = {};
  55801. _this._colors4 = {};
  55802. _this._vectors2 = {};
  55803. _this._vectors3 = {};
  55804. _this._matrices = {};
  55805. _this._fallbackTextureUsed = false;
  55806. _this._cachedDefines = "";
  55807. _this._contentUpdateId = -1;
  55808. scene = _this.getScene();
  55809. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  55810. if (!component) {
  55811. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  55812. scene._addComponent(component);
  55813. }
  55814. scene.proceduralTextures.push(_this);
  55815. _this._engine = scene.getEngine();
  55816. _this.name = name;
  55817. _this.isRenderTarget = true;
  55818. _this._size = size;
  55819. _this._generateMipMaps = generateMipMaps;
  55820. _this.setFragment(fragment);
  55821. _this._fallbackTexture = fallbackTexture;
  55822. if (isCube) {
  55823. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  55824. _this.setFloat("face", 0);
  55825. }
  55826. else {
  55827. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  55828. }
  55829. // VBO
  55830. var vertices = [];
  55831. vertices.push(1, 1);
  55832. vertices.push(-1, 1);
  55833. vertices.push(-1, -1);
  55834. vertices.push(1, -1);
  55835. _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);
  55836. _this._createIndexBuffer();
  55837. return _this;
  55838. }
  55839. /**
  55840. * The effect that is created when initializing the post process.
  55841. * @returns The created effect corrisponding the the postprocess.
  55842. */
  55843. ProceduralTexture.prototype.getEffect = function () {
  55844. return this._effect;
  55845. };
  55846. /**
  55847. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  55848. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  55849. */
  55850. ProceduralTexture.prototype.getContent = function () {
  55851. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  55852. return this._contentData;
  55853. }
  55854. this._contentData = this.readPixels(0, 0, this._contentData);
  55855. this._contentUpdateId = this._currentRefreshId;
  55856. return this._contentData;
  55857. };
  55858. ProceduralTexture.prototype._createIndexBuffer = function () {
  55859. var engine = this._engine;
  55860. // Indices
  55861. var indices = [];
  55862. indices.push(0);
  55863. indices.push(1);
  55864. indices.push(2);
  55865. indices.push(0);
  55866. indices.push(2);
  55867. indices.push(3);
  55868. this._indexBuffer = engine.createIndexBuffer(indices);
  55869. };
  55870. /** @hidden */
  55871. ProceduralTexture.prototype._rebuild = function () {
  55872. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  55873. if (vb) {
  55874. vb._rebuild();
  55875. }
  55876. this._createIndexBuffer();
  55877. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  55878. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  55879. }
  55880. };
  55881. /**
  55882. * Resets the texture in order to recreate its associated resources.
  55883. * This can be called in case of context loss
  55884. */
  55885. ProceduralTexture.prototype.reset = function () {
  55886. if (this._effect === undefined) {
  55887. return;
  55888. }
  55889. var engine = this._engine;
  55890. engine._releaseEffect(this._effect);
  55891. };
  55892. ProceduralTexture.prototype._getDefines = function () {
  55893. return "";
  55894. };
  55895. /**
  55896. * Is the texture ready to be used ? (rendered at least once)
  55897. * @returns true if ready, otherwise, false.
  55898. */
  55899. ProceduralTexture.prototype.isReady = function () {
  55900. var _this = this;
  55901. var engine = this._engine;
  55902. var shaders;
  55903. if (!this._fragment) {
  55904. return false;
  55905. }
  55906. if (this._fallbackTextureUsed) {
  55907. return true;
  55908. }
  55909. var defines = this._getDefines();
  55910. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  55911. return true;
  55912. }
  55913. if (this._fragment.fragmentElement !== undefined) {
  55914. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  55915. }
  55916. else {
  55917. shaders = { vertex: "procedural", fragment: this._fragment };
  55918. }
  55919. this._cachedDefines = defines;
  55920. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  55921. _this.releaseInternalTexture();
  55922. if (_this._fallbackTexture) {
  55923. _this._texture = _this._fallbackTexture._texture;
  55924. if (_this._texture) {
  55925. _this._texture.incrementReferences();
  55926. }
  55927. }
  55928. _this._fallbackTextureUsed = true;
  55929. });
  55930. return this._effect.isReady();
  55931. };
  55932. /**
  55933. * Resets the refresh counter of the texture and start bak from scratch.
  55934. * Could be useful to regenerate the texture if it is setup to render only once.
  55935. */
  55936. ProceduralTexture.prototype.resetRefreshCounter = function () {
  55937. this._currentRefreshId = -1;
  55938. };
  55939. /**
  55940. * Set the fragment shader to use in order to render the texture.
  55941. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  55942. */
  55943. ProceduralTexture.prototype.setFragment = function (fragment) {
  55944. this._fragment = fragment;
  55945. };
  55946. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  55947. /**
  55948. * Define the refresh rate of the texture or the rendering frequency.
  55949. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  55950. */
  55951. get: function () {
  55952. return this._refreshRate;
  55953. },
  55954. set: function (value) {
  55955. this._refreshRate = value;
  55956. this.resetRefreshCounter();
  55957. },
  55958. enumerable: true,
  55959. configurable: true
  55960. });
  55961. /** @hidden */
  55962. ProceduralTexture.prototype._shouldRender = function () {
  55963. if (!this.isEnabled || !this.isReady() || !this._texture) {
  55964. if (this._texture) {
  55965. this._texture.isReady = false;
  55966. }
  55967. return false;
  55968. }
  55969. if (this._fallbackTextureUsed) {
  55970. return false;
  55971. }
  55972. if (this._currentRefreshId === -1) { // At least render once
  55973. this._currentRefreshId = 1;
  55974. return true;
  55975. }
  55976. if (this.refreshRate === this._currentRefreshId) {
  55977. this._currentRefreshId = 1;
  55978. return true;
  55979. }
  55980. this._currentRefreshId++;
  55981. return false;
  55982. };
  55983. /**
  55984. * Get the size the texture is rendering at.
  55985. * @returns the size (texture is always squared)
  55986. */
  55987. ProceduralTexture.prototype.getRenderSize = function () {
  55988. return this._size;
  55989. };
  55990. /**
  55991. * Resize the texture to new value.
  55992. * @param size Define the new size the texture should have
  55993. * @param generateMipMaps Define whether the new texture should create mip maps
  55994. */
  55995. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  55996. if (this._fallbackTextureUsed) {
  55997. return;
  55998. }
  55999. this.releaseInternalTexture();
  56000. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  56001. // Update properties
  56002. this._size = size;
  56003. this._generateMipMaps = generateMipMaps;
  56004. };
  56005. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  56006. if (this._uniforms.indexOf(uniformName) === -1) {
  56007. this._uniforms.push(uniformName);
  56008. }
  56009. };
  56010. /**
  56011. * Set a texture in the shader program used to render.
  56012. * @param name Define the name of the uniform samplers as defined in the shader
  56013. * @param texture Define the texture to bind to this sampler
  56014. * @return the texture itself allowing "fluent" like uniform updates
  56015. */
  56016. ProceduralTexture.prototype.setTexture = function (name, texture) {
  56017. if (this._samplers.indexOf(name) === -1) {
  56018. this._samplers.push(name);
  56019. }
  56020. this._textures[name] = texture;
  56021. return this;
  56022. };
  56023. /**
  56024. * Set a float in the shader.
  56025. * @param name Define the name of the uniform as defined in the shader
  56026. * @param value Define the value to give to the uniform
  56027. * @return the texture itself allowing "fluent" like uniform updates
  56028. */
  56029. ProceduralTexture.prototype.setFloat = function (name, value) {
  56030. this._checkUniform(name);
  56031. this._floats[name] = value;
  56032. return this;
  56033. };
  56034. /**
  56035. * Set a int in the shader.
  56036. * @param name Define the name of the uniform as defined in the shader
  56037. * @param value Define the value to give to the uniform
  56038. * @return the texture itself allowing "fluent" like uniform updates
  56039. */
  56040. ProceduralTexture.prototype.setInt = function (name, value) {
  56041. this._checkUniform(name);
  56042. this._ints[name] = value;
  56043. return this;
  56044. };
  56045. /**
  56046. * Set an array of floats in the shader.
  56047. * @param name Define the name of the uniform as defined in the shader
  56048. * @param value Define the value to give to the uniform
  56049. * @return the texture itself allowing "fluent" like uniform updates
  56050. */
  56051. ProceduralTexture.prototype.setFloats = function (name, value) {
  56052. this._checkUniform(name);
  56053. this._floatsArrays[name] = value;
  56054. return this;
  56055. };
  56056. /**
  56057. * Set a vec3 in the shader from a Color3.
  56058. * @param name Define the name of the uniform as defined in the shader
  56059. * @param value Define the value to give to the uniform
  56060. * @return the texture itself allowing "fluent" like uniform updates
  56061. */
  56062. ProceduralTexture.prototype.setColor3 = function (name, value) {
  56063. this._checkUniform(name);
  56064. this._colors3[name] = value;
  56065. return this;
  56066. };
  56067. /**
  56068. * Set a vec4 in the shader from a Color4.
  56069. * @param name Define the name of the uniform as defined in the shader
  56070. * @param value Define the value to give to the uniform
  56071. * @return the texture itself allowing "fluent" like uniform updates
  56072. */
  56073. ProceduralTexture.prototype.setColor4 = function (name, value) {
  56074. this._checkUniform(name);
  56075. this._colors4[name] = value;
  56076. return this;
  56077. };
  56078. /**
  56079. * Set a vec2 in the shader from a Vector2.
  56080. * @param name Define the name of the uniform as defined in the shader
  56081. * @param value Define the value to give to the uniform
  56082. * @return the texture itself allowing "fluent" like uniform updates
  56083. */
  56084. ProceduralTexture.prototype.setVector2 = function (name, value) {
  56085. this._checkUniform(name);
  56086. this._vectors2[name] = value;
  56087. return this;
  56088. };
  56089. /**
  56090. * Set a vec3 in the shader from a Vector3.
  56091. * @param name Define the name of the uniform as defined in the shader
  56092. * @param value Define the value to give to the uniform
  56093. * @return the texture itself allowing "fluent" like uniform updates
  56094. */
  56095. ProceduralTexture.prototype.setVector3 = function (name, value) {
  56096. this._checkUniform(name);
  56097. this._vectors3[name] = value;
  56098. return this;
  56099. };
  56100. /**
  56101. * Set a mat4 in the shader from a MAtrix.
  56102. * @param name Define the name of the uniform as defined in the shader
  56103. * @param value Define the value to give to the uniform
  56104. * @return the texture itself allowing "fluent" like uniform updates
  56105. */
  56106. ProceduralTexture.prototype.setMatrix = function (name, value) {
  56107. this._checkUniform(name);
  56108. this._matrices[name] = value;
  56109. return this;
  56110. };
  56111. /**
  56112. * Render the texture to its associated render target.
  56113. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56114. */
  56115. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56116. var scene = this.getScene();
  56117. if (!scene) {
  56118. return;
  56119. }
  56120. var engine = this._engine;
  56121. // Render
  56122. engine.enableEffect(this._effect);
  56123. engine.setState(false);
  56124. // Texture
  56125. for (var name in this._textures) {
  56126. this._effect.setTexture(name, this._textures[name]);
  56127. }
  56128. // Float
  56129. for (name in this._ints) {
  56130. this._effect.setInt(name, this._ints[name]);
  56131. }
  56132. // Float
  56133. for (name in this._floats) {
  56134. this._effect.setFloat(name, this._floats[name]);
  56135. }
  56136. // Floats
  56137. for (name in this._floatsArrays) {
  56138. this._effect.setArray(name, this._floatsArrays[name]);
  56139. }
  56140. // Color3
  56141. for (name in this._colors3) {
  56142. this._effect.setColor3(name, this._colors3[name]);
  56143. }
  56144. // Color4
  56145. for (name in this._colors4) {
  56146. var color = this._colors4[name];
  56147. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  56148. }
  56149. // Vector2
  56150. for (name in this._vectors2) {
  56151. this._effect.setVector2(name, this._vectors2[name]);
  56152. }
  56153. // Vector3
  56154. for (name in this._vectors3) {
  56155. this._effect.setVector3(name, this._vectors3[name]);
  56156. }
  56157. // Matrix
  56158. for (name in this._matrices) {
  56159. this._effect.setMatrix(name, this._matrices[name]);
  56160. }
  56161. if (!this._texture) {
  56162. return;
  56163. }
  56164. if (this.isCube) {
  56165. for (var face = 0; face < 6; face++) {
  56166. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  56167. // VBOs
  56168. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  56169. this._effect.setFloat("face", face);
  56170. // Clear
  56171. if (this.autoClear) {
  56172. engine.clear(scene.clearColor, true, false, false);
  56173. }
  56174. // Draw order
  56175. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  56176. // Mipmaps
  56177. if (face === 5) {
  56178. engine.generateMipMapsForCubemap(this._texture);
  56179. }
  56180. }
  56181. }
  56182. else {
  56183. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  56184. // VBOs
  56185. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  56186. // Clear
  56187. if (this.autoClear) {
  56188. engine.clear(scene.clearColor, true, false, false);
  56189. }
  56190. // Draw order
  56191. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  56192. }
  56193. // Unbind
  56194. engine.unBindFramebuffer(this._texture, this.isCube);
  56195. if (this.onGenerated) {
  56196. this.onGenerated();
  56197. }
  56198. this.onGeneratedObservable.notifyObservers(this);
  56199. };
  56200. /**
  56201. * Clone the texture.
  56202. * @returns the cloned texture
  56203. */
  56204. ProceduralTexture.prototype.clone = function () {
  56205. var textureSize = this.getSize();
  56206. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  56207. // Base texture
  56208. newTexture.hasAlpha = this.hasAlpha;
  56209. newTexture.level = this.level;
  56210. // RenderTarget Texture
  56211. newTexture.coordinatesMode = this.coordinatesMode;
  56212. return newTexture;
  56213. };
  56214. /**
  56215. * Dispose the texture and release its asoociated resources.
  56216. */
  56217. ProceduralTexture.prototype.dispose = function () {
  56218. var scene = this.getScene();
  56219. if (!scene) {
  56220. return;
  56221. }
  56222. var index = scene.proceduralTextures.indexOf(this);
  56223. if (index >= 0) {
  56224. scene.proceduralTextures.splice(index, 1);
  56225. }
  56226. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  56227. if (vertexBuffer) {
  56228. vertexBuffer.dispose();
  56229. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  56230. }
  56231. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  56232. this._indexBuffer = null;
  56233. }
  56234. _super.prototype.dispose.call(this);
  56235. };
  56236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56238. ], ProceduralTexture.prototype, "isEnabled", void 0);
  56239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56241. ], ProceduralTexture.prototype, "autoClear", void 0);
  56242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56244. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  56245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56247. ], ProceduralTexture.prototype, "_size", void 0);
  56248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56250. ], ProceduralTexture.prototype, "refreshRate", null);
  56251. return ProceduralTexture;
  56252. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  56253. /***/ }),
  56254. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  56255. /*!***************************************************************************!*\
  56256. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  56257. \***************************************************************************/
  56258. /*! exports provided: ProceduralTextureSceneComponent */
  56259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56260. "use strict";
  56261. __webpack_require__.r(__webpack_exports__);
  56262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  56263. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  56264. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  56265. /**
  56266. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  56267. * in a given scene.
  56268. */
  56269. var ProceduralTextureSceneComponent = /** @class */ (function () {
  56270. /**
  56271. * Creates a new instance of the component for the given scene
  56272. * @param scene Defines the scene to register the component in
  56273. */
  56274. function ProceduralTextureSceneComponent(scene) {
  56275. /**
  56276. * The component name helpfull to identify the component in the list of scene components.
  56277. */
  56278. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  56279. this.scene = scene;
  56280. this.scene.proceduralTextures = new Array();
  56281. scene.layers = new Array();
  56282. }
  56283. /**
  56284. * Registers the component in a given scene
  56285. */
  56286. ProceduralTextureSceneComponent.prototype.register = function () {
  56287. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  56288. };
  56289. /**
  56290. * Rebuilds the elements related to this component in case of
  56291. * context lost for instance.
  56292. */
  56293. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  56294. // Nothing to do here.
  56295. };
  56296. /**
  56297. * Disposes the component and the associated ressources.
  56298. */
  56299. ProceduralTextureSceneComponent.prototype.dispose = function () {
  56300. // Nothing to do here.
  56301. };
  56302. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  56303. if (this.scene.proceduralTexturesEnabled) {
  56304. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  56305. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  56306. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  56307. if (proceduralTexture._shouldRender()) {
  56308. proceduralTexture.render();
  56309. }
  56310. }
  56311. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  56312. }
  56313. };
  56314. return ProceduralTextureSceneComponent;
  56315. }());
  56316. /***/ }),
  56317. /***/ "./Materials/Textures/baseTexture.ts":
  56318. /*!*******************************************!*\
  56319. !*** ./Materials/Textures/baseTexture.ts ***!
  56320. \*******************************************/
  56321. /*! exports provided: BaseTexture */
  56322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56323. "use strict";
  56324. __webpack_require__.r(__webpack_exports__);
  56325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  56326. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56327. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56328. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56329. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  56330. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  56331. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56332. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  56333. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56334. /**
  56335. * Base class of all the textures in babylon.
  56336. * It groups all the common properties the materials, post process, lights... might need
  56337. * in order to make a correct use of the texture.
  56338. */
  56339. var BaseTexture = /** @class */ (function () {
  56340. /**
  56341. * Instantiates a new BaseTexture.
  56342. * Base class of all the textures in babylon.
  56343. * It groups all the common properties the materials, post process, lights... might need
  56344. * in order to make a correct use of the texture.
  56345. * @param scene Define the scene the texture blongs to
  56346. */
  56347. function BaseTexture(scene) {
  56348. /**
  56349. * Gets or sets an object used to store user defined information.
  56350. */
  56351. this.metadata = null;
  56352. /**
  56353. * For internal use only. Please do not use.
  56354. */
  56355. this.reservedDataStore = null;
  56356. this._hasAlpha = false;
  56357. /**
  56358. * Defines if the alpha value should be determined via the rgb values.
  56359. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  56360. */
  56361. this.getAlphaFromRGB = false;
  56362. /**
  56363. * Intensity or strength of the texture.
  56364. * It is commonly used by materials to fine tune the intensity of the texture
  56365. */
  56366. this.level = 1;
  56367. /**
  56368. * Define the UV chanel to use starting from 0 and defaulting to 0.
  56369. * This is part of the texture as textures usually maps to one uv set.
  56370. */
  56371. this.coordinatesIndex = 0;
  56372. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  56373. /**
  56374. * | Value | Type | Description |
  56375. * | ----- | ------------------ | ----------- |
  56376. * | 0 | CLAMP_ADDRESSMODE | |
  56377. * | 1 | WRAP_ADDRESSMODE | |
  56378. * | 2 | MIRROR_ADDRESSMODE | |
  56379. */
  56380. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56381. /**
  56382. * | Value | Type | Description |
  56383. * | ----- | ------------------ | ----------- |
  56384. * | 0 | CLAMP_ADDRESSMODE | |
  56385. * | 1 | WRAP_ADDRESSMODE | |
  56386. * | 2 | MIRROR_ADDRESSMODE | |
  56387. */
  56388. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56389. /**
  56390. * | Value | Type | Description |
  56391. * | ----- | ------------------ | ----------- |
  56392. * | 0 | CLAMP_ADDRESSMODE | |
  56393. * | 1 | WRAP_ADDRESSMODE | |
  56394. * | 2 | MIRROR_ADDRESSMODE | |
  56395. */
  56396. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56397. /**
  56398. * With compliant hardware and browser (supporting anisotropic filtering)
  56399. * this defines the level of anisotropic filtering in the texture.
  56400. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  56401. */
  56402. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  56403. /**
  56404. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  56405. * HDR texture are usually stored in linear space.
  56406. * This only impacts the PBR and Background materials
  56407. */
  56408. this.gammaSpace = true;
  56409. /**
  56410. * Is Z inverted in the texture (useful in a cube texture).
  56411. */
  56412. this.invertZ = false;
  56413. /**
  56414. * @hidden
  56415. */
  56416. this.lodLevelInAlpha = false;
  56417. /**
  56418. * Define if the texture is a render target.
  56419. */
  56420. this.isRenderTarget = false;
  56421. /**
  56422. * Define the list of animation attached to the texture.
  56423. */
  56424. this.animations = new Array();
  56425. /**
  56426. * An event triggered when the texture is disposed.
  56427. */
  56428. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  56429. /**
  56430. * Define the current state of the loading sequence when in delayed load mode.
  56431. */
  56432. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  56433. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  56434. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  56435. if (this._scene) {
  56436. this.uniqueId = this._scene.getUniqueId();
  56437. this._scene.addTexture(this);
  56438. }
  56439. this._uid = null;
  56440. }
  56441. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  56442. get: function () {
  56443. return this._hasAlpha;
  56444. },
  56445. /**
  56446. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  56447. */
  56448. set: function (value) {
  56449. if (this._hasAlpha === value) {
  56450. return;
  56451. }
  56452. this._hasAlpha = value;
  56453. if (this._scene) {
  56454. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  56455. }
  56456. },
  56457. enumerable: true,
  56458. configurable: true
  56459. });
  56460. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  56461. get: function () {
  56462. return this._coordinatesMode;
  56463. },
  56464. /**
  56465. * How a texture is mapped.
  56466. *
  56467. * | Value | Type | Description |
  56468. * | ----- | ----------------------------------- | ----------- |
  56469. * | 0 | EXPLICIT_MODE | |
  56470. * | 1 | SPHERICAL_MODE | |
  56471. * | 2 | PLANAR_MODE | |
  56472. * | 3 | CUBIC_MODE | |
  56473. * | 4 | PROJECTION_MODE | |
  56474. * | 5 | SKYBOX_MODE | |
  56475. * | 6 | INVCUBIC_MODE | |
  56476. * | 7 | EQUIRECTANGULAR_MODE | |
  56477. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  56478. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  56479. */
  56480. set: function (value) {
  56481. if (this._coordinatesMode === value) {
  56482. return;
  56483. }
  56484. this._coordinatesMode = value;
  56485. if (this._scene) {
  56486. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  56487. }
  56488. },
  56489. enumerable: true,
  56490. configurable: true
  56491. });
  56492. Object.defineProperty(BaseTexture.prototype, "isCube", {
  56493. /**
  56494. * Define if the texture is a cube texture or if false a 2d texture.
  56495. */
  56496. get: function () {
  56497. if (!this._texture) {
  56498. return false;
  56499. }
  56500. return this._texture.isCube;
  56501. },
  56502. set: function (value) {
  56503. if (!this._texture) {
  56504. return;
  56505. }
  56506. this._texture.isCube = value;
  56507. },
  56508. enumerable: true,
  56509. configurable: true
  56510. });
  56511. Object.defineProperty(BaseTexture.prototype, "is3D", {
  56512. /**
  56513. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  56514. */
  56515. get: function () {
  56516. if (!this._texture) {
  56517. return false;
  56518. }
  56519. return this._texture.is3D;
  56520. },
  56521. set: function (value) {
  56522. if (!this._texture) {
  56523. return;
  56524. }
  56525. this._texture.is3D = value;
  56526. },
  56527. enumerable: true,
  56528. configurable: true
  56529. });
  56530. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  56531. /**
  56532. * Gets whether or not the texture contains RGBD data.
  56533. */
  56534. get: function () {
  56535. return this._texture != null && this._texture._isRGBD;
  56536. },
  56537. enumerable: true,
  56538. configurable: true
  56539. });
  56540. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  56541. /**
  56542. * Are mip maps generated for this texture or not.
  56543. */
  56544. get: function () {
  56545. return false;
  56546. },
  56547. enumerable: true,
  56548. configurable: true
  56549. });
  56550. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  56551. /**
  56552. * With prefiltered texture, defined the offset used during the prefiltering steps.
  56553. */
  56554. get: function () {
  56555. if (this._texture) {
  56556. return this._texture._lodGenerationOffset;
  56557. }
  56558. return 0.0;
  56559. },
  56560. set: function (value) {
  56561. if (this._texture) {
  56562. this._texture._lodGenerationOffset = value;
  56563. }
  56564. },
  56565. enumerable: true,
  56566. configurable: true
  56567. });
  56568. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  56569. /**
  56570. * With prefiltered texture, defined the scale used during the prefiltering steps.
  56571. */
  56572. get: function () {
  56573. if (this._texture) {
  56574. return this._texture._lodGenerationScale;
  56575. }
  56576. return 0.0;
  56577. },
  56578. set: function (value) {
  56579. if (this._texture) {
  56580. this._texture._lodGenerationScale = value;
  56581. }
  56582. },
  56583. enumerable: true,
  56584. configurable: true
  56585. });
  56586. Object.defineProperty(BaseTexture.prototype, "uid", {
  56587. /**
  56588. * Define the unique id of the texture in the scene.
  56589. */
  56590. get: function () {
  56591. if (!this._uid) {
  56592. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  56593. }
  56594. return this._uid;
  56595. },
  56596. enumerable: true,
  56597. configurable: true
  56598. });
  56599. /**
  56600. * Return a string representation of the texture.
  56601. * @returns the texture as a string
  56602. */
  56603. BaseTexture.prototype.toString = function () {
  56604. return this.name;
  56605. };
  56606. /**
  56607. * Get the class name of the texture.
  56608. * @returns "BaseTexture"
  56609. */
  56610. BaseTexture.prototype.getClassName = function () {
  56611. return "BaseTexture";
  56612. };
  56613. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  56614. /**
  56615. * Callback triggered when the texture has been disposed.
  56616. * Kept for back compatibility, you can use the onDisposeObservable instead.
  56617. */
  56618. set: function (callback) {
  56619. if (this._onDisposeObserver) {
  56620. this.onDisposeObservable.remove(this._onDisposeObserver);
  56621. }
  56622. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  56623. },
  56624. enumerable: true,
  56625. configurable: true
  56626. });
  56627. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  56628. /**
  56629. * Define if the texture is preventinga material to render or not.
  56630. * If not and the texture is not ready, the engine will use a default black texture instead.
  56631. */
  56632. get: function () {
  56633. return true;
  56634. },
  56635. enumerable: true,
  56636. configurable: true
  56637. });
  56638. /**
  56639. * Get the scene the texture belongs to.
  56640. * @returns the scene or null if undefined
  56641. */
  56642. BaseTexture.prototype.getScene = function () {
  56643. return this._scene;
  56644. };
  56645. /**
  56646. * Get the texture transform matrix used to offset tile the texture for istance.
  56647. * @returns the transformation matrix
  56648. */
  56649. BaseTexture.prototype.getTextureMatrix = function () {
  56650. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  56651. };
  56652. /**
  56653. * Get the texture reflection matrix used to rotate/transform the reflection.
  56654. * @returns the reflection matrix
  56655. */
  56656. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  56657. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  56658. };
  56659. /**
  56660. * Get the underlying lower level texture from Babylon.
  56661. * @returns the insternal texture
  56662. */
  56663. BaseTexture.prototype.getInternalTexture = function () {
  56664. return this._texture;
  56665. };
  56666. /**
  56667. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  56668. * @returns true if ready or not blocking
  56669. */
  56670. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  56671. return !this.isBlocking || this.isReady();
  56672. };
  56673. /**
  56674. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  56675. * @returns true if fully ready
  56676. */
  56677. BaseTexture.prototype.isReady = function () {
  56678. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  56679. this.delayLoad();
  56680. return false;
  56681. }
  56682. if (this._texture) {
  56683. return this._texture.isReady;
  56684. }
  56685. return false;
  56686. };
  56687. /**
  56688. * Get the size of the texture.
  56689. * @returns the texture size.
  56690. */
  56691. BaseTexture.prototype.getSize = function () {
  56692. if (this._texture) {
  56693. if (this._texture.width) {
  56694. this._cachedSize.width = this._texture.width;
  56695. this._cachedSize.height = this._texture.height;
  56696. return this._cachedSize;
  56697. }
  56698. if (this._texture._size) {
  56699. this._cachedSize.width = this._texture._size;
  56700. this._cachedSize.height = this._texture._size;
  56701. return this._cachedSize;
  56702. }
  56703. }
  56704. return this._cachedSize;
  56705. };
  56706. /**
  56707. * Get the base size of the texture.
  56708. * It can be different from the size if the texture has been resized for POT for instance
  56709. * @returns the base size
  56710. */
  56711. BaseTexture.prototype.getBaseSize = function () {
  56712. if (!this.isReady() || !this._texture) {
  56713. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  56714. }
  56715. if (this._texture._size) {
  56716. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  56717. }
  56718. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  56719. };
  56720. /**
  56721. * Update the sampling mode of the texture.
  56722. * Default is Trilinear mode.
  56723. *
  56724. * | Value | Type | Description |
  56725. * | ----- | ------------------ | ----------- |
  56726. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  56727. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  56728. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  56729. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  56730. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  56731. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  56732. * | 7 | NEAREST_LINEAR | |
  56733. * | 8 | NEAREST_NEAREST | |
  56734. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  56735. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  56736. * | 11 | LINEAR_LINEAR | |
  56737. * | 12 | LINEAR_NEAREST | |
  56738. *
  56739. * > _mag_: magnification filter (close to the viewer)
  56740. * > _min_: minification filter (far from the viewer)
  56741. * > _mip_: filter used between mip map levels
  56742. *@param samplingMode Define the new sampling mode of the texture
  56743. */
  56744. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  56745. if (!this._texture) {
  56746. return;
  56747. }
  56748. var scene = this.getScene();
  56749. if (!scene) {
  56750. return;
  56751. }
  56752. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  56753. };
  56754. /**
  56755. * Scales the texture if is `canRescale()`
  56756. * @param ratio the resize factor we want to use to rescale
  56757. */
  56758. BaseTexture.prototype.scale = function (ratio) {
  56759. };
  56760. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  56761. /**
  56762. * Get if the texture can rescale.
  56763. */
  56764. get: function () {
  56765. return false;
  56766. },
  56767. enumerable: true,
  56768. configurable: true
  56769. });
  56770. /** @hidden */
  56771. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  56772. if (!this._scene) {
  56773. return null;
  56774. }
  56775. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  56776. for (var index = 0; index < texturesCache.length; index++) {
  56777. var texturesCacheEntry = texturesCache[index];
  56778. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  56779. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  56780. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  56781. texturesCacheEntry.incrementReferences();
  56782. return texturesCacheEntry;
  56783. }
  56784. }
  56785. }
  56786. }
  56787. return null;
  56788. };
  56789. /** @hidden */
  56790. BaseTexture.prototype._rebuild = function () {
  56791. };
  56792. /**
  56793. * Triggers the load sequence in delayed load mode.
  56794. */
  56795. BaseTexture.prototype.delayLoad = function () {
  56796. };
  56797. /**
  56798. * Clones the texture.
  56799. * @returns the cloned texture
  56800. */
  56801. BaseTexture.prototype.clone = function () {
  56802. return null;
  56803. };
  56804. Object.defineProperty(BaseTexture.prototype, "textureType", {
  56805. /**
  56806. * Get the texture underlying type (INT, FLOAT...)
  56807. */
  56808. get: function () {
  56809. if (!this._texture) {
  56810. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  56811. }
  56812. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  56813. },
  56814. enumerable: true,
  56815. configurable: true
  56816. });
  56817. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  56818. /**
  56819. * Get the texture underlying format (RGB, RGBA...)
  56820. */
  56821. get: function () {
  56822. if (!this._texture) {
  56823. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  56824. }
  56825. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  56826. },
  56827. enumerable: true,
  56828. configurable: true
  56829. });
  56830. /**
  56831. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  56832. * This will returns an RGBA array buffer containing either in values (0-255) or
  56833. * float values (0-1) depending of the underlying buffer type.
  56834. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  56835. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  56836. * @param buffer defines a user defined buffer to fill with data (can be null)
  56837. * @returns The Array buffer containing the pixels data.
  56838. */
  56839. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  56840. if (faceIndex === void 0) { faceIndex = 0; }
  56841. if (level === void 0) { level = 0; }
  56842. if (buffer === void 0) { buffer = null; }
  56843. if (!this._texture) {
  56844. return null;
  56845. }
  56846. var size = this.getSize();
  56847. var width = size.width;
  56848. var height = size.height;
  56849. var scene = this.getScene();
  56850. if (!scene) {
  56851. return null;
  56852. }
  56853. var engine = scene.getEngine();
  56854. if (level != 0) {
  56855. width = width / Math.pow(2, level);
  56856. height = height / Math.pow(2, level);
  56857. width = Math.round(width);
  56858. height = Math.round(height);
  56859. }
  56860. if (this._texture.isCube) {
  56861. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  56862. }
  56863. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  56864. };
  56865. /**
  56866. * Release and destroy the underlying lower level texture aka internalTexture.
  56867. */
  56868. BaseTexture.prototype.releaseInternalTexture = function () {
  56869. if (this._texture) {
  56870. this._texture.dispose();
  56871. this._texture = null;
  56872. }
  56873. };
  56874. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  56875. /**
  56876. * Get the polynomial representation of the texture data.
  56877. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  56878. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  56879. */
  56880. get: function () {
  56881. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  56882. return null;
  56883. }
  56884. if (!this._texture._sphericalPolynomial) {
  56885. this._texture._sphericalPolynomial =
  56886. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  56887. }
  56888. return this._texture._sphericalPolynomial;
  56889. },
  56890. set: function (value) {
  56891. if (this._texture) {
  56892. this._texture._sphericalPolynomial = value;
  56893. }
  56894. },
  56895. enumerable: true,
  56896. configurable: true
  56897. });
  56898. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  56899. /** @hidden */
  56900. get: function () {
  56901. if (this._texture) {
  56902. return this._texture._lodTextureHigh;
  56903. }
  56904. return null;
  56905. },
  56906. enumerable: true,
  56907. configurable: true
  56908. });
  56909. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  56910. /** @hidden */
  56911. get: function () {
  56912. if (this._texture) {
  56913. return this._texture._lodTextureMid;
  56914. }
  56915. return null;
  56916. },
  56917. enumerable: true,
  56918. configurable: true
  56919. });
  56920. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  56921. /** @hidden */
  56922. get: function () {
  56923. if (this._texture) {
  56924. return this._texture._lodTextureLow;
  56925. }
  56926. return null;
  56927. },
  56928. enumerable: true,
  56929. configurable: true
  56930. });
  56931. /**
  56932. * Dispose the texture and release its associated resources.
  56933. */
  56934. BaseTexture.prototype.dispose = function () {
  56935. if (!this._scene) {
  56936. return;
  56937. }
  56938. // Animations
  56939. this._scene.stopAnimation(this);
  56940. // Remove from scene
  56941. this._scene._removePendingData(this);
  56942. var index = this._scene.textures.indexOf(this);
  56943. if (index >= 0) {
  56944. this._scene.textures.splice(index, 1);
  56945. }
  56946. this._scene.onTextureRemovedObservable.notifyObservers(this);
  56947. if (this._texture === undefined) {
  56948. return;
  56949. }
  56950. // Release
  56951. this.releaseInternalTexture();
  56952. // Callback
  56953. this.onDisposeObservable.notifyObservers(this);
  56954. this.onDisposeObservable.clear();
  56955. };
  56956. /**
  56957. * Serialize the texture into a JSON representation that can be parsed later on.
  56958. * @returns the JSON representation of the texture
  56959. */
  56960. BaseTexture.prototype.serialize = function () {
  56961. if (!this.name) {
  56962. return null;
  56963. }
  56964. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  56965. // Animations
  56966. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  56967. return serializationObject;
  56968. };
  56969. /**
  56970. * Helper function to be called back once a list of texture contains only ready textures.
  56971. * @param textures Define the list of textures to wait for
  56972. * @param callback Define the callback triggered once the entire list will be ready
  56973. */
  56974. BaseTexture.WhenAllReady = function (textures, callback) {
  56975. var numRemaining = textures.length;
  56976. if (numRemaining === 0) {
  56977. callback();
  56978. return;
  56979. }
  56980. var _loop_1 = function () {
  56981. texture = textures[i];
  56982. if (texture.isReady()) {
  56983. if (--numRemaining === 0) {
  56984. callback();
  56985. }
  56986. }
  56987. else {
  56988. onLoadObservable = texture.onLoadObservable;
  56989. var onLoadCallback_1 = function () {
  56990. onLoadObservable.removeCallback(onLoadCallback_1);
  56991. if (--numRemaining === 0) {
  56992. callback();
  56993. }
  56994. };
  56995. onLoadObservable.add(onLoadCallback_1);
  56996. }
  56997. };
  56998. var texture, onLoadObservable;
  56999. for (var i = 0; i < textures.length; i++) {
  57000. _loop_1();
  57001. }
  57002. };
  57003. /**
  57004. * Default anisotropic filtering level for the application.
  57005. * It is set to 4 as a good tradeoff between perf and quality.
  57006. */
  57007. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  57008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57010. ], BaseTexture.prototype, "uniqueId", void 0);
  57011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57013. ], BaseTexture.prototype, "name", void 0);
  57014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57016. ], BaseTexture.prototype, "metadata", void 0);
  57017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  57019. ], BaseTexture.prototype, "_hasAlpha", void 0);
  57020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57022. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  57023. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57025. ], BaseTexture.prototype, "level", void 0);
  57026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57028. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  57029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  57031. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  57032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57034. ], BaseTexture.prototype, "wrapU", void 0);
  57035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57037. ], BaseTexture.prototype, "wrapV", void 0);
  57038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57040. ], BaseTexture.prototype, "wrapR", void 0);
  57041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57043. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  57044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57046. ], BaseTexture.prototype, "isCube", null);
  57047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57049. ], BaseTexture.prototype, "is3D", null);
  57050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57052. ], BaseTexture.prototype, "gammaSpace", void 0);
  57053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57055. ], BaseTexture.prototype, "invertZ", void 0);
  57056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57058. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  57059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57061. ], BaseTexture.prototype, "lodGenerationOffset", null);
  57062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57064. ], BaseTexture.prototype, "lodGenerationScale", null);
  57065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57067. ], BaseTexture.prototype, "isRenderTarget", void 0);
  57068. return BaseTexture;
  57069. }());
  57070. /***/ }),
  57071. /***/ "./Materials/Textures/colorGradingTexture.ts":
  57072. /*!***************************************************!*\
  57073. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  57074. \***************************************************/
  57075. /*! exports provided: ColorGradingTexture */
  57076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57077. "use strict";
  57078. __webpack_require__.r(__webpack_exports__);
  57079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  57080. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57081. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57082. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57083. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57084. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57085. /**
  57086. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  57087. * It can help converting any input color in a desired output one. This can then be used to create effects
  57088. * from sepia, black and white to sixties or futuristic rendering...
  57089. *
  57090. * The only supported format is currently 3dl.
  57091. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  57092. */
  57093. var ColorGradingTexture = /** @class */ (function (_super) {
  57094. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  57095. /**
  57096. * Instantiates a ColorGradingTexture from the following parameters.
  57097. *
  57098. * @param url The location of the color gradind data (currently only supporting 3dl)
  57099. * @param scene The scene the texture will be used in
  57100. */
  57101. function ColorGradingTexture(url, scene) {
  57102. var _this = _super.call(this, scene) || this;
  57103. if (!url) {
  57104. return _this;
  57105. }
  57106. _this._engine = scene.getEngine();
  57107. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  57108. _this.name = url;
  57109. _this.url = url;
  57110. _this.hasAlpha = false;
  57111. _this.isCube = false;
  57112. _this.is3D = _this._engine.webGLVersion > 1;
  57113. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57114. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57115. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57116. _this.anisotropicFilteringLevel = 1;
  57117. _this._texture = _this._getFromCache(url, true);
  57118. if (!_this._texture) {
  57119. if (!scene.useDelayedTextureLoading) {
  57120. _this.loadTexture();
  57121. }
  57122. else {
  57123. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57124. }
  57125. }
  57126. return _this;
  57127. }
  57128. /**
  57129. * Returns the texture matrix used in most of the material.
  57130. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  57131. */
  57132. ColorGradingTexture.prototype.getTextureMatrix = function () {
  57133. return this._textureMatrix;
  57134. };
  57135. /**
  57136. * Occurs when the file being loaded is a .3dl LUT file.
  57137. */
  57138. ColorGradingTexture.prototype.load3dlTexture = function () {
  57139. var engine = this._engine;
  57140. var texture;
  57141. if (engine.webGLVersion === 1) {
  57142. 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);
  57143. }
  57144. else {
  57145. 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);
  57146. }
  57147. this._texture = texture;
  57148. var callback = function (text) {
  57149. if (typeof text !== "string") {
  57150. return;
  57151. }
  57152. var data = null;
  57153. var tempData = null;
  57154. var line;
  57155. var lines = text.split('\n');
  57156. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  57157. var maxColor = 0;
  57158. for (var i = 0; i < lines.length; i++) {
  57159. line = lines[i];
  57160. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  57161. continue;
  57162. }
  57163. if (line.indexOf('#') === 0) {
  57164. continue;
  57165. }
  57166. var words = line.split(" ");
  57167. if (size === 0) {
  57168. // Number of space + one
  57169. size = words.length;
  57170. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  57171. tempData = new Float32Array(size * size * size * 4);
  57172. continue;
  57173. }
  57174. if (size != 0) {
  57175. var r = Math.max(parseInt(words[0]), 0);
  57176. var g = Math.max(parseInt(words[1]), 0);
  57177. var b = Math.max(parseInt(words[2]), 0);
  57178. maxColor = Math.max(r, maxColor);
  57179. maxColor = Math.max(g, maxColor);
  57180. maxColor = Math.max(b, maxColor);
  57181. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  57182. if (tempData) {
  57183. tempData[pixelStorageIndex + 0] = r;
  57184. tempData[pixelStorageIndex + 1] = g;
  57185. tempData[pixelStorageIndex + 2] = b;
  57186. }
  57187. // Keep for reference in case of back compat problems.
  57188. // pixelIndexSlice++;
  57189. // if (pixelIndexSlice % size == 0) {
  57190. // pixelIndexH++;
  57191. // pixelIndexSlice = 0;
  57192. // if (pixelIndexH % size == 0) {
  57193. // pixelIndexW++;
  57194. // pixelIndexH = 0;
  57195. // }
  57196. // }
  57197. pixelIndexH++;
  57198. if (pixelIndexH % size == 0) {
  57199. pixelIndexSlice++;
  57200. pixelIndexH = 0;
  57201. if (pixelIndexSlice % size == 0) {
  57202. pixelIndexW++;
  57203. pixelIndexSlice = 0;
  57204. }
  57205. }
  57206. }
  57207. }
  57208. if (tempData && data) {
  57209. for (var i = 0; i < tempData.length; i++) {
  57210. if (i > 0 && (i + 1) % 4 === 0) {
  57211. data[i] = 255;
  57212. }
  57213. else {
  57214. var value = tempData[i];
  57215. data[i] = (value / maxColor * 255);
  57216. }
  57217. }
  57218. }
  57219. if (texture.is3D) {
  57220. texture.updateSize(size, size, size);
  57221. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  57222. }
  57223. else {
  57224. texture.updateSize(size * size, size);
  57225. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  57226. }
  57227. };
  57228. var scene = this.getScene();
  57229. if (scene) {
  57230. scene._loadFile(this.url, callback);
  57231. }
  57232. else {
  57233. this._engine._loadFile(this.url, callback);
  57234. }
  57235. return this._texture;
  57236. };
  57237. /**
  57238. * Starts the loading process of the texture.
  57239. */
  57240. ColorGradingTexture.prototype.loadTexture = function () {
  57241. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  57242. this.load3dlTexture();
  57243. }
  57244. };
  57245. /**
  57246. * Clones the color gradind texture.
  57247. */
  57248. ColorGradingTexture.prototype.clone = function () {
  57249. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  57250. // Base texture
  57251. newTexture.level = this.level;
  57252. return newTexture;
  57253. };
  57254. /**
  57255. * Called during delayed load for textures.
  57256. */
  57257. ColorGradingTexture.prototype.delayLoad = function () {
  57258. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57259. return;
  57260. }
  57261. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  57262. this._texture = this._getFromCache(this.url, true);
  57263. if (!this._texture) {
  57264. this.loadTexture();
  57265. }
  57266. };
  57267. /**
  57268. * Parses a color grading texture serialized by Babylon.
  57269. * @param parsedTexture The texture information being parsedTexture
  57270. * @param scene The scene to load the texture in
  57271. * @param rootUrl The root url of the data assets to load
  57272. * @return A color gradind texture
  57273. */
  57274. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  57275. var texture = null;
  57276. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  57277. texture = new ColorGradingTexture(parsedTexture.name, scene);
  57278. texture.name = parsedTexture.name;
  57279. texture.level = parsedTexture.level;
  57280. }
  57281. return texture;
  57282. };
  57283. /**
  57284. * Serializes the LUT texture to json format.
  57285. */
  57286. ColorGradingTexture.prototype.serialize = function () {
  57287. if (!this.name) {
  57288. return null;
  57289. }
  57290. var serializationObject = {};
  57291. serializationObject.name = this.name;
  57292. serializationObject.level = this.level;
  57293. serializationObject.customType = "BABYLON.ColorGradingTexture";
  57294. return serializationObject;
  57295. };
  57296. /**
  57297. * Empty line regex stored for GC.
  57298. */
  57299. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  57300. return ColorGradingTexture;
  57301. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  57302. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  57303. /***/ }),
  57304. /***/ "./Materials/Textures/cubeTexture.ts":
  57305. /*!*******************************************!*\
  57306. !*** ./Materials/Textures/cubeTexture.ts ***!
  57307. \*******************************************/
  57308. /*! exports provided: CubeTexture */
  57309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57310. "use strict";
  57311. __webpack_require__.r(__webpack_exports__);
  57312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  57313. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57314. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57315. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57316. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57317. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57318. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57319. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57320. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57321. /**
  57322. * Class for creating a cube texture
  57323. */
  57324. var CubeTexture = /** @class */ (function (_super) {
  57325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  57326. /**
  57327. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  57328. * as prefiltered data.
  57329. * @param rootUrl defines the url of the texture or the root name of the six images
  57330. * @param scene defines the scene the texture is attached to
  57331. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  57332. * @param noMipmap defines if mipmaps should be created or not
  57333. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  57334. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  57335. * @param onError defines a callback triggered in case of error during load
  57336. * @param format defines the internal format to use for the texture once loaded
  57337. * @param prefiltered defines whether or not the texture is created from prefiltered data
  57338. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  57339. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  57340. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57341. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57342. * @return the cube texture
  57343. */
  57344. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  57345. if (extensions === void 0) { extensions = null; }
  57346. if (noMipmap === void 0) { noMipmap = false; }
  57347. if (files === void 0) { files = null; }
  57348. if (onLoad === void 0) { onLoad = null; }
  57349. if (onError === void 0) { onError = null; }
  57350. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  57351. if (prefiltered === void 0) { prefiltered = false; }
  57352. if (forcedExtension === void 0) { forcedExtension = null; }
  57353. if (createPolynomials === void 0) { createPolynomials = false; }
  57354. if (lodScale === void 0) { lodScale = 0.8; }
  57355. if (lodOffset === void 0) { lodOffset = 0; }
  57356. var _this = _super.call(this, scene) || this;
  57357. /**
  57358. * Gets or sets the center of the bounding box associated with the cube texture.
  57359. * It must define where the camera used to render the texture was set
  57360. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  57361. */
  57362. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57363. _this._rotationY = 0;
  57364. /** @hidden */
  57365. _this._prefiltered = false;
  57366. _this.name = rootUrl;
  57367. _this.url = rootUrl;
  57368. _this._noMipmap = noMipmap;
  57369. _this.hasAlpha = false;
  57370. _this._format = format;
  57371. _this.isCube = true;
  57372. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57373. _this._createPolynomials = createPolynomials;
  57374. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  57375. if (!rootUrl && !files) {
  57376. return _this;
  57377. }
  57378. var lastDot = rootUrl.lastIndexOf(".");
  57379. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  57380. var isDDS = (extension === ".dds");
  57381. var isEnv = (extension === ".env");
  57382. if (isEnv) {
  57383. _this.gammaSpace = false;
  57384. _this._prefiltered = false;
  57385. }
  57386. else {
  57387. _this._prefiltered = prefiltered;
  57388. if (prefiltered) {
  57389. _this.gammaSpace = false;
  57390. }
  57391. }
  57392. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  57393. if (!files) {
  57394. if (!isEnv && !isDDS && !extensions) {
  57395. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  57396. }
  57397. files = [];
  57398. if (extensions) {
  57399. for (var index = 0; index < extensions.length; index++) {
  57400. files.push(rootUrl + extensions[index]);
  57401. }
  57402. }
  57403. }
  57404. _this._files = files;
  57405. if (!_this._texture) {
  57406. if (!scene.useDelayedTextureLoading) {
  57407. if (prefiltered) {
  57408. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  57409. }
  57410. else {
  57411. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  57412. }
  57413. }
  57414. else {
  57415. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57416. }
  57417. }
  57418. else if (onLoad) {
  57419. if (_this._texture.isReady) {
  57420. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  57421. }
  57422. else {
  57423. _this._texture.onLoadedObservable.add(onLoad);
  57424. }
  57425. }
  57426. return _this;
  57427. }
  57428. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  57429. /**
  57430. * Returns the bounding box size
  57431. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  57432. */
  57433. get: function () {
  57434. return this._boundingBoxSize;
  57435. },
  57436. /**
  57437. * Gets or sets the size of the bounding box associated with the cube texture
  57438. * When defined, the cubemap will switch to local mode
  57439. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57440. * @example https://www.babylonjs-playground.com/#RNASML
  57441. */
  57442. set: function (value) {
  57443. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57444. return;
  57445. }
  57446. this._boundingBoxSize = value;
  57447. var scene = this.getScene();
  57448. if (scene) {
  57449. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  57450. }
  57451. },
  57452. enumerable: true,
  57453. configurable: true
  57454. });
  57455. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  57456. /**
  57457. * Gets texture matrix rotation angle around Y axis radians.
  57458. */
  57459. get: function () {
  57460. return this._rotationY;
  57461. },
  57462. /**
  57463. * Sets texture matrix rotation angle around Y axis in radians.
  57464. */
  57465. set: function (value) {
  57466. this._rotationY = value;
  57467. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  57468. },
  57469. enumerable: true,
  57470. configurable: true
  57471. });
  57472. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  57473. /**
  57474. * Are mip maps generated for this texture or not.
  57475. */
  57476. get: function () {
  57477. return this._noMipmap;
  57478. },
  57479. enumerable: true,
  57480. configurable: true
  57481. });
  57482. /**
  57483. * Creates a cube texture from an array of image urls
  57484. * @param files defines an array of image urls
  57485. * @param scene defines the hosting scene
  57486. * @param noMipmap specifies if mip maps are not used
  57487. * @returns a cube texture
  57488. */
  57489. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  57490. var rootUrlKey = "";
  57491. files.forEach(function (url) { return rootUrlKey += url; });
  57492. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  57493. };
  57494. /**
  57495. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  57496. * @param url defines the url of the prefiltered texture
  57497. * @param scene defines the scene the texture is attached to
  57498. * @param forcedExtension defines the extension of the file if different from the url
  57499. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  57500. * @return the prefiltered texture
  57501. */
  57502. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  57503. if (forcedExtension === void 0) { forcedExtension = null; }
  57504. if (createPolynomials === void 0) { createPolynomials = true; }
  57505. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  57506. };
  57507. /**
  57508. * Get the current class name of the texture useful for serialization or dynamic coding.
  57509. * @returns "CubeTexture"
  57510. */
  57511. CubeTexture.prototype.getClassName = function () {
  57512. return "CubeTexture";
  57513. };
  57514. /**
  57515. * Update the url (and optional buffer) of this texture if url was null during construction.
  57516. * @param url the url of the texture
  57517. * @param forcedExtension defines the extension to use
  57518. * @param onLoad callback called when the texture is loaded (defaults to null)
  57519. */
  57520. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  57521. if (this.url) {
  57522. this.releaseInternalTexture();
  57523. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  57524. }
  57525. this.url = url;
  57526. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57527. this._prefiltered = false;
  57528. if (onLoad) {
  57529. this._delayedOnLoad = onLoad;
  57530. }
  57531. this.delayLoad(forcedExtension);
  57532. };
  57533. /**
  57534. * Delays loading of the cube texture
  57535. * @param forcedExtension defines the extension to use
  57536. */
  57537. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  57538. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57539. return;
  57540. }
  57541. var scene = this.getScene();
  57542. if (!scene) {
  57543. return;
  57544. }
  57545. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  57546. this._texture = this._getFromCache(this.url, this._noMipmap);
  57547. if (!this._texture) {
  57548. if (this._prefiltered) {
  57549. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  57550. }
  57551. else {
  57552. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  57553. }
  57554. }
  57555. };
  57556. /**
  57557. * Returns the reflection texture matrix
  57558. * @returns the reflection texture matrix
  57559. */
  57560. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  57561. return this._textureMatrix;
  57562. };
  57563. /**
  57564. * Sets the reflection texture matrix
  57565. * @param value Reflection texture matrix
  57566. */
  57567. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  57568. var _this = this;
  57569. if (value.updateFlag === this._textureMatrix.updateFlag) {
  57570. return;
  57571. }
  57572. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  57573. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  57574. }
  57575. this._textureMatrix = value;
  57576. };
  57577. /**
  57578. * Parses text to create a cube texture
  57579. * @param parsedTexture define the serialized text to read from
  57580. * @param scene defines the hosting scene
  57581. * @param rootUrl defines the root url of the cube texture
  57582. * @returns a cube texture
  57583. */
  57584. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  57585. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  57586. var prefiltered = false;
  57587. if (parsedTexture.prefiltered) {
  57588. prefiltered = parsedTexture.prefiltered;
  57589. }
  57590. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  57591. }, parsedTexture, scene);
  57592. // Local Cubemaps
  57593. if (parsedTexture.boundingBoxPosition) {
  57594. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  57595. }
  57596. if (parsedTexture.boundingBoxSize) {
  57597. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  57598. }
  57599. // Animations
  57600. if (parsedTexture.animations) {
  57601. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  57602. var parsedAnimation = parsedTexture.animations[animationIndex];
  57603. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  57604. if (internalClass) {
  57605. texture.animations.push(internalClass.Parse(parsedAnimation));
  57606. }
  57607. }
  57608. }
  57609. return texture;
  57610. };
  57611. /**
  57612. * Makes a clone, or deep copy, of the cube texture
  57613. * @returns a new cube texture
  57614. */
  57615. CubeTexture.prototype.clone = function () {
  57616. var _this = this;
  57617. var scene = this.getScene();
  57618. var uniqueId = 0;
  57619. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57620. if (!scene) {
  57621. return _this;
  57622. }
  57623. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  57624. uniqueId = cubeTexture.uniqueId;
  57625. return cubeTexture;
  57626. }, this);
  57627. newCubeTexture.uniqueId = uniqueId;
  57628. return newCubeTexture;
  57629. };
  57630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  57632. ], CubeTexture.prototype, "rotationY", null);
  57633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMatrix"])("textureMatrix")
  57635. ], CubeTexture.prototype, "_textureMatrix", void 0);
  57636. return CubeTexture;
  57637. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  57638. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  57639. // Some exporters relies on Tools.Instantiate
  57640. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  57641. /***/ }),
  57642. /***/ "./Materials/Textures/dynamicTexture.ts":
  57643. /*!**********************************************!*\
  57644. !*** ./Materials/Textures/dynamicTexture.ts ***!
  57645. \**********************************************/
  57646. /*! exports provided: DynamicTexture */
  57647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57648. "use strict";
  57649. __webpack_require__.r(__webpack_exports__);
  57650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  57651. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57652. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  57653. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57654. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57655. /**
  57656. * A class extending Texture allowing drawing on a texture
  57657. * @see http://doc.babylonjs.com/how_to/dynamictexture
  57658. */
  57659. var DynamicTexture = /** @class */ (function (_super) {
  57660. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  57661. /**
  57662. * Creates a DynamicTexture
  57663. * @param name defines the name of the texture
  57664. * @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
  57665. * @param scene defines the scene where you want the texture
  57666. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  57667. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57668. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  57669. */
  57670. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  57671. if (scene === void 0) { scene = null; }
  57672. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57673. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  57674. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  57675. _this.name = name;
  57676. _this._engine = _this.getScene().getEngine();
  57677. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  57678. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  57679. _this._generateMipMaps = generateMipMaps;
  57680. if (options.getContext) {
  57681. _this._canvas = options;
  57682. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  57683. }
  57684. else {
  57685. _this._canvas = document.createElement("canvas");
  57686. if (options.width || options.width === 0) {
  57687. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  57688. }
  57689. else {
  57690. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  57691. }
  57692. }
  57693. var textureSize = _this.getSize();
  57694. _this._canvas.width = textureSize.width;
  57695. _this._canvas.height = textureSize.height;
  57696. _this._context = _this._canvas.getContext("2d");
  57697. return _this;
  57698. }
  57699. /**
  57700. * Get the current class name of the texture useful for serialization or dynamic coding.
  57701. * @returns "DynamicTexture"
  57702. */
  57703. DynamicTexture.prototype.getClassName = function () {
  57704. return "DynamicTexture";
  57705. };
  57706. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  57707. /**
  57708. * Gets the current state of canRescale
  57709. */
  57710. get: function () {
  57711. return true;
  57712. },
  57713. enumerable: true,
  57714. configurable: true
  57715. });
  57716. DynamicTexture.prototype._recreate = function (textureSize) {
  57717. this._canvas.width = textureSize.width;
  57718. this._canvas.height = textureSize.height;
  57719. this.releaseInternalTexture();
  57720. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  57721. };
  57722. /**
  57723. * Scales the texture
  57724. * @param ratio the scale factor to apply to both width and height
  57725. */
  57726. DynamicTexture.prototype.scale = function (ratio) {
  57727. var textureSize = this.getSize();
  57728. textureSize.width *= ratio;
  57729. textureSize.height *= ratio;
  57730. this._recreate(textureSize);
  57731. };
  57732. /**
  57733. * Resizes the texture
  57734. * @param width the new width
  57735. * @param height the new height
  57736. */
  57737. DynamicTexture.prototype.scaleTo = function (width, height) {
  57738. var textureSize = this.getSize();
  57739. textureSize.width = width;
  57740. textureSize.height = height;
  57741. this._recreate(textureSize);
  57742. };
  57743. /**
  57744. * Gets the context of the canvas used by the texture
  57745. * @returns the canvas context of the dynamic texture
  57746. */
  57747. DynamicTexture.prototype.getContext = function () {
  57748. return this._context;
  57749. };
  57750. /**
  57751. * Clears the texture
  57752. */
  57753. DynamicTexture.prototype.clear = function () {
  57754. var size = this.getSize();
  57755. this._context.fillRect(0, 0, size.width, size.height);
  57756. };
  57757. /**
  57758. * Updates the texture
  57759. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  57760. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  57761. */
  57762. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  57763. if (premulAlpha === void 0) { premulAlpha = false; }
  57764. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  57765. };
  57766. /**
  57767. * Draws text onto the texture
  57768. * @param text defines the text to be drawn
  57769. * @param x defines the placement of the text from the left
  57770. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  57771. * @param font defines the font to be used with font-style, font-size, font-name
  57772. * @param color defines the color used for the text
  57773. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  57774. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  57775. * @param update defines whether texture is immediately update (default is true)
  57776. */
  57777. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  57778. if (update === void 0) { update = true; }
  57779. var size = this.getSize();
  57780. if (clearColor) {
  57781. this._context.fillStyle = clearColor;
  57782. this._context.fillRect(0, 0, size.width, size.height);
  57783. }
  57784. this._context.font = font;
  57785. if (x === null || x === undefined) {
  57786. var textSize = this._context.measureText(text);
  57787. x = (size.width - textSize.width) / 2;
  57788. }
  57789. if (y === null || y === undefined) {
  57790. var fontSize = parseInt((font.replace(/\D/g, '')));
  57791. y = (size.height / 2) + (fontSize / 3.65);
  57792. }
  57793. this._context.fillStyle = color;
  57794. this._context.fillText(text, x, y);
  57795. if (update) {
  57796. this.update(invertY);
  57797. }
  57798. };
  57799. /**
  57800. * Clones the texture
  57801. * @returns the clone of the texture.
  57802. */
  57803. DynamicTexture.prototype.clone = function () {
  57804. var scene = this.getScene();
  57805. if (!scene) {
  57806. return this;
  57807. }
  57808. var textureSize = this.getSize();
  57809. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  57810. // Base texture
  57811. newTexture.hasAlpha = this.hasAlpha;
  57812. newTexture.level = this.level;
  57813. // Dynamic Texture
  57814. newTexture.wrapU = this.wrapU;
  57815. newTexture.wrapV = this.wrapV;
  57816. return newTexture;
  57817. };
  57818. /**
  57819. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  57820. * @returns a serialized dynamic texture object
  57821. */
  57822. DynamicTexture.prototype.serialize = function () {
  57823. var scene = this.getScene();
  57824. if (scene && !scene.isReady()) {
  57825. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  57826. }
  57827. var serializationObject = _super.prototype.serialize.call(this);
  57828. serializationObject.base64String = this._canvas.toDataURL();
  57829. serializationObject.invertY = this._invertY;
  57830. serializationObject.samplingMode = this.samplingMode;
  57831. return serializationObject;
  57832. };
  57833. /** @hidden */
  57834. DynamicTexture.prototype._rebuild = function () {
  57835. this.update();
  57836. };
  57837. return DynamicTexture;
  57838. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  57839. /***/ }),
  57840. /***/ "./Materials/Textures/equiRectangularCubeTexture.ts":
  57841. /*!**********************************************************!*\
  57842. !*** ./Materials/Textures/equiRectangularCubeTexture.ts ***!
  57843. \**********************************************************/
  57844. /*! exports provided: EquiRectangularCubeTexture */
  57845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57846. "use strict";
  57847. __webpack_require__.r(__webpack_exports__);
  57848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return EquiRectangularCubeTexture; });
  57849. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57850. /* harmony import */ var _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  57851. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  57852. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  57853. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  57854. /**
  57855. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  57856. */
  57857. var EquiRectangularCubeTexture = /** @class */ (function (_super) {
  57858. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTexture, _super);
  57859. /**
  57860. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  57861. * @param url The location of the image
  57862. * @param scene The scene the texture will be used in
  57863. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57864. * @param noMipmap Forces to not generate the mipmap if true
  57865. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57866. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57867. * @param onLoad — defines a callback called when texture is loaded
  57868. * @param onError — defines a callback called if there is an error
  57869. */
  57870. function EquiRectangularCubeTexture(url, scene, size, noMipmap, gammaSpace, onLoad, onError) {
  57871. if (noMipmap === void 0) { noMipmap = false; }
  57872. if (gammaSpace === void 0) { gammaSpace = true; }
  57873. if (onLoad === void 0) { onLoad = null; }
  57874. if (onError === void 0) { onError = null; }
  57875. var _this = _super.call(this, scene) || this;
  57876. _this._onLoad = null;
  57877. _this._onError = null;
  57878. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  57879. _this.coordinatesMode = _texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  57880. if (!url) {
  57881. throw new Error('Image url is not set');
  57882. }
  57883. _this.name = url;
  57884. _this.url = url;
  57885. _this._size = size;
  57886. _this._noMipmap = noMipmap;
  57887. _this.gammaSpace = gammaSpace;
  57888. _this._onLoad = onLoad;
  57889. _this._onError = onError;
  57890. _this.hasAlpha = false;
  57891. _this.isCube = true;
  57892. _this._texture = _this._getFromCache(url, _this._noMipmap);
  57893. if (!_this._texture) {
  57894. if (!scene.useDelayedTextureLoading) {
  57895. _this.loadImage(_this.loadTexture.bind(_this));
  57896. }
  57897. else {
  57898. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  57899. }
  57900. }
  57901. return _this;
  57902. }
  57903. /**
  57904. * Load the image data, by putting the image on a canvas and extracting its buffer.
  57905. */
  57906. EquiRectangularCubeTexture.prototype.loadImage = function (loadTextureCallback) {
  57907. var _this = this;
  57908. var canvas = document.createElement('canvas');
  57909. var image = new Image();
  57910. image.addEventListener('load', function () {
  57911. _this._width = image.width;
  57912. _this._height = image.height;
  57913. canvas.width = _this._width;
  57914. canvas.height = _this._height;
  57915. var ctx = canvas.getContext('2d');
  57916. ctx.drawImage(image, 0, 0);
  57917. var imageData = ctx.getImageData(0, 0, image.width, image.height);
  57918. _this._buffer = imageData.data.buffer;
  57919. canvas.remove();
  57920. loadTextureCallback();
  57921. });
  57922. image.src = this.url;
  57923. };
  57924. /**
  57925. * Convert the image buffer into a cubemap and create a CubeTexture.
  57926. */
  57927. EquiRectangularCubeTexture.prototype.loadTexture = function () {
  57928. var _this = this;
  57929. var scene = this.getScene();
  57930. var callback = function () {
  57931. var imageData = _this.getFloat32ArrayFromArrayBuffer(_this._buffer);
  57932. // Extract the raw linear data.
  57933. var data = _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(imageData, _this._width, _this._height, _this._size);
  57934. var results = [];
  57935. // Push each faces.
  57936. for (var i = 0; i < 6; i++) {
  57937. var dataFace = data[EquiRectangularCubeTexture._FacesMapping[i]];
  57938. results.push(dataFace);
  57939. }
  57940. return results;
  57941. };
  57942. if (!scene) {
  57943. return;
  57944. }
  57945. this._texture = scene
  57946. .getEngine()
  57947. .createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat
  57948. ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT
  57949. : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, callback, null, this._onLoad, this._onError);
  57950. };
  57951. /**
  57952. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  57953. * @param buffer The ArrayBuffer that should be converted.
  57954. * @returns The buffer as Float32Array.
  57955. */
  57956. EquiRectangularCubeTexture.prototype.getFloat32ArrayFromArrayBuffer = function (buffer) {
  57957. var dataView = new DataView(buffer);
  57958. var floatImageData = new Float32Array((buffer.byteLength * 3) / 4);
  57959. var k = 0;
  57960. for (var i = 0; i < buffer.byteLength; i++) {
  57961. // We drop the transparency channel, because we do not need/want it
  57962. if ((i + 1) % 4 !== 0) {
  57963. floatImageData[k++] = dataView.getUint8(i) / 255;
  57964. }
  57965. }
  57966. return floatImageData;
  57967. };
  57968. /**
  57969. * Get the current class name of the texture useful for serialization or dynamic coding.
  57970. * @returns "EquiRectangularCubeTexture"
  57971. */
  57972. EquiRectangularCubeTexture.prototype.getClassName = function () {
  57973. return "EquiRectangularCubeTexture";
  57974. };
  57975. /**
  57976. * Create a clone of the current EquiRectangularCubeTexture and return it.
  57977. * @returns A clone of the current EquiRectangularCubeTexture.
  57978. */
  57979. EquiRectangularCubeTexture.prototype.clone = function () {
  57980. var scene = this.getScene();
  57981. if (!scene) {
  57982. return this;
  57983. }
  57984. var newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);
  57985. // Base texture
  57986. newTexture.level = this.level;
  57987. newTexture.wrapU = this.wrapU;
  57988. newTexture.wrapV = this.wrapV;
  57989. newTexture.coordinatesIndex = this.coordinatesIndex;
  57990. newTexture.coordinatesMode = this.coordinatesMode;
  57991. return newTexture;
  57992. };
  57993. /** The six faces of the cube. */
  57994. EquiRectangularCubeTexture._FacesMapping = ['right', 'left', 'up', 'down', 'front', 'back'];
  57995. return EquiRectangularCubeTexture;
  57996. }(_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  57997. /***/ }),
  57998. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  57999. /*!**********************************************!*\
  58000. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  58001. \**********************************************/
  58002. /*! exports provided: HDRCubeTexture */
  58003. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58004. "use strict";
  58005. __webpack_require__.r(__webpack_exports__);
  58006. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  58007. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58008. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58009. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  58010. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58011. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58012. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58013. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  58014. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  58015. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58016. /**
  58017. * This represents a texture coming from an HDR input.
  58018. *
  58019. * The only supported format is currently panorama picture stored in RGBE format.
  58020. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58021. */
  58022. var HDRCubeTexture = /** @class */ (function (_super) {
  58023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  58024. /**
  58025. * Instantiates an HDRTexture from the following parameters.
  58026. *
  58027. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58028. * @param scene The scene the texture will be used in
  58029. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58030. * @param noMipmap Forces to not generate the mipmap if true
  58031. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58032. * @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)
  58033. * @param reserved Reserved flag for internal use.
  58034. */
  58035. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  58036. if (noMipmap === void 0) { noMipmap = false; }
  58037. if (generateHarmonics === void 0) { generateHarmonics = true; }
  58038. if (gammaSpace === void 0) { gammaSpace = false; }
  58039. if (reserved === void 0) { reserved = false; }
  58040. if (onLoad === void 0) { onLoad = null; }
  58041. if (onError === void 0) { onError = null; }
  58042. var _this = _super.call(this, scene) || this;
  58043. _this._generateHarmonics = true;
  58044. _this._onLoad = null;
  58045. _this._onError = null;
  58046. /**
  58047. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58048. */
  58049. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  58050. _this._isBlocking = true;
  58051. _this._rotationY = 0;
  58052. /**
  58053. * Gets or sets the center of the bounding box associated with the cube texture
  58054. * It must define where the camera used to render the texture was set
  58055. */
  58056. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  58057. if (!url) {
  58058. return _this;
  58059. }
  58060. _this.name = url;
  58061. _this.url = url;
  58062. _this.hasAlpha = false;
  58063. _this.isCube = true;
  58064. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  58065. _this._onLoad = onLoad;
  58066. _this._onError = onError;
  58067. _this.gammaSpace = gammaSpace;
  58068. _this._noMipmap = noMipmap;
  58069. _this._size = size;
  58070. _this._texture = _this._getFromCache(url, _this._noMipmap);
  58071. if (!_this._texture) {
  58072. if (!scene.useDelayedTextureLoading) {
  58073. _this.loadTexture();
  58074. }
  58075. else {
  58076. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  58077. }
  58078. }
  58079. return _this;
  58080. }
  58081. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  58082. /**
  58083. * Gets wether or not the texture is blocking during loading.
  58084. */
  58085. get: function () {
  58086. return this._isBlocking;
  58087. },
  58088. /**
  58089. * Sets wether or not the texture is blocking during loading.
  58090. */
  58091. set: function (value) {
  58092. this._isBlocking = value;
  58093. },
  58094. enumerable: true,
  58095. configurable: true
  58096. });
  58097. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  58098. /**
  58099. * Gets texture matrix rotation angle around Y axis radians.
  58100. */
  58101. get: function () {
  58102. return this._rotationY;
  58103. },
  58104. /**
  58105. * Sets texture matrix rotation angle around Y axis in radians.
  58106. */
  58107. set: function (value) {
  58108. this._rotationY = value;
  58109. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  58110. },
  58111. enumerable: true,
  58112. configurable: true
  58113. });
  58114. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  58115. get: function () {
  58116. return this._boundingBoxSize;
  58117. },
  58118. /**
  58119. * Gets or sets the size of the bounding box associated with the cube texture
  58120. * When defined, the cubemap will switch to local mode
  58121. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58122. * @example https://www.babylonjs-playground.com/#RNASML
  58123. */
  58124. set: function (value) {
  58125. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  58126. return;
  58127. }
  58128. this._boundingBoxSize = value;
  58129. var scene = this.getScene();
  58130. if (scene) {
  58131. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  58132. }
  58133. },
  58134. enumerable: true,
  58135. configurable: true
  58136. });
  58137. /**
  58138. * Get the current class name of the texture useful for serialization or dynamic coding.
  58139. * @returns "HDRCubeTexture"
  58140. */
  58141. HDRCubeTexture.prototype.getClassName = function () {
  58142. return "HDRCubeTexture";
  58143. };
  58144. /**
  58145. * Occurs when the file is raw .hdr file.
  58146. */
  58147. HDRCubeTexture.prototype.loadTexture = function () {
  58148. var _this = this;
  58149. var callback = function (buffer) {
  58150. _this.lodGenerationOffset = 0.0;
  58151. _this.lodGenerationScale = 0.8;
  58152. var scene = _this.getScene();
  58153. if (!scene) {
  58154. return null;
  58155. }
  58156. // Extract the raw linear data.
  58157. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  58158. // Generate harmonics if needed.
  58159. if (_this._generateHarmonics) {
  58160. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  58161. _this.sphericalPolynomial = sphericalPolynomial;
  58162. }
  58163. var results = [];
  58164. var byteArray = null;
  58165. // Push each faces.
  58166. for (var j = 0; j < 6; j++) {
  58167. // Create uintarray fallback.
  58168. if (!scene.getEngine().getCaps().textureFloat) {
  58169. // 3 channels of 1 bytes per pixel in bytes.
  58170. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  58171. byteArray = new Uint8Array(byteBuffer);
  58172. }
  58173. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  58174. // If special cases.
  58175. if (_this.gammaSpace || byteArray) {
  58176. for (var i = 0; i < _this._size * _this._size; i++) {
  58177. // Put in gamma space if requested.
  58178. if (_this.gammaSpace) {
  58179. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58180. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58181. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58182. }
  58183. // Convert to int texture for fallback.
  58184. if (byteArray) {
  58185. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  58186. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  58187. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  58188. // May use luminance instead if the result is not accurate.
  58189. var max = Math.max(Math.max(r, g), b);
  58190. if (max > 255) {
  58191. var scale = 255 / max;
  58192. r *= scale;
  58193. g *= scale;
  58194. b *= scale;
  58195. }
  58196. byteArray[(i * 3) + 0] = r;
  58197. byteArray[(i * 3) + 1] = g;
  58198. byteArray[(i * 3) + 2] = b;
  58199. }
  58200. }
  58201. }
  58202. if (byteArray) {
  58203. results.push(byteArray);
  58204. }
  58205. else {
  58206. results.push(dataFace);
  58207. }
  58208. }
  58209. return results;
  58210. };
  58211. var scene = this.getScene();
  58212. if (scene) {
  58213. 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);
  58214. }
  58215. };
  58216. HDRCubeTexture.prototype.clone = function () {
  58217. var scene = this.getScene();
  58218. if (!scene) {
  58219. return this;
  58220. }
  58221. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  58222. // Base texture
  58223. newTexture.level = this.level;
  58224. newTexture.wrapU = this.wrapU;
  58225. newTexture.wrapV = this.wrapV;
  58226. newTexture.coordinatesIndex = this.coordinatesIndex;
  58227. newTexture.coordinatesMode = this.coordinatesMode;
  58228. return newTexture;
  58229. };
  58230. // Methods
  58231. HDRCubeTexture.prototype.delayLoad = function () {
  58232. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  58233. return;
  58234. }
  58235. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  58236. this._texture = this._getFromCache(this.url, this._noMipmap);
  58237. if (!this._texture) {
  58238. this.loadTexture();
  58239. }
  58240. };
  58241. /**
  58242. * Get the texture reflection matrix used to rotate/transform the reflection.
  58243. * @returns the reflection matrix
  58244. */
  58245. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  58246. return this._textureMatrix;
  58247. };
  58248. /**
  58249. * Set the texture reflection matrix used to rotate/transform the reflection.
  58250. * @param value Define the reflection matrix to set
  58251. */
  58252. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  58253. var _this = this;
  58254. this._textureMatrix = value;
  58255. if (value.updateFlag === this._textureMatrix.updateFlag) {
  58256. return;
  58257. }
  58258. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  58259. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  58260. }
  58261. };
  58262. /**
  58263. * Parses a JSON representation of an HDR Texture in order to create the texture
  58264. * @param parsedTexture Define the JSON representation
  58265. * @param scene Define the scene the texture should be created in
  58266. * @param rootUrl Define the root url in case we need to load relative dependencies
  58267. * @returns the newly created texture after parsing
  58268. */
  58269. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  58270. var texture = null;
  58271. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  58272. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  58273. texture.name = parsedTexture.name;
  58274. texture.hasAlpha = parsedTexture.hasAlpha;
  58275. texture.level = parsedTexture.level;
  58276. texture.coordinatesMode = parsedTexture.coordinatesMode;
  58277. texture.isBlocking = parsedTexture.isBlocking;
  58278. }
  58279. if (texture) {
  58280. if (parsedTexture.boundingBoxPosition) {
  58281. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  58282. }
  58283. if (parsedTexture.boundingBoxSize) {
  58284. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  58285. }
  58286. if (parsedTexture.rotationY) {
  58287. texture.rotationY = parsedTexture.rotationY;
  58288. }
  58289. }
  58290. return texture;
  58291. };
  58292. HDRCubeTexture.prototype.serialize = function () {
  58293. if (!this.name) {
  58294. return null;
  58295. }
  58296. var serializationObject = {};
  58297. serializationObject.name = this.name;
  58298. serializationObject.hasAlpha = this.hasAlpha;
  58299. serializationObject.isCube = true;
  58300. serializationObject.level = this.level;
  58301. serializationObject.size = this._size;
  58302. serializationObject.coordinatesMode = this.coordinatesMode;
  58303. serializationObject.useInGammaSpace = this.gammaSpace;
  58304. serializationObject.generateHarmonics = this._generateHarmonics;
  58305. serializationObject.customType = "BABYLON.HDRCubeTexture";
  58306. serializationObject.noMipmap = this._noMipmap;
  58307. serializationObject.isBlocking = this._isBlocking;
  58308. serializationObject.rotationY = this._rotationY;
  58309. return serializationObject;
  58310. };
  58311. HDRCubeTexture._facesMapping = [
  58312. "right",
  58313. "left",
  58314. "up",
  58315. "down",
  58316. "front",
  58317. "back"
  58318. ];
  58319. return HDRCubeTexture;
  58320. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  58321. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  58322. /***/ }),
  58323. /***/ "./Materials/Textures/index.ts":
  58324. /*!*************************************!*\
  58325. !*** ./Materials/Textures/index.ts ***!
  58326. \*************************************/
  58327. /*! exports provided: BaseTexture, CubeTexture, DynamicTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, VideoTexture, ColorGradingTexture, EquiRectangularCubeTexture, HDRCubeTexture, DummyInternalTextureTracker, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  58328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58329. "use strict";
  58330. __webpack_require__.r(__webpack_exports__);
  58331. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  58332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  58333. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  58334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  58335. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  58336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  58337. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  58338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  58339. /* harmony import */ var _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  58340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__["EquiRectangularCubeTexture"]; });
  58341. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  58342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__["HDRCubeTexture"]; });
  58343. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  58344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_6__["InternalTexture"]; });
  58345. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  58346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_7__["DummyInternalTextureTracker"]; });
  58347. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  58348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_DDSTextureLoader"]; });
  58349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_ENVTextureLoader"]; });
  58350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_KTXTextureLoader"]; });
  58351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_TGATextureLoader"]; });
  58352. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  58353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_9__["MirrorTexture"]; });
  58354. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  58355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_10__["MultiRenderTarget"]; });
  58356. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  58357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["CustomProceduralTexture"]; });
  58358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["NoiseProceduralTexture"]; });
  58359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["ProceduralTexture"]; });
  58360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["ProceduralTextureSceneComponent"]; });
  58361. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  58362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_12__["RawCubeTexture"]; });
  58363. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  58364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  58365. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  58366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_14__["RawTexture3D"]; });
  58367. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  58368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_15__["RefractionTexture"]; });
  58369. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_16__["RenderTargetTexture"]; });
  58371. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  58372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_17__["Texture"]; });
  58373. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  58374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_18__["VideoTexture"]; });
  58375. /***/ }),
  58376. /***/ "./Materials/Textures/internalTexture.ts":
  58377. /*!***********************************************!*\
  58378. !*** ./Materials/Textures/internalTexture.ts ***!
  58379. \***********************************************/
  58380. /*! exports provided: InternalTexture */
  58381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58382. "use strict";
  58383. __webpack_require__.r(__webpack_exports__);
  58384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  58385. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58386. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  58387. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58388. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58389. /**
  58390. * Class used to store data associated with WebGL texture data for the engine
  58391. * This class should not be used directly
  58392. */
  58393. var InternalTexture = /** @class */ (function () {
  58394. /**
  58395. * Creates a new InternalTexture
  58396. * @param engine defines the engine to use
  58397. * @param dataSource defines the type of data that will be used
  58398. * @param delayAllocation if the texture allocation should be delayed (default: false)
  58399. */
  58400. function InternalTexture(engine, dataSource, delayAllocation) {
  58401. if (delayAllocation === void 0) { delayAllocation = false; }
  58402. /**
  58403. * Observable called when the texture is loaded
  58404. */
  58405. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  58406. /**
  58407. * Gets or set the previous tracker in the list
  58408. */
  58409. this.previous = null;
  58410. /**
  58411. * Gets or set the next tracker in the list
  58412. */
  58413. this.next = null;
  58414. // Private
  58415. /** @hidden */
  58416. this._invertVScale = false;
  58417. /** @hidden */
  58418. this._initialSlot = -1;
  58419. /** @hidden */
  58420. this._designatedSlot = -1;
  58421. /** @hidden */
  58422. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  58423. /** @hidden */
  58424. this._comparisonFunction = 0;
  58425. /** @hidden */
  58426. this._sphericalPolynomial = null;
  58427. /** @hidden */
  58428. this._lodGenerationScale = 0;
  58429. /** @hidden */
  58430. this._lodGenerationOffset = 0;
  58431. /** @hidden */
  58432. this._isRGBD = false;
  58433. /** @hidden */
  58434. this._references = 1;
  58435. this._engine = engine;
  58436. this._dataSource = dataSource;
  58437. if (!delayAllocation) {
  58438. this._webGLTexture = engine._createTexture();
  58439. }
  58440. }
  58441. /**
  58442. * Gets the Engine the texture belongs to.
  58443. * @returns The babylon engine
  58444. */
  58445. InternalTexture.prototype.getEngine = function () {
  58446. return this._engine;
  58447. };
  58448. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  58449. /**
  58450. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  58451. */
  58452. get: function () {
  58453. return this._dataSource;
  58454. },
  58455. enumerable: true,
  58456. configurable: true
  58457. });
  58458. /**
  58459. * Increments the number of references (ie. the number of Texture that point to it)
  58460. */
  58461. InternalTexture.prototype.incrementReferences = function () {
  58462. this._references++;
  58463. };
  58464. /**
  58465. * Change the size of the texture (not the size of the content)
  58466. * @param width defines the new width
  58467. * @param height defines the new height
  58468. * @param depth defines the new depth (1 by default)
  58469. */
  58470. InternalTexture.prototype.updateSize = function (width, height, depth) {
  58471. if (depth === void 0) { depth = 1; }
  58472. this.width = width;
  58473. this.height = height;
  58474. this.depth = depth;
  58475. this.baseWidth = width;
  58476. this.baseHeight = height;
  58477. this.baseDepth = depth;
  58478. this._size = width * height * depth;
  58479. };
  58480. /** @hidden */
  58481. InternalTexture.prototype._rebuild = function () {
  58482. var _this = this;
  58483. var proxy;
  58484. this.isReady = false;
  58485. this._cachedCoordinatesMode = null;
  58486. this._cachedWrapU = null;
  58487. this._cachedWrapV = null;
  58488. this._cachedAnisotropicFilteringLevel = null;
  58489. switch (this._dataSource) {
  58490. case InternalTexture.DATASOURCE_TEMP:
  58491. return;
  58492. case InternalTexture.DATASOURCE_URL:
  58493. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  58494. proxy._swapAndDie(_this);
  58495. _this.isReady = true;
  58496. }, null, this._buffer, undefined, this.format);
  58497. return;
  58498. case InternalTexture.DATASOURCE_RAW:
  58499. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58500. proxy._swapAndDie(this);
  58501. this.isReady = true;
  58502. return;
  58503. case InternalTexture.DATASOURCE_RAW3D:
  58504. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58505. proxy._swapAndDie(this);
  58506. this.isReady = true;
  58507. return;
  58508. case InternalTexture.DATASOURCE_DYNAMIC:
  58509. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  58510. proxy._swapAndDie(this);
  58511. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  58512. // The engine will make sure to update content so no need to flag it as isReady = true
  58513. return;
  58514. case InternalTexture.DATASOURCE_RENDERTARGET:
  58515. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  58516. options.generateDepthBuffer = this._generateDepthBuffer;
  58517. options.generateMipMaps = this.generateMipMaps;
  58518. options.generateStencilBuffer = this._generateStencilBuffer;
  58519. options.samplingMode = this.samplingMode;
  58520. options.type = this.type;
  58521. if (this.isCube) {
  58522. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  58523. }
  58524. else {
  58525. var size = {
  58526. width: this.width,
  58527. height: this.height
  58528. };
  58529. proxy = this._engine.createRenderTargetTexture(size, options);
  58530. }
  58531. proxy._swapAndDie(this);
  58532. this.isReady = true;
  58533. return;
  58534. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  58535. var depthTextureOptions = {
  58536. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  58537. comparisonFunction: this._comparisonFunction,
  58538. generateStencil: this._generateStencilBuffer,
  58539. isCube: this.isCube
  58540. };
  58541. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  58542. proxy._swapAndDie(this);
  58543. this.isReady = true;
  58544. return;
  58545. case InternalTexture.DATASOURCE_CUBE:
  58546. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  58547. proxy._swapAndDie(_this);
  58548. _this.isReady = true;
  58549. }, null, this.format, this._extension);
  58550. return;
  58551. case InternalTexture.DATASOURCE_CUBERAW:
  58552. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58553. proxy._swapAndDie(this);
  58554. this.isReady = true;
  58555. return;
  58556. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  58557. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58558. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  58559. proxy._swapAndDie(_this);
  58560. _this.isReady = true;
  58561. });
  58562. return;
  58563. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  58564. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  58565. if (proxy) {
  58566. proxy._swapAndDie(_this);
  58567. }
  58568. _this.isReady = true;
  58569. }, null, this.format, this._extension);
  58570. proxy._sphericalPolynomial = this._sphericalPolynomial;
  58571. return;
  58572. }
  58573. };
  58574. /** @hidden */
  58575. InternalTexture.prototype._swapAndDie = function (target) {
  58576. target._webGLTexture = this._webGLTexture;
  58577. if (this._framebuffer) {
  58578. target._framebuffer = this._framebuffer;
  58579. }
  58580. if (this._depthStencilBuffer) {
  58581. target._depthStencilBuffer = this._depthStencilBuffer;
  58582. }
  58583. if (this._lodTextureHigh) {
  58584. if (target._lodTextureHigh) {
  58585. target._lodTextureHigh.dispose();
  58586. }
  58587. target._lodTextureHigh = this._lodTextureHigh;
  58588. }
  58589. if (this._lodTextureMid) {
  58590. if (target._lodTextureMid) {
  58591. target._lodTextureMid.dispose();
  58592. }
  58593. target._lodTextureMid = this._lodTextureMid;
  58594. }
  58595. if (this._lodTextureLow) {
  58596. if (target._lodTextureLow) {
  58597. target._lodTextureLow.dispose();
  58598. }
  58599. target._lodTextureLow = this._lodTextureLow;
  58600. }
  58601. var cache = this._engine.getLoadedTexturesCache();
  58602. var index = cache.indexOf(this);
  58603. if (index !== -1) {
  58604. cache.splice(index, 1);
  58605. }
  58606. };
  58607. /**
  58608. * Dispose the current allocated resources
  58609. */
  58610. InternalTexture.prototype.dispose = function () {
  58611. if (!this._webGLTexture) {
  58612. return;
  58613. }
  58614. this._references--;
  58615. if (this._references === 0) {
  58616. this._engine._releaseTexture(this);
  58617. this._webGLTexture = null;
  58618. this.previous = null;
  58619. this.next = null;
  58620. }
  58621. };
  58622. /** hidden */
  58623. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  58624. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  58625. };
  58626. /**
  58627. * The source of the texture data is unknown
  58628. */
  58629. InternalTexture.DATASOURCE_UNKNOWN = 0;
  58630. /**
  58631. * Texture data comes from an URL
  58632. */
  58633. InternalTexture.DATASOURCE_URL = 1;
  58634. /**
  58635. * Texture data is only used for temporary storage
  58636. */
  58637. InternalTexture.DATASOURCE_TEMP = 2;
  58638. /**
  58639. * Texture data comes from raw data (ArrayBuffer)
  58640. */
  58641. InternalTexture.DATASOURCE_RAW = 3;
  58642. /**
  58643. * Texture content is dynamic (video or dynamic texture)
  58644. */
  58645. InternalTexture.DATASOURCE_DYNAMIC = 4;
  58646. /**
  58647. * Texture content is generated by rendering to it
  58648. */
  58649. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  58650. /**
  58651. * Texture content is part of a multi render target process
  58652. */
  58653. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  58654. /**
  58655. * Texture data comes from a cube data file
  58656. */
  58657. InternalTexture.DATASOURCE_CUBE = 7;
  58658. /**
  58659. * Texture data comes from a raw cube data
  58660. */
  58661. InternalTexture.DATASOURCE_CUBERAW = 8;
  58662. /**
  58663. * Texture data come from a prefiltered cube data file
  58664. */
  58665. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  58666. /**
  58667. * Texture content is raw 3D data
  58668. */
  58669. InternalTexture.DATASOURCE_RAW3D = 10;
  58670. /**
  58671. * Texture content is a depth texture
  58672. */
  58673. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  58674. /**
  58675. * Texture data comes from a raw cube data encoded with RGBD
  58676. */
  58677. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  58678. return InternalTexture;
  58679. }());
  58680. /***/ }),
  58681. /***/ "./Materials/Textures/internalTextureTracker.ts":
  58682. /*!******************************************************!*\
  58683. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  58684. \******************************************************/
  58685. /*! exports provided: DummyInternalTextureTracker */
  58686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58687. "use strict";
  58688. __webpack_require__.r(__webpack_exports__);
  58689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  58690. /**
  58691. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  58692. */
  58693. var DummyInternalTextureTracker = /** @class */ (function () {
  58694. function DummyInternalTextureTracker() {
  58695. /**
  58696. * Gets or set the previous tracker in the list
  58697. */
  58698. this.previous = null;
  58699. /**
  58700. * Gets or set the next tracker in the list
  58701. */
  58702. this.next = null;
  58703. }
  58704. return DummyInternalTextureTracker;
  58705. }());
  58706. /***/ }),
  58707. /***/ "./Materials/Textures/mirrorTexture.ts":
  58708. /*!*********************************************!*\
  58709. !*** ./Materials/Textures/mirrorTexture.ts ***!
  58710. \*********************************************/
  58711. /*! exports provided: MirrorTexture */
  58712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58713. "use strict";
  58714. __webpack_require__.r(__webpack_exports__);
  58715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  58716. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58718. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58719. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58720. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  58721. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58722. /**
  58723. * Mirror texture can be used to simulate the view from a mirror in a scene.
  58724. * It will dynamically be rendered every frame to adapt to the camera point of view.
  58725. * You can then easily use it as a reflectionTexture on a flat surface.
  58726. * In case the surface is not a plane, please consider relying on reflection probes.
  58727. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58728. */
  58729. var MirrorTexture = /** @class */ (function (_super) {
  58730. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  58731. /**
  58732. * Instantiates a Mirror Texture.
  58733. * Mirror texture can be used to simulate the view from a mirror in a scene.
  58734. * It will dynamically be rendered every frame to adapt to the camera point of view.
  58735. * You can then easily use it as a reflectionTexture on a flat surface.
  58736. * In case the surface is not a plane, please consider relying on reflection probes.
  58737. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58738. * @param name
  58739. * @param size
  58740. * @param scene
  58741. * @param generateMipMaps
  58742. * @param type
  58743. * @param samplingMode
  58744. * @param generateDepthBuffer
  58745. */
  58746. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  58747. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58748. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  58749. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  58750. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  58751. _this.scene = scene;
  58752. /**
  58753. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  58754. * 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.
  58755. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58756. */
  58757. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  58758. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  58759. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  58760. _this._adaptiveBlurKernel = 0;
  58761. _this._blurKernelX = 0;
  58762. _this._blurKernelY = 0;
  58763. _this._blurRatio = 1.0;
  58764. _this.ignoreCameraViewport = true;
  58765. _this._updateGammaSpace();
  58766. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  58767. _this._updateGammaSpace;
  58768. });
  58769. _this.onBeforeRenderObservable.add(function () {
  58770. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  58771. _this._savedViewMatrix = scene.getViewMatrix();
  58772. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  58773. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  58774. scene.clipPlane = _this.mirrorPlane;
  58775. scene.getEngine().cullBackFaces = false;
  58776. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  58777. });
  58778. _this.onAfterRenderObservable.add(function () {
  58779. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  58780. scene.getEngine().cullBackFaces = true;
  58781. scene._mirroredCameraPosition = null;
  58782. delete scene.clipPlane;
  58783. });
  58784. return _this;
  58785. }
  58786. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  58787. get: function () {
  58788. return this._blurRatio;
  58789. },
  58790. /**
  58791. * Define the blur ratio used to blur the reflection if needed.
  58792. */
  58793. set: function (value) {
  58794. if (this._blurRatio === value) {
  58795. return;
  58796. }
  58797. this._blurRatio = value;
  58798. this._preparePostProcesses();
  58799. },
  58800. enumerable: true,
  58801. configurable: true
  58802. });
  58803. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  58804. /**
  58805. * Define the adaptive blur kernel used to blur the reflection if needed.
  58806. * This will autocompute the closest best match for the `blurKernel`
  58807. */
  58808. set: function (value) {
  58809. this._adaptiveBlurKernel = value;
  58810. this._autoComputeBlurKernel();
  58811. },
  58812. enumerable: true,
  58813. configurable: true
  58814. });
  58815. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  58816. /**
  58817. * Define the blur kernel used to blur the reflection if needed.
  58818. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58819. */
  58820. set: function (value) {
  58821. this.blurKernelX = value;
  58822. this.blurKernelY = value;
  58823. },
  58824. enumerable: true,
  58825. configurable: true
  58826. });
  58827. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  58828. get: function () {
  58829. return this._blurKernelX;
  58830. },
  58831. /**
  58832. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  58833. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58834. */
  58835. set: function (value) {
  58836. if (this._blurKernelX === value) {
  58837. return;
  58838. }
  58839. this._blurKernelX = value;
  58840. this._preparePostProcesses();
  58841. },
  58842. enumerable: true,
  58843. configurable: true
  58844. });
  58845. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  58846. get: function () {
  58847. return this._blurKernelY;
  58848. },
  58849. /**
  58850. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  58851. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58852. */
  58853. set: function (value) {
  58854. if (this._blurKernelY === value) {
  58855. return;
  58856. }
  58857. this._blurKernelY = value;
  58858. this._preparePostProcesses();
  58859. },
  58860. enumerable: true,
  58861. configurable: true
  58862. });
  58863. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  58864. var engine = this.getScene().getEngine();
  58865. var dw = this.getRenderWidth() / engine.getRenderWidth();
  58866. var dh = this.getRenderHeight() / engine.getRenderHeight();
  58867. this.blurKernelX = this._adaptiveBlurKernel * dw;
  58868. this.blurKernelY = this._adaptiveBlurKernel * dh;
  58869. };
  58870. MirrorTexture.prototype._onRatioRescale = function () {
  58871. if (this._sizeRatio) {
  58872. this.resize(this._initialSizeParameter);
  58873. if (!this._adaptiveBlurKernel) {
  58874. this._preparePostProcesses();
  58875. }
  58876. }
  58877. if (this._adaptiveBlurKernel) {
  58878. this._autoComputeBlurKernel();
  58879. }
  58880. };
  58881. MirrorTexture.prototype._updateGammaSpace = function () {
  58882. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  58883. };
  58884. MirrorTexture.prototype._preparePostProcesses = function () {
  58885. this.clearPostProcesses(true);
  58886. if (this._blurKernelX && this._blurKernelY) {
  58887. var engine = this.getScene().getEngine();
  58888. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  58889. 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);
  58890. this._blurX.autoClear = false;
  58891. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  58892. this._blurX.inputTexture = this._texture;
  58893. }
  58894. else {
  58895. this._blurX.alwaysForcePOT = true;
  58896. }
  58897. 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);
  58898. this._blurY.autoClear = false;
  58899. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  58900. this.addPostProcess(this._blurX);
  58901. this.addPostProcess(this._blurY);
  58902. }
  58903. else {
  58904. if (this._blurY) {
  58905. this.removePostProcess(this._blurY);
  58906. this._blurY.dispose();
  58907. this._blurY = null;
  58908. }
  58909. if (this._blurX) {
  58910. this.removePostProcess(this._blurX);
  58911. this._blurX.dispose();
  58912. this._blurX = null;
  58913. }
  58914. }
  58915. };
  58916. /**
  58917. * Clone the mirror texture.
  58918. * @returns the cloned texture
  58919. */
  58920. MirrorTexture.prototype.clone = function () {
  58921. var scene = this.getScene();
  58922. if (!scene) {
  58923. return this;
  58924. }
  58925. var textureSize = this.getSize();
  58926. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  58927. // Base texture
  58928. newTexture.hasAlpha = this.hasAlpha;
  58929. newTexture.level = this.level;
  58930. // Mirror Texture
  58931. newTexture.mirrorPlane = this.mirrorPlane.clone();
  58932. if (this.renderList) {
  58933. newTexture.renderList = this.renderList.slice(0);
  58934. }
  58935. return newTexture;
  58936. };
  58937. /**
  58938. * Serialize the texture to a JSON representation you could use in Parse later on
  58939. * @returns the serialized JSON representation
  58940. */
  58941. MirrorTexture.prototype.serialize = function () {
  58942. if (!this.name) {
  58943. return null;
  58944. }
  58945. var serializationObject = _super.prototype.serialize.call(this);
  58946. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  58947. return serializationObject;
  58948. };
  58949. /**
  58950. * Dispose the texture and release its associated resources.
  58951. */
  58952. MirrorTexture.prototype.dispose = function () {
  58953. _super.prototype.dispose.call(this);
  58954. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  58955. };
  58956. return MirrorTexture;
  58957. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  58958. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  58959. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  58960. };
  58961. /***/ }),
  58962. /***/ "./Materials/Textures/multiRenderTarget.ts":
  58963. /*!*************************************************!*\
  58964. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  58965. \*************************************************/
  58966. /*! exports provided: MultiRenderTarget */
  58967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58968. "use strict";
  58969. __webpack_require__.r(__webpack_exports__);
  58970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  58971. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58972. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58973. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58974. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58975. /**
  58976. * A multi render target, like a render target provides the ability to render to a texture.
  58977. * Unlike the render target, it can render to several draw buffers in one draw.
  58978. * This is specially interesting in deferred rendering or for any effects requiring more than
  58979. * just one color from a single pass.
  58980. */
  58981. var MultiRenderTarget = /** @class */ (function (_super) {
  58982. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  58983. /**
  58984. * Instantiate a new multi render target texture.
  58985. * A multi render target, like a render target provides the ability to render to a texture.
  58986. * Unlike the render target, it can render to several draw buffers in one draw.
  58987. * This is specially interesting in deferred rendering or for any effects requiring more than
  58988. * just one color from a single pass.
  58989. * @param name Define the name of the texture
  58990. * @param size Define the size of the buffers to render to
  58991. * @param count Define the number of target we are rendering into
  58992. * @param scene Define the scene the texture belongs to
  58993. * @param options Define the options used to create the multi render target
  58994. */
  58995. function MultiRenderTarget(name, size, count, scene, options) {
  58996. var _this = this;
  58997. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  58998. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  58999. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  59000. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  59001. _this._engine = scene.getEngine();
  59002. if (!_this.isSupported) {
  59003. _this.dispose();
  59004. return;
  59005. }
  59006. var types = [];
  59007. var samplingModes = [];
  59008. for (var i = 0; i < count; i++) {
  59009. if (options && options.types && options.types[i] !== undefined) {
  59010. types.push(options.types[i]);
  59011. }
  59012. else {
  59013. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  59014. }
  59015. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  59016. samplingModes.push(options.samplingModes[i]);
  59017. }
  59018. else {
  59019. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  59020. }
  59021. }
  59022. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  59023. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  59024. _this._size = size;
  59025. _this._multiRenderTargetOptions = {
  59026. samplingModes: samplingModes,
  59027. generateMipMaps: generateMipMaps,
  59028. generateDepthBuffer: generateDepthBuffer,
  59029. generateStencilBuffer: generateStencilBuffer,
  59030. generateDepthTexture: generateDepthTexture,
  59031. types: types,
  59032. textureCount: count
  59033. };
  59034. _this._createInternalTextures();
  59035. _this._createTextures();
  59036. return _this;
  59037. }
  59038. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  59039. /**
  59040. * Get if draw buffers are currently supported by the used hardware and browser.
  59041. */
  59042. get: function () {
  59043. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  59044. },
  59045. enumerable: true,
  59046. configurable: true
  59047. });
  59048. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  59049. /**
  59050. * Get the list of textures generated by the multi render target.
  59051. */
  59052. get: function () {
  59053. return this._textures;
  59054. },
  59055. enumerable: true,
  59056. configurable: true
  59057. });
  59058. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  59059. /**
  59060. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  59061. */
  59062. get: function () {
  59063. return this._textures[this._textures.length - 1];
  59064. },
  59065. enumerable: true,
  59066. configurable: true
  59067. });
  59068. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  59069. /**
  59070. * Set the wrapping mode on U of all the textures we are rendering to.
  59071. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  59072. */
  59073. set: function (wrap) {
  59074. if (this._textures) {
  59075. for (var i = 0; i < this._textures.length; i++) {
  59076. this._textures[i].wrapU = wrap;
  59077. }
  59078. }
  59079. },
  59080. enumerable: true,
  59081. configurable: true
  59082. });
  59083. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  59084. /**
  59085. * Set the wrapping mode on V of all the textures we are rendering to.
  59086. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  59087. */
  59088. set: function (wrap) {
  59089. if (this._textures) {
  59090. for (var i = 0; i < this._textures.length; i++) {
  59091. this._textures[i].wrapV = wrap;
  59092. }
  59093. }
  59094. },
  59095. enumerable: true,
  59096. configurable: true
  59097. });
  59098. /** @hidden */
  59099. MultiRenderTarget.prototype._rebuild = function () {
  59100. this.releaseInternalTextures();
  59101. this._createInternalTextures();
  59102. for (var i = 0; i < this._internalTextures.length; i++) {
  59103. var texture = this._textures[i];
  59104. texture._texture = this._internalTextures[i];
  59105. }
  59106. // Keeps references to frame buffer and stencil/depth buffer
  59107. this._texture = this._internalTextures[0];
  59108. };
  59109. MultiRenderTarget.prototype._createInternalTextures = function () {
  59110. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  59111. };
  59112. MultiRenderTarget.prototype._createTextures = function () {
  59113. this._textures = [];
  59114. for (var i = 0; i < this._internalTextures.length; i++) {
  59115. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  59116. texture._texture = this._internalTextures[i];
  59117. this._textures.push(texture);
  59118. }
  59119. // Keeps references to frame buffer and stencil/depth buffer
  59120. this._texture = this._internalTextures[0];
  59121. };
  59122. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  59123. /**
  59124. * Define the number of samples used if MSAA is enabled.
  59125. */
  59126. get: function () {
  59127. return this._samples;
  59128. },
  59129. set: function (value) {
  59130. if (this._samples === value) {
  59131. return;
  59132. }
  59133. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  59134. },
  59135. enumerable: true,
  59136. configurable: true
  59137. });
  59138. /**
  59139. * Resize all the textures in the multi render target.
  59140. * Be carrefull as it will recreate all the data in the new texture.
  59141. * @param size Define the new size
  59142. */
  59143. MultiRenderTarget.prototype.resize = function (size) {
  59144. this.releaseInternalTextures();
  59145. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  59146. this._createInternalTextures();
  59147. };
  59148. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  59149. var _this = this;
  59150. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  59151. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  59152. });
  59153. };
  59154. /**
  59155. * Dispose the render targets and their associated resources
  59156. */
  59157. MultiRenderTarget.prototype.dispose = function () {
  59158. this.releaseInternalTextures();
  59159. _super.prototype.dispose.call(this);
  59160. };
  59161. /**
  59162. * Release all the underlying texture used as draw buffers.
  59163. */
  59164. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  59165. if (!this._internalTextures) {
  59166. return;
  59167. }
  59168. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  59169. if (this._internalTextures[i] !== undefined) {
  59170. this._internalTextures[i].dispose();
  59171. this._internalTextures.splice(i, 1);
  59172. }
  59173. }
  59174. };
  59175. return MultiRenderTarget;
  59176. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  59177. /***/ }),
  59178. /***/ "./Materials/Textures/rawCubeTexture.ts":
  59179. /*!**********************************************!*\
  59180. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  59181. \**********************************************/
  59182. /*! exports provided: RawCubeTexture */
  59183. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59184. "use strict";
  59185. __webpack_require__.r(__webpack_exports__);
  59186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  59187. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59188. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  59189. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  59190. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  59191. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  59192. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59193. /**
  59194. * Raw cube texture where the raw buffers are passed in
  59195. */
  59196. var RawCubeTexture = /** @class */ (function (_super) {
  59197. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  59198. /**
  59199. * Creates a cube texture where the raw buffers are passed in.
  59200. * @param scene defines the scene the texture is attached to
  59201. * @param data defines the array of data to use to create each face
  59202. * @param size defines the size of the textures
  59203. * @param format defines the format of the data
  59204. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59205. * @param generateMipMaps defines if the engine should generate the mip levels
  59206. * @param invertY defines if data must be stored with Y axis inverted
  59207. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59208. * @param compression defines the compression used (null by default)
  59209. */
  59210. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  59211. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  59212. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59213. if (generateMipMaps === void 0) { generateMipMaps = false; }
  59214. if (invertY === void 0) { invertY = false; }
  59215. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59216. if (compression === void 0) { compression = null; }
  59217. var _this = _super.call(this, "", scene) || this;
  59218. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  59219. return _this;
  59220. }
  59221. /**
  59222. * Updates the raw cube texture.
  59223. * @param data defines the data to store
  59224. * @param format defines the data format
  59225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59226. * @param invertY defines if data must be stored with Y axis inverted
  59227. * @param compression defines the compression used (null by default)
  59228. * @param level defines which level of the texture to update
  59229. */
  59230. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  59231. if (compression === void 0) { compression = null; }
  59232. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  59233. };
  59234. /**
  59235. * Updates a raw cube texture with RGBD encoded data.
  59236. * @param data defines the array of data [mipmap][face] to use to create each face
  59237. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59238. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59239. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59240. * @returns a promsie that resolves when the operation is complete
  59241. */
  59242. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  59243. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  59244. if (lodScale === void 0) { lodScale = 0.8; }
  59245. if (lodOffset === void 0) { lodOffset = 0; }
  59246. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  59247. };
  59248. /**
  59249. * Clones the raw cube texture.
  59250. * @return a new cube texture
  59251. */
  59252. RawCubeTexture.prototype.clone = function () {
  59253. var _this = this;
  59254. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  59255. var scene = _this.getScene();
  59256. var internalTexture = _this._texture;
  59257. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  59258. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  59259. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  59260. }
  59261. return texture;
  59262. }, this);
  59263. };
  59264. /** @hidden */
  59265. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  59266. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  59267. internalTexture._bufferViewArrayArray = data;
  59268. internalTexture._lodGenerationScale = lodScale;
  59269. internalTexture._lodGenerationOffset = lodOffset;
  59270. internalTexture._sphericalPolynomial = sphericalPolynomial;
  59271. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  59272. internalTexture.isReady = true;
  59273. });
  59274. };
  59275. return RawCubeTexture;
  59276. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  59277. /***/ }),
  59278. /***/ "./Materials/Textures/rawTexture.ts":
  59279. /*!******************************************!*\
  59280. !*** ./Materials/Textures/rawTexture.ts ***!
  59281. \******************************************/
  59282. /*! exports provided: RawTexture */
  59283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59284. "use strict";
  59285. __webpack_require__.r(__webpack_exports__);
  59286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  59287. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59288. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59289. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59290. /**
  59291. * Raw texture can help creating a texture directly from an array of data.
  59292. * This can be super useful if you either get the data from an uncompressed source or
  59293. * if you wish to create your texture pixel by pixel.
  59294. */
  59295. var RawTexture = /** @class */ (function (_super) {
  59296. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  59297. /**
  59298. * Instantiates a new RawTexture.
  59299. * Raw texture can help creating a texture directly from an array of data.
  59300. * This can be super useful if you either get the data from an uncompressed source or
  59301. * if you wish to create your texture pixel by pixel.
  59302. * @param data define the array of data to use to create the texture
  59303. * @param width define the width of the texture
  59304. * @param height define the height of the texture
  59305. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  59306. * @param scene define the scene the texture belongs to
  59307. * @param generateMipMaps define whether mip maps should be generated or not
  59308. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59309. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59310. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59311. */
  59312. function RawTexture(data, width, height,
  59313. /**
  59314. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  59315. */
  59316. format, scene, generateMipMaps, invertY, samplingMode, type) {
  59317. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59318. if (invertY === void 0) { invertY = false; }
  59319. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59320. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59321. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59322. _this.format = format;
  59323. _this._engine = scene.getEngine();
  59324. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  59325. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  59326. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  59327. return _this;
  59328. }
  59329. /**
  59330. * Updates the texture underlying data.
  59331. * @param data Define the new data of the texture
  59332. */
  59333. RawTexture.prototype.update = function (data) {
  59334. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  59335. };
  59336. /**
  59337. * Creates a luminance texture from some data.
  59338. * @param data Define the texture data
  59339. * @param width Define the width of the texture
  59340. * @param height Define the height of the texture
  59341. * @param scene Define the scene the texture belongs to
  59342. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59343. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59344. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59345. * @returns the luminance texture
  59346. */
  59347. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59348. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59349. if (invertY === void 0) { invertY = false; }
  59350. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59351. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  59352. };
  59353. /**
  59354. * Creates a luminance alpha texture from some data.
  59355. * @param data Define the texture data
  59356. * @param width Define the width of the texture
  59357. * @param height Define the height of the texture
  59358. * @param scene Define the scene the texture belongs to
  59359. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59360. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59361. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59362. * @returns the luminance alpha texture
  59363. */
  59364. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59365. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59366. if (invertY === void 0) { invertY = false; }
  59367. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59368. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  59369. };
  59370. /**
  59371. * Creates an alpha texture from some data.
  59372. * @param data Define the texture data
  59373. * @param width Define the width of the texture
  59374. * @param height Define the height of the texture
  59375. * @param scene Define the scene the texture belongs to
  59376. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59377. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59378. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59379. * @returns the alpha texture
  59380. */
  59381. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59382. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59383. if (invertY === void 0) { invertY = false; }
  59384. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59385. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  59386. };
  59387. /**
  59388. * Creates a RGB texture from some data.
  59389. * @param data Define the texture data
  59390. * @param width Define the width of the texture
  59391. * @param height Define the height of the texture
  59392. * @param scene Define the scene the texture belongs to
  59393. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59394. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59395. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59396. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59397. * @returns the RGB alpha texture
  59398. */
  59399. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59400. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59401. if (invertY === void 0) { invertY = false; }
  59402. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59403. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59404. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  59405. };
  59406. /**
  59407. * Creates a RGBA texture from some data.
  59408. * @param data Define the texture data
  59409. * @param width Define the width of the texture
  59410. * @param height Define the height of the texture
  59411. * @param scene Define the scene the texture belongs to
  59412. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59413. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59414. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59415. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59416. * @returns the RGBA texture
  59417. */
  59418. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59419. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59420. if (invertY === void 0) { invertY = false; }
  59421. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59422. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59423. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  59424. };
  59425. /**
  59426. * Creates a R texture from some data.
  59427. * @param data Define the texture data
  59428. * @param width Define the width of the texture
  59429. * @param height Define the height of the texture
  59430. * @param scene Define the scene the texture belongs to
  59431. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59432. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59433. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59434. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59435. * @returns the R texture
  59436. */
  59437. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59438. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59439. if (invertY === void 0) { invertY = false; }
  59440. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59441. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  59442. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  59443. };
  59444. return RawTexture;
  59445. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  59446. /***/ }),
  59447. /***/ "./Materials/Textures/rawTexture3D.ts":
  59448. /*!********************************************!*\
  59449. !*** ./Materials/Textures/rawTexture3D.ts ***!
  59450. \********************************************/
  59451. /*! exports provided: RawTexture3D */
  59452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59453. "use strict";
  59454. __webpack_require__.r(__webpack_exports__);
  59455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  59456. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59457. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59458. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59459. /**
  59460. * Class used to store 3D textures containing user data
  59461. */
  59462. var RawTexture3D = /** @class */ (function (_super) {
  59463. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  59464. /**
  59465. * Create a new RawTexture3D
  59466. * @param data defines the data of the texture
  59467. * @param width defines the width of the texture
  59468. * @param height defines the height of the texture
  59469. * @param depth defines the depth of the texture
  59470. * @param format defines the texture format to use
  59471. * @param scene defines the hosting scene
  59472. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59473. * @param invertY defines if texture must be stored with Y axis inverted
  59474. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59475. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59476. */
  59477. function RawTexture3D(data, width, height, depth,
  59478. /** Gets or sets the texture format to use */
  59479. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  59480. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59481. if (invertY === void 0) { invertY = false; }
  59482. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59483. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59484. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59485. _this.format = format;
  59486. _this._engine = scene.getEngine();
  59487. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  59488. _this.is3D = true;
  59489. return _this;
  59490. }
  59491. /**
  59492. * Update the texture with new data
  59493. * @param data defines the data to store in the texture
  59494. */
  59495. RawTexture3D.prototype.update = function (data) {
  59496. if (!this._texture) {
  59497. return;
  59498. }
  59499. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  59500. };
  59501. return RawTexture3D;
  59502. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  59503. /***/ }),
  59504. /***/ "./Materials/Textures/refractionTexture.ts":
  59505. /*!*************************************************!*\
  59506. !*** ./Materials/Textures/refractionTexture.ts ***!
  59507. \*************************************************/
  59508. /*! exports provided: RefractionTexture */
  59509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59510. "use strict";
  59511. __webpack_require__.r(__webpack_exports__);
  59512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  59513. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59514. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59515. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59516. /**
  59517. * Creates a refraction texture used by refraction channel of the standard material.
  59518. * It is like a mirror but to see through a material.
  59519. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59520. */
  59521. var RefractionTexture = /** @class */ (function (_super) {
  59522. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  59523. /**
  59524. * Creates a refraction texture used by refraction channel of the standard material.
  59525. * It is like a mirror but to see through a material.
  59526. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59527. * @param name Define the texture name
  59528. * @param size Define the size of the underlying texture
  59529. * @param scene Define the scene the refraction belongs to
  59530. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59531. */
  59532. function RefractionTexture(name, size, scene, generateMipMaps) {
  59533. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  59534. /**
  59535. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59536. * 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.
  59537. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59538. */
  59539. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  59540. /**
  59541. * Define how deep under the surface we should see.
  59542. */
  59543. _this.depth = 2.0;
  59544. _this.onBeforeRenderObservable.add(function () {
  59545. scene.clipPlane = _this.refractionPlane;
  59546. });
  59547. _this.onAfterRenderObservable.add(function () {
  59548. delete scene.clipPlane;
  59549. });
  59550. return _this;
  59551. }
  59552. /**
  59553. * Clone the refraction texture.
  59554. * @returns the cloned texture
  59555. */
  59556. RefractionTexture.prototype.clone = function () {
  59557. var scene = this.getScene();
  59558. if (!scene) {
  59559. return this;
  59560. }
  59561. var textureSize = this.getSize();
  59562. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  59563. // Base texture
  59564. newTexture.hasAlpha = this.hasAlpha;
  59565. newTexture.level = this.level;
  59566. // Refraction Texture
  59567. newTexture.refractionPlane = this.refractionPlane.clone();
  59568. if (this.renderList) {
  59569. newTexture.renderList = this.renderList.slice(0);
  59570. }
  59571. newTexture.depth = this.depth;
  59572. return newTexture;
  59573. };
  59574. /**
  59575. * Serialize the texture to a JSON representation you could use in Parse later on
  59576. * @returns the serialized JSON representation
  59577. */
  59578. RefractionTexture.prototype.serialize = function () {
  59579. if (!this.name) {
  59580. return null;
  59581. }
  59582. var serializationObject = _super.prototype.serialize.call(this);
  59583. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  59584. serializationObject.depth = this.depth;
  59585. return serializationObject;
  59586. };
  59587. return RefractionTexture;
  59588. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  59589. /***/ }),
  59590. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  59591. /*!***********************************************************!*\
  59592. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  59593. \***********************************************************/
  59594. /*! exports provided: RenderTargetCreationOptions */
  59595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59596. "use strict";
  59597. __webpack_require__.r(__webpack_exports__);
  59598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  59599. /**
  59600. * Define options used to create a render target texture
  59601. */
  59602. var RenderTargetCreationOptions = /** @class */ (function () {
  59603. function RenderTargetCreationOptions() {
  59604. }
  59605. return RenderTargetCreationOptions;
  59606. }());
  59607. /***/ }),
  59608. /***/ "./Materials/Textures/renderTargetTexture.ts":
  59609. /*!***************************************************!*\
  59610. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  59611. \***************************************************/
  59612. /*! exports provided: RenderTargetTexture */
  59613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59614. "use strict";
  59615. __webpack_require__.r(__webpack_exports__);
  59616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  59617. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59618. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59619. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59620. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59621. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59622. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  59623. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  59624. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59625. /**
  59626. * This Helps creating a texture that will be created from a camera in your scene.
  59627. * It is basically a dynamic texture that could be used to create special effects for instance.
  59628. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  59629. */
  59630. var RenderTargetTexture = /** @class */ (function (_super) {
  59631. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  59632. /**
  59633. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  59634. * or used a shadow, depth texture...
  59635. * @param name The friendly name of the texture
  59636. * @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)
  59637. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  59638. * @param generateMipMaps True if mip maps need to be generated after render.
  59639. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  59640. * @param type The type of the buffer in the RTT (int, half float, float...)
  59641. * @param isCube True if a cube texture needs to be created
  59642. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  59643. * @param generateDepthBuffer True to generate a depth buffer
  59644. * @param generateStencilBuffer True to generate a stencil buffer
  59645. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  59646. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  59647. * @param delayAllocation if the texture allocation should be delayed (default: false)
  59648. */
  59649. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  59650. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  59651. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59652. if (isCube === void 0) { isCube = false; }
  59653. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59654. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  59655. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  59656. if (isMulti === void 0) { isMulti = false; }
  59657. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  59658. if (delayAllocation === void 0) { delayAllocation = false; }
  59659. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  59660. _this.isCube = isCube;
  59661. /**
  59662. * Define if particles should be rendered in your texture.
  59663. */
  59664. _this.renderParticles = true;
  59665. /**
  59666. * Define if sprites should be rendered in your texture.
  59667. */
  59668. _this.renderSprites = false;
  59669. /**
  59670. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  59671. */
  59672. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  59673. /**
  59674. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  59675. */
  59676. _this.ignoreCameraViewport = false;
  59677. /**
  59678. * An event triggered when the texture is unbind.
  59679. */
  59680. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59681. /**
  59682. * An event triggered when the texture is unbind.
  59683. */
  59684. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59685. /**
  59686. * An event triggered before rendering the texture
  59687. */
  59688. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59689. /**
  59690. * An event triggered after rendering the texture
  59691. */
  59692. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59693. /**
  59694. * An event triggered after the texture clear
  59695. */
  59696. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59697. _this._currentRefreshId = -1;
  59698. _this._refreshRate = 1;
  59699. _this._samples = 1;
  59700. /**
  59701. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  59702. * It must define where the camera used to render the texture is set
  59703. */
  59704. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  59705. scene = _this.getScene();
  59706. if (!scene) {
  59707. return _this;
  59708. }
  59709. _this.renderList = new Array();
  59710. _this._engine = scene.getEngine();
  59711. _this.name = name;
  59712. _this.isRenderTarget = true;
  59713. _this._initialSizeParameter = size;
  59714. _this._processSizeParameter(size);
  59715. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  59716. });
  59717. _this._generateMipMaps = generateMipMaps ? true : false;
  59718. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  59719. // Rendering groups
  59720. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  59721. _this._renderingManager._useSceneAutoClearSetup = true;
  59722. if (isMulti) {
  59723. return _this;
  59724. }
  59725. _this._renderTargetOptions = {
  59726. generateMipMaps: generateMipMaps,
  59727. type: type,
  59728. format: format,
  59729. samplingMode: samplingMode,
  59730. generateDepthBuffer: generateDepthBuffer,
  59731. generateStencilBuffer: generateStencilBuffer
  59732. };
  59733. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  59734. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59735. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59736. }
  59737. if (!delayAllocation) {
  59738. if (isCube) {
  59739. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  59740. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  59741. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  59742. }
  59743. else {
  59744. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  59745. }
  59746. }
  59747. return _this;
  59748. }
  59749. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  59750. /**
  59751. * Use this list to define the list of mesh you want to render.
  59752. */
  59753. get: function () {
  59754. return this._renderList;
  59755. },
  59756. set: function (value) {
  59757. this._renderList = value;
  59758. if (this._renderList) {
  59759. this._hookArray(this._renderList);
  59760. }
  59761. },
  59762. enumerable: true,
  59763. configurable: true
  59764. });
  59765. RenderTargetTexture.prototype._hookArray = function (array) {
  59766. var _this = this;
  59767. var oldPush = array.push;
  59768. array.push = function () {
  59769. var items = [];
  59770. for (var _i = 0; _i < arguments.length; _i++) {
  59771. items[_i] = arguments[_i];
  59772. }
  59773. var wasEmpty = array.length === 0;
  59774. var result = oldPush.apply(array, items);
  59775. if (wasEmpty) {
  59776. _this.getScene().meshes.forEach(function (mesh) {
  59777. mesh._markSubMeshesAsLightDirty();
  59778. });
  59779. }
  59780. return result;
  59781. };
  59782. var oldSplice = array.splice;
  59783. array.splice = function (index, deleteCount) {
  59784. var deleted = oldSplice.apply(array, [index, deleteCount]);
  59785. if (array.length === 0) {
  59786. _this.getScene().meshes.forEach(function (mesh) {
  59787. mesh._markSubMeshesAsLightDirty();
  59788. });
  59789. }
  59790. return deleted;
  59791. };
  59792. };
  59793. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  59794. /**
  59795. * Set a after unbind callback in the texture.
  59796. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  59797. */
  59798. set: function (callback) {
  59799. if (this._onAfterUnbindObserver) {
  59800. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  59801. }
  59802. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  59803. },
  59804. enumerable: true,
  59805. configurable: true
  59806. });
  59807. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  59808. /**
  59809. * Set a before render callback in the texture.
  59810. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  59811. */
  59812. set: function (callback) {
  59813. if (this._onBeforeRenderObserver) {
  59814. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  59815. }
  59816. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  59817. },
  59818. enumerable: true,
  59819. configurable: true
  59820. });
  59821. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  59822. /**
  59823. * Set a after render callback in the texture.
  59824. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  59825. */
  59826. set: function (callback) {
  59827. if (this._onAfterRenderObserver) {
  59828. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  59829. }
  59830. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  59831. },
  59832. enumerable: true,
  59833. configurable: true
  59834. });
  59835. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  59836. /**
  59837. * Set a clear callback in the texture.
  59838. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  59839. */
  59840. set: function (callback) {
  59841. if (this._onClearObserver) {
  59842. this.onClearObservable.remove(this._onClearObserver);
  59843. }
  59844. this._onClearObserver = this.onClearObservable.add(callback);
  59845. },
  59846. enumerable: true,
  59847. configurable: true
  59848. });
  59849. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  59850. /**
  59851. * Gets render target creation options that were used.
  59852. */
  59853. get: function () {
  59854. return this._renderTargetOptions;
  59855. },
  59856. enumerable: true,
  59857. configurable: true
  59858. });
  59859. RenderTargetTexture.prototype._onRatioRescale = function () {
  59860. if (this._sizeRatio) {
  59861. this.resize(this._initialSizeParameter);
  59862. }
  59863. };
  59864. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  59865. get: function () {
  59866. return this._boundingBoxSize;
  59867. },
  59868. /**
  59869. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  59870. * When defined, the cubemap will switch to local mode
  59871. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59872. * @example https://www.babylonjs-playground.com/#RNASML
  59873. */
  59874. set: function (value) {
  59875. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  59876. return;
  59877. }
  59878. this._boundingBoxSize = value;
  59879. var scene = this.getScene();
  59880. if (scene) {
  59881. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  59882. }
  59883. },
  59884. enumerable: true,
  59885. configurable: true
  59886. });
  59887. /**
  59888. * Creates a depth stencil texture.
  59889. * This is only available in WebGL 2 or with the depth texture extension available.
  59890. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  59891. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  59892. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  59893. */
  59894. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  59895. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  59896. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  59897. if (generateStencil === void 0) { generateStencil = false; }
  59898. if (!this.getScene()) {
  59899. return;
  59900. }
  59901. var engine = this.getScene().getEngine();
  59902. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  59903. bilinearFiltering: bilinearFiltering,
  59904. comparisonFunction: comparisonFunction,
  59905. generateStencil: generateStencil,
  59906. isCube: this.isCube
  59907. });
  59908. engine.setFrameBufferDepthStencilTexture(this);
  59909. };
  59910. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  59911. if (size.ratio) {
  59912. this._sizeRatio = size.ratio;
  59913. this._size = {
  59914. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  59915. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  59916. };
  59917. }
  59918. else {
  59919. this._size = size;
  59920. }
  59921. };
  59922. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  59923. /**
  59924. * Define the number of samples to use in case of MSAA.
  59925. * It defaults to one meaning no MSAA has been enabled.
  59926. */
  59927. get: function () {
  59928. return this._samples;
  59929. },
  59930. set: function (value) {
  59931. if (this._samples === value) {
  59932. return;
  59933. }
  59934. var scene = this.getScene();
  59935. if (!scene) {
  59936. return;
  59937. }
  59938. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  59939. },
  59940. enumerable: true,
  59941. configurable: true
  59942. });
  59943. /**
  59944. * Resets the refresh counter of the texture and start bak from scratch.
  59945. * Could be useful to regenerate the texture if it is setup to render only once.
  59946. */
  59947. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  59948. this._currentRefreshId = -1;
  59949. };
  59950. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  59951. /**
  59952. * Define the refresh rate of the texture or the rendering frequency.
  59953. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  59954. */
  59955. get: function () {
  59956. return this._refreshRate;
  59957. },
  59958. set: function (value) {
  59959. this._refreshRate = value;
  59960. this.resetRefreshCounter();
  59961. },
  59962. enumerable: true,
  59963. configurable: true
  59964. });
  59965. /**
  59966. * Adds a post process to the render target rendering passes.
  59967. * @param postProcess define the post process to add
  59968. */
  59969. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  59970. if (!this._postProcessManager) {
  59971. var scene = this.getScene();
  59972. if (!scene) {
  59973. return;
  59974. }
  59975. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  59976. this._postProcesses = new Array();
  59977. }
  59978. this._postProcesses.push(postProcess);
  59979. this._postProcesses[0].autoClear = false;
  59980. };
  59981. /**
  59982. * Clear all the post processes attached to the render target
  59983. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  59984. */
  59985. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  59986. if (dispose === void 0) { dispose = false; }
  59987. if (!this._postProcesses) {
  59988. return;
  59989. }
  59990. if (dispose) {
  59991. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  59992. var postProcess = _a[_i];
  59993. postProcess.dispose();
  59994. }
  59995. }
  59996. this._postProcesses = [];
  59997. };
  59998. /**
  59999. * Remove one of the post process from the list of attached post processes to the texture
  60000. * @param postProcess define the post process to remove from the list
  60001. */
  60002. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  60003. if (!this._postProcesses) {
  60004. return;
  60005. }
  60006. var index = this._postProcesses.indexOf(postProcess);
  60007. if (index === -1) {
  60008. return;
  60009. }
  60010. this._postProcesses.splice(index, 1);
  60011. if (this._postProcesses.length > 0) {
  60012. this._postProcesses[0].autoClear = false;
  60013. }
  60014. };
  60015. /** @hidden */
  60016. RenderTargetTexture.prototype._shouldRender = function () {
  60017. if (this._currentRefreshId === -1) { // At least render once
  60018. this._currentRefreshId = 1;
  60019. return true;
  60020. }
  60021. if (this.refreshRate === this._currentRefreshId) {
  60022. this._currentRefreshId = 1;
  60023. return true;
  60024. }
  60025. this._currentRefreshId++;
  60026. return false;
  60027. };
  60028. /**
  60029. * Gets the actual render size of the texture.
  60030. * @returns the width of the render size
  60031. */
  60032. RenderTargetTexture.prototype.getRenderSize = function () {
  60033. return this.getRenderWidth();
  60034. };
  60035. /**
  60036. * Gets the actual render width of the texture.
  60037. * @returns the width of the render size
  60038. */
  60039. RenderTargetTexture.prototype.getRenderWidth = function () {
  60040. if (this._size.width) {
  60041. return this._size.width;
  60042. }
  60043. return this._size;
  60044. };
  60045. /**
  60046. * Gets the actual render height of the texture.
  60047. * @returns the height of the render size
  60048. */
  60049. RenderTargetTexture.prototype.getRenderHeight = function () {
  60050. if (this._size.width) {
  60051. return this._size.height;
  60052. }
  60053. return this._size;
  60054. };
  60055. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  60056. /**
  60057. * Get if the texture can be rescaled or not.
  60058. */
  60059. get: function () {
  60060. return true;
  60061. },
  60062. enumerable: true,
  60063. configurable: true
  60064. });
  60065. /**
  60066. * Resize the texture using a ratio.
  60067. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  60068. */
  60069. RenderTargetTexture.prototype.scale = function (ratio) {
  60070. var newSize = this.getRenderSize() * ratio;
  60071. this.resize(newSize);
  60072. };
  60073. /**
  60074. * Get the texture reflection matrix used to rotate/transform the reflection.
  60075. * @returns the reflection matrix
  60076. */
  60077. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  60078. if (this.isCube) {
  60079. return this._textureMatrix;
  60080. }
  60081. return _super.prototype.getReflectionTextureMatrix.call(this);
  60082. };
  60083. /**
  60084. * Resize the texture to a new desired size.
  60085. * Be carrefull as it will recreate all the data in the new texture.
  60086. * @param size Define the new size. It can be:
  60087. * - a number for squared texture,
  60088. * - an object containing { width: number, height: number }
  60089. * - or an object containing a ratio { ratio: number }
  60090. */
  60091. RenderTargetTexture.prototype.resize = function (size) {
  60092. this.releaseInternalTexture();
  60093. var scene = this.getScene();
  60094. if (!scene) {
  60095. return;
  60096. }
  60097. this._processSizeParameter(size);
  60098. if (this.isCube) {
  60099. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  60100. }
  60101. else {
  60102. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  60103. }
  60104. };
  60105. /**
  60106. * Renders all the objects from the render list into the texture.
  60107. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  60108. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  60109. */
  60110. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  60111. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  60112. if (dumpForDebug === void 0) { dumpForDebug = false; }
  60113. var scene = this.getScene();
  60114. if (!scene) {
  60115. return;
  60116. }
  60117. var engine = scene.getEngine();
  60118. if (this.useCameraPostProcesses !== undefined) {
  60119. useCameraPostProcess = this.useCameraPostProcesses;
  60120. }
  60121. if (this._waitingRenderList) {
  60122. this.renderList = [];
  60123. for (var index = 0; index < this._waitingRenderList.length; index++) {
  60124. var id = this._waitingRenderList[index];
  60125. var mesh_1 = scene.getMeshByID(id);
  60126. if (mesh_1) {
  60127. this.renderList.push(mesh_1);
  60128. }
  60129. }
  60130. delete this._waitingRenderList;
  60131. }
  60132. // Is predicate defined?
  60133. if (this.renderListPredicate) {
  60134. if (this.renderList) {
  60135. this.renderList.length = 0; // Clear previous renderList
  60136. }
  60137. else {
  60138. this.renderList = [];
  60139. }
  60140. var scene = this.getScene();
  60141. if (!scene) {
  60142. return;
  60143. }
  60144. var sceneMeshes = scene.meshes;
  60145. for (var index = 0; index < sceneMeshes.length; index++) {
  60146. var mesh = sceneMeshes[index];
  60147. if (this.renderListPredicate(mesh)) {
  60148. this.renderList.push(mesh);
  60149. }
  60150. }
  60151. }
  60152. this.onBeforeBindObservable.notifyObservers(this);
  60153. // Set custom projection.
  60154. // Needs to be before binding to prevent changing the aspect ratio.
  60155. var camera;
  60156. if (this.activeCamera) {
  60157. camera = this.activeCamera;
  60158. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  60159. if (this.activeCamera !== scene.activeCamera) {
  60160. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  60161. }
  60162. }
  60163. else {
  60164. camera = scene.activeCamera;
  60165. if (camera) {
  60166. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  60167. }
  60168. }
  60169. // Prepare renderingManager
  60170. this._renderingManager.reset();
  60171. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  60172. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  60173. var sceneRenderId = scene.getRenderId();
  60174. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  60175. var mesh = currentRenderList[meshIndex];
  60176. if (mesh) {
  60177. if (!mesh.isReady(this.refreshRate === 0)) {
  60178. this.resetRefreshCounter();
  60179. continue;
  60180. }
  60181. mesh._preActivateForIntermediateRendering(sceneRenderId);
  60182. var isMasked = void 0;
  60183. if (!this.renderList && camera) {
  60184. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  60185. }
  60186. else {
  60187. isMasked = false;
  60188. }
  60189. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  60190. mesh._activate(sceneRenderId);
  60191. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  60192. var subMesh = mesh.subMeshes[subIndex];
  60193. scene._activeIndices.addCount(subMesh.indexCount, false);
  60194. this._renderingManager.dispatch(subMesh, mesh);
  60195. }
  60196. }
  60197. }
  60198. }
  60199. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  60200. var particleSystem = scene.particleSystems[particleIndex];
  60201. var emitter = particleSystem.emitter;
  60202. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  60203. continue;
  60204. }
  60205. if (currentRenderList.indexOf(emitter) >= 0) {
  60206. this._renderingManager.dispatchParticles(particleSystem);
  60207. }
  60208. }
  60209. if (this.isCube) {
  60210. for (var face = 0; face < 6; face++) {
  60211. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  60212. scene.incrementRenderId();
  60213. scene.resetCachedMaterial();
  60214. }
  60215. }
  60216. else {
  60217. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  60218. }
  60219. this.onAfterUnbindObservable.notifyObservers(this);
  60220. if (scene.activeCamera) {
  60221. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  60222. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  60223. }
  60224. engine.setViewport(scene.activeCamera.viewport);
  60225. }
  60226. scene.resetCachedMaterial();
  60227. };
  60228. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  60229. var minimum = 128;
  60230. var x = renderDimension * scale;
  60231. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  60232. // Ensure we don't exceed the render dimension (while staying POT)
  60233. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  60234. };
  60235. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  60236. var _this = this;
  60237. if (!this._texture) {
  60238. return;
  60239. }
  60240. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  60241. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  60242. });
  60243. };
  60244. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  60245. var scene = this.getScene();
  60246. if (!scene) {
  60247. return;
  60248. }
  60249. var engine = scene.getEngine();
  60250. if (!this._texture) {
  60251. return;
  60252. }
  60253. // Bind
  60254. if (this._postProcessManager) {
  60255. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  60256. }
  60257. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  60258. if (this._texture) {
  60259. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  60260. }
  60261. }
  60262. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  60263. // Clear
  60264. if (this.onClearObservable.hasObservers()) {
  60265. this.onClearObservable.notifyObservers(engine);
  60266. }
  60267. else {
  60268. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  60269. }
  60270. if (!this._doNotChangeAspectRatio) {
  60271. scene.updateTransformMatrix(true);
  60272. }
  60273. // Before Camera Draw
  60274. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  60275. var step = _a[_i];
  60276. step.action(this);
  60277. }
  60278. // Render
  60279. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  60280. // After Camera Draw
  60281. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  60282. var step = _c[_b];
  60283. step.action(this);
  60284. }
  60285. if (this._postProcessManager) {
  60286. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  60287. }
  60288. else if (useCameraPostProcess) {
  60289. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  60290. }
  60291. if (!this._doNotChangeAspectRatio) {
  60292. scene.updateTransformMatrix(true);
  60293. }
  60294. // Dump ?
  60295. if (dumpForDebug) {
  60296. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  60297. }
  60298. // Unbind
  60299. if (!this.isCube || faceIndex === 5) {
  60300. if (this.isCube) {
  60301. if (faceIndex === 5) {
  60302. engine.generateMipMapsForCubemap(this._texture);
  60303. }
  60304. }
  60305. this.unbindFrameBuffer(engine, faceIndex);
  60306. }
  60307. else {
  60308. this.onAfterRenderObservable.notifyObservers(faceIndex);
  60309. }
  60310. };
  60311. /**
  60312. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  60313. * This allowed control for front to back rendering or reversly depending of the special needs.
  60314. *
  60315. * @param renderingGroupId The rendering group id corresponding to its index
  60316. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  60317. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  60318. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  60319. */
  60320. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  60321. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  60322. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  60323. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  60324. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  60325. };
  60326. /**
  60327. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  60328. *
  60329. * @param renderingGroupId The rendering group id corresponding to its index
  60330. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60331. */
  60332. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  60333. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  60334. this._renderingManager._useSceneAutoClearSetup = false;
  60335. };
  60336. /**
  60337. * Clones the texture.
  60338. * @returns the cloned texture
  60339. */
  60340. RenderTargetTexture.prototype.clone = function () {
  60341. var textureSize = this.getSize();
  60342. 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);
  60343. // Base texture
  60344. newTexture.hasAlpha = this.hasAlpha;
  60345. newTexture.level = this.level;
  60346. // RenderTarget Texture
  60347. newTexture.coordinatesMode = this.coordinatesMode;
  60348. if (this.renderList) {
  60349. newTexture.renderList = this.renderList.slice(0);
  60350. }
  60351. return newTexture;
  60352. };
  60353. /**
  60354. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  60355. * @returns The JSON representation of the texture
  60356. */
  60357. RenderTargetTexture.prototype.serialize = function () {
  60358. if (!this.name) {
  60359. return null;
  60360. }
  60361. var serializationObject = _super.prototype.serialize.call(this);
  60362. serializationObject.renderTargetSize = this.getRenderSize();
  60363. serializationObject.renderList = [];
  60364. if (this.renderList) {
  60365. for (var index = 0; index < this.renderList.length; index++) {
  60366. serializationObject.renderList.push(this.renderList[index].id);
  60367. }
  60368. }
  60369. return serializationObject;
  60370. };
  60371. /**
  60372. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  60373. */
  60374. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  60375. var objBuffer = this.getInternalTexture();
  60376. var scene = this.getScene();
  60377. if (objBuffer && scene) {
  60378. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  60379. }
  60380. };
  60381. /**
  60382. * Dispose the texture and release its associated resources.
  60383. */
  60384. RenderTargetTexture.prototype.dispose = function () {
  60385. if (this._postProcessManager) {
  60386. this._postProcessManager.dispose();
  60387. this._postProcessManager = null;
  60388. }
  60389. this.clearPostProcesses(true);
  60390. if (this._resizeObserver) {
  60391. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  60392. this._resizeObserver = null;
  60393. }
  60394. this.renderList = null;
  60395. // Remove from custom render targets
  60396. var scene = this.getScene();
  60397. if (!scene) {
  60398. return;
  60399. }
  60400. var index = scene.customRenderTargets.indexOf(this);
  60401. if (index >= 0) {
  60402. scene.customRenderTargets.splice(index, 1);
  60403. }
  60404. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  60405. var camera = _a[_i];
  60406. index = camera.customRenderTargets.indexOf(this);
  60407. if (index >= 0) {
  60408. camera.customRenderTargets.splice(index, 1);
  60409. }
  60410. }
  60411. _super.prototype.dispose.call(this);
  60412. };
  60413. /** @hidden */
  60414. RenderTargetTexture.prototype._rebuild = function () {
  60415. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  60416. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  60417. }
  60418. if (this._postProcessManager) {
  60419. this._postProcessManager._rebuild();
  60420. }
  60421. };
  60422. /**
  60423. * Clear the info related to rendering groups preventing retention point in material dispose.
  60424. */
  60425. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  60426. if (this._renderingManager) {
  60427. this._renderingManager.freeRenderingGroups();
  60428. }
  60429. };
  60430. /**
  60431. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  60432. */
  60433. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  60434. /**
  60435. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  60436. */
  60437. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  60438. /**
  60439. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  60440. * the central point of your effect and can save a lot of performances.
  60441. */
  60442. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  60443. return RenderTargetTexture;
  60444. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  60445. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  60446. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  60447. };
  60448. /***/ }),
  60449. /***/ "./Materials/Textures/texture.ts":
  60450. /*!***************************************!*\
  60451. !*** ./Materials/Textures/texture.ts ***!
  60452. \***************************************/
  60453. /*! exports provided: Texture */
  60454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60455. "use strict";
  60456. __webpack_require__.r(__webpack_exports__);
  60457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  60458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60459. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60460. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60461. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60462. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60463. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  60464. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60465. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  60466. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  60467. /**
  60468. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  60469. * @see http://doc.babylonjs.com/babylon101/materials#texture
  60470. */
  60471. var Texture = /** @class */ (function (_super) {
  60472. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  60473. /**
  60474. * Instantiates a new texture.
  60475. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  60476. * @see http://doc.babylonjs.com/babylon101/materials#texture
  60477. * @param url define the url of the picture to load as a texture
  60478. * @param scene define the scene the texture will belong to
  60479. * @param noMipmap define if the texture will require mip maps or not
  60480. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60481. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60482. * @param onLoad define a callback triggered when the texture has been loaded
  60483. * @param onError define a callback triggered when an error occurred during the loading session
  60484. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  60485. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  60486. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60487. */
  60488. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  60489. if (noMipmap === void 0) { noMipmap = false; }
  60490. if (invertY === void 0) { invertY = true; }
  60491. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60492. if (onLoad === void 0) { onLoad = null; }
  60493. if (onError === void 0) { onError = null; }
  60494. if (buffer === void 0) { buffer = null; }
  60495. if (deleteBuffer === void 0) { deleteBuffer = false; }
  60496. var _this = _super.call(this, scene) || this;
  60497. /**
  60498. * Define an offset on the texture to offset the u coordinates of the UVs
  60499. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  60500. */
  60501. _this.uOffset = 0;
  60502. /**
  60503. * Define an offset on the texture to offset the v coordinates of the UVs
  60504. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  60505. */
  60506. _this.vOffset = 0;
  60507. /**
  60508. * Define an offset on the texture to scale the u coordinates of the UVs
  60509. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  60510. */
  60511. _this.uScale = 1.0;
  60512. /**
  60513. * Define an offset on the texture to scale the v coordinates of the UVs
  60514. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  60515. */
  60516. _this.vScale = 1.0;
  60517. /**
  60518. * Define an offset on the texture to rotate around the u coordinates of the UVs
  60519. * @see http://doc.babylonjs.com/how_to/more_materials
  60520. */
  60521. _this.uAng = 0;
  60522. /**
  60523. * Define an offset on the texture to rotate around the v coordinates of the UVs
  60524. * @see http://doc.babylonjs.com/how_to/more_materials
  60525. */
  60526. _this.vAng = 0;
  60527. /**
  60528. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  60529. * @see http://doc.babylonjs.com/how_to/more_materials
  60530. */
  60531. _this.wAng = 0;
  60532. /**
  60533. * Defines the center of rotation (U)
  60534. */
  60535. _this.uRotationCenter = 0.5;
  60536. /**
  60537. * Defines the center of rotation (V)
  60538. */
  60539. _this.vRotationCenter = 0.5;
  60540. /**
  60541. * Defines the center of rotation (W)
  60542. */
  60543. _this.wRotationCenter = 0.5;
  60544. /** @hidden */
  60545. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  60546. /**
  60547. * Observable triggered once the texture has been loaded.
  60548. */
  60549. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  60550. _this._isBlocking = true;
  60551. _this.name = url || "";
  60552. _this.url = url;
  60553. _this._noMipmap = noMipmap;
  60554. _this._invertY = invertY;
  60555. _this._initialSamplingMode = samplingMode;
  60556. _this._buffer = buffer;
  60557. _this._deleteBuffer = deleteBuffer;
  60558. if (format) {
  60559. _this._format = format;
  60560. }
  60561. scene = _this.getScene();
  60562. if (!scene) {
  60563. return _this;
  60564. }
  60565. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  60566. var load = function () {
  60567. if (_this._texture && _this._texture._invertVScale) {
  60568. _this.vScale = -1;
  60569. }
  60570. if (_this.onLoadObservable.hasObservers()) {
  60571. _this.onLoadObservable.notifyObservers(_this);
  60572. }
  60573. if (onLoad) {
  60574. onLoad();
  60575. }
  60576. if (!_this.isBlocking && scene) {
  60577. scene.resetCachedMaterial();
  60578. }
  60579. };
  60580. if (!_this.url) {
  60581. _this._delayedOnLoad = load;
  60582. _this._delayedOnError = onError;
  60583. return _this;
  60584. }
  60585. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  60586. if (!_this._texture) {
  60587. if (!scene.useDelayedTextureLoading) {
  60588. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  60589. if (deleteBuffer) {
  60590. delete _this._buffer;
  60591. }
  60592. }
  60593. else {
  60594. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  60595. _this._delayedOnLoad = load;
  60596. _this._delayedOnError = onError;
  60597. }
  60598. }
  60599. else {
  60600. if (_this._texture.isReady) {
  60601. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  60602. }
  60603. else {
  60604. _this._texture.onLoadedObservable.add(load);
  60605. }
  60606. }
  60607. return _this;
  60608. }
  60609. Object.defineProperty(Texture.prototype, "noMipmap", {
  60610. /**
  60611. * Are mip maps generated for this texture or not.
  60612. */
  60613. get: function () {
  60614. return this._noMipmap;
  60615. },
  60616. enumerable: true,
  60617. configurable: true
  60618. });
  60619. Object.defineProperty(Texture.prototype, "isBlocking", {
  60620. get: function () {
  60621. return this._isBlocking;
  60622. },
  60623. /**
  60624. * Is the texture preventing material to render while loading.
  60625. * If false, a default texture will be used instead of the loading one during the preparation step.
  60626. */
  60627. set: function (value) {
  60628. this._isBlocking = value;
  60629. },
  60630. enumerable: true,
  60631. configurable: true
  60632. });
  60633. Object.defineProperty(Texture.prototype, "samplingMode", {
  60634. /**
  60635. * Get the current sampling mode associated with the texture.
  60636. */
  60637. get: function () {
  60638. if (!this._texture) {
  60639. return this._initialSamplingMode;
  60640. }
  60641. return this._texture.samplingMode;
  60642. },
  60643. enumerable: true,
  60644. configurable: true
  60645. });
  60646. Object.defineProperty(Texture.prototype, "invertY", {
  60647. /**
  60648. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  60649. */
  60650. get: function () {
  60651. return this._invertY;
  60652. },
  60653. enumerable: true,
  60654. configurable: true
  60655. });
  60656. /**
  60657. * Update the url (and optional buffer) of this texture if url was null during construction.
  60658. * @param url the url of the texture
  60659. * @param buffer the buffer of the texture (defaults to null)
  60660. * @param onLoad callback called when the texture is loaded (defaults to null)
  60661. */
  60662. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  60663. if (buffer === void 0) { buffer = null; }
  60664. if (this.url) {
  60665. this.releaseInternalTexture();
  60666. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  60667. }
  60668. this.url = url;
  60669. this._buffer = buffer;
  60670. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  60671. if (onLoad) {
  60672. this._delayedOnLoad = onLoad;
  60673. }
  60674. this.delayLoad();
  60675. };
  60676. /**
  60677. * Finish the loading sequence of a texture flagged as delayed load.
  60678. * @hidden
  60679. */
  60680. Texture.prototype.delayLoad = function () {
  60681. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  60682. return;
  60683. }
  60684. var scene = this.getScene();
  60685. if (!scene) {
  60686. return;
  60687. }
  60688. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  60689. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  60690. if (!this._texture) {
  60691. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  60692. if (this._deleteBuffer) {
  60693. delete this._buffer;
  60694. }
  60695. }
  60696. else {
  60697. if (this._delayedOnLoad) {
  60698. if (this._texture.isReady) {
  60699. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  60700. }
  60701. else {
  60702. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  60703. }
  60704. }
  60705. }
  60706. this._delayedOnLoad = null;
  60707. this._delayedOnError = null;
  60708. };
  60709. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  60710. x *= this.uScale;
  60711. y *= this.vScale;
  60712. x -= this.uRotationCenter * this.uScale;
  60713. y -= this.vRotationCenter * this.vScale;
  60714. z -= this.wRotationCenter;
  60715. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  60716. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  60717. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  60718. t.z += this.wRotationCenter;
  60719. };
  60720. /**
  60721. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  60722. * @returns the transform matrix of the texture.
  60723. */
  60724. Texture.prototype.getTextureMatrix = function () {
  60725. var _this = this;
  60726. if (this.uOffset === this._cachedUOffset &&
  60727. this.vOffset === this._cachedVOffset &&
  60728. this.uScale === this._cachedUScale &&
  60729. this.vScale === this._cachedVScale &&
  60730. this.uAng === this._cachedUAng &&
  60731. this.vAng === this._cachedVAng &&
  60732. this.wAng === this._cachedWAng) {
  60733. return this._cachedTextureMatrix;
  60734. }
  60735. this._cachedUOffset = this.uOffset;
  60736. this._cachedVOffset = this.vOffset;
  60737. this._cachedUScale = this.uScale;
  60738. this._cachedVScale = this.vScale;
  60739. this._cachedUAng = this.uAng;
  60740. this._cachedVAng = this.vAng;
  60741. this._cachedWAng = this.wAng;
  60742. if (!this._cachedTextureMatrix) {
  60743. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60744. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  60745. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60746. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60747. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60748. }
  60749. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  60750. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  60751. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  60752. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  60753. this._t1.subtractInPlace(this._t0);
  60754. this._t2.subtractInPlace(this._t0);
  60755. _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);
  60756. var scene = this.getScene();
  60757. if (!scene) {
  60758. return this._cachedTextureMatrix;
  60759. }
  60760. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  60761. return mat.hasTexture(_this);
  60762. });
  60763. return this._cachedTextureMatrix;
  60764. };
  60765. /**
  60766. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  60767. * @returns The reflection texture transform
  60768. */
  60769. Texture.prototype.getReflectionTextureMatrix = function () {
  60770. var _this = this;
  60771. var scene = this.getScene();
  60772. if (!scene) {
  60773. return this._cachedTextureMatrix;
  60774. }
  60775. if (this.uOffset === this._cachedUOffset &&
  60776. this.vOffset === this._cachedVOffset &&
  60777. this.uScale === this._cachedUScale &&
  60778. this.vScale === this._cachedVScale &&
  60779. this.coordinatesMode === this._cachedCoordinatesMode) {
  60780. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  60781. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  60782. return this._cachedTextureMatrix;
  60783. }
  60784. }
  60785. else {
  60786. return this._cachedTextureMatrix;
  60787. }
  60788. }
  60789. if (!this._cachedTextureMatrix) {
  60790. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60791. }
  60792. if (!this._projectionModeMatrix) {
  60793. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60794. }
  60795. this._cachedUOffset = this.uOffset;
  60796. this._cachedVOffset = this.vOffset;
  60797. this._cachedUScale = this.uScale;
  60798. this._cachedVScale = this.vScale;
  60799. this._cachedCoordinatesMode = this.coordinatesMode;
  60800. switch (this.coordinatesMode) {
  60801. case Texture.PLANAR_MODE:
  60802. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  60803. this._cachedTextureMatrix[0] = this.uScale;
  60804. this._cachedTextureMatrix[5] = this.vScale;
  60805. this._cachedTextureMatrix[12] = this.uOffset;
  60806. this._cachedTextureMatrix[13] = this.vOffset;
  60807. break;
  60808. case Texture.PROJECTION_MODE:
  60809. _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);
  60810. var projectionMatrix = scene.getProjectionMatrix();
  60811. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  60812. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  60813. break;
  60814. default:
  60815. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  60816. break;
  60817. }
  60818. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  60819. return (mat.getActiveTextures().indexOf(_this) !== -1);
  60820. });
  60821. return this._cachedTextureMatrix;
  60822. };
  60823. /**
  60824. * Clones the texture.
  60825. * @returns the cloned texture
  60826. */
  60827. Texture.prototype.clone = function () {
  60828. var _this = this;
  60829. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  60830. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  60831. }, this);
  60832. };
  60833. /**
  60834. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  60835. * @returns The JSON representation of the texture
  60836. */
  60837. Texture.prototype.serialize = function () {
  60838. var serializationObject = _super.prototype.serialize.call(this);
  60839. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  60840. serializationObject.base64String = this._buffer;
  60841. serializationObject.name = serializationObject.name.replace("data:", "");
  60842. }
  60843. serializationObject.invertY = this._invertY;
  60844. serializationObject.samplingMode = this.samplingMode;
  60845. return serializationObject;
  60846. };
  60847. /**
  60848. * Get the current class name of the texture useful for serialization or dynamic coding.
  60849. * @returns "Texture"
  60850. */
  60851. Texture.prototype.getClassName = function () {
  60852. return "Texture";
  60853. };
  60854. /**
  60855. * Dispose the texture and release its associated resources.
  60856. */
  60857. Texture.prototype.dispose = function () {
  60858. _super.prototype.dispose.call(this);
  60859. this.onLoadObservable.clear();
  60860. this._delayedOnLoad = null;
  60861. this._delayedOnError = null;
  60862. };
  60863. /**
  60864. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  60865. * @param parsedTexture Define the JSON representation of the texture
  60866. * @param scene Define the scene the parsed texture should be instantiated in
  60867. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60868. * @returns The parsed texture if successful
  60869. */
  60870. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  60871. if (parsedTexture.customType) {
  60872. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  60873. // Update Sampling Mode
  60874. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  60875. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  60876. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  60877. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  60878. }
  60879. }
  60880. return parsedCustomTexture;
  60881. }
  60882. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  60883. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  60884. }
  60885. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  60886. return null;
  60887. }
  60888. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  60889. var generateMipMaps = true;
  60890. if (parsedTexture.noMipmap) {
  60891. generateMipMaps = false;
  60892. }
  60893. if (parsedTexture.mirrorPlane) {
  60894. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  60895. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  60896. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  60897. return mirrorTexture;
  60898. }
  60899. else if (parsedTexture.isRenderTarget) {
  60900. var renderTargetTexture = null;
  60901. if (parsedTexture.isCube) {
  60902. // Search for an existing reflection probe (which contains a cube render target texture)
  60903. if (scene.reflectionProbes) {
  60904. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  60905. var probe = scene.reflectionProbes[index];
  60906. if (probe.name === parsedTexture.name) {
  60907. return probe.cubeTexture;
  60908. }
  60909. }
  60910. }
  60911. }
  60912. else {
  60913. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  60914. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  60915. }
  60916. return renderTargetTexture;
  60917. }
  60918. else {
  60919. var texture;
  60920. if (parsedTexture.base64String) {
  60921. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  60922. }
  60923. else {
  60924. var url = rootUrl + parsedTexture.name;
  60925. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  60926. url = parsedTexture.url;
  60927. }
  60928. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  60929. }
  60930. return texture;
  60931. }
  60932. }, parsedTexture, scene);
  60933. // Update Sampling Mode
  60934. if (parsedTexture.samplingMode) {
  60935. var sampling = parsedTexture.samplingMode;
  60936. if (texture && texture.samplingMode !== sampling) {
  60937. texture.updateSamplingMode(sampling);
  60938. }
  60939. }
  60940. // Animations
  60941. if (texture && parsedTexture.animations) {
  60942. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  60943. var parsedAnimation = parsedTexture.animations[animationIndex];
  60944. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  60945. if (internalClass) {
  60946. texture.animations.push(internalClass.Parse(parsedAnimation));
  60947. }
  60948. }
  60949. }
  60950. return texture;
  60951. };
  60952. /**
  60953. * Creates a texture from its base 64 representation.
  60954. * @param data Define the base64 payload without the data: prefix
  60955. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  60956. * @param scene Define the scene the texture should belong to
  60957. * @param noMipmap Forces the texture to not create mip map information if true
  60958. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60959. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60960. * @param onLoad define a callback triggered when the texture has been loaded
  60961. * @param onError define a callback triggered when an error occurred during the loading session
  60962. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60963. * @returns the created texture
  60964. */
  60965. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  60966. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60967. if (onLoad === void 0) { onLoad = null; }
  60968. if (onError === void 0) { onError = null; }
  60969. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  60970. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  60971. };
  60972. /**
  60973. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  60974. * @param data Define the base64 payload without the data: prefix
  60975. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  60976. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  60977. * @param scene Define the scene the texture should belong to
  60978. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  60979. * @param noMipmap Forces the texture to not create mip map information if true
  60980. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60981. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60982. * @param onLoad define a callback triggered when the texture has been loaded
  60983. * @param onError define a callback triggered when an error occurred during the loading session
  60984. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60985. * @returns the created texture
  60986. */
  60987. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  60988. if (deleteBuffer === void 0) { deleteBuffer = false; }
  60989. if (noMipmap === void 0) { noMipmap = false; }
  60990. if (invertY === void 0) { invertY = true; }
  60991. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60992. if (onLoad === void 0) { onLoad = null; }
  60993. if (onError === void 0) { onError = null; }
  60994. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  60995. if (name.substr(0, 5) !== "data:") {
  60996. name = "data:" + name;
  60997. }
  60998. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  60999. };
  61000. /** @hidden */
  61001. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  61002. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  61003. };
  61004. /** @hidden */
  61005. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  61006. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  61007. };
  61008. /** @hidden */
  61009. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  61010. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  61011. };
  61012. /** nearest is mag = nearest and min = nearest and mip = linear */
  61013. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  61014. /** nearest is mag = nearest and min = nearest and mip = linear */
  61015. 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
  61016. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61017. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  61018. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61019. 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
  61020. /** Trilinear is mag = linear and min = linear and mip = linear */
  61021. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  61022. /** Trilinear is mag = linear and min = linear and mip = linear */
  61023. 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
  61024. /** mag = nearest and min = nearest and mip = nearest */
  61025. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  61026. /** mag = nearest and min = linear and mip = nearest */
  61027. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  61028. /** mag = nearest and min = linear and mip = linear */
  61029. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  61030. /** mag = nearest and min = linear and mip = none */
  61031. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  61032. /** mag = nearest and min = nearest and mip = none */
  61033. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  61034. /** mag = linear and min = nearest and mip = nearest */
  61035. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  61036. /** mag = linear and min = nearest and mip = linear */
  61037. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  61038. /** mag = linear and min = linear and mip = none */
  61039. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  61040. /** mag = linear and min = nearest and mip = none */
  61041. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  61042. /** Explicit coordinates mode */
  61043. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  61044. /** Spherical coordinates mode */
  61045. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  61046. /** Planar coordinates mode */
  61047. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  61048. /** Cubic coordinates mode */
  61049. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  61050. /** Projection coordinates mode */
  61051. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  61052. /** Inverse Cubic coordinates mode */
  61053. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  61054. /** Inverse Cubic coordinates mode */
  61055. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  61056. /** Equirectangular coordinates mode */
  61057. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  61058. /** Equirectangular Fixed coordinates mode */
  61059. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  61060. /** Equirectangular Fixed Mirrored coordinates mode */
  61061. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  61062. /** Texture is not repeating outside of 0..1 UVs */
  61063. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  61064. /** Texture is repeating outside of 0..1 UVs */
  61065. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  61066. /** Texture is repeating and mirrored */
  61067. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  61068. /**
  61069. * 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
  61070. */
  61071. Texture.UseSerializedUrlIfAny = false;
  61072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61074. ], Texture.prototype, "url", void 0);
  61075. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61077. ], Texture.prototype, "uOffset", void 0);
  61078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61080. ], Texture.prototype, "vOffset", void 0);
  61081. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61083. ], Texture.prototype, "uScale", void 0);
  61084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61086. ], Texture.prototype, "vScale", void 0);
  61087. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61089. ], Texture.prototype, "uAng", void 0);
  61090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61092. ], Texture.prototype, "vAng", void 0);
  61093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61095. ], Texture.prototype, "wAng", void 0);
  61096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61098. ], Texture.prototype, "uRotationCenter", void 0);
  61099. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61101. ], Texture.prototype, "vRotationCenter", void 0);
  61102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61104. ], Texture.prototype, "wRotationCenter", void 0);
  61105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61107. ], Texture.prototype, "isBlocking", null);
  61108. return Texture;
  61109. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  61110. // References the dependencies.
  61111. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  61112. /***/ }),
  61113. /***/ "./Materials/Textures/videoTexture.ts":
  61114. /*!********************************************!*\
  61115. !*** ./Materials/Textures/videoTexture.ts ***!
  61116. \********************************************/
  61117. /*! exports provided: VideoTexture */
  61118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61119. "use strict";
  61120. __webpack_require__.r(__webpack_exports__);
  61121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  61122. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61123. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  61124. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  61125. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  61126. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  61127. /**
  61128. * If you want to display a video in your scene, this is the special texture for that.
  61129. * This special texture works similar to other textures, with the exception of a few parameters.
  61130. * @see https://doc.babylonjs.com/how_to/video_texture
  61131. */
  61132. var VideoTexture = /** @class */ (function (_super) {
  61133. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  61134. /**
  61135. * Creates a video texture.
  61136. * If you want to display a video in your scene, this is the special texture for that.
  61137. * This special texture works similar to other textures, with the exception of a few parameters.
  61138. * @see https://doc.babylonjs.com/how_to/video_texture
  61139. * @param name optional name, will detect from video source, if not defined
  61140. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  61141. * @param scene is obviously the current scene.
  61142. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  61143. * @param invertY is false by default but can be used to invert video on Y axis
  61144. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  61145. * @param settings allows finer control over video usage
  61146. */
  61147. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  61148. if (generateMipMaps === void 0) { generateMipMaps = false; }
  61149. if (invertY === void 0) { invertY = false; }
  61150. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  61151. if (settings === void 0) { settings = {
  61152. autoPlay: true,
  61153. loop: true,
  61154. autoUpdateTexture: true,
  61155. }; }
  61156. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  61157. _this._onUserActionRequestedObservable = null;
  61158. _this._stillImageCaptured = false;
  61159. _this._displayingPosterTexture = false;
  61160. _this._createInternalTexture = function () {
  61161. if (_this._texture != null) {
  61162. if (_this._displayingPosterTexture) {
  61163. _this._texture.dispose();
  61164. _this._displayingPosterTexture = false;
  61165. }
  61166. else {
  61167. return;
  61168. }
  61169. }
  61170. if (!_this._engine.needPOTTextures ||
  61171. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  61172. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  61173. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  61174. }
  61175. else {
  61176. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  61177. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  61178. _this._generateMipMaps = false;
  61179. }
  61180. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  61181. if (!_this.video.autoplay && !_this._settings.poster) {
  61182. var oldHandler_1 = _this.video.onplaying;
  61183. var error_1 = false;
  61184. var oldMuted_1 = _this.video.muted;
  61185. _this.video.muted = true;
  61186. _this.video.onplaying = function () {
  61187. _this.video.muted = oldMuted_1;
  61188. _this.video.onplaying = oldHandler_1;
  61189. _this._texture.isReady = true;
  61190. _this._updateInternalTexture();
  61191. if (!error_1) {
  61192. _this.video.pause();
  61193. }
  61194. if (_this.onLoadObservable.hasObservers()) {
  61195. _this.onLoadObservable.notifyObservers(_this);
  61196. }
  61197. };
  61198. var playing = _this.video.play();
  61199. if (playing) {
  61200. playing.then(function () {
  61201. // Everything is good.
  61202. })
  61203. .catch(function () {
  61204. error_1 = true;
  61205. // On Chrome for instance, new policies might prevent playing without user interaction.
  61206. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  61207. _this._onUserActionRequestedObservable.notifyObservers(_this);
  61208. }
  61209. });
  61210. }
  61211. else {
  61212. _this.video.onplaying = oldHandler_1;
  61213. _this._texture.isReady = true;
  61214. _this._updateInternalTexture();
  61215. if (_this.onLoadObservable.hasObservers()) {
  61216. _this.onLoadObservable.notifyObservers(_this);
  61217. }
  61218. }
  61219. }
  61220. else {
  61221. _this._texture.isReady = true;
  61222. _this._updateInternalTexture();
  61223. if (_this.onLoadObservable.hasObservers()) {
  61224. _this.onLoadObservable.notifyObservers(_this);
  61225. }
  61226. }
  61227. };
  61228. _this.reset = function () {
  61229. if (_this._texture == null) {
  61230. return;
  61231. }
  61232. if (!_this._displayingPosterTexture) {
  61233. _this._texture.dispose();
  61234. _this._texture = null;
  61235. }
  61236. };
  61237. _this._updateInternalTexture = function () {
  61238. if (_this._texture == null || !_this._texture.isReady) {
  61239. return;
  61240. }
  61241. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  61242. return;
  61243. }
  61244. if (_this._displayingPosterTexture) {
  61245. return;
  61246. }
  61247. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  61248. };
  61249. _this._engine = _this.getScene().getEngine();
  61250. _this._generateMipMaps = generateMipMaps;
  61251. _this._initialSamplingMode = samplingMode;
  61252. _this.autoUpdateTexture = settings.autoUpdateTexture;
  61253. _this.name = name || _this._getName(src);
  61254. _this.video = _this._getVideo(src);
  61255. _this._settings = settings;
  61256. if (settings.poster) {
  61257. _this.video.poster = settings.poster;
  61258. }
  61259. if (settings.autoPlay !== undefined) {
  61260. _this.video.autoplay = settings.autoPlay;
  61261. }
  61262. if (settings.loop !== undefined) {
  61263. _this.video.loop = settings.loop;
  61264. }
  61265. _this.video.setAttribute("playsinline", "");
  61266. _this.video.addEventListener("paused", _this._updateInternalTexture);
  61267. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  61268. _this.video.addEventListener("emptied", _this.reset);
  61269. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  61270. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  61271. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  61272. if (settings.poster &&
  61273. (!settings.autoPlay || !videoHasEnoughData)) {
  61274. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  61275. _this._displayingPosterTexture = true;
  61276. }
  61277. else if (videoHasEnoughData) {
  61278. _this._createInternalTexture();
  61279. }
  61280. return _this;
  61281. }
  61282. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  61283. /**
  61284. * Event triggerd when a dom action is required by the user to play the video.
  61285. * This happens due to recent changes in browser policies preventing video to auto start.
  61286. */
  61287. get: function () {
  61288. if (!this._onUserActionRequestedObservable) {
  61289. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  61290. }
  61291. return this._onUserActionRequestedObservable;
  61292. },
  61293. enumerable: true,
  61294. configurable: true
  61295. });
  61296. VideoTexture.prototype._getName = function (src) {
  61297. if (src instanceof HTMLVideoElement) {
  61298. return src.currentSrc;
  61299. }
  61300. if (typeof src === "object") {
  61301. return src.toString();
  61302. }
  61303. return src;
  61304. };
  61305. VideoTexture.prototype._getVideo = function (src) {
  61306. if (src instanceof HTMLVideoElement) {
  61307. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  61308. return src;
  61309. }
  61310. var video = document.createElement("video");
  61311. if (typeof src === "string") {
  61312. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  61313. video.src = src;
  61314. }
  61315. else {
  61316. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  61317. src.forEach(function (url) {
  61318. var source = document.createElement("source");
  61319. source.src = url;
  61320. video.appendChild(source);
  61321. });
  61322. }
  61323. return video;
  61324. };
  61325. /**
  61326. * @hidden Internal method to initiate `update`.
  61327. */
  61328. VideoTexture.prototype._rebuild = function () {
  61329. this.update();
  61330. };
  61331. /**
  61332. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  61333. */
  61334. VideoTexture.prototype.update = function () {
  61335. if (!this.autoUpdateTexture) {
  61336. // Expecting user to call `updateTexture` manually
  61337. return;
  61338. }
  61339. this.updateTexture(true);
  61340. };
  61341. /**
  61342. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  61343. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  61344. */
  61345. VideoTexture.prototype.updateTexture = function (isVisible) {
  61346. if (!isVisible) {
  61347. return;
  61348. }
  61349. if (this.video.paused && this._stillImageCaptured) {
  61350. return;
  61351. }
  61352. this._stillImageCaptured = true;
  61353. this._updateInternalTexture();
  61354. };
  61355. /**
  61356. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  61357. * @param url New url.
  61358. */
  61359. VideoTexture.prototype.updateURL = function (url) {
  61360. this.video.src = url;
  61361. };
  61362. /**
  61363. * Dispose the texture and release its associated resources.
  61364. */
  61365. VideoTexture.prototype.dispose = function () {
  61366. _super.prototype.dispose.call(this);
  61367. if (this._onUserActionRequestedObservable) {
  61368. this._onUserActionRequestedObservable.clear();
  61369. this._onUserActionRequestedObservable = null;
  61370. }
  61371. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  61372. this.video.removeEventListener("paused", this._updateInternalTexture);
  61373. this.video.removeEventListener("seeked", this._updateInternalTexture);
  61374. this.video.removeEventListener("emptied", this.reset);
  61375. this.video.pause();
  61376. };
  61377. /**
  61378. * Creates a video texture straight from a stream.
  61379. * @param scene Define the scene the texture should be created in
  61380. * @param stream Define the stream the texture should be created from
  61381. * @returns The created video texture as a promise
  61382. */
  61383. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  61384. var video = document.createElement("video");
  61385. video.setAttribute('autoplay', '');
  61386. video.setAttribute('muted', 'true');
  61387. video.setAttribute('playsinline', '');
  61388. video.muted = true;
  61389. if (video.mozSrcObject !== undefined) {
  61390. // hack for Firefox < 19
  61391. video.mozSrcObject = stream;
  61392. }
  61393. else {
  61394. if (typeof video.srcObject == "object") {
  61395. video.srcObject = stream;
  61396. }
  61397. else {
  61398. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  61399. video.src = (window.URL && window.URL.createObjectURL(stream));
  61400. }
  61401. }
  61402. return new Promise(function (resolve) {
  61403. var onPlaying = function () {
  61404. resolve(new VideoTexture("video", video, scene, true, true));
  61405. video.removeEventListener("playing", onPlaying);
  61406. };
  61407. video.addEventListener("playing", onPlaying);
  61408. video.play();
  61409. });
  61410. };
  61411. /**
  61412. * Creates a video texture straight from your WebCam video feed.
  61413. * @param scene Define the scene the texture should be created in
  61414. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  61415. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  61416. * @returns The created video texture as a promise
  61417. */
  61418. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  61419. var _this = this;
  61420. if (audioConstaints === void 0) { audioConstaints = false; }
  61421. var constraintsDeviceId;
  61422. if (constraints && constraints.deviceId) {
  61423. constraintsDeviceId = {
  61424. exact: constraints.deviceId,
  61425. };
  61426. }
  61427. if (navigator.mediaDevices) {
  61428. return navigator.mediaDevices.getUserMedia({
  61429. video: constraints,
  61430. audio: audioConstaints
  61431. })
  61432. .then(function (stream) {
  61433. return _this.CreateFromStreamAsync(scene, stream);
  61434. });
  61435. }
  61436. else {
  61437. navigator.getUserMedia =
  61438. navigator.getUserMedia ||
  61439. navigator.webkitGetUserMedia ||
  61440. navigator.mozGetUserMedia ||
  61441. navigator.msGetUserMedia;
  61442. if (navigator.getUserMedia) {
  61443. navigator.getUserMedia({
  61444. video: {
  61445. deviceId: constraintsDeviceId,
  61446. width: {
  61447. min: (constraints && constraints.minWidth) || 256,
  61448. max: (constraints && constraints.maxWidth) || 640,
  61449. },
  61450. height: {
  61451. min: (constraints && constraints.minHeight) || 256,
  61452. max: (constraints && constraints.maxHeight) || 480,
  61453. },
  61454. },
  61455. audio: audioConstaints
  61456. }, function (stream) {
  61457. return _this.CreateFromStreamAsync(scene, stream);
  61458. }, function (e) {
  61459. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  61460. });
  61461. }
  61462. }
  61463. return Promise.reject("No support for userMedia on this device");
  61464. };
  61465. /**
  61466. * Creates a video texture straight from your WebCam video feed.
  61467. * @param scene Define the scene the texture should be created in
  61468. * @param onReady Define a callback to triggered once the texture will be ready
  61469. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  61470. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  61471. */
  61472. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  61473. if (audioConstaints === void 0) { audioConstaints = false; }
  61474. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  61475. .then(function (videoTexture) {
  61476. if (onReady) {
  61477. onReady(videoTexture);
  61478. }
  61479. })
  61480. .catch(function (err) {
  61481. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  61482. });
  61483. };
  61484. return VideoTexture;
  61485. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  61486. /***/ }),
  61487. /***/ "./Materials/colorCurves.ts":
  61488. /*!**********************************!*\
  61489. !*** ./Materials/colorCurves.ts ***!
  61490. \**********************************/
  61491. /*! exports provided: ColorCurves */
  61492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61493. "use strict";
  61494. __webpack_require__.r(__webpack_exports__);
  61495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  61496. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61497. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61498. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61499. /**
  61500. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61501. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61502. * 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;
  61503. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61504. */
  61505. var ColorCurves = /** @class */ (function () {
  61506. function ColorCurves() {
  61507. this._dirty = true;
  61508. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61509. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61510. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61511. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61512. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61513. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61514. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61515. this._globalHue = 30;
  61516. this._globalDensity = 0;
  61517. this._globalSaturation = 0;
  61518. this._globalExposure = 0;
  61519. this._highlightsHue = 30;
  61520. this._highlightsDensity = 0;
  61521. this._highlightsSaturation = 0;
  61522. this._highlightsExposure = 0;
  61523. this._midtonesHue = 30;
  61524. this._midtonesDensity = 0;
  61525. this._midtonesSaturation = 0;
  61526. this._midtonesExposure = 0;
  61527. this._shadowsHue = 30;
  61528. this._shadowsDensity = 0;
  61529. this._shadowsSaturation = 0;
  61530. this._shadowsExposure = 0;
  61531. }
  61532. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  61533. /**
  61534. * Gets the global Hue value.
  61535. * 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).
  61536. */
  61537. get: function () {
  61538. return this._globalHue;
  61539. },
  61540. /**
  61541. * Sets the global Hue value.
  61542. * 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).
  61543. */
  61544. set: function (value) {
  61545. this._globalHue = value;
  61546. this._dirty = true;
  61547. },
  61548. enumerable: true,
  61549. configurable: true
  61550. });
  61551. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  61552. /**
  61553. * Gets the global Density value.
  61554. * 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.
  61555. * Values less than zero provide a filter of opposite hue.
  61556. */
  61557. get: function () {
  61558. return this._globalDensity;
  61559. },
  61560. /**
  61561. * Sets the global Density value.
  61562. * 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.
  61563. * Values less than zero provide a filter of opposite hue.
  61564. */
  61565. set: function (value) {
  61566. this._globalDensity = value;
  61567. this._dirty = true;
  61568. },
  61569. enumerable: true,
  61570. configurable: true
  61571. });
  61572. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  61573. /**
  61574. * Gets the global Saturation value.
  61575. * 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.
  61576. */
  61577. get: function () {
  61578. return this._globalSaturation;
  61579. },
  61580. /**
  61581. * Sets the global Saturation value.
  61582. * 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.
  61583. */
  61584. set: function (value) {
  61585. this._globalSaturation = value;
  61586. this._dirty = true;
  61587. },
  61588. enumerable: true,
  61589. configurable: true
  61590. });
  61591. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  61592. /**
  61593. * Gets the global Exposure value.
  61594. * 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.
  61595. */
  61596. get: function () {
  61597. return this._globalExposure;
  61598. },
  61599. /**
  61600. * Sets the global Exposure value.
  61601. * 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.
  61602. */
  61603. set: function (value) {
  61604. this._globalExposure = value;
  61605. this._dirty = true;
  61606. },
  61607. enumerable: true,
  61608. configurable: true
  61609. });
  61610. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  61611. /**
  61612. * Gets the highlights Hue value.
  61613. * 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).
  61614. */
  61615. get: function () {
  61616. return this._highlightsHue;
  61617. },
  61618. /**
  61619. * Sets the highlights Hue value.
  61620. * 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).
  61621. */
  61622. set: function (value) {
  61623. this._highlightsHue = value;
  61624. this._dirty = true;
  61625. },
  61626. enumerable: true,
  61627. configurable: true
  61628. });
  61629. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  61630. /**
  61631. * Gets the highlights Density value.
  61632. * 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.
  61633. * Values less than zero provide a filter of opposite hue.
  61634. */
  61635. get: function () {
  61636. return this._highlightsDensity;
  61637. },
  61638. /**
  61639. * Sets the highlights Density value.
  61640. * 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.
  61641. * Values less than zero provide a filter of opposite hue.
  61642. */
  61643. set: function (value) {
  61644. this._highlightsDensity = value;
  61645. this._dirty = true;
  61646. },
  61647. enumerable: true,
  61648. configurable: true
  61649. });
  61650. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  61651. /**
  61652. * Gets the highlights Saturation value.
  61653. * 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.
  61654. */
  61655. get: function () {
  61656. return this._highlightsSaturation;
  61657. },
  61658. /**
  61659. * Sets the highlights Saturation value.
  61660. * 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.
  61661. */
  61662. set: function (value) {
  61663. this._highlightsSaturation = value;
  61664. this._dirty = true;
  61665. },
  61666. enumerable: true,
  61667. configurable: true
  61668. });
  61669. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  61670. /**
  61671. * Gets the highlights Exposure value.
  61672. * 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.
  61673. */
  61674. get: function () {
  61675. return this._highlightsExposure;
  61676. },
  61677. /**
  61678. * Sets the highlights Exposure value.
  61679. * 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.
  61680. */
  61681. set: function (value) {
  61682. this._highlightsExposure = value;
  61683. this._dirty = true;
  61684. },
  61685. enumerable: true,
  61686. configurable: true
  61687. });
  61688. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  61689. /**
  61690. * Gets the midtones Hue value.
  61691. * 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).
  61692. */
  61693. get: function () {
  61694. return this._midtonesHue;
  61695. },
  61696. /**
  61697. * Sets the midtones Hue value.
  61698. * 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).
  61699. */
  61700. set: function (value) {
  61701. this._midtonesHue = value;
  61702. this._dirty = true;
  61703. },
  61704. enumerable: true,
  61705. configurable: true
  61706. });
  61707. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  61708. /**
  61709. * Gets the midtones Density value.
  61710. * 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.
  61711. * Values less than zero provide a filter of opposite hue.
  61712. */
  61713. get: function () {
  61714. return this._midtonesDensity;
  61715. },
  61716. /**
  61717. * Sets the midtones Density value.
  61718. * 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.
  61719. * Values less than zero provide a filter of opposite hue.
  61720. */
  61721. set: function (value) {
  61722. this._midtonesDensity = value;
  61723. this._dirty = true;
  61724. },
  61725. enumerable: true,
  61726. configurable: true
  61727. });
  61728. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  61729. /**
  61730. * Gets the midtones Saturation value.
  61731. * 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.
  61732. */
  61733. get: function () {
  61734. return this._midtonesSaturation;
  61735. },
  61736. /**
  61737. * Sets the midtones Saturation value.
  61738. * 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.
  61739. */
  61740. set: function (value) {
  61741. this._midtonesSaturation = value;
  61742. this._dirty = true;
  61743. },
  61744. enumerable: true,
  61745. configurable: true
  61746. });
  61747. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  61748. /**
  61749. * Gets the midtones Exposure value.
  61750. * 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.
  61751. */
  61752. get: function () {
  61753. return this._midtonesExposure;
  61754. },
  61755. /**
  61756. * Sets the midtones Exposure value.
  61757. * 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.
  61758. */
  61759. set: function (value) {
  61760. this._midtonesExposure = value;
  61761. this._dirty = true;
  61762. },
  61763. enumerable: true,
  61764. configurable: true
  61765. });
  61766. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  61767. /**
  61768. * Gets the shadows Hue value.
  61769. * 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).
  61770. */
  61771. get: function () {
  61772. return this._shadowsHue;
  61773. },
  61774. /**
  61775. * Sets the shadows Hue value.
  61776. * 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).
  61777. */
  61778. set: function (value) {
  61779. this._shadowsHue = value;
  61780. this._dirty = true;
  61781. },
  61782. enumerable: true,
  61783. configurable: true
  61784. });
  61785. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  61786. /**
  61787. * Gets the shadows Density value.
  61788. * 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.
  61789. * Values less than zero provide a filter of opposite hue.
  61790. */
  61791. get: function () {
  61792. return this._shadowsDensity;
  61793. },
  61794. /**
  61795. * Sets the shadows Density value.
  61796. * 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.
  61797. * Values less than zero provide a filter of opposite hue.
  61798. */
  61799. set: function (value) {
  61800. this._shadowsDensity = value;
  61801. this._dirty = true;
  61802. },
  61803. enumerable: true,
  61804. configurable: true
  61805. });
  61806. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  61807. /**
  61808. * Gets the shadows Saturation value.
  61809. * 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.
  61810. */
  61811. get: function () {
  61812. return this._shadowsSaturation;
  61813. },
  61814. /**
  61815. * Sets the shadows Saturation value.
  61816. * 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.
  61817. */
  61818. set: function (value) {
  61819. this._shadowsSaturation = value;
  61820. this._dirty = true;
  61821. },
  61822. enumerable: true,
  61823. configurable: true
  61824. });
  61825. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  61826. /**
  61827. * Gets the shadows Exposure value.
  61828. * 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.
  61829. */
  61830. get: function () {
  61831. return this._shadowsExposure;
  61832. },
  61833. /**
  61834. * Sets the shadows Exposure value.
  61835. * 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.
  61836. */
  61837. set: function (value) {
  61838. this._shadowsExposure = value;
  61839. this._dirty = true;
  61840. },
  61841. enumerable: true,
  61842. configurable: true
  61843. });
  61844. /**
  61845. * Returns the class name
  61846. * @returns The class name
  61847. */
  61848. ColorCurves.prototype.getClassName = function () {
  61849. return "ColorCurves";
  61850. };
  61851. /**
  61852. * Binds the color curves to the shader.
  61853. * @param colorCurves The color curve to bind
  61854. * @param effect The effect to bind to
  61855. * @param positiveUniform The positive uniform shader parameter
  61856. * @param neutralUniform The neutral uniform shader parameter
  61857. * @param negativeUniform The negative uniform shader parameter
  61858. */
  61859. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  61860. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  61861. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  61862. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  61863. if (colorCurves._dirty) {
  61864. colorCurves._dirty = false;
  61865. // Fill in global info.
  61866. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  61867. // Compute highlights info.
  61868. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  61869. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  61870. // Compute midtones info.
  61871. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  61872. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  61873. // Compute shadows info.
  61874. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  61875. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  61876. // Compute deltas (neutral is midtones).
  61877. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  61878. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  61879. }
  61880. if (effect) {
  61881. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  61882. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  61883. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  61884. }
  61885. };
  61886. /**
  61887. * Prepare the list of uniforms associated with the ColorCurves effects.
  61888. * @param uniformsList The list of uniforms used in the effect
  61889. */
  61890. ColorCurves.PrepareUniforms = function (uniformsList) {
  61891. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  61892. };
  61893. /**
  61894. * Returns color grading data based on a hue, density, saturation and exposure value.
  61895. * @param filterHue The hue of the color filter.
  61896. * @param filterDensity The density of the color filter.
  61897. * @param saturation The saturation.
  61898. * @param exposure The exposure.
  61899. * @param result The result data container.
  61900. */
  61901. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  61902. if (hue == null) {
  61903. return;
  61904. }
  61905. hue = ColorCurves.clamp(hue, 0, 360);
  61906. density = ColorCurves.clamp(density, -100, 100);
  61907. saturation = ColorCurves.clamp(saturation, -100, 100);
  61908. exposure = ColorCurves.clamp(exposure, -100, 100);
  61909. // Remap the slider/config filter density with non-linear mapping and also scale by half
  61910. // so that the maximum filter density is only 50% control. This provides fine control
  61911. // for small values and reasonable range.
  61912. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  61913. density *= 0.5;
  61914. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  61915. if (density < 0) {
  61916. density *= -1;
  61917. hue = (hue + 180) % 360;
  61918. }
  61919. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  61920. result.scaleToRef(2, result);
  61921. result.a = 1 + 0.01 * saturation;
  61922. };
  61923. /**
  61924. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  61925. * @param value The input slider value in range [-100,100].
  61926. * @returns Adjusted value.
  61927. */
  61928. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  61929. value /= 100;
  61930. var x = Math.abs(value);
  61931. x = Math.pow(x, 2);
  61932. if (value < 0) {
  61933. x *= -1;
  61934. }
  61935. x *= 100;
  61936. return x;
  61937. };
  61938. /**
  61939. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  61940. * @param hue The hue (H) input.
  61941. * @param saturation The saturation (S) input.
  61942. * @param brightness The brightness (B) input.
  61943. * @result An RGBA color represented as Vector4.
  61944. */
  61945. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  61946. var h = ColorCurves.clamp(hue, 0, 360);
  61947. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  61948. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  61949. if (s === 0) {
  61950. result.r = v;
  61951. result.g = v;
  61952. result.b = v;
  61953. }
  61954. else {
  61955. // sector 0 to 5
  61956. h /= 60;
  61957. var i = Math.floor(h);
  61958. // fractional part of h
  61959. var f = h - i;
  61960. var p = v * (1 - s);
  61961. var q = v * (1 - s * f);
  61962. var t = v * (1 - s * (1 - f));
  61963. switch (i) {
  61964. case 0:
  61965. result.r = v;
  61966. result.g = t;
  61967. result.b = p;
  61968. break;
  61969. case 1:
  61970. result.r = q;
  61971. result.g = v;
  61972. result.b = p;
  61973. break;
  61974. case 2:
  61975. result.r = p;
  61976. result.g = v;
  61977. result.b = t;
  61978. break;
  61979. case 3:
  61980. result.r = p;
  61981. result.g = q;
  61982. result.b = v;
  61983. break;
  61984. case 4:
  61985. result.r = t;
  61986. result.g = p;
  61987. result.b = v;
  61988. break;
  61989. default: // case 5:
  61990. result.r = v;
  61991. result.g = p;
  61992. result.b = q;
  61993. break;
  61994. }
  61995. }
  61996. result.a = 1;
  61997. };
  61998. /**
  61999. * Returns a value clamped between min and max
  62000. * @param value The value to clamp
  62001. * @param min The minimum of value
  62002. * @param max The maximum of value
  62003. * @returns The clamped value.
  62004. */
  62005. ColorCurves.clamp = function (value, min, max) {
  62006. return Math.min(Math.max(value, min), max);
  62007. };
  62008. /**
  62009. * Clones the current color curve instance.
  62010. * @return The cloned curves
  62011. */
  62012. ColorCurves.prototype.clone = function () {
  62013. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  62014. };
  62015. /**
  62016. * Serializes the current color curve instance to a json representation.
  62017. * @return a JSON representation
  62018. */
  62019. ColorCurves.prototype.serialize = function () {
  62020. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62021. };
  62022. /**
  62023. * Parses the color curve from a json representation.
  62024. * @param source the JSON source to parse
  62025. * @return The parsed curves
  62026. */
  62027. ColorCurves.Parse = function (source) {
  62028. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  62029. };
  62030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62032. ], ColorCurves.prototype, "_globalHue", void 0);
  62033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62035. ], ColorCurves.prototype, "_globalDensity", void 0);
  62036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62038. ], ColorCurves.prototype, "_globalSaturation", void 0);
  62039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62041. ], ColorCurves.prototype, "_globalExposure", void 0);
  62042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62044. ], ColorCurves.prototype, "_highlightsHue", void 0);
  62045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62047. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  62048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62050. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  62051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62053. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  62054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62056. ], ColorCurves.prototype, "_midtonesHue", void 0);
  62057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62059. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  62060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62062. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  62063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62065. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  62066. return ColorCurves;
  62067. }());
  62068. // References the dependencies.
  62069. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  62070. /***/ }),
  62071. /***/ "./Materials/effect.ts":
  62072. /*!*****************************!*\
  62073. !*** ./Materials/effect.ts ***!
  62074. \*****************************/
  62075. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  62076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62077. "use strict";
  62078. __webpack_require__.r(__webpack_exports__);
  62079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  62080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  62081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  62082. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62083. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62084. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  62085. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62086. /**
  62087. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  62088. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  62089. */
  62090. var EffectFallbacks = /** @class */ (function () {
  62091. function EffectFallbacks() {
  62092. this._defines = {};
  62093. this._currentRank = 32;
  62094. this._maxRank = -1;
  62095. }
  62096. /**
  62097. * Removes the fallback from the bound mesh.
  62098. */
  62099. EffectFallbacks.prototype.unBindMesh = function () {
  62100. this._mesh = null;
  62101. };
  62102. /**
  62103. * Adds a fallback on the specified property.
  62104. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  62105. * @param define The name of the define in the shader
  62106. */
  62107. EffectFallbacks.prototype.addFallback = function (rank, define) {
  62108. if (!this._defines[rank]) {
  62109. if (rank < this._currentRank) {
  62110. this._currentRank = rank;
  62111. }
  62112. if (rank > this._maxRank) {
  62113. this._maxRank = rank;
  62114. }
  62115. this._defines[rank] = new Array();
  62116. }
  62117. this._defines[rank].push(define);
  62118. };
  62119. /**
  62120. * Sets the mesh to use CPU skinning when needing to fallback.
  62121. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  62122. * @param mesh The mesh to use the fallbacks.
  62123. */
  62124. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  62125. this._mesh = mesh;
  62126. if (rank < this._currentRank) {
  62127. this._currentRank = rank;
  62128. }
  62129. if (rank > this._maxRank) {
  62130. this._maxRank = rank;
  62131. }
  62132. };
  62133. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  62134. /**
  62135. * Checks to see if more fallbacks are still availible.
  62136. */
  62137. get: function () {
  62138. return this._currentRank <= this._maxRank;
  62139. },
  62140. enumerable: true,
  62141. configurable: true
  62142. });
  62143. /**
  62144. * Removes the defines that shoould be removed when falling back.
  62145. * @param currentDefines defines the current define statements for the shader.
  62146. * @param effect defines the current effect we try to compile
  62147. * @returns The resulting defines with defines of the current rank removed.
  62148. */
  62149. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  62150. // First we try to switch to CPU skinning
  62151. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  62152. this._mesh.computeBonesUsingShaders = false;
  62153. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  62154. effect._bonesComputationForcedToCPU = true;
  62155. var scene = this._mesh.getScene();
  62156. for (var index = 0; index < scene.meshes.length; index++) {
  62157. var otherMesh = scene.meshes[index];
  62158. if (!otherMesh.material) {
  62159. continue;
  62160. }
  62161. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  62162. continue;
  62163. }
  62164. if (otherMesh.material.getEffect() === effect) {
  62165. otherMesh.computeBonesUsingShaders = false;
  62166. }
  62167. else if (otherMesh.subMeshes) {
  62168. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  62169. var subMesh = _a[_i];
  62170. var subMeshEffect = subMesh.effect;
  62171. if (subMeshEffect === effect) {
  62172. otherMesh.computeBonesUsingShaders = false;
  62173. break;
  62174. }
  62175. }
  62176. }
  62177. }
  62178. }
  62179. else {
  62180. var currentFallbacks = this._defines[this._currentRank];
  62181. if (currentFallbacks) {
  62182. for (var index = 0; index < currentFallbacks.length; index++) {
  62183. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  62184. }
  62185. }
  62186. this._currentRank++;
  62187. }
  62188. return currentDefines;
  62189. };
  62190. return EffectFallbacks;
  62191. }());
  62192. /**
  62193. * Options to be used when creating an effect.
  62194. */
  62195. var EffectCreationOptions = /** @class */ (function () {
  62196. function EffectCreationOptions() {
  62197. }
  62198. return EffectCreationOptions;
  62199. }());
  62200. /**
  62201. * Effect containing vertex and fragment shader that can be executed on an object.
  62202. */
  62203. var Effect = /** @class */ (function () {
  62204. /**
  62205. * Instantiates an effect.
  62206. * An effect can be used to create/manage/execute vertex and fragment shaders.
  62207. * @param baseName Name of the effect.
  62208. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  62209. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  62210. * @param samplers List of sampler variables that will be passed to the shader.
  62211. * @param engine Engine to be used to render the effect
  62212. * @param defines Define statements to be added to the shader.
  62213. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  62214. * @param onCompiled Callback that will be called when the shader is compiled.
  62215. * @param onError Callback that will be called if an error occurs during shader compilation.
  62216. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  62217. */
  62218. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  62219. if (samplers === void 0) { samplers = null; }
  62220. if (defines === void 0) { defines = null; }
  62221. if (fallbacks === void 0) { fallbacks = null; }
  62222. if (onCompiled === void 0) { onCompiled = null; }
  62223. if (onError === void 0) { onError = null; }
  62224. var _this = this;
  62225. /**
  62226. * Unique ID of the effect.
  62227. */
  62228. this.uniqueId = 0;
  62229. /**
  62230. * Observable that will be called when the shader is compiled.
  62231. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  62232. */
  62233. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62234. /**
  62235. * Observable that will be called if an error occurs during shader compilation.
  62236. */
  62237. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62238. /** @hidden */
  62239. this._bonesComputationForcedToCPU = false;
  62240. this._uniformBuffersNames = {};
  62241. this._isReady = false;
  62242. this._compilationError = "";
  62243. this.name = baseName;
  62244. if (attributesNamesOrOptions.attributes) {
  62245. var options = attributesNamesOrOptions;
  62246. this._engine = uniformsNamesOrEngine;
  62247. this._attributesNames = options.attributes;
  62248. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  62249. this._samplers = options.samplers.slice();
  62250. this.defines = options.defines;
  62251. this.onError = options.onError;
  62252. this.onCompiled = options.onCompiled;
  62253. this._fallbacks = options.fallbacks;
  62254. this._indexParameters = options.indexParameters;
  62255. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  62256. if (options.uniformBuffersNames) {
  62257. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  62258. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  62259. }
  62260. }
  62261. }
  62262. else {
  62263. this._engine = engine;
  62264. this.defines = defines;
  62265. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  62266. this._samplers = samplers ? samplers.slice() : [];
  62267. this._attributesNames = attributesNamesOrOptions;
  62268. this.onError = onError;
  62269. this.onCompiled = onCompiled;
  62270. this._indexParameters = indexParameters;
  62271. this._fallbacks = fallbacks;
  62272. }
  62273. this.uniqueId = Effect._uniqueIdSeed++;
  62274. var vertexSource;
  62275. var fragmentSource;
  62276. if (baseName.vertexElement) {
  62277. vertexSource = document.getElementById(baseName.vertexElement);
  62278. if (!vertexSource) {
  62279. vertexSource = baseName.vertexElement;
  62280. }
  62281. }
  62282. else {
  62283. vertexSource = baseName.vertex || baseName;
  62284. }
  62285. if (baseName.fragmentElement) {
  62286. fragmentSource = document.getElementById(baseName.fragmentElement);
  62287. if (!fragmentSource) {
  62288. fragmentSource = baseName.fragmentElement;
  62289. }
  62290. }
  62291. else {
  62292. fragmentSource = baseName.fragment || baseName;
  62293. }
  62294. this._loadVertexShader(vertexSource, function (vertexCode) {
  62295. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  62296. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  62297. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  62298. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  62299. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  62300. if (baseName) {
  62301. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  62302. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  62303. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  62304. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  62305. }
  62306. else {
  62307. _this._vertexSourceCode = migratedVertexCode;
  62308. _this._fragmentSourceCode = migratedFragmentCode;
  62309. }
  62310. _this._prepareEffect();
  62311. });
  62312. });
  62313. });
  62314. });
  62315. });
  62316. });
  62317. }
  62318. Object.defineProperty(Effect.prototype, "onBindObservable", {
  62319. /**
  62320. * Observable that will be called when effect is bound.
  62321. */
  62322. get: function () {
  62323. if (!this._onBindObservable) {
  62324. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62325. }
  62326. return this._onBindObservable;
  62327. },
  62328. enumerable: true,
  62329. configurable: true
  62330. });
  62331. Object.defineProperty(Effect.prototype, "key", {
  62332. /**
  62333. * Unique key for this effect
  62334. */
  62335. get: function () {
  62336. return this._key;
  62337. },
  62338. enumerable: true,
  62339. configurable: true
  62340. });
  62341. /**
  62342. * If the effect has been compiled and prepared.
  62343. * @returns if the effect is compiled and prepared.
  62344. */
  62345. Effect.prototype.isReady = function () {
  62346. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  62347. return this._engine._isProgramCompiled(this._program);
  62348. }
  62349. return this._isReady;
  62350. };
  62351. /**
  62352. * The engine the effect was initialized with.
  62353. * @returns the engine.
  62354. */
  62355. Effect.prototype.getEngine = function () {
  62356. return this._engine;
  62357. };
  62358. /**
  62359. * The compiled webGL program for the effect
  62360. * @returns the webGL program.
  62361. */
  62362. Effect.prototype.getProgram = function () {
  62363. return this._program;
  62364. };
  62365. /**
  62366. * The set of names of attribute variables for the shader.
  62367. * @returns An array of attribute names.
  62368. */
  62369. Effect.prototype.getAttributesNames = function () {
  62370. return this._attributesNames;
  62371. };
  62372. /**
  62373. * Returns the attribute at the given index.
  62374. * @param index The index of the attribute.
  62375. * @returns The location of the attribute.
  62376. */
  62377. Effect.prototype.getAttributeLocation = function (index) {
  62378. return this._attributes[index];
  62379. };
  62380. /**
  62381. * Returns the attribute based on the name of the variable.
  62382. * @param name of the attribute to look up.
  62383. * @returns the attribute location.
  62384. */
  62385. Effect.prototype.getAttributeLocationByName = function (name) {
  62386. var index = this._attributesNames.indexOf(name);
  62387. return this._attributes[index];
  62388. };
  62389. /**
  62390. * The number of attributes.
  62391. * @returns the numnber of attributes.
  62392. */
  62393. Effect.prototype.getAttributesCount = function () {
  62394. return this._attributes.length;
  62395. };
  62396. /**
  62397. * Gets the index of a uniform variable.
  62398. * @param uniformName of the uniform to look up.
  62399. * @returns the index.
  62400. */
  62401. Effect.prototype.getUniformIndex = function (uniformName) {
  62402. return this._uniformsNames.indexOf(uniformName);
  62403. };
  62404. /**
  62405. * Returns the attribute based on the name of the variable.
  62406. * @param uniformName of the uniform to look up.
  62407. * @returns the location of the uniform.
  62408. */
  62409. Effect.prototype.getUniform = function (uniformName) {
  62410. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  62411. };
  62412. /**
  62413. * Returns an array of sampler variable names
  62414. * @returns The array of sampler variable neames.
  62415. */
  62416. Effect.prototype.getSamplers = function () {
  62417. return this._samplers;
  62418. };
  62419. /**
  62420. * The error from the last compilation.
  62421. * @returns the error string.
  62422. */
  62423. Effect.prototype.getCompilationError = function () {
  62424. return this._compilationError;
  62425. };
  62426. /**
  62427. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  62428. * @param func The callback to be used.
  62429. */
  62430. Effect.prototype.executeWhenCompiled = function (func) {
  62431. var _this = this;
  62432. if (this.isReady()) {
  62433. func(this);
  62434. return;
  62435. }
  62436. this.onCompileObservable.add(function (effect) {
  62437. func(effect);
  62438. });
  62439. if (!this._program || this._program.isParallelCompiled) {
  62440. setTimeout(function () {
  62441. _this._checkIsReady();
  62442. }, 16);
  62443. }
  62444. };
  62445. Effect.prototype._checkIsReady = function () {
  62446. var _this = this;
  62447. if (this.isReady()) {
  62448. return;
  62449. }
  62450. setTimeout(function () {
  62451. _this._checkIsReady();
  62452. }, 16);
  62453. };
  62454. /** @hidden */
  62455. Effect.prototype._loadVertexShader = function (vertex, callback) {
  62456. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  62457. // DOM element ?
  62458. if (vertex instanceof HTMLElement) {
  62459. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  62460. callback(vertexCode);
  62461. return;
  62462. }
  62463. }
  62464. // Base64 encoded ?
  62465. if (vertex.substr(0, 7) === "base64:") {
  62466. var vertexBinary = window.atob(vertex.substr(7));
  62467. callback(vertexBinary);
  62468. return;
  62469. }
  62470. // Is in local store ?
  62471. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  62472. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  62473. return;
  62474. }
  62475. var vertexShaderUrl;
  62476. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  62477. vertexShaderUrl = vertex;
  62478. }
  62479. else {
  62480. vertexShaderUrl = Effect.ShadersRepository + vertex;
  62481. }
  62482. // Vertex shader
  62483. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  62484. };
  62485. /** @hidden */
  62486. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  62487. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  62488. // DOM element ?
  62489. if (fragment instanceof HTMLElement) {
  62490. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  62491. callback(fragmentCode);
  62492. return;
  62493. }
  62494. }
  62495. // Base64 encoded ?
  62496. if (fragment.substr(0, 7) === "base64:") {
  62497. var fragmentBinary = window.atob(fragment.substr(7));
  62498. callback(fragmentBinary);
  62499. return;
  62500. }
  62501. // Is in local store ?
  62502. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  62503. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  62504. return;
  62505. }
  62506. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  62507. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  62508. return;
  62509. }
  62510. var fragmentShaderUrl;
  62511. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  62512. fragmentShaderUrl = fragment;
  62513. }
  62514. else {
  62515. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  62516. }
  62517. // Fragment shader
  62518. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  62519. };
  62520. /** @hidden */
  62521. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  62522. // Rebuild shaders source code
  62523. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  62524. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  62525. vertexCode = prefix + vertexCode;
  62526. fragmentCode = prefix + fragmentCode;
  62527. // Number lines of shaders source code
  62528. var i = 2;
  62529. var regex = /\n/gm;
  62530. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  62531. i = 2;
  62532. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  62533. // Dump shaders name and formatted source code
  62534. if (this.name.vertexElement) {
  62535. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  62536. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  62537. }
  62538. else if (this.name.vertex) {
  62539. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  62540. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  62541. }
  62542. else {
  62543. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  62544. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  62545. }
  62546. };
  62547. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  62548. var preparedSourceCode = this._processPrecision(sourceCode);
  62549. if (this._engine.webGLVersion == 1) {
  62550. callback(preparedSourceCode);
  62551. return;
  62552. }
  62553. // Already converted
  62554. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  62555. callback(preparedSourceCode.replace("#version 300 es", ""));
  62556. return;
  62557. }
  62558. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  62559. // Remove extensions
  62560. // #extension GL_OES_standard_derivatives : enable
  62561. // #extension GL_EXT_shader_texture_lod : enable
  62562. // #extension GL_EXT_frag_depth : enable
  62563. // #extension GL_EXT_draw_buffers : require
  62564. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  62565. var result = preparedSourceCode.replace(regex, "");
  62566. // Migrate to GLSL v300
  62567. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  62568. result = result.replace(/attribute[ \t]/g, "in ");
  62569. result = result.replace(/[ \t]attribute/g, " in");
  62570. result = result.replace(/texture2D\s*\(/g, "texture(");
  62571. if (isFragment) {
  62572. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  62573. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  62574. result = result.replace(/textureCube\s*\(/g, "texture(");
  62575. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  62576. result = result.replace(/gl_FragColor/g, "glFragColor");
  62577. result = result.replace(/gl_FragData/g, "glFragData");
  62578. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  62579. }
  62580. callback(result);
  62581. };
  62582. Effect.prototype._processIncludes = function (sourceCode, callback) {
  62583. var _this = this;
  62584. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  62585. var match = regex.exec(sourceCode);
  62586. var returnValue = new String(sourceCode);
  62587. while (match != null) {
  62588. var includeFile = match[1];
  62589. // Uniform declaration
  62590. if (includeFile.indexOf("__decl__") !== -1) {
  62591. includeFile = includeFile.replace(/__decl__/, "");
  62592. if (this._engine.supportsUniformBuffers) {
  62593. includeFile = includeFile.replace(/Vertex/, "Ubo");
  62594. includeFile = includeFile.replace(/Fragment/, "Ubo");
  62595. }
  62596. includeFile = includeFile + "Declaration";
  62597. }
  62598. if (Effect.IncludesShadersStore[includeFile]) {
  62599. // Substitution
  62600. var includeContent = Effect.IncludesShadersStore[includeFile];
  62601. if (match[2]) {
  62602. var splits = match[3].split(",");
  62603. for (var index = 0; index < splits.length; index += 2) {
  62604. var source = new RegExp(splits[index], "g");
  62605. var dest = splits[index + 1];
  62606. includeContent = includeContent.replace(source, dest);
  62607. }
  62608. }
  62609. if (match[4]) {
  62610. var indexString = match[5];
  62611. if (indexString.indexOf("..") !== -1) {
  62612. var indexSplits = indexString.split("..");
  62613. var minIndex = parseInt(indexSplits[0]);
  62614. var maxIndex = parseInt(indexSplits[1]);
  62615. var sourceIncludeContent = includeContent.slice(0);
  62616. includeContent = "";
  62617. if (isNaN(maxIndex)) {
  62618. maxIndex = this._indexParameters[indexSplits[1]];
  62619. }
  62620. for (var i = minIndex; i < maxIndex; i++) {
  62621. if (!this._engine.supportsUniformBuffers) {
  62622. // Ubo replacement
  62623. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  62624. return p1 + "{X}";
  62625. });
  62626. }
  62627. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  62628. }
  62629. }
  62630. else {
  62631. if (!this._engine.supportsUniformBuffers) {
  62632. // Ubo replacement
  62633. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  62634. return p1 + "{X}";
  62635. });
  62636. }
  62637. includeContent = includeContent.replace(/\{X\}/g, indexString);
  62638. }
  62639. }
  62640. // Replace
  62641. returnValue = returnValue.replace(match[0], includeContent);
  62642. }
  62643. else {
  62644. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  62645. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  62646. Effect.IncludesShadersStore[includeFile] = fileContent;
  62647. _this._processIncludes(returnValue, callback);
  62648. });
  62649. return;
  62650. }
  62651. match = regex.exec(sourceCode);
  62652. }
  62653. callback(returnValue);
  62654. };
  62655. Effect.prototype._processPrecision = function (source) {
  62656. var shouldUseHighPrecisionShader = this._engine._shouldUseHighPrecisionShader;
  62657. if (source.indexOf("precision highp float") === -1) {
  62658. if (!shouldUseHighPrecisionShader) {
  62659. source = "precision mediump float;\n" + source;
  62660. }
  62661. else {
  62662. source = "precision highp float;\n" + source;
  62663. }
  62664. }
  62665. else {
  62666. if (!shouldUseHighPrecisionShader) { // Moving highp to mediump
  62667. source = source.replace("precision highp float", "precision mediump float");
  62668. }
  62669. }
  62670. return source;
  62671. };
  62672. /**
  62673. * Recompiles the webGL program
  62674. * @param vertexSourceCode The source code for the vertex shader.
  62675. * @param fragmentSourceCode The source code for the fragment shader.
  62676. * @param onCompiled Callback called when completed.
  62677. * @param onError Callback called on error.
  62678. * @hidden
  62679. */
  62680. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  62681. var _this = this;
  62682. this._isReady = false;
  62683. this._vertexSourceCodeOverride = vertexSourceCode;
  62684. this._fragmentSourceCodeOverride = fragmentSourceCode;
  62685. this.onError = function (effect, error) {
  62686. if (onError) {
  62687. onError(error);
  62688. }
  62689. };
  62690. this.onCompiled = function () {
  62691. var scenes = _this.getEngine().scenes;
  62692. for (var i = 0; i < scenes.length; i++) {
  62693. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  62694. }
  62695. if (onCompiled) {
  62696. onCompiled(_this._program);
  62697. }
  62698. };
  62699. this._fallbacks = null;
  62700. this._prepareEffect();
  62701. };
  62702. /**
  62703. * Gets the uniform locations of the the specified variable names
  62704. * @param names THe names of the variables to lookup.
  62705. * @returns Array of locations in the same order as variable names.
  62706. */
  62707. Effect.prototype.getSpecificUniformLocations = function (names) {
  62708. var engine = this._engine;
  62709. return engine.getUniforms(this._program, names);
  62710. };
  62711. /**
  62712. * Prepares the effect
  62713. * @hidden
  62714. */
  62715. Effect.prototype._prepareEffect = function () {
  62716. var _this = this;
  62717. var attributesNames = this._attributesNames;
  62718. var defines = this.defines;
  62719. var fallbacks = this._fallbacks;
  62720. this._valueCache = {};
  62721. var previousProgram = this._program;
  62722. try {
  62723. var engine_1 = this._engine;
  62724. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  62725. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  62726. }
  62727. else {
  62728. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  62729. }
  62730. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  62731. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  62732. if (engine_1.supportsUniformBuffers) {
  62733. for (var name in _this._uniformBuffersNames) {
  62734. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  62735. }
  62736. }
  62737. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  62738. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  62739. var index;
  62740. for (index = 0; index < _this._samplers.length; index++) {
  62741. var sampler = _this.getUniform(_this._samplers[index]);
  62742. if (sampler == null) {
  62743. _this._samplers.splice(index, 1);
  62744. index--;
  62745. }
  62746. }
  62747. engine_1.bindSamplers(_this);
  62748. _this._compilationError = "";
  62749. _this._isReady = true;
  62750. if (_this.onCompiled) {
  62751. _this.onCompiled(_this);
  62752. }
  62753. _this.onCompileObservable.notifyObservers(_this);
  62754. _this.onCompileObservable.clear();
  62755. // Unbind mesh reference in fallbacks
  62756. if (_this._fallbacks) {
  62757. _this._fallbacks.unBindMesh();
  62758. }
  62759. if (previousProgram) {
  62760. _this.getEngine()._deleteProgram(previousProgram);
  62761. }
  62762. });
  62763. if (this._program.isParallelCompiled) {
  62764. this._checkIsReady();
  62765. }
  62766. }
  62767. catch (e) {
  62768. this._compilationError = e.message;
  62769. // Let's go through fallbacks then
  62770. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  62771. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  62772. return " " + uniform;
  62773. }));
  62774. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  62775. return " " + attribute;
  62776. }));
  62777. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  62778. if (previousProgram) {
  62779. this._program = previousProgram;
  62780. this._isReady = true;
  62781. if (this.onError) {
  62782. this.onError(this, this._compilationError);
  62783. }
  62784. this.onErrorObservable.notifyObservers(this);
  62785. }
  62786. if (fallbacks && fallbacks.isMoreFallbacks) {
  62787. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  62788. this.defines = fallbacks.reduce(this.defines, this);
  62789. this._prepareEffect();
  62790. }
  62791. else { // Sorry we did everything we can
  62792. if (this.onError) {
  62793. this.onError(this, this._compilationError);
  62794. }
  62795. this.onErrorObservable.notifyObservers(this);
  62796. this.onErrorObservable.clear();
  62797. // Unbind mesh reference in fallbacks
  62798. if (this._fallbacks) {
  62799. this._fallbacks.unBindMesh();
  62800. }
  62801. }
  62802. }
  62803. };
  62804. Object.defineProperty(Effect.prototype, "isSupported", {
  62805. /**
  62806. * Checks if the effect is supported. (Must be called after compilation)
  62807. */
  62808. get: function () {
  62809. return this._compilationError === "";
  62810. },
  62811. enumerable: true,
  62812. configurable: true
  62813. });
  62814. /**
  62815. * Binds a texture to the engine to be used as output of the shader.
  62816. * @param channel Name of the output variable.
  62817. * @param texture Texture to bind.
  62818. * @hidden
  62819. */
  62820. Effect.prototype._bindTexture = function (channel, texture) {
  62821. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  62822. };
  62823. /**
  62824. * Sets a texture on the engine to be used in the shader.
  62825. * @param channel Name of the sampler variable.
  62826. * @param texture Texture to set.
  62827. */
  62828. Effect.prototype.setTexture = function (channel, texture) {
  62829. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  62830. };
  62831. /**
  62832. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  62833. * @param channel Name of the sampler variable.
  62834. * @param texture Texture to set.
  62835. */
  62836. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  62837. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  62838. };
  62839. /**
  62840. * Sets an array of textures on the engine to be used in the shader.
  62841. * @param channel Name of the variable.
  62842. * @param textures Textures to set.
  62843. */
  62844. Effect.prototype.setTextureArray = function (channel, textures) {
  62845. if (this._samplers.indexOf(channel + "Ex") === -1) {
  62846. var initialPos = this._samplers.indexOf(channel);
  62847. for (var index = 1; index < textures.length; index++) {
  62848. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  62849. }
  62850. }
  62851. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  62852. };
  62853. /**
  62854. * 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)
  62855. * @param channel Name of the sampler variable.
  62856. * @param postProcess Post process to get the input texture from.
  62857. */
  62858. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  62859. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  62860. };
  62861. /**
  62862. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  62863. * 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)
  62864. * @param channel Name of the sampler variable.
  62865. * @param postProcess Post process to get the output texture from.
  62866. */
  62867. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  62868. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  62869. };
  62870. /** @hidden */
  62871. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  62872. var cache = this._valueCache[uniformName];
  62873. var flag = matrix.updateFlag;
  62874. if (cache !== undefined && cache === flag) {
  62875. return false;
  62876. }
  62877. this._valueCache[uniformName] = flag;
  62878. return true;
  62879. };
  62880. /** @hidden */
  62881. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  62882. var cache = this._valueCache[uniformName];
  62883. if (!cache) {
  62884. cache = [x, y];
  62885. this._valueCache[uniformName] = cache;
  62886. return true;
  62887. }
  62888. var changed = false;
  62889. if (cache[0] !== x) {
  62890. cache[0] = x;
  62891. changed = true;
  62892. }
  62893. if (cache[1] !== y) {
  62894. cache[1] = y;
  62895. changed = true;
  62896. }
  62897. return changed;
  62898. };
  62899. /** @hidden */
  62900. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  62901. var cache = this._valueCache[uniformName];
  62902. if (!cache) {
  62903. cache = [x, y, z];
  62904. this._valueCache[uniformName] = cache;
  62905. return true;
  62906. }
  62907. var changed = false;
  62908. if (cache[0] !== x) {
  62909. cache[0] = x;
  62910. changed = true;
  62911. }
  62912. if (cache[1] !== y) {
  62913. cache[1] = y;
  62914. changed = true;
  62915. }
  62916. if (cache[2] !== z) {
  62917. cache[2] = z;
  62918. changed = true;
  62919. }
  62920. return changed;
  62921. };
  62922. /** @hidden */
  62923. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  62924. var cache = this._valueCache[uniformName];
  62925. if (!cache) {
  62926. cache = [x, y, z, w];
  62927. this._valueCache[uniformName] = cache;
  62928. return true;
  62929. }
  62930. var changed = false;
  62931. if (cache[0] !== x) {
  62932. cache[0] = x;
  62933. changed = true;
  62934. }
  62935. if (cache[1] !== y) {
  62936. cache[1] = y;
  62937. changed = true;
  62938. }
  62939. if (cache[2] !== z) {
  62940. cache[2] = z;
  62941. changed = true;
  62942. }
  62943. if (cache[3] !== w) {
  62944. cache[3] = w;
  62945. changed = true;
  62946. }
  62947. return changed;
  62948. };
  62949. /**
  62950. * Binds a buffer to a uniform.
  62951. * @param buffer Buffer to bind.
  62952. * @param name Name of the uniform variable to bind to.
  62953. */
  62954. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  62955. var bufferName = this._uniformBuffersNames[name];
  62956. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  62957. return;
  62958. }
  62959. Effect._baseCache[bufferName] = buffer;
  62960. this._engine.bindUniformBufferBase(buffer, bufferName);
  62961. };
  62962. /**
  62963. * Binds block to a uniform.
  62964. * @param blockName Name of the block to bind.
  62965. * @param index Index to bind.
  62966. */
  62967. Effect.prototype.bindUniformBlock = function (blockName, index) {
  62968. this._engine.bindUniformBlock(this._program, blockName, index);
  62969. };
  62970. /**
  62971. * Sets an interger value on a uniform variable.
  62972. * @param uniformName Name of the variable.
  62973. * @param value Value to be set.
  62974. * @returns this effect.
  62975. */
  62976. Effect.prototype.setInt = function (uniformName, value) {
  62977. var cache = this._valueCache[uniformName];
  62978. if (cache !== undefined && cache === value) {
  62979. return this;
  62980. }
  62981. this._valueCache[uniformName] = value;
  62982. this._engine.setInt(this.getUniform(uniformName), value);
  62983. return this;
  62984. };
  62985. /**
  62986. * Sets an int array on a uniform variable.
  62987. * @param uniformName Name of the variable.
  62988. * @param array array to be set.
  62989. * @returns this effect.
  62990. */
  62991. Effect.prototype.setIntArray = function (uniformName, array) {
  62992. this._valueCache[uniformName] = null;
  62993. this._engine.setIntArray(this.getUniform(uniformName), array);
  62994. return this;
  62995. };
  62996. /**
  62997. * 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)
  62998. * @param uniformName Name of the variable.
  62999. * @param array array to be set.
  63000. * @returns this effect.
  63001. */
  63002. Effect.prototype.setIntArray2 = function (uniformName, array) {
  63003. this._valueCache[uniformName] = null;
  63004. this._engine.setIntArray2(this.getUniform(uniformName), array);
  63005. return this;
  63006. };
  63007. /**
  63008. * 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)
  63009. * @param uniformName Name of the variable.
  63010. * @param array array to be set.
  63011. * @returns this effect.
  63012. */
  63013. Effect.prototype.setIntArray3 = function (uniformName, array) {
  63014. this._valueCache[uniformName] = null;
  63015. this._engine.setIntArray3(this.getUniform(uniformName), array);
  63016. return this;
  63017. };
  63018. /**
  63019. * 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)
  63020. * @param uniformName Name of the variable.
  63021. * @param array array to be set.
  63022. * @returns this effect.
  63023. */
  63024. Effect.prototype.setIntArray4 = function (uniformName, array) {
  63025. this._valueCache[uniformName] = null;
  63026. this._engine.setIntArray4(this.getUniform(uniformName), array);
  63027. return this;
  63028. };
  63029. /**
  63030. * Sets an float array on a uniform variable.
  63031. * @param uniformName Name of the variable.
  63032. * @param array array to be set.
  63033. * @returns this effect.
  63034. */
  63035. Effect.prototype.setFloatArray = function (uniformName, array) {
  63036. this._valueCache[uniformName] = null;
  63037. this._engine.setFloatArray(this.getUniform(uniformName), array);
  63038. return this;
  63039. };
  63040. /**
  63041. * 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)
  63042. * @param uniformName Name of the variable.
  63043. * @param array array to be set.
  63044. * @returns this effect.
  63045. */
  63046. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  63047. this._valueCache[uniformName] = null;
  63048. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  63049. return this;
  63050. };
  63051. /**
  63052. * 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)
  63053. * @param uniformName Name of the variable.
  63054. * @param array array to be set.
  63055. * @returns this effect.
  63056. */
  63057. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  63058. this._valueCache[uniformName] = null;
  63059. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  63060. return this;
  63061. };
  63062. /**
  63063. * 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)
  63064. * @param uniformName Name of the variable.
  63065. * @param array array to be set.
  63066. * @returns this effect.
  63067. */
  63068. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  63069. this._valueCache[uniformName] = null;
  63070. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  63071. return this;
  63072. };
  63073. /**
  63074. * Sets an array on a uniform variable.
  63075. * @param uniformName Name of the variable.
  63076. * @param array array to be set.
  63077. * @returns this effect.
  63078. */
  63079. Effect.prototype.setArray = function (uniformName, array) {
  63080. this._valueCache[uniformName] = null;
  63081. this._engine.setArray(this.getUniform(uniformName), array);
  63082. return this;
  63083. };
  63084. /**
  63085. * 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)
  63086. * @param uniformName Name of the variable.
  63087. * @param array array to be set.
  63088. * @returns this effect.
  63089. */
  63090. Effect.prototype.setArray2 = function (uniformName, array) {
  63091. this._valueCache[uniformName] = null;
  63092. this._engine.setArray2(this.getUniform(uniformName), array);
  63093. return this;
  63094. };
  63095. /**
  63096. * 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)
  63097. * @param uniformName Name of the variable.
  63098. * @param array array to be set.
  63099. * @returns this effect.
  63100. */
  63101. Effect.prototype.setArray3 = function (uniformName, array) {
  63102. this._valueCache[uniformName] = null;
  63103. this._engine.setArray3(this.getUniform(uniformName), array);
  63104. return this;
  63105. };
  63106. /**
  63107. * 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)
  63108. * @param uniformName Name of the variable.
  63109. * @param array array to be set.
  63110. * @returns this effect.
  63111. */
  63112. Effect.prototype.setArray4 = function (uniformName, array) {
  63113. this._valueCache[uniformName] = null;
  63114. this._engine.setArray4(this.getUniform(uniformName), array);
  63115. return this;
  63116. };
  63117. /**
  63118. * Sets matrices on a uniform variable.
  63119. * @param uniformName Name of the variable.
  63120. * @param matrices matrices to be set.
  63121. * @returns this effect.
  63122. */
  63123. Effect.prototype.setMatrices = function (uniformName, matrices) {
  63124. if (!matrices) {
  63125. return this;
  63126. }
  63127. this._valueCache[uniformName] = null;
  63128. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  63129. return this;
  63130. };
  63131. /**
  63132. * Sets matrix on a uniform variable.
  63133. * @param uniformName Name of the variable.
  63134. * @param matrix matrix to be set.
  63135. * @returns this effect.
  63136. */
  63137. Effect.prototype.setMatrix = function (uniformName, matrix) {
  63138. if (this._cacheMatrix(uniformName, matrix)) {
  63139. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  63140. }
  63141. return this;
  63142. };
  63143. /**
  63144. * 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)
  63145. * @param uniformName Name of the variable.
  63146. * @param matrix matrix to be set.
  63147. * @returns this effect.
  63148. */
  63149. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  63150. this._valueCache[uniformName] = null;
  63151. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  63152. return this;
  63153. };
  63154. /**
  63155. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  63156. * @param uniformName Name of the variable.
  63157. * @param matrix matrix to be set.
  63158. * @returns this effect.
  63159. */
  63160. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  63161. this._valueCache[uniformName] = null;
  63162. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  63163. return this;
  63164. };
  63165. /**
  63166. * Sets a float on a uniform variable.
  63167. * @param uniformName Name of the variable.
  63168. * @param value value to be set.
  63169. * @returns this effect.
  63170. */
  63171. Effect.prototype.setFloat = function (uniformName, value) {
  63172. var cache = this._valueCache[uniformName];
  63173. if (cache !== undefined && cache === value) {
  63174. return this;
  63175. }
  63176. this._valueCache[uniformName] = value;
  63177. this._engine.setFloat(this.getUniform(uniformName), value);
  63178. return this;
  63179. };
  63180. /**
  63181. * Sets a boolean on a uniform variable.
  63182. * @param uniformName Name of the variable.
  63183. * @param bool value to be set.
  63184. * @returns this effect.
  63185. */
  63186. Effect.prototype.setBool = function (uniformName, bool) {
  63187. var cache = this._valueCache[uniformName];
  63188. if (cache !== undefined && cache === bool) {
  63189. return this;
  63190. }
  63191. this._valueCache[uniformName] = bool;
  63192. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  63193. return this;
  63194. };
  63195. /**
  63196. * Sets a Vector2 on a uniform variable.
  63197. * @param uniformName Name of the variable.
  63198. * @param vector2 vector2 to be set.
  63199. * @returns this effect.
  63200. */
  63201. Effect.prototype.setVector2 = function (uniformName, vector2) {
  63202. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  63203. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  63204. }
  63205. return this;
  63206. };
  63207. /**
  63208. * Sets a float2 on a uniform variable.
  63209. * @param uniformName Name of the variable.
  63210. * @param x First float in float2.
  63211. * @param y Second float in float2.
  63212. * @returns this effect.
  63213. */
  63214. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  63215. if (this._cacheFloat2(uniformName, x, y)) {
  63216. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  63217. }
  63218. return this;
  63219. };
  63220. /**
  63221. * Sets a Vector3 on a uniform variable.
  63222. * @param uniformName Name of the variable.
  63223. * @param vector3 Value to be set.
  63224. * @returns this effect.
  63225. */
  63226. Effect.prototype.setVector3 = function (uniformName, vector3) {
  63227. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  63228. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  63229. }
  63230. return this;
  63231. };
  63232. /**
  63233. * Sets a float3 on a uniform variable.
  63234. * @param uniformName Name of the variable.
  63235. * @param x First float in float3.
  63236. * @param y Second float in float3.
  63237. * @param z Third float in float3.
  63238. * @returns this effect.
  63239. */
  63240. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  63241. if (this._cacheFloat3(uniformName, x, y, z)) {
  63242. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  63243. }
  63244. return this;
  63245. };
  63246. /**
  63247. * Sets a Vector4 on a uniform variable.
  63248. * @param uniformName Name of the variable.
  63249. * @param vector4 Value to be set.
  63250. * @returns this effect.
  63251. */
  63252. Effect.prototype.setVector4 = function (uniformName, vector4) {
  63253. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  63254. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  63255. }
  63256. return this;
  63257. };
  63258. /**
  63259. * Sets a float4 on a uniform variable.
  63260. * @param uniformName Name of the variable.
  63261. * @param x First float in float4.
  63262. * @param y Second float in float4.
  63263. * @param z Third float in float4.
  63264. * @param w Fourth float in float4.
  63265. * @returns this effect.
  63266. */
  63267. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  63268. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  63269. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  63270. }
  63271. return this;
  63272. };
  63273. /**
  63274. * Sets a Color3 on a uniform variable.
  63275. * @param uniformName Name of the variable.
  63276. * @param color3 Value to be set.
  63277. * @returns this effect.
  63278. */
  63279. Effect.prototype.setColor3 = function (uniformName, color3) {
  63280. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  63281. this._engine.setColor3(this.getUniform(uniformName), color3);
  63282. }
  63283. return this;
  63284. };
  63285. /**
  63286. * Sets a Color4 on a uniform variable.
  63287. * @param uniformName Name of the variable.
  63288. * @param color3 Value to be set.
  63289. * @param alpha Alpha value to be set.
  63290. * @returns this effect.
  63291. */
  63292. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  63293. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  63294. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  63295. }
  63296. return this;
  63297. };
  63298. /**
  63299. * Sets a Color4 on a uniform variable
  63300. * @param uniformName defines the name of the variable
  63301. * @param color4 defines the value to be set
  63302. * @returns this effect.
  63303. */
  63304. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  63305. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  63306. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  63307. }
  63308. return this;
  63309. };
  63310. /**
  63311. * This function will add a new shader to the shader store
  63312. * @param name the name of the shader
  63313. * @param pixelShader optional pixel shader content
  63314. * @param vertexShader optional vertex shader content
  63315. */
  63316. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  63317. if (pixelShader) {
  63318. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  63319. }
  63320. if (vertexShader) {
  63321. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  63322. }
  63323. };
  63324. /**
  63325. * Resets the cache of effects.
  63326. */
  63327. Effect.ResetCache = function () {
  63328. Effect._baseCache = {};
  63329. };
  63330. /**
  63331. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  63332. */
  63333. Effect.ShadersRepository = "src/Shaders/";
  63334. Effect._uniqueIdSeed = 0;
  63335. Effect._baseCache = {};
  63336. /**
  63337. * Store of each shader (The can be looked up using effect.key)
  63338. */
  63339. Effect.ShadersStore = {};
  63340. /**
  63341. * Store of each included file for a shader (The can be looked up using effect.key)
  63342. */
  63343. Effect.IncludesShadersStore = {};
  63344. return Effect;
  63345. }());
  63346. /***/ }),
  63347. /***/ "./Materials/fresnelParameters.ts":
  63348. /*!****************************************!*\
  63349. !*** ./Materials/fresnelParameters.ts ***!
  63350. \****************************************/
  63351. /*! exports provided: FresnelParameters */
  63352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63353. "use strict";
  63354. __webpack_require__.r(__webpack_exports__);
  63355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  63356. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  63357. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63358. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63359. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63360. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63361. /**
  63362. * This represents all the required information to add a fresnel effect on a material:
  63363. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  63364. */
  63365. var FresnelParameters = /** @class */ (function () {
  63366. function FresnelParameters() {
  63367. this._isEnabled = true;
  63368. /**
  63369. * Define the color used on edges (grazing angle)
  63370. */
  63371. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  63372. /**
  63373. * Define the color used on center
  63374. */
  63375. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  63376. /**
  63377. * Define bias applied to computed fresnel term
  63378. */
  63379. this.bias = 0;
  63380. /**
  63381. * Defined the power exponent applied to fresnel term
  63382. */
  63383. this.power = 1;
  63384. }
  63385. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  63386. /**
  63387. * Define if the fresnel effect is enable or not.
  63388. */
  63389. get: function () {
  63390. return this._isEnabled;
  63391. },
  63392. set: function (value) {
  63393. if (this._isEnabled === value) {
  63394. return;
  63395. }
  63396. this._isEnabled = value;
  63397. _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);
  63398. },
  63399. enumerable: true,
  63400. configurable: true
  63401. });
  63402. /**
  63403. * Clones the current fresnel and its valuues
  63404. * @returns a clone fresnel configuration
  63405. */
  63406. FresnelParameters.prototype.clone = function () {
  63407. var newFresnelParameters = new FresnelParameters();
  63408. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  63409. return newFresnelParameters;
  63410. };
  63411. /**
  63412. * Serializes the current fresnel parameters to a JSON representation.
  63413. * @return the JSON serialization
  63414. */
  63415. FresnelParameters.prototype.serialize = function () {
  63416. var serializationObject = {};
  63417. serializationObject.isEnabled = this.isEnabled;
  63418. serializationObject.leftColor = this.leftColor.asArray();
  63419. serializationObject.rightColor = this.rightColor.asArray();
  63420. serializationObject.bias = this.bias;
  63421. serializationObject.power = this.power;
  63422. return serializationObject;
  63423. };
  63424. /**
  63425. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  63426. * @param parsedFresnelParameters Define the JSON representation
  63427. * @returns the parsed parameters
  63428. */
  63429. FresnelParameters.Parse = function (parsedFresnelParameters) {
  63430. var fresnelParameters = new FresnelParameters();
  63431. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  63432. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  63433. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  63434. fresnelParameters.bias = parsedFresnelParameters.bias;
  63435. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  63436. return fresnelParameters;
  63437. };
  63438. return FresnelParameters;
  63439. }());
  63440. // References the dependencies.
  63441. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  63442. /***/ }),
  63443. /***/ "./Materials/imageProcessingConfiguration.ts":
  63444. /*!***************************************************!*\
  63445. !*** ./Materials/imageProcessingConfiguration.ts ***!
  63446. \***************************************************/
  63447. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  63448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63449. "use strict";
  63450. __webpack_require__.r(__webpack_exports__);
  63451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  63452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  63453. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63454. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63455. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  63456. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  63457. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63458. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  63459. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  63460. /**
  63461. * @hidden
  63462. */
  63463. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  63464. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  63465. function ImageProcessingConfigurationDefines() {
  63466. var _this = _super.call(this) || this;
  63467. _this.IMAGEPROCESSING = false;
  63468. _this.VIGNETTE = false;
  63469. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  63470. _this.VIGNETTEBLENDMODEOPAQUE = false;
  63471. _this.TONEMAPPING = false;
  63472. _this.TONEMAPPING_ACES = false;
  63473. _this.CONTRAST = false;
  63474. _this.COLORCURVES = false;
  63475. _this.COLORGRADING = false;
  63476. _this.COLORGRADING3D = false;
  63477. _this.SAMPLER3DGREENDEPTH = false;
  63478. _this.SAMPLER3DBGRMAP = false;
  63479. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  63480. _this.EXPOSURE = false;
  63481. _this.rebuild();
  63482. return _this;
  63483. }
  63484. return ImageProcessingConfigurationDefines;
  63485. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  63486. /**
  63487. * This groups together the common properties used for image processing either in direct forward pass
  63488. * or through post processing effect depending on the use of the image processing pipeline in your scene
  63489. * or not.
  63490. */
  63491. var ImageProcessingConfiguration = /** @class */ (function () {
  63492. function ImageProcessingConfiguration() {
  63493. /**
  63494. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  63495. */
  63496. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  63497. this._colorCurvesEnabled = false;
  63498. this._colorGradingEnabled = false;
  63499. this._colorGradingWithGreenDepth = true;
  63500. this._colorGradingBGR = true;
  63501. /** @hidden */
  63502. this._exposure = 1.0;
  63503. this._toneMappingEnabled = false;
  63504. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  63505. this._contrast = 1.0;
  63506. /**
  63507. * Vignette stretch size.
  63508. */
  63509. this.vignetteStretch = 0;
  63510. /**
  63511. * Vignette centre X Offset.
  63512. */
  63513. this.vignetteCentreX = 0;
  63514. /**
  63515. * Vignette centre Y Offset.
  63516. */
  63517. this.vignetteCentreY = 0;
  63518. /**
  63519. * Vignette weight or intensity of the vignette effect.
  63520. */
  63521. this.vignetteWeight = 1.5;
  63522. /**
  63523. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  63524. * if vignetteEnabled is set to true.
  63525. */
  63526. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  63527. /**
  63528. * Camera field of view used by the Vignette effect.
  63529. */
  63530. this.vignetteCameraFov = 0.5;
  63531. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  63532. this._vignetteEnabled = false;
  63533. this._applyByPostProcess = false;
  63534. this._isEnabled = true;
  63535. /**
  63536. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  63537. */
  63538. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  63539. }
  63540. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  63541. /**
  63542. * Gets wether the color curves effect is enabled.
  63543. */
  63544. get: function () {
  63545. return this._colorCurvesEnabled;
  63546. },
  63547. /**
  63548. * Sets wether the color curves effect is enabled.
  63549. */
  63550. set: function (value) {
  63551. if (this._colorCurvesEnabled === value) {
  63552. return;
  63553. }
  63554. this._colorCurvesEnabled = value;
  63555. this._updateParameters();
  63556. },
  63557. enumerable: true,
  63558. configurable: true
  63559. });
  63560. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  63561. /**
  63562. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  63563. */
  63564. get: function () {
  63565. return this._colorGradingTexture;
  63566. },
  63567. /**
  63568. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  63569. */
  63570. set: function (value) {
  63571. if (this._colorGradingTexture === value) {
  63572. return;
  63573. }
  63574. this._colorGradingTexture = value;
  63575. this._updateParameters();
  63576. },
  63577. enumerable: true,
  63578. configurable: true
  63579. });
  63580. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  63581. /**
  63582. * Gets wether the color grading effect is enabled.
  63583. */
  63584. get: function () {
  63585. return this._colorGradingEnabled;
  63586. },
  63587. /**
  63588. * Sets wether the color grading effect is enabled.
  63589. */
  63590. set: function (value) {
  63591. if (this._colorGradingEnabled === value) {
  63592. return;
  63593. }
  63594. this._colorGradingEnabled = value;
  63595. this._updateParameters();
  63596. },
  63597. enumerable: true,
  63598. configurable: true
  63599. });
  63600. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  63601. /**
  63602. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  63603. */
  63604. get: function () {
  63605. return this._colorGradingWithGreenDepth;
  63606. },
  63607. /**
  63608. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  63609. */
  63610. set: function (value) {
  63611. if (this._colorGradingWithGreenDepth === value) {
  63612. return;
  63613. }
  63614. this._colorGradingWithGreenDepth = value;
  63615. this._updateParameters();
  63616. },
  63617. enumerable: true,
  63618. configurable: true
  63619. });
  63620. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  63621. /**
  63622. * Gets wether the color grading texture contains BGR values.
  63623. */
  63624. get: function () {
  63625. return this._colorGradingBGR;
  63626. },
  63627. /**
  63628. * Sets wether the color grading texture contains BGR values.
  63629. */
  63630. set: function (value) {
  63631. if (this._colorGradingBGR === value) {
  63632. return;
  63633. }
  63634. this._colorGradingBGR = value;
  63635. this._updateParameters();
  63636. },
  63637. enumerable: true,
  63638. configurable: true
  63639. });
  63640. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  63641. /**
  63642. * Gets the Exposure used in the effect.
  63643. */
  63644. get: function () {
  63645. return this._exposure;
  63646. },
  63647. /**
  63648. * Sets the Exposure used in the effect.
  63649. */
  63650. set: function (value) {
  63651. if (this._exposure === value) {
  63652. return;
  63653. }
  63654. this._exposure = value;
  63655. this._updateParameters();
  63656. },
  63657. enumerable: true,
  63658. configurable: true
  63659. });
  63660. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  63661. /**
  63662. * Gets wether the tone mapping effect is enabled.
  63663. */
  63664. get: function () {
  63665. return this._toneMappingEnabled;
  63666. },
  63667. /**
  63668. * Sets wether the tone mapping effect is enabled.
  63669. */
  63670. set: function (value) {
  63671. if (this._toneMappingEnabled === value) {
  63672. return;
  63673. }
  63674. this._toneMappingEnabled = value;
  63675. this._updateParameters();
  63676. },
  63677. enumerable: true,
  63678. configurable: true
  63679. });
  63680. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  63681. /**
  63682. * Gets the type of tone mapping effect.
  63683. */
  63684. get: function () {
  63685. return this._toneMappingType;
  63686. },
  63687. /**
  63688. * Sets the type of tone mapping effect used in BabylonJS.
  63689. */
  63690. set: function (value) {
  63691. if (this._toneMappingType === value) {
  63692. return;
  63693. }
  63694. this._toneMappingType = value;
  63695. this._updateParameters();
  63696. },
  63697. enumerable: true,
  63698. configurable: true
  63699. });
  63700. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  63701. /**
  63702. * Gets the contrast used in the effect.
  63703. */
  63704. get: function () {
  63705. return this._contrast;
  63706. },
  63707. /**
  63708. * Sets the contrast used in the effect.
  63709. */
  63710. set: function (value) {
  63711. if (this._contrast === value) {
  63712. return;
  63713. }
  63714. this._contrast = value;
  63715. this._updateParameters();
  63716. },
  63717. enumerable: true,
  63718. configurable: true
  63719. });
  63720. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  63721. /**
  63722. * Gets the vignette blend mode allowing different kind of effect.
  63723. */
  63724. get: function () {
  63725. return this._vignetteBlendMode;
  63726. },
  63727. /**
  63728. * Sets the vignette blend mode allowing different kind of effect.
  63729. */
  63730. set: function (value) {
  63731. if (this._vignetteBlendMode === value) {
  63732. return;
  63733. }
  63734. this._vignetteBlendMode = value;
  63735. this._updateParameters();
  63736. },
  63737. enumerable: true,
  63738. configurable: true
  63739. });
  63740. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  63741. /**
  63742. * Gets wether the vignette effect is enabled.
  63743. */
  63744. get: function () {
  63745. return this._vignetteEnabled;
  63746. },
  63747. /**
  63748. * Sets wether the vignette effect is enabled.
  63749. */
  63750. set: function (value) {
  63751. if (this._vignetteEnabled === value) {
  63752. return;
  63753. }
  63754. this._vignetteEnabled = value;
  63755. this._updateParameters();
  63756. },
  63757. enumerable: true,
  63758. configurable: true
  63759. });
  63760. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  63761. /**
  63762. * Gets wether the image processing is applied through a post process or not.
  63763. */
  63764. get: function () {
  63765. return this._applyByPostProcess;
  63766. },
  63767. /**
  63768. * Sets wether the image processing is applied through a post process or not.
  63769. */
  63770. set: function (value) {
  63771. if (this._applyByPostProcess === value) {
  63772. return;
  63773. }
  63774. this._applyByPostProcess = value;
  63775. this._updateParameters();
  63776. },
  63777. enumerable: true,
  63778. configurable: true
  63779. });
  63780. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  63781. /**
  63782. * Gets wether the image processing is enabled or not.
  63783. */
  63784. get: function () {
  63785. return this._isEnabled;
  63786. },
  63787. /**
  63788. * Sets wether the image processing is enabled or not.
  63789. */
  63790. set: function (value) {
  63791. if (this._isEnabled === value) {
  63792. return;
  63793. }
  63794. this._isEnabled = value;
  63795. this._updateParameters();
  63796. },
  63797. enumerable: true,
  63798. configurable: true
  63799. });
  63800. /**
  63801. * Method called each time the image processing information changes requires to recompile the effect.
  63802. */
  63803. ImageProcessingConfiguration.prototype._updateParameters = function () {
  63804. this.onUpdateParameters.notifyObservers(this);
  63805. };
  63806. /**
  63807. * Gets the current class name.
  63808. * @return "ImageProcessingConfiguration"
  63809. */
  63810. ImageProcessingConfiguration.prototype.getClassName = function () {
  63811. return "ImageProcessingConfiguration";
  63812. };
  63813. /**
  63814. * Prepare the list of uniforms associated with the Image Processing effects.
  63815. * @param uniforms The list of uniforms used in the effect
  63816. * @param defines the list of defines currently in use
  63817. */
  63818. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  63819. if (defines.EXPOSURE) {
  63820. uniforms.push("exposureLinear");
  63821. }
  63822. if (defines.CONTRAST) {
  63823. uniforms.push("contrast");
  63824. }
  63825. if (defines.COLORGRADING) {
  63826. uniforms.push("colorTransformSettings");
  63827. }
  63828. if (defines.VIGNETTE) {
  63829. uniforms.push("vInverseScreenSize");
  63830. uniforms.push("vignetteSettings1");
  63831. uniforms.push("vignetteSettings2");
  63832. }
  63833. if (defines.COLORCURVES) {
  63834. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  63835. }
  63836. };
  63837. /**
  63838. * Prepare the list of samplers associated with the Image Processing effects.
  63839. * @param samplersList The list of uniforms used in the effect
  63840. * @param defines the list of defines currently in use
  63841. */
  63842. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  63843. if (defines.COLORGRADING) {
  63844. samplersList.push("txColorTransform");
  63845. }
  63846. };
  63847. /**
  63848. * Prepare the list of defines associated to the shader.
  63849. * @param defines the list of defines to complete
  63850. * @param forPostProcess Define if we are currently in post process mode or not
  63851. */
  63852. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  63853. if (forPostProcess === void 0) { forPostProcess = false; }
  63854. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  63855. defines.VIGNETTE = false;
  63856. defines.TONEMAPPING = false;
  63857. defines.TONEMAPPING_ACES = false;
  63858. defines.CONTRAST = false;
  63859. defines.EXPOSURE = false;
  63860. defines.COLORCURVES = false;
  63861. defines.COLORGRADING = false;
  63862. defines.COLORGRADING3D = false;
  63863. defines.IMAGEPROCESSING = false;
  63864. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  63865. return;
  63866. }
  63867. defines.VIGNETTE = this.vignetteEnabled;
  63868. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  63869. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  63870. defines.TONEMAPPING = this.toneMappingEnabled;
  63871. switch (this._toneMappingType) {
  63872. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  63873. defines.TONEMAPPING_ACES = true;
  63874. break;
  63875. default:
  63876. defines.TONEMAPPING_ACES = false;
  63877. break;
  63878. }
  63879. defines.CONTRAST = (this.contrast !== 1.0);
  63880. defines.EXPOSURE = (this.exposure !== 1.0);
  63881. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  63882. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  63883. if (defines.COLORGRADING) {
  63884. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  63885. }
  63886. else {
  63887. defines.COLORGRADING3D = false;
  63888. }
  63889. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  63890. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  63891. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  63892. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  63893. };
  63894. /**
  63895. * Returns true if all the image processing information are ready.
  63896. * @returns True if ready, otherwise, false
  63897. */
  63898. ImageProcessingConfiguration.prototype.isReady = function () {
  63899. // Color Grading texure can not be none blocking.
  63900. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  63901. };
  63902. /**
  63903. * Binds the image processing to the shader.
  63904. * @param effect The effect to bind to
  63905. * @param aspectRatio Define the current aspect ratio of the effect
  63906. */
  63907. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  63908. if (aspectRatio === void 0) { aspectRatio = 1; }
  63909. // Color Curves
  63910. if (this._colorCurvesEnabled && this.colorCurves) {
  63911. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  63912. }
  63913. // Vignette
  63914. if (this._vignetteEnabled) {
  63915. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  63916. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  63917. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  63918. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  63919. var vignetteScaleX = vignetteScaleY * aspectRatio;
  63920. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  63921. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  63922. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  63923. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  63924. var vignettePower = -2.0 * this.vignetteWeight;
  63925. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  63926. }
  63927. // Exposure
  63928. effect.setFloat("exposureLinear", this.exposure);
  63929. // Contrast
  63930. effect.setFloat("contrast", this.contrast);
  63931. // Color transform settings
  63932. if (this.colorGradingTexture) {
  63933. effect.setTexture("txColorTransform", this.colorGradingTexture);
  63934. var textureSize = this.colorGradingTexture.getSize().height;
  63935. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  63936. 0.5 / textureSize, // textureOffset
  63937. textureSize, // textureSize
  63938. this.colorGradingTexture.level // weight
  63939. );
  63940. }
  63941. };
  63942. /**
  63943. * Clones the current image processing instance.
  63944. * @return The cloned image processing
  63945. */
  63946. ImageProcessingConfiguration.prototype.clone = function () {
  63947. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  63948. };
  63949. /**
  63950. * Serializes the current image processing instance to a json representation.
  63951. * @return a JSON representation
  63952. */
  63953. ImageProcessingConfiguration.prototype.serialize = function () {
  63954. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63955. };
  63956. /**
  63957. * Parses the image processing from a json representation.
  63958. * @param source the JSON source to parse
  63959. * @return The parsed image processing
  63960. */
  63961. ImageProcessingConfiguration.Parse = function (source) {
  63962. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  63963. };
  63964. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  63965. /**
  63966. * Used to apply the vignette as a mix with the pixel color.
  63967. */
  63968. get: function () {
  63969. return this._VIGNETTEMODE_MULTIPLY;
  63970. },
  63971. enumerable: true,
  63972. configurable: true
  63973. });
  63974. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  63975. /**
  63976. * Used to apply the vignette as a replacement of the pixel color.
  63977. */
  63978. get: function () {
  63979. return this._VIGNETTEMODE_OPAQUE;
  63980. },
  63981. enumerable: true,
  63982. configurable: true
  63983. });
  63984. /**
  63985. * Default tone mapping applied in BabylonJS.
  63986. */
  63987. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  63988. /**
  63989. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  63990. * to other engines rendering to increase portability.
  63991. */
  63992. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  63993. // Static constants associated to the image processing.
  63994. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  63995. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  63996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  63998. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  63999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64001. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  64002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  64004. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  64005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64007. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  64008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64010. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  64011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64013. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  64014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64016. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  64017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64019. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  64020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64022. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  64023. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64025. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  64026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64028. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  64029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64031. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  64032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64034. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  64035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64037. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  64038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  64040. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  64041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64043. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  64044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64046. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  64047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64049. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  64050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64052. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  64053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64055. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  64056. return ImageProcessingConfiguration;
  64057. }());
  64058. // References the dependencies.
  64059. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  64060. /***/ }),
  64061. /***/ "./Materials/index.ts":
  64062. /*!****************************!*\
  64063. !*** ./Materials/index.ts ***!
  64064. \****************************/
  64065. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PBRBaseMaterial, PBRMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, DynamicTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, VideoTexture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseSimpleMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, EquiRectangularCubeTexture, HDRCubeTexture, DummyInternalTextureTracker, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  64066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64067. "use strict";
  64068. __webpack_require__.r(__webpack_exports__);
  64069. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  64070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  64071. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  64072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  64073. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  64075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  64076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  64077. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  64078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  64079. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  64080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  64081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  64082. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  64083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  64084. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  64085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  64086. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  64088. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  64089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  64090. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  64091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  64092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  64093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  64094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  64095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  64096. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  64097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  64098. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  64099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  64100. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  64101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  64102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  64103. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  64104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  64105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  64106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  64107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  64108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  64109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  64110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  64111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  64112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  64113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  64114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["EquiRectangularCubeTexture"]; });
  64115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  64116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  64117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  64118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  64119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  64120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  64121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  64122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  64123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  64124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  64125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  64126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  64127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  64128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  64129. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  64130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  64131. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  64132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  64133. /***/ }),
  64134. /***/ "./Materials/material.ts":
  64135. /*!*******************************!*\
  64136. !*** ./Materials/material.ts ***!
  64137. \*******************************/
  64138. /*! exports provided: Material */
  64139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64140. "use strict";
  64141. __webpack_require__.r(__webpack_exports__);
  64142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  64143. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64144. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64145. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  64146. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  64147. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64148. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  64149. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  64150. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  64151. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64152. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  64153. /**
  64154. * Base class for the main features of a material in Babylon.js
  64155. */
  64156. var Material = /** @class */ (function () {
  64157. /**
  64158. * Creates a material instance
  64159. * @param name defines the name of the material
  64160. * @param scene defines the scene to reference
  64161. * @param doNotAdd specifies if the material should be added to the scene
  64162. */
  64163. function Material(name, scene, doNotAdd) {
  64164. /**
  64165. * Gets or sets user defined metadata
  64166. */
  64167. this.metadata = null;
  64168. /**
  64169. * For internal use only. Please do not use.
  64170. */
  64171. this.reservedDataStore = null;
  64172. /**
  64173. * Specifies if the ready state should be checked on each call
  64174. */
  64175. this.checkReadyOnEveryCall = false;
  64176. /**
  64177. * Specifies if the ready state should be checked once
  64178. */
  64179. this.checkReadyOnlyOnce = false;
  64180. /**
  64181. * The state of the material
  64182. */
  64183. this.state = "";
  64184. /**
  64185. * The alpha value of the material
  64186. */
  64187. this._alpha = 1.0;
  64188. /**
  64189. * Specifies if back face culling is enabled
  64190. */
  64191. this._backFaceCulling = true;
  64192. /**
  64193. * Specifies if the material should be serialized
  64194. */
  64195. this.doNotSerialize = false;
  64196. /**
  64197. * @hidden
  64198. */
  64199. this._storeEffectOnSubMeshes = false;
  64200. /**
  64201. * An event triggered when the material is disposed
  64202. */
  64203. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64204. /**
  64205. * Stores the value of the alpha mode
  64206. */
  64207. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  64208. /**
  64209. * Stores the state of the need depth pre-pass value
  64210. */
  64211. this._needDepthPrePass = false;
  64212. /**
  64213. * Specifies if depth writing should be disabled
  64214. */
  64215. this.disableDepthWrite = false;
  64216. /**
  64217. * Specifies if depth writing should be forced
  64218. */
  64219. this.forceDepthWrite = false;
  64220. /**
  64221. * Specifies if there should be a separate pass for culling
  64222. */
  64223. this.separateCullingPass = false;
  64224. /**
  64225. * Stores the state specifing if fog should be enabled
  64226. */
  64227. this._fogEnabled = true;
  64228. /**
  64229. * Stores the size of points
  64230. */
  64231. this.pointSize = 1.0;
  64232. /**
  64233. * Stores the z offset value
  64234. */
  64235. this.zOffset = 0;
  64236. /**
  64237. * @hidden
  64238. * Specifies if the material was previously ready
  64239. */
  64240. this._wasPreviouslyReady = false;
  64241. /**
  64242. * Stores the fill mode state
  64243. */
  64244. this._fillMode = Material.TriangleFillMode;
  64245. /** @hidden */
  64246. this._indexInSceneMaterialArray = -1;
  64247. this.name = name;
  64248. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  64249. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  64250. this.uniqueId = this._scene.getUniqueId();
  64251. if (this._scene.useRightHandedSystem) {
  64252. this.sideOrientation = Material.ClockWiseSideOrientation;
  64253. }
  64254. else {
  64255. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  64256. }
  64257. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  64258. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  64259. if (!doNotAdd) {
  64260. this._scene.addMaterial(this);
  64261. }
  64262. if (this._scene.useMaterialMeshMap) {
  64263. this.meshMap = {};
  64264. }
  64265. }
  64266. Object.defineProperty(Material.prototype, "alpha", {
  64267. /**
  64268. * Gets the alpha value of the material
  64269. */
  64270. get: function () {
  64271. return this._alpha;
  64272. },
  64273. /**
  64274. * Sets the alpha value of the material
  64275. */
  64276. set: function (value) {
  64277. if (this._alpha === value) {
  64278. return;
  64279. }
  64280. this._alpha = value;
  64281. this.markAsDirty(Material.MiscDirtyFlag);
  64282. },
  64283. enumerable: true,
  64284. configurable: true
  64285. });
  64286. Object.defineProperty(Material.prototype, "backFaceCulling", {
  64287. /**
  64288. * Gets the back-face culling state
  64289. */
  64290. get: function () {
  64291. return this._backFaceCulling;
  64292. },
  64293. /**
  64294. * Sets the back-face culling state
  64295. */
  64296. set: function (value) {
  64297. if (this._backFaceCulling === value) {
  64298. return;
  64299. }
  64300. this._backFaceCulling = value;
  64301. this.markAsDirty(Material.TextureDirtyFlag);
  64302. },
  64303. enumerable: true,
  64304. configurable: true
  64305. });
  64306. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  64307. /**
  64308. * Gets a boolean indicating that current material needs to register RTT
  64309. */
  64310. get: function () {
  64311. return false;
  64312. },
  64313. enumerable: true,
  64314. configurable: true
  64315. });
  64316. Object.defineProperty(Material.prototype, "onDispose", {
  64317. /**
  64318. * Called during a dispose event
  64319. */
  64320. set: function (callback) {
  64321. if (this._onDisposeObserver) {
  64322. this.onDisposeObservable.remove(this._onDisposeObserver);
  64323. }
  64324. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  64325. },
  64326. enumerable: true,
  64327. configurable: true
  64328. });
  64329. Object.defineProperty(Material.prototype, "onBindObservable", {
  64330. /**
  64331. * An event triggered when the material is bound
  64332. */
  64333. get: function () {
  64334. if (!this._onBindObservable) {
  64335. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64336. }
  64337. return this._onBindObservable;
  64338. },
  64339. enumerable: true,
  64340. configurable: true
  64341. });
  64342. Object.defineProperty(Material.prototype, "onBind", {
  64343. /**
  64344. * Called during a bind event
  64345. */
  64346. set: function (callback) {
  64347. if (this._onBindObserver) {
  64348. this.onBindObservable.remove(this._onBindObserver);
  64349. }
  64350. this._onBindObserver = this.onBindObservable.add(callback);
  64351. },
  64352. enumerable: true,
  64353. configurable: true
  64354. });
  64355. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  64356. /**
  64357. * An event triggered when the material is unbound
  64358. */
  64359. get: function () {
  64360. if (!this._onUnBindObservable) {
  64361. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64362. }
  64363. return this._onUnBindObservable;
  64364. },
  64365. enumerable: true,
  64366. configurable: true
  64367. });
  64368. Object.defineProperty(Material.prototype, "alphaMode", {
  64369. /**
  64370. * Gets the value of the alpha mode
  64371. */
  64372. get: function () {
  64373. return this._alphaMode;
  64374. },
  64375. /**
  64376. * Sets the value of the alpha mode.
  64377. *
  64378. * | Value | Type | Description |
  64379. * | --- | --- | --- |
  64380. * | 0 | ALPHA_DISABLE | |
  64381. * | 1 | ALPHA_ADD | |
  64382. * | 2 | ALPHA_COMBINE | |
  64383. * | 3 | ALPHA_SUBTRACT | |
  64384. * | 4 | ALPHA_MULTIPLY | |
  64385. * | 5 | ALPHA_MAXIMIZED | |
  64386. * | 6 | ALPHA_ONEONE | |
  64387. * | 7 | ALPHA_PREMULTIPLIED | |
  64388. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  64389. * | 9 | ALPHA_INTERPOLATE | |
  64390. * | 10 | ALPHA_SCREENMODE | |
  64391. *
  64392. */
  64393. set: function (value) {
  64394. if (this._alphaMode === value) {
  64395. return;
  64396. }
  64397. this._alphaMode = value;
  64398. this.markAsDirty(Material.TextureDirtyFlag);
  64399. },
  64400. enumerable: true,
  64401. configurable: true
  64402. });
  64403. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  64404. /**
  64405. * Gets the depth pre-pass value
  64406. */
  64407. get: function () {
  64408. return this._needDepthPrePass;
  64409. },
  64410. /**
  64411. * Sets the need depth pre-pass value
  64412. */
  64413. set: function (value) {
  64414. if (this._needDepthPrePass === value) {
  64415. return;
  64416. }
  64417. this._needDepthPrePass = value;
  64418. if (this._needDepthPrePass) {
  64419. this.checkReadyOnEveryCall = true;
  64420. }
  64421. },
  64422. enumerable: true,
  64423. configurable: true
  64424. });
  64425. Object.defineProperty(Material.prototype, "fogEnabled", {
  64426. /**
  64427. * Gets the value of the fog enabled state
  64428. */
  64429. get: function () {
  64430. return this._fogEnabled;
  64431. },
  64432. /**
  64433. * Sets the state for enabling fog
  64434. */
  64435. set: function (value) {
  64436. if (this._fogEnabled === value) {
  64437. return;
  64438. }
  64439. this._fogEnabled = value;
  64440. this.markAsDirty(Material.MiscDirtyFlag);
  64441. },
  64442. enumerable: true,
  64443. configurable: true
  64444. });
  64445. Object.defineProperty(Material.prototype, "wireframe", {
  64446. /**
  64447. * Gets a value specifying if wireframe mode is enabled
  64448. */
  64449. get: function () {
  64450. switch (this._fillMode) {
  64451. case Material.WireFrameFillMode:
  64452. case Material.LineListDrawMode:
  64453. case Material.LineLoopDrawMode:
  64454. case Material.LineStripDrawMode:
  64455. return true;
  64456. }
  64457. return this._scene.forceWireframe;
  64458. },
  64459. /**
  64460. * Sets the state of wireframe mode
  64461. */
  64462. set: function (value) {
  64463. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  64464. },
  64465. enumerable: true,
  64466. configurable: true
  64467. });
  64468. Object.defineProperty(Material.prototype, "pointsCloud", {
  64469. /**
  64470. * Gets the value specifying if point clouds are enabled
  64471. */
  64472. get: function () {
  64473. switch (this._fillMode) {
  64474. case Material.PointFillMode:
  64475. case Material.PointListDrawMode:
  64476. return true;
  64477. }
  64478. return this._scene.forcePointsCloud;
  64479. },
  64480. /**
  64481. * Sets the state of point cloud mode
  64482. */
  64483. set: function (value) {
  64484. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  64485. },
  64486. enumerable: true,
  64487. configurable: true
  64488. });
  64489. Object.defineProperty(Material.prototype, "fillMode", {
  64490. /**
  64491. * Gets the material fill mode
  64492. */
  64493. get: function () {
  64494. return this._fillMode;
  64495. },
  64496. /**
  64497. * Sets the material fill mode
  64498. */
  64499. set: function (value) {
  64500. if (this._fillMode === value) {
  64501. return;
  64502. }
  64503. this._fillMode = value;
  64504. this.markAsDirty(Material.MiscDirtyFlag);
  64505. },
  64506. enumerable: true,
  64507. configurable: true
  64508. });
  64509. /**
  64510. * Returns a string representation of the current material
  64511. * @param fullDetails defines a boolean indicating which levels of logging is desired
  64512. * @returns a string with material information
  64513. */
  64514. Material.prototype.toString = function (fullDetails) {
  64515. var ret = "Name: " + this.name;
  64516. if (fullDetails) {
  64517. }
  64518. return ret;
  64519. };
  64520. /**
  64521. * Gets the class name of the material
  64522. * @returns a string with the class name of the material
  64523. */
  64524. Material.prototype.getClassName = function () {
  64525. return "Material";
  64526. };
  64527. Object.defineProperty(Material.prototype, "isFrozen", {
  64528. /**
  64529. * Specifies if updates for the material been locked
  64530. */
  64531. get: function () {
  64532. return this.checkReadyOnlyOnce;
  64533. },
  64534. enumerable: true,
  64535. configurable: true
  64536. });
  64537. /**
  64538. * Locks updates for the material
  64539. */
  64540. Material.prototype.freeze = function () {
  64541. this.checkReadyOnlyOnce = true;
  64542. };
  64543. /**
  64544. * Unlocks updates for the material
  64545. */
  64546. Material.prototype.unfreeze = function () {
  64547. this.checkReadyOnlyOnce = false;
  64548. };
  64549. /**
  64550. * Specifies if the material is ready to be used
  64551. * @param mesh defines the mesh to check
  64552. * @param useInstances specifies if instances should be used
  64553. * @returns a boolean indicating if the material is ready to be used
  64554. */
  64555. Material.prototype.isReady = function (mesh, useInstances) {
  64556. return true;
  64557. };
  64558. /**
  64559. * Specifies that the submesh is ready to be used
  64560. * @param mesh defines the mesh to check
  64561. * @param subMesh defines which submesh to check
  64562. * @param useInstances specifies that instances should be used
  64563. * @returns a boolean indicating that the submesh is ready or not
  64564. */
  64565. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64566. return false;
  64567. };
  64568. /**
  64569. * Returns the material effect
  64570. * @returns the effect associated with the material
  64571. */
  64572. Material.prototype.getEffect = function () {
  64573. return this._effect;
  64574. };
  64575. /**
  64576. * Returns the current scene
  64577. * @returns a Scene
  64578. */
  64579. Material.prototype.getScene = function () {
  64580. return this._scene;
  64581. };
  64582. /**
  64583. * Specifies if the material will require alpha blending
  64584. * @returns a boolean specifying if alpha blending is needed
  64585. */
  64586. Material.prototype.needAlphaBlending = function () {
  64587. return (this.alpha < 1.0);
  64588. };
  64589. /**
  64590. * Specifies if the mesh will require alpha blending
  64591. * @param mesh defines the mesh to check
  64592. * @returns a boolean specifying if alpha blending is needed for the mesh
  64593. */
  64594. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  64595. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  64596. };
  64597. /**
  64598. * Specifies if this material should be rendered in alpha test mode
  64599. * @returns a boolean specifying if an alpha test is needed.
  64600. */
  64601. Material.prototype.needAlphaTesting = function () {
  64602. return false;
  64603. };
  64604. /**
  64605. * Gets the texture used for the alpha test
  64606. * @returns the texture to use for alpha testing
  64607. */
  64608. Material.prototype.getAlphaTestTexture = function () {
  64609. return null;
  64610. };
  64611. /**
  64612. * Marks the material to indicate that it needs to be re-calculated
  64613. */
  64614. Material.prototype.markDirty = function () {
  64615. this._wasPreviouslyReady = false;
  64616. };
  64617. /** @hidden */
  64618. Material.prototype._preBind = function (effect, overrideOrientation) {
  64619. if (overrideOrientation === void 0) { overrideOrientation = null; }
  64620. var engine = this._scene.getEngine();
  64621. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  64622. var reverse = orientation === Material.ClockWiseSideOrientation;
  64623. engine.enableEffect(effect ? effect : this._effect);
  64624. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  64625. return reverse;
  64626. };
  64627. /**
  64628. * Binds the material to the mesh
  64629. * @param world defines the world transformation matrix
  64630. * @param mesh defines the mesh to bind the material to
  64631. */
  64632. Material.prototype.bind = function (world, mesh) {
  64633. };
  64634. /**
  64635. * Binds the submesh to the material
  64636. * @param world defines the world transformation matrix
  64637. * @param mesh defines the mesh containing the submesh
  64638. * @param subMesh defines the submesh to bind the material to
  64639. */
  64640. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  64641. };
  64642. /**
  64643. * Binds the world matrix to the material
  64644. * @param world defines the world transformation matrix
  64645. */
  64646. Material.prototype.bindOnlyWorldMatrix = function (world) {
  64647. };
  64648. /**
  64649. * Binds the scene's uniform buffer to the effect.
  64650. * @param effect defines the effect to bind to the scene uniform buffer
  64651. * @param sceneUbo defines the uniform buffer storing scene data
  64652. */
  64653. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  64654. sceneUbo.bindToEffect(effect, "Scene");
  64655. };
  64656. /**
  64657. * Binds the view matrix to the effect
  64658. * @param effect defines the effect to bind the view matrix to
  64659. */
  64660. Material.prototype.bindView = function (effect) {
  64661. if (!this._useUBO) {
  64662. effect.setMatrix("view", this.getScene().getViewMatrix());
  64663. }
  64664. else {
  64665. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  64666. }
  64667. };
  64668. /**
  64669. * Binds the view projection matrix to the effect
  64670. * @param effect defines the effect to bind the view projection matrix to
  64671. */
  64672. Material.prototype.bindViewProjection = function (effect) {
  64673. if (!this._useUBO) {
  64674. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64675. }
  64676. else {
  64677. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  64678. }
  64679. };
  64680. /**
  64681. * Specifies if material alpha testing should be turned on for the mesh
  64682. * @param mesh defines the mesh to check
  64683. */
  64684. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  64685. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  64686. };
  64687. /**
  64688. * Processes to execute after binding the material to a mesh
  64689. * @param mesh defines the rendered mesh
  64690. */
  64691. Material.prototype._afterBind = function (mesh) {
  64692. this._scene._cachedMaterial = this;
  64693. if (mesh) {
  64694. this._scene._cachedVisibility = mesh.visibility;
  64695. }
  64696. else {
  64697. this._scene._cachedVisibility = 1;
  64698. }
  64699. if (this._onBindObservable && mesh) {
  64700. this._onBindObservable.notifyObservers(mesh);
  64701. }
  64702. if (this.disableDepthWrite) {
  64703. var engine = this._scene.getEngine();
  64704. this._cachedDepthWriteState = engine.getDepthWrite();
  64705. engine.setDepthWrite(false);
  64706. }
  64707. };
  64708. /**
  64709. * Unbinds the material from the mesh
  64710. */
  64711. Material.prototype.unbind = function () {
  64712. if (this._onUnBindObservable) {
  64713. this._onUnBindObservable.notifyObservers(this);
  64714. }
  64715. if (this.disableDepthWrite) {
  64716. var engine = this._scene.getEngine();
  64717. engine.setDepthWrite(this._cachedDepthWriteState);
  64718. }
  64719. };
  64720. /**
  64721. * Gets the active textures from the material
  64722. * @returns an array of textures
  64723. */
  64724. Material.prototype.getActiveTextures = function () {
  64725. return [];
  64726. };
  64727. /**
  64728. * Specifies if the material uses a texture
  64729. * @param texture defines the texture to check against the material
  64730. * @returns a boolean specifying if the material uses the texture
  64731. */
  64732. Material.prototype.hasTexture = function (texture) {
  64733. return false;
  64734. };
  64735. /**
  64736. * Makes a duplicate of the material, and gives it a new name
  64737. * @param name defines the new name for the duplicated material
  64738. * @returns the cloned material
  64739. */
  64740. Material.prototype.clone = function (name) {
  64741. return null;
  64742. };
  64743. /**
  64744. * Gets the meshes bound to the material
  64745. * @returns an array of meshes bound to the material
  64746. */
  64747. Material.prototype.getBindedMeshes = function () {
  64748. var _this = this;
  64749. if (this.meshMap) {
  64750. var result = new Array();
  64751. for (var meshId in this.meshMap) {
  64752. var mesh = this.meshMap[meshId];
  64753. if (mesh) {
  64754. result.push(mesh);
  64755. }
  64756. }
  64757. return result;
  64758. }
  64759. else {
  64760. var meshes = this._scene.meshes;
  64761. return meshes.filter(function (mesh) { return mesh.material === _this; });
  64762. }
  64763. };
  64764. /**
  64765. * Force shader compilation
  64766. * @param mesh defines the mesh associated with this material
  64767. * @param onCompiled defines a function to execute once the material is compiled
  64768. * @param options defines the options to configure the compilation
  64769. */
  64770. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  64771. var _this = this;
  64772. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  64773. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  64774. var scene = this.getScene();
  64775. var checkReady = function () {
  64776. if (!_this._scene || !_this._scene.getEngine()) {
  64777. return;
  64778. }
  64779. if (subMesh._materialDefines) {
  64780. subMesh._materialDefines._renderId = -1;
  64781. }
  64782. var clipPlaneState = scene.clipPlane;
  64783. if (localOptions.clipPlane) {
  64784. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  64785. }
  64786. if (_this._storeEffectOnSubMeshes) {
  64787. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  64788. if (onCompiled) {
  64789. onCompiled(_this);
  64790. }
  64791. }
  64792. else {
  64793. setTimeout(checkReady, 16);
  64794. }
  64795. }
  64796. else {
  64797. if (_this.isReady()) {
  64798. if (onCompiled) {
  64799. onCompiled(_this);
  64800. }
  64801. }
  64802. else {
  64803. setTimeout(checkReady, 16);
  64804. }
  64805. }
  64806. if (localOptions.clipPlane) {
  64807. scene.clipPlane = clipPlaneState;
  64808. }
  64809. };
  64810. checkReady();
  64811. };
  64812. /**
  64813. * Force shader compilation
  64814. * @param mesh defines the mesh that will use this material
  64815. * @param options defines additional options for compiling the shaders
  64816. * @returns a promise that resolves when the compilation completes
  64817. */
  64818. Material.prototype.forceCompilationAsync = function (mesh, options) {
  64819. var _this = this;
  64820. return new Promise(function (resolve) {
  64821. _this.forceCompilation(mesh, function () {
  64822. resolve();
  64823. }, options);
  64824. });
  64825. };
  64826. /**
  64827. * Marks a define in the material to indicate that it needs to be re-computed
  64828. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  64829. */
  64830. Material.prototype.markAsDirty = function (flag) {
  64831. if (this.getScene().blockMaterialDirtyMechanism) {
  64832. return;
  64833. }
  64834. Material._DirtyCallbackArray.length = 0;
  64835. if (flag & Material.TextureDirtyFlag) {
  64836. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  64837. }
  64838. if (flag & Material.LightDirtyFlag) {
  64839. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  64840. }
  64841. if (flag & Material.FresnelDirtyFlag) {
  64842. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  64843. }
  64844. if (flag & Material.AttributesDirtyFlag) {
  64845. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  64846. }
  64847. if (flag & Material.MiscDirtyFlag) {
  64848. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  64849. }
  64850. if (Material._DirtyCallbackArray.length) {
  64851. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  64852. }
  64853. this.getScene().resetCachedMaterial();
  64854. };
  64855. /**
  64856. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  64857. * @param func defines a function which checks material defines against the submeshes
  64858. */
  64859. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  64860. if (this.getScene().blockMaterialDirtyMechanism) {
  64861. return;
  64862. }
  64863. var meshes = this.getScene().meshes;
  64864. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  64865. var mesh = meshes_1[_i];
  64866. if (!mesh.subMeshes) {
  64867. continue;
  64868. }
  64869. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  64870. var subMesh = _b[_a];
  64871. if (subMesh.getMaterial() !== this) {
  64872. continue;
  64873. }
  64874. if (!subMesh._materialDefines) {
  64875. continue;
  64876. }
  64877. func(subMesh._materialDefines);
  64878. }
  64879. }
  64880. };
  64881. /**
  64882. * Indicates that image processing needs to be re-calculated for all submeshes
  64883. */
  64884. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  64885. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  64886. };
  64887. /**
  64888. * Indicates that textures need to be re-calculated for all submeshes
  64889. */
  64890. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  64891. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  64892. };
  64893. /**
  64894. * Indicates that fresnel needs to be re-calculated for all submeshes
  64895. */
  64896. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  64897. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  64898. };
  64899. /**
  64900. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  64901. */
  64902. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  64903. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  64904. };
  64905. /**
  64906. * Indicates that lights need to be re-calculated for all submeshes
  64907. */
  64908. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  64909. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  64910. };
  64911. /**
  64912. * Indicates that attributes need to be re-calculated for all submeshes
  64913. */
  64914. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  64915. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  64916. };
  64917. /**
  64918. * Indicates that misc needs to be re-calculated for all submeshes
  64919. */
  64920. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  64921. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  64922. };
  64923. /**
  64924. * Indicates that textures and misc need to be re-calculated for all submeshes
  64925. */
  64926. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  64927. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  64928. };
  64929. /**
  64930. * Disposes the material
  64931. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64932. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  64933. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  64934. */
  64935. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  64936. var scene = this.getScene();
  64937. // Animations
  64938. scene.stopAnimation(this);
  64939. scene.freeProcessedMaterials();
  64940. // Remove from scene
  64941. scene.removeMaterial(this);
  64942. if (notBoundToMesh !== true) {
  64943. // Remove from meshes
  64944. if (this.meshMap) {
  64945. for (var meshId in this.meshMap) {
  64946. var mesh = this.meshMap[meshId];
  64947. if (mesh) {
  64948. mesh.material = null; // will set the entry in the map to undefined
  64949. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  64950. }
  64951. }
  64952. }
  64953. else {
  64954. var meshes = scene.meshes;
  64955. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  64956. var mesh = meshes_2[_i];
  64957. if (mesh.material === this) {
  64958. mesh.material = null;
  64959. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  64960. }
  64961. }
  64962. }
  64963. }
  64964. this._uniformBuffer.dispose();
  64965. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  64966. if (forceDisposeEffect && this._effect) {
  64967. if (!this._storeEffectOnSubMeshes) {
  64968. scene.getEngine()._releaseEffect(this._effect);
  64969. }
  64970. this._effect = null;
  64971. }
  64972. // Callback
  64973. this.onDisposeObservable.notifyObservers(this);
  64974. this.onDisposeObservable.clear();
  64975. if (this._onBindObservable) {
  64976. this._onBindObservable.clear();
  64977. }
  64978. if (this._onUnBindObservable) {
  64979. this._onUnBindObservable.clear();
  64980. }
  64981. };
  64982. /** @hidden */
  64983. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  64984. if (mesh.geometry) {
  64985. var geometry = (mesh.geometry);
  64986. var scene = this.getScene();
  64987. if (this._storeEffectOnSubMeshes) {
  64988. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  64989. var subMesh = _a[_i];
  64990. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  64991. if (forceDisposeEffect && subMesh._materialEffect) {
  64992. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  64993. }
  64994. }
  64995. }
  64996. else {
  64997. geometry._releaseVertexArrayObject(this._effect);
  64998. }
  64999. }
  65000. };
  65001. /**
  65002. * Serializes this material
  65003. * @returns the serialized material object
  65004. */
  65005. Material.prototype.serialize = function () {
  65006. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65007. };
  65008. /**
  65009. * Creates a material from parsed material data
  65010. * @param parsedMaterial defines parsed material data
  65011. * @param scene defines the hosting scene
  65012. * @param rootUrl defines the root URL to use to load textures
  65013. * @returns a new material
  65014. */
  65015. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  65016. if (!parsedMaterial.customType) {
  65017. parsedMaterial.customType = "BABYLON.StandardMaterial";
  65018. }
  65019. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  65020. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  65021. if (!BABYLON.LegacyPBRMaterial) {
  65022. _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.");
  65023. return;
  65024. }
  65025. }
  65026. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  65027. return materialType.Parse(parsedMaterial, scene, rootUrl);
  65028. };
  65029. /**
  65030. * Returns the triangle fill mode
  65031. */
  65032. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  65033. /**
  65034. * Returns the wireframe mode
  65035. */
  65036. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  65037. /**
  65038. * Returns the point fill mode
  65039. */
  65040. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  65041. /**
  65042. * Returns the point list draw mode
  65043. */
  65044. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  65045. /**
  65046. * Returns the line list draw mode
  65047. */
  65048. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  65049. /**
  65050. * Returns the line loop draw mode
  65051. */
  65052. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  65053. /**
  65054. * Returns the line strip draw mode
  65055. */
  65056. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  65057. /**
  65058. * Returns the triangle strip draw mode
  65059. */
  65060. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  65061. /**
  65062. * Returns the triangle fan draw mode
  65063. */
  65064. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  65065. /**
  65066. * Stores the clock-wise side orientation
  65067. */
  65068. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  65069. /**
  65070. * Stores the counter clock-wise side orientation
  65071. */
  65072. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  65073. /**
  65074. * The dirty texture flag value
  65075. */
  65076. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  65077. /**
  65078. * The dirty light flag value
  65079. */
  65080. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  65081. /**
  65082. * The dirty fresnel flag value
  65083. */
  65084. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  65085. /**
  65086. * The dirty attribute flag value
  65087. */
  65088. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  65089. /**
  65090. * The dirty misc flag value
  65091. */
  65092. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  65093. /**
  65094. * The all dirty flag value
  65095. */
  65096. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  65097. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  65098. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  65099. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  65100. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  65101. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  65102. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  65103. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  65104. Material._FresnelDirtyCallBack(defines);
  65105. Material._MiscDirtyCallBack(defines);
  65106. };
  65107. Material._TextureAndMiscDirtyCallBack = function (defines) {
  65108. Material._TextureDirtyCallBack(defines);
  65109. Material._MiscDirtyCallBack(defines);
  65110. };
  65111. Material._DirtyCallbackArray = [];
  65112. Material._RunDirtyCallBacks = function (defines) {
  65113. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  65114. var cb = _a[_i];
  65115. cb(defines);
  65116. }
  65117. };
  65118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65120. ], Material.prototype, "id", void 0);
  65121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65123. ], Material.prototype, "uniqueId", void 0);
  65124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65126. ], Material.prototype, "name", void 0);
  65127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65129. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  65130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65132. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  65133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65135. ], Material.prototype, "state", void 0);
  65136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  65138. ], Material.prototype, "_alpha", void 0);
  65139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  65141. ], Material.prototype, "_backFaceCulling", void 0);
  65142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65144. ], Material.prototype, "sideOrientation", void 0);
  65145. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65146. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  65147. ], Material.prototype, "_alphaMode", void 0);
  65148. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65149. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65150. ], Material.prototype, "_needDepthPrePass", void 0);
  65151. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65153. ], Material.prototype, "disableDepthWrite", void 0);
  65154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65156. ], Material.prototype, "forceDepthWrite", void 0);
  65157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65159. ], Material.prototype, "separateCullingPass", void 0);
  65160. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65161. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  65162. ], Material.prototype, "_fogEnabled", void 0);
  65163. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65165. ], Material.prototype, "pointSize", void 0);
  65166. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65168. ], Material.prototype, "zOffset", void 0);
  65169. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65170. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65171. ], Material.prototype, "wireframe", null);
  65172. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65173. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65174. ], Material.prototype, "pointsCloud", null);
  65175. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65176. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65177. ], Material.prototype, "fillMode", null);
  65178. return Material;
  65179. }());
  65180. /***/ }),
  65181. /***/ "./Materials/materialDefines.ts":
  65182. /*!**************************************!*\
  65183. !*** ./Materials/materialDefines.ts ***!
  65184. \**************************************/
  65185. /*! exports provided: MaterialDefines */
  65186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65187. "use strict";
  65188. __webpack_require__.r(__webpack_exports__);
  65189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  65190. /**
  65191. * Manages the defines for the Material
  65192. */
  65193. var MaterialDefines = /** @class */ (function () {
  65194. function MaterialDefines() {
  65195. this._isDirty = true;
  65196. /** @hidden */
  65197. this._areLightsDirty = true;
  65198. /** @hidden */
  65199. this._areAttributesDirty = true;
  65200. /** @hidden */
  65201. this._areTexturesDirty = true;
  65202. /** @hidden */
  65203. this._areFresnelDirty = true;
  65204. /** @hidden */
  65205. this._areMiscDirty = true;
  65206. /** @hidden */
  65207. this._areImageProcessingDirty = true;
  65208. /** @hidden */
  65209. this._normals = false;
  65210. /** @hidden */
  65211. this._uvs = false;
  65212. /** @hidden */
  65213. this._needNormals = false;
  65214. /** @hidden */
  65215. this._needUVs = false;
  65216. }
  65217. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  65218. /**
  65219. * Specifies if the material needs to be re-calculated
  65220. */
  65221. get: function () {
  65222. return this._isDirty;
  65223. },
  65224. enumerable: true,
  65225. configurable: true
  65226. });
  65227. /**
  65228. * Marks the material to indicate that it has been re-calculated
  65229. */
  65230. MaterialDefines.prototype.markAsProcessed = function () {
  65231. this._isDirty = false;
  65232. this._areAttributesDirty = false;
  65233. this._areTexturesDirty = false;
  65234. this._areFresnelDirty = false;
  65235. this._areLightsDirty = false;
  65236. this._areMiscDirty = false;
  65237. this._areImageProcessingDirty = false;
  65238. };
  65239. /**
  65240. * Marks the material to indicate that it needs to be re-calculated
  65241. */
  65242. MaterialDefines.prototype.markAsUnprocessed = function () {
  65243. this._isDirty = true;
  65244. };
  65245. /**
  65246. * Marks the material to indicate all of its defines need to be re-calculated
  65247. */
  65248. MaterialDefines.prototype.markAllAsDirty = function () {
  65249. this._areTexturesDirty = true;
  65250. this._areAttributesDirty = true;
  65251. this._areLightsDirty = true;
  65252. this._areFresnelDirty = true;
  65253. this._areMiscDirty = true;
  65254. this._areImageProcessingDirty = true;
  65255. this._isDirty = true;
  65256. };
  65257. /**
  65258. * Marks the material to indicate that image processing needs to be re-calculated
  65259. */
  65260. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  65261. this._areImageProcessingDirty = true;
  65262. this._isDirty = true;
  65263. };
  65264. /**
  65265. * Marks the material to indicate the lights need to be re-calculated
  65266. */
  65267. MaterialDefines.prototype.markAsLightDirty = function () {
  65268. this._areLightsDirty = true;
  65269. this._isDirty = true;
  65270. };
  65271. /**
  65272. * Marks the attribute state as changed
  65273. */
  65274. MaterialDefines.prototype.markAsAttributesDirty = function () {
  65275. this._areAttributesDirty = true;
  65276. this._isDirty = true;
  65277. };
  65278. /**
  65279. * Marks the texture state as changed
  65280. */
  65281. MaterialDefines.prototype.markAsTexturesDirty = function () {
  65282. this._areTexturesDirty = true;
  65283. this._isDirty = true;
  65284. };
  65285. /**
  65286. * Marks the fresnel state as changed
  65287. */
  65288. MaterialDefines.prototype.markAsFresnelDirty = function () {
  65289. this._areFresnelDirty = true;
  65290. this._isDirty = true;
  65291. };
  65292. /**
  65293. * Marks the misc state as changed
  65294. */
  65295. MaterialDefines.prototype.markAsMiscDirty = function () {
  65296. this._areMiscDirty = true;
  65297. this._isDirty = true;
  65298. };
  65299. /**
  65300. * Rebuilds the material defines
  65301. */
  65302. MaterialDefines.prototype.rebuild = function () {
  65303. if (this._keys) {
  65304. delete this._keys;
  65305. }
  65306. this._keys = [];
  65307. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  65308. var key = _a[_i];
  65309. if (key[0] === "_") {
  65310. continue;
  65311. }
  65312. this._keys.push(key);
  65313. }
  65314. };
  65315. /**
  65316. * Specifies if two material defines are equal
  65317. * @param other - A material define instance to compare to
  65318. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65319. */
  65320. MaterialDefines.prototype.isEqual = function (other) {
  65321. if (this._keys.length !== other._keys.length) {
  65322. return false;
  65323. }
  65324. for (var index = 0; index < this._keys.length; index++) {
  65325. var prop = this._keys[index];
  65326. if (this[prop] !== other[prop]) {
  65327. return false;
  65328. }
  65329. }
  65330. return true;
  65331. };
  65332. /**
  65333. * Clones this instance's defines to another instance
  65334. * @param other - material defines to clone values to
  65335. */
  65336. MaterialDefines.prototype.cloneTo = function (other) {
  65337. if (this._keys.length !== other._keys.length) {
  65338. other._keys = this._keys.slice(0);
  65339. }
  65340. for (var index = 0; index < this._keys.length; index++) {
  65341. var prop = this._keys[index];
  65342. other[prop] = this[prop];
  65343. }
  65344. };
  65345. /**
  65346. * Resets the material define values
  65347. */
  65348. MaterialDefines.prototype.reset = function () {
  65349. for (var index = 0; index < this._keys.length; index++) {
  65350. var prop = this._keys[index];
  65351. var type = typeof this[prop];
  65352. switch (type) {
  65353. case "number":
  65354. this[prop] = 0;
  65355. break;
  65356. case "string":
  65357. this[prop] = "";
  65358. break;
  65359. default:
  65360. this[prop] = false;
  65361. break;
  65362. }
  65363. }
  65364. };
  65365. /**
  65366. * Converts the material define values to a string
  65367. * @returns - String of material define information
  65368. */
  65369. MaterialDefines.prototype.toString = function () {
  65370. var result = "";
  65371. for (var index = 0; index < this._keys.length; index++) {
  65372. var prop = this._keys[index];
  65373. var value = this[prop];
  65374. var type = typeof value;
  65375. switch (type) {
  65376. case "number":
  65377. case "string":
  65378. result += "#define " + prop + " " + value + "\n";
  65379. break;
  65380. default:
  65381. if (value) {
  65382. result += "#define " + prop + "\n";
  65383. }
  65384. break;
  65385. }
  65386. }
  65387. return result;
  65388. };
  65389. return MaterialDefines;
  65390. }());
  65391. /***/ }),
  65392. /***/ "./Materials/materialFlags.ts":
  65393. /*!************************************!*\
  65394. !*** ./Materials/materialFlags.ts ***!
  65395. \************************************/
  65396. /*! exports provided: MaterialFlags */
  65397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65398. "use strict";
  65399. __webpack_require__.r(__webpack_exports__);
  65400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  65401. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  65402. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65403. /**
  65404. * This groups all the flags used to control the materials channel.
  65405. */
  65406. var MaterialFlags = /** @class */ (function () {
  65407. function MaterialFlags() {
  65408. }
  65409. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  65410. /**
  65411. * Are diffuse textures enabled in the application.
  65412. */
  65413. get: function () {
  65414. return this._DiffuseTextureEnabled;
  65415. },
  65416. set: function (value) {
  65417. if (this._DiffuseTextureEnabled === value) {
  65418. return;
  65419. }
  65420. this._DiffuseTextureEnabled = value;
  65421. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65422. },
  65423. enumerable: true,
  65424. configurable: true
  65425. });
  65426. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  65427. /**
  65428. * Are ambient textures enabled in the application.
  65429. */
  65430. get: function () {
  65431. return this._AmbientTextureEnabled;
  65432. },
  65433. set: function (value) {
  65434. if (this._AmbientTextureEnabled === value) {
  65435. return;
  65436. }
  65437. this._AmbientTextureEnabled = value;
  65438. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65439. },
  65440. enumerable: true,
  65441. configurable: true
  65442. });
  65443. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  65444. /**
  65445. * Are opacity textures enabled in the application.
  65446. */
  65447. get: function () {
  65448. return this._OpacityTextureEnabled;
  65449. },
  65450. set: function (value) {
  65451. if (this._OpacityTextureEnabled === value) {
  65452. return;
  65453. }
  65454. this._OpacityTextureEnabled = value;
  65455. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65456. },
  65457. enumerable: true,
  65458. configurable: true
  65459. });
  65460. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  65461. /**
  65462. * Are reflection textures enabled in the application.
  65463. */
  65464. get: function () {
  65465. return this._ReflectionTextureEnabled;
  65466. },
  65467. set: function (value) {
  65468. if (this._ReflectionTextureEnabled === value) {
  65469. return;
  65470. }
  65471. this._ReflectionTextureEnabled = value;
  65472. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65473. },
  65474. enumerable: true,
  65475. configurable: true
  65476. });
  65477. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  65478. /**
  65479. * Are emissive textures enabled in the application.
  65480. */
  65481. get: function () {
  65482. return this._EmissiveTextureEnabled;
  65483. },
  65484. set: function (value) {
  65485. if (this._EmissiveTextureEnabled === value) {
  65486. return;
  65487. }
  65488. this._EmissiveTextureEnabled = value;
  65489. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65490. },
  65491. enumerable: true,
  65492. configurable: true
  65493. });
  65494. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  65495. /**
  65496. * Are specular textures enabled in the application.
  65497. */
  65498. get: function () {
  65499. return this._SpecularTextureEnabled;
  65500. },
  65501. set: function (value) {
  65502. if (this._SpecularTextureEnabled === value) {
  65503. return;
  65504. }
  65505. this._SpecularTextureEnabled = value;
  65506. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65507. },
  65508. enumerable: true,
  65509. configurable: true
  65510. });
  65511. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  65512. /**
  65513. * Are bump textures enabled in the application.
  65514. */
  65515. get: function () {
  65516. return this._BumpTextureEnabled;
  65517. },
  65518. set: function (value) {
  65519. if (this._BumpTextureEnabled === value) {
  65520. return;
  65521. }
  65522. this._BumpTextureEnabled = value;
  65523. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65524. },
  65525. enumerable: true,
  65526. configurable: true
  65527. });
  65528. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  65529. /**
  65530. * Are lightmap textures enabled in the application.
  65531. */
  65532. get: function () {
  65533. return this._LightmapTextureEnabled;
  65534. },
  65535. set: function (value) {
  65536. if (this._LightmapTextureEnabled === value) {
  65537. return;
  65538. }
  65539. this._LightmapTextureEnabled = value;
  65540. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65541. },
  65542. enumerable: true,
  65543. configurable: true
  65544. });
  65545. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  65546. /**
  65547. * Are refraction textures enabled in the application.
  65548. */
  65549. get: function () {
  65550. return this._RefractionTextureEnabled;
  65551. },
  65552. set: function (value) {
  65553. if (this._RefractionTextureEnabled === value) {
  65554. return;
  65555. }
  65556. this._RefractionTextureEnabled = value;
  65557. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65558. },
  65559. enumerable: true,
  65560. configurable: true
  65561. });
  65562. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  65563. /**
  65564. * Are color grading textures enabled in the application.
  65565. */
  65566. get: function () {
  65567. return this._ColorGradingTextureEnabled;
  65568. },
  65569. set: function (value) {
  65570. if (this._ColorGradingTextureEnabled === value) {
  65571. return;
  65572. }
  65573. this._ColorGradingTextureEnabled = value;
  65574. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65575. },
  65576. enumerable: true,
  65577. configurable: true
  65578. });
  65579. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  65580. /**
  65581. * Are fresnels enabled in the application.
  65582. */
  65583. get: function () {
  65584. return this._FresnelEnabled;
  65585. },
  65586. set: function (value) {
  65587. if (this._FresnelEnabled === value) {
  65588. return;
  65589. }
  65590. this._FresnelEnabled = value;
  65591. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  65592. },
  65593. enumerable: true,
  65594. configurable: true
  65595. });
  65596. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  65597. /**
  65598. * Are clear coat textures enabled in the application.
  65599. */
  65600. get: function () {
  65601. return this._ClearCoatTextureEnabled;
  65602. },
  65603. set: function (value) {
  65604. if (this._ClearCoatTextureEnabled === value) {
  65605. return;
  65606. }
  65607. this._ClearCoatTextureEnabled = value;
  65608. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65609. },
  65610. enumerable: true,
  65611. configurable: true
  65612. });
  65613. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  65614. /**
  65615. * Are clear coat bump textures enabled in the application.
  65616. */
  65617. get: function () {
  65618. return this._ClearCoatBumpTextureEnabled;
  65619. },
  65620. set: function (value) {
  65621. if (this._ClearCoatBumpTextureEnabled === value) {
  65622. return;
  65623. }
  65624. this._ClearCoatBumpTextureEnabled = value;
  65625. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65626. },
  65627. enumerable: true,
  65628. configurable: true
  65629. });
  65630. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  65631. /**
  65632. * Are clear coat tint textures enabled in the application.
  65633. */
  65634. get: function () {
  65635. return this._ClearCoatTintTextureEnabled;
  65636. },
  65637. set: function (value) {
  65638. if (this._ClearCoatTintTextureEnabled === value) {
  65639. return;
  65640. }
  65641. this._ClearCoatTintTextureEnabled = value;
  65642. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65643. },
  65644. enumerable: true,
  65645. configurable: true
  65646. });
  65647. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  65648. /**
  65649. * Are sheen textures enabled in the application.
  65650. */
  65651. get: function () {
  65652. return this._SheenTextureEnabled;
  65653. },
  65654. set: function (value) {
  65655. if (this._SheenTextureEnabled === value) {
  65656. return;
  65657. }
  65658. this._SheenTextureEnabled = value;
  65659. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65660. },
  65661. enumerable: true,
  65662. configurable: true
  65663. });
  65664. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  65665. /**
  65666. * Are anisotropic textures enabled in the application.
  65667. */
  65668. get: function () {
  65669. return this._AnisotropicTextureEnabled;
  65670. },
  65671. set: function (value) {
  65672. if (this._AnisotropicTextureEnabled === value) {
  65673. return;
  65674. }
  65675. this._AnisotropicTextureEnabled = value;
  65676. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65677. },
  65678. enumerable: true,
  65679. configurable: true
  65680. });
  65681. // Flags used to enable or disable a type of texture for all Standard Materials
  65682. MaterialFlags._DiffuseTextureEnabled = true;
  65683. MaterialFlags._AmbientTextureEnabled = true;
  65684. MaterialFlags._OpacityTextureEnabled = true;
  65685. MaterialFlags._ReflectionTextureEnabled = true;
  65686. MaterialFlags._EmissiveTextureEnabled = true;
  65687. MaterialFlags._SpecularTextureEnabled = true;
  65688. MaterialFlags._BumpTextureEnabled = true;
  65689. MaterialFlags._LightmapTextureEnabled = true;
  65690. MaterialFlags._RefractionTextureEnabled = true;
  65691. MaterialFlags._ColorGradingTextureEnabled = true;
  65692. MaterialFlags._FresnelEnabled = true;
  65693. MaterialFlags._ClearCoatTextureEnabled = true;
  65694. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  65695. MaterialFlags._ClearCoatTintTextureEnabled = true;
  65696. MaterialFlags._SheenTextureEnabled = true;
  65697. MaterialFlags._AnisotropicTextureEnabled = true;
  65698. return MaterialFlags;
  65699. }());
  65700. /***/ }),
  65701. /***/ "./Materials/materialHelper.ts":
  65702. /*!*************************************!*\
  65703. !*** ./Materials/materialHelper.ts ***!
  65704. \*************************************/
  65705. /*! exports provided: MaterialHelper */
  65706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65707. "use strict";
  65708. __webpack_require__.r(__webpack_exports__);
  65709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  65710. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  65711. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65712. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65713. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  65714. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65715. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  65716. /**
  65717. * "Static Class" containing the most commonly used helper while dealing with material for
  65718. * rendering purpose.
  65719. *
  65720. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65721. *
  65722. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65723. */
  65724. var MaterialHelper = /** @class */ (function () {
  65725. function MaterialHelper() {
  65726. }
  65727. /**
  65728. * Bind the current view position to an effect.
  65729. * @param effect The effect to be bound
  65730. * @param scene The scene the eyes position is used from
  65731. */
  65732. MaterialHelper.BindEyePosition = function (effect, scene) {
  65733. if (scene._forcedViewPosition) {
  65734. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  65735. return;
  65736. }
  65737. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  65738. };
  65739. /**
  65740. * Helps preparing the defines values about the UVs in used in the effect.
  65741. * UVs are shared as much as we can accross channels in the shaders.
  65742. * @param texture The texture we are preparing the UVs for
  65743. * @param defines The defines to update
  65744. * @param key The channel key "diffuse", "specular"... used in the shader
  65745. */
  65746. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  65747. defines._needUVs = true;
  65748. defines[key] = true;
  65749. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  65750. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  65751. if (texture.coordinatesIndex === 0) {
  65752. defines["MAINUV1"] = true;
  65753. }
  65754. else {
  65755. defines["MAINUV2"] = true;
  65756. }
  65757. }
  65758. else {
  65759. defines[key + "DIRECTUV"] = 0;
  65760. }
  65761. };
  65762. /**
  65763. * Binds a texture matrix value to its corrsponding uniform
  65764. * @param texture The texture to bind the matrix for
  65765. * @param uniformBuffer The uniform buffer receivin the data
  65766. * @param key The channel key "diffuse", "specular"... used in the shader
  65767. */
  65768. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  65769. var matrix = texture.getTextureMatrix();
  65770. if (!matrix.isIdentityAs3x2()) {
  65771. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  65772. }
  65773. };
  65774. /**
  65775. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65776. * @param mesh defines the current mesh
  65777. * @param scene defines the current scene
  65778. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65779. * @param pointsCloud defines if point cloud rendering has to be turned on
  65780. * @param fogEnabled defines if fog has to be turned on
  65781. * @param alphaTest defines if alpha testing has to be turned on
  65782. * @param defines defines the current list of defines
  65783. */
  65784. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  65785. if (defines._areMiscDirty) {
  65786. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  65787. defines["POINTSIZE"] = pointsCloud;
  65788. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  65789. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  65790. defines["ALPHATEST"] = alphaTest;
  65791. }
  65792. };
  65793. /**
  65794. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65795. * @param scene defines the current scene
  65796. * @param engine defines the current engine
  65797. * @param defines specifies the list of active defines
  65798. * @param useInstances defines if instances have to be turned on
  65799. * @param useClipPlane defines if clip plane have to be turned on
  65800. */
  65801. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  65802. if (useClipPlane === void 0) { useClipPlane = null; }
  65803. var changed = false;
  65804. var useClipPlane1 = false;
  65805. var useClipPlane2 = false;
  65806. var useClipPlane3 = false;
  65807. var useClipPlane4 = false;
  65808. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  65809. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  65810. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  65811. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  65812. if (defines["CLIPPLANE"] !== useClipPlane1) {
  65813. defines["CLIPPLANE"] = useClipPlane1;
  65814. changed = true;
  65815. }
  65816. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  65817. defines["CLIPPLANE2"] = useClipPlane2;
  65818. changed = true;
  65819. }
  65820. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  65821. defines["CLIPPLANE3"] = useClipPlane3;
  65822. changed = true;
  65823. }
  65824. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  65825. defines["CLIPPLANE4"] = useClipPlane4;
  65826. changed = true;
  65827. }
  65828. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  65829. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  65830. changed = true;
  65831. }
  65832. if (defines["INSTANCES"] !== useInstances) {
  65833. defines["INSTANCES"] = useInstances;
  65834. changed = true;
  65835. }
  65836. if (changed) {
  65837. defines.markAsUnprocessed();
  65838. }
  65839. };
  65840. /**
  65841. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65842. * @param mesh The mesh containing the geometry data we will draw
  65843. * @param defines The defines to update
  65844. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65845. * @param useBones Precise whether bones should be used or not (override mesh info)
  65846. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65847. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65848. * @returns false if defines are considered not dirty and have not been checked
  65849. */
  65850. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  65851. if (useMorphTargets === void 0) { useMorphTargets = false; }
  65852. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  65853. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  65854. return false;
  65855. }
  65856. defines._normals = defines._needNormals;
  65857. defines._uvs = defines._needUVs;
  65858. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  65859. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  65860. defines["TANGENT"] = true;
  65861. }
  65862. if (defines._needUVs) {
  65863. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  65864. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  65865. }
  65866. else {
  65867. defines["UV1"] = false;
  65868. defines["UV2"] = false;
  65869. }
  65870. if (useVertexColor) {
  65871. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  65872. defines["VERTEXCOLOR"] = hasVertexColors;
  65873. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  65874. }
  65875. if (useBones) {
  65876. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  65877. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  65878. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  65879. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  65880. defines["BONETEXTURE"] = true;
  65881. }
  65882. else {
  65883. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  65884. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  65885. }
  65886. }
  65887. else {
  65888. defines["NUM_BONE_INFLUENCERS"] = 0;
  65889. defines["BonesPerMesh"] = 0;
  65890. }
  65891. }
  65892. if (useMorphTargets) {
  65893. var manager = mesh.morphTargetManager;
  65894. if (manager) {
  65895. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  65896. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  65897. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  65898. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  65899. }
  65900. else {
  65901. defines["MORPHTARGETS_TANGENT"] = false;
  65902. defines["MORPHTARGETS_NORMAL"] = false;
  65903. defines["MORPHTARGETS"] = false;
  65904. defines["NUM_MORPH_INFLUENCERS"] = 0;
  65905. }
  65906. }
  65907. return true;
  65908. };
  65909. /**
  65910. * Prepares the defines related to the light information passed in parameter
  65911. * @param scene The scene we are intending to draw
  65912. * @param mesh The mesh the effect is compiling for
  65913. * @param defines The defines to update
  65914. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65915. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65916. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65917. * @returns true if normals will be required for the rest of the effect
  65918. */
  65919. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  65920. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65921. if (disableLighting === void 0) { disableLighting = false; }
  65922. if (!defines._areLightsDirty) {
  65923. return defines._needNormals;
  65924. }
  65925. var lightIndex = 0;
  65926. var needNormals = false;
  65927. var needRebuild = false;
  65928. var lightmapMode = false;
  65929. var shadowEnabled = false;
  65930. var specularEnabled = false;
  65931. if (scene.lightsEnabled && !disableLighting) {
  65932. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  65933. var light = _a[_i];
  65934. needNormals = true;
  65935. if (defines["LIGHT" + lightIndex] === undefined) {
  65936. needRebuild = true;
  65937. }
  65938. defines["LIGHT" + lightIndex] = true;
  65939. defines["SPOTLIGHT" + lightIndex] = false;
  65940. defines["HEMILIGHT" + lightIndex] = false;
  65941. defines["POINTLIGHT" + lightIndex] = false;
  65942. defines["DIRLIGHT" + lightIndex] = false;
  65943. light.prepareLightSpecificDefines(defines, lightIndex);
  65944. // FallOff.
  65945. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  65946. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  65947. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  65948. switch (light.falloffType) {
  65949. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  65950. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  65951. break;
  65952. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  65953. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  65954. break;
  65955. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  65956. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  65957. break;
  65958. }
  65959. // Specular
  65960. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  65961. specularEnabled = true;
  65962. }
  65963. // Shadows
  65964. defines["SHADOW" + lightIndex] = false;
  65965. defines["SHADOWPCF" + lightIndex] = false;
  65966. defines["SHADOWPCSS" + lightIndex] = false;
  65967. defines["SHADOWPOISSON" + lightIndex] = false;
  65968. defines["SHADOWESM" + lightIndex] = false;
  65969. defines["SHADOWCUBE" + lightIndex] = false;
  65970. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  65971. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  65972. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  65973. var shadowGenerator = light.getShadowGenerator();
  65974. if (shadowGenerator) {
  65975. var shadowMap = shadowGenerator.getShadowMap();
  65976. if (shadowMap) {
  65977. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  65978. shadowEnabled = true;
  65979. shadowGenerator.prepareDefines(defines, lightIndex);
  65980. }
  65981. }
  65982. }
  65983. }
  65984. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  65985. lightmapMode = true;
  65986. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  65987. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  65988. }
  65989. else {
  65990. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  65991. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  65992. }
  65993. lightIndex++;
  65994. if (lightIndex === maxSimultaneousLights) {
  65995. break;
  65996. }
  65997. }
  65998. }
  65999. defines["SPECULARTERM"] = specularEnabled;
  66000. defines["SHADOWS"] = shadowEnabled;
  66001. // Resetting all other lights if any
  66002. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  66003. if (defines["LIGHT" + index] !== undefined) {
  66004. defines["LIGHT" + index] = false;
  66005. defines["HEMILIGHT" + index] = false;
  66006. defines["POINTLIGHT" + index] = false;
  66007. defines["DIRLIGHT" + index] = false;
  66008. defines["SPOTLIGHT" + index] = false;
  66009. defines["SHADOW" + index] = false;
  66010. defines["SHADOWPCF" + index] = false;
  66011. defines["SHADOWPCSS" + index] = false;
  66012. defines["SHADOWPOISSON" + index] = false;
  66013. defines["SHADOWESM" + index] = false;
  66014. defines["SHADOWCUBE" + index] = false;
  66015. defines["SHADOWLOWQUALITY" + index] = false;
  66016. defines["SHADOWMEDIUMQUALITY" + index] = false;
  66017. }
  66018. }
  66019. var caps = scene.getEngine().getCaps();
  66020. if (defines["SHADOWFLOAT"] === undefined) {
  66021. needRebuild = true;
  66022. }
  66023. defines["SHADOWFLOAT"] = shadowEnabled &&
  66024. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  66025. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  66026. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  66027. if (needRebuild) {
  66028. defines.rebuild();
  66029. }
  66030. return needNormals;
  66031. };
  66032. /**
  66033. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66034. * that won t be acctive due to defines being turned off.
  66035. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66036. * @param samplersList The samplers list
  66037. * @param defines The defines helping in the list generation
  66038. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66039. */
  66040. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  66041. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66042. var uniformsList;
  66043. var uniformBuffersList = null;
  66044. if (uniformsListOrOptions.uniformsNames) {
  66045. var options = uniformsListOrOptions;
  66046. uniformsList = options.uniformsNames;
  66047. uniformBuffersList = options.uniformBuffersNames;
  66048. samplersList = options.samplers;
  66049. defines = options.defines;
  66050. maxSimultaneousLights = options.maxSimultaneousLights;
  66051. }
  66052. else {
  66053. uniformsList = uniformsListOrOptions;
  66054. if (!samplersList) {
  66055. samplersList = [];
  66056. }
  66057. }
  66058. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  66059. if (!defines["LIGHT" + lightIndex]) {
  66060. break;
  66061. }
  66062. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  66063. if (uniformBuffersList) {
  66064. uniformBuffersList.push("Light" + lightIndex);
  66065. }
  66066. samplersList.push("shadowSampler" + lightIndex);
  66067. samplersList.push("depthSampler" + lightIndex);
  66068. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  66069. samplersList.push("projectionLightSampler" + lightIndex);
  66070. uniformsList.push("textureProjectionMatrix" + lightIndex);
  66071. }
  66072. }
  66073. if (defines["NUM_MORPH_INFLUENCERS"]) {
  66074. uniformsList.push("morphTargetInfluences");
  66075. }
  66076. };
  66077. /**
  66078. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66079. * @param defines The defines to update while falling back
  66080. * @param fallbacks The authorized effect fallbacks
  66081. * @param maxSimultaneousLights The maximum number of lights allowed
  66082. * @param rank the current rank of the Effect
  66083. * @returns The newly affected rank
  66084. */
  66085. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  66086. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66087. if (rank === void 0) { rank = 0; }
  66088. var lightFallbackRank = 0;
  66089. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  66090. if (!defines["LIGHT" + lightIndex]) {
  66091. break;
  66092. }
  66093. if (lightIndex > 0) {
  66094. lightFallbackRank = rank + lightIndex;
  66095. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  66096. }
  66097. if (!defines["SHADOWS"]) {
  66098. if (defines["SHADOW" + lightIndex]) {
  66099. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  66100. }
  66101. if (defines["SHADOWPCF" + lightIndex]) {
  66102. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  66103. }
  66104. if (defines["SHADOWPCSS" + lightIndex]) {
  66105. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  66106. }
  66107. if (defines["SHADOWPOISSON" + lightIndex]) {
  66108. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  66109. }
  66110. if (defines["SHADOWESM" + lightIndex]) {
  66111. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  66112. }
  66113. }
  66114. }
  66115. return lightFallbackRank++;
  66116. };
  66117. /**
  66118. * Prepares the list of attributes required for morph targets according to the effect defines.
  66119. * @param attribs The current list of supported attribs
  66120. * @param mesh The mesh to prepare the morph targets attributes for
  66121. * @param defines The current Defines of the effect
  66122. */
  66123. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  66124. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  66125. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  66126. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  66127. var manager = mesh.morphTargetManager;
  66128. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  66129. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  66130. for (var index = 0; index < influencers; index++) {
  66131. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  66132. if (normal) {
  66133. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  66134. }
  66135. if (tangent) {
  66136. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  66137. }
  66138. if (attribs.length > maxAttributesCount) {
  66139. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  66140. }
  66141. }
  66142. }
  66143. };
  66144. /**
  66145. * Prepares the list of attributes required for bones according to the effect defines.
  66146. * @param attribs The current list of supported attribs
  66147. * @param mesh The mesh to prepare the bones attributes for
  66148. * @param defines The current Defines of the effect
  66149. * @param fallbacks The current efffect fallback strategy
  66150. */
  66151. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  66152. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  66153. fallbacks.addCPUSkinningFallback(0, mesh);
  66154. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  66155. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  66156. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  66157. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  66158. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  66159. }
  66160. }
  66161. };
  66162. /**
  66163. * Prepares the list of attributes required for instances according to the effect defines.
  66164. * @param attribs The current list of supported attribs
  66165. * @param defines The current Defines of the effect
  66166. */
  66167. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  66168. if (defines["INSTANCES"]) {
  66169. attribs.push("world0");
  66170. attribs.push("world1");
  66171. attribs.push("world2");
  66172. attribs.push("world3");
  66173. }
  66174. };
  66175. /**
  66176. * Binds the light shadow information to the effect for the given mesh.
  66177. * @param light The light containing the generator
  66178. * @param scene The scene the lights belongs to
  66179. * @param mesh The mesh we are binding the information to render
  66180. * @param lightIndex The light index in the effect used to render the mesh
  66181. * @param effect The effect we are binding the data to
  66182. */
  66183. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  66184. if (light.shadowEnabled && mesh.receiveShadows) {
  66185. var shadowGenerator = light.getShadowGenerator();
  66186. if (shadowGenerator) {
  66187. shadowGenerator.bindShadowLight(lightIndex, effect);
  66188. }
  66189. }
  66190. };
  66191. /**
  66192. * Binds the light information to the effect.
  66193. * @param light The light containing the generator
  66194. * @param effect The effect we are binding the data to
  66195. * @param lightIndex The light index in the effect used to render
  66196. */
  66197. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  66198. light.transferToEffect(effect, lightIndex + "");
  66199. };
  66200. /**
  66201. * Binds the lights information from the scene to the effect for the given mesh.
  66202. * @param scene The scene the lights belongs to
  66203. * @param mesh The mesh we are binding the information to render
  66204. * @param effect The effect we are binding the data to
  66205. * @param defines The generated defines for the effect
  66206. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66207. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66208. */
  66209. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  66210. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66211. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  66212. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  66213. for (var i = 0; i < len; i++) {
  66214. var light = mesh._lightSources[i];
  66215. var iAsString = i.toString();
  66216. var scaledIntensity = light.getScaledIntensity();
  66217. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  66218. MaterialHelper.BindLightProperties(light, effect, i);
  66219. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  66220. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  66221. if (defines["SPECULARTERM"]) {
  66222. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  66223. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  66224. }
  66225. // Shadows
  66226. if (scene.shadowsEnabled) {
  66227. this.BindLightShadow(light, mesh, iAsString, effect);
  66228. }
  66229. light._uniformBuffer.update();
  66230. }
  66231. };
  66232. /**
  66233. * Binds the fog information from the scene to the effect for the given mesh.
  66234. * @param scene The scene the lights belongs to
  66235. * @param mesh The mesh we are binding the information to render
  66236. * @param effect The effect we are binding the data to
  66237. * @param linearSpace Defines if the fog effect is applied in linear space
  66238. */
  66239. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  66240. if (linearSpace === void 0) { linearSpace = false; }
  66241. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  66242. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  66243. // Convert fog color to linear space if used in a linear space computed shader.
  66244. if (linearSpace) {
  66245. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  66246. effect.setColor3("vFogColor", this._tempFogColor);
  66247. }
  66248. else {
  66249. effect.setColor3("vFogColor", scene.fogColor);
  66250. }
  66251. }
  66252. };
  66253. /**
  66254. * Binds the bones information from the mesh to the effect.
  66255. * @param mesh The mesh we are binding the information to render
  66256. * @param effect The effect we are binding the data to
  66257. */
  66258. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  66259. if (!effect || !mesh) {
  66260. return;
  66261. }
  66262. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  66263. mesh.computeBonesUsingShaders = false;
  66264. }
  66265. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66266. var skeleton = mesh.skeleton;
  66267. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  66268. var boneTexture = skeleton.getTransformMatrixTexture();
  66269. effect.setTexture("boneSampler", boneTexture);
  66270. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  66271. }
  66272. else {
  66273. var matrices = skeleton.getTransformMatrices(mesh);
  66274. if (matrices) {
  66275. effect.setMatrices("mBones", matrices);
  66276. }
  66277. }
  66278. }
  66279. };
  66280. /**
  66281. * Binds the morph targets information from the mesh to the effect.
  66282. * @param abstractMesh The mesh we are binding the information to render
  66283. * @param effect The effect we are binding the data to
  66284. */
  66285. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  66286. var manager = abstractMesh.morphTargetManager;
  66287. if (!abstractMesh || !manager) {
  66288. return;
  66289. }
  66290. effect.setFloatArray("morphTargetInfluences", manager.influences);
  66291. };
  66292. /**
  66293. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66294. * @param defines The generated defines used in the effect
  66295. * @param effect The effect we are binding the data to
  66296. * @param scene The scene we are willing to render with logarithmic scale for
  66297. */
  66298. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  66299. if (defines["LOGARITHMICDEPTH"]) {
  66300. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  66301. }
  66302. };
  66303. /**
  66304. * Binds the clip plane information from the scene to the effect.
  66305. * @param scene The scene the clip plane information are extracted from
  66306. * @param effect The effect we are binding the data to
  66307. */
  66308. MaterialHelper.BindClipPlane = function (effect, scene) {
  66309. if (scene.clipPlane) {
  66310. var clipPlane = scene.clipPlane;
  66311. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66312. }
  66313. if (scene.clipPlane2) {
  66314. var clipPlane = scene.clipPlane2;
  66315. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66316. }
  66317. if (scene.clipPlane3) {
  66318. var clipPlane = scene.clipPlane3;
  66319. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66320. }
  66321. if (scene.clipPlane4) {
  66322. var clipPlane = scene.clipPlane4;
  66323. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66324. }
  66325. };
  66326. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  66327. return MaterialHelper;
  66328. }());
  66329. /***/ }),
  66330. /***/ "./Materials/multiMaterial.ts":
  66331. /*!************************************!*\
  66332. !*** ./Materials/multiMaterial.ts ***!
  66333. \************************************/
  66334. /*! exports provided: MultiMaterial */
  66335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66336. "use strict";
  66337. __webpack_require__.r(__webpack_exports__);
  66338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  66339. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66340. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  66341. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  66342. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  66343. /**
  66344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66345. * separate meshes. This can be use to improve performances.
  66346. * @see http://doc.babylonjs.com/how_to/multi_materials
  66347. */
  66348. var MultiMaterial = /** @class */ (function (_super) {
  66349. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  66350. /**
  66351. * Instantiates a new Multi Material
  66352. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66353. * separate meshes. This can be use to improve performances.
  66354. * @see http://doc.babylonjs.com/how_to/multi_materials
  66355. * @param name Define the name in the scene
  66356. * @param scene Define the scene the material belongs to
  66357. */
  66358. function MultiMaterial(name, scene) {
  66359. var _this = _super.call(this, name, scene, true) || this;
  66360. scene.multiMaterials.push(_this);
  66361. _this.subMaterials = new Array();
  66362. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  66363. return _this;
  66364. }
  66365. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  66366. /**
  66367. * Gets or Sets the list of Materials used within the multi material.
  66368. * They need to be ordered according to the submeshes order in the associated mesh
  66369. */
  66370. get: function () {
  66371. return this._subMaterials;
  66372. },
  66373. set: function (value) {
  66374. this._subMaterials = value;
  66375. this._hookArray(value);
  66376. },
  66377. enumerable: true,
  66378. configurable: true
  66379. });
  66380. /**
  66381. * Function used to align with Node.getChildren()
  66382. * @returns the list of Materials used within the multi material
  66383. */
  66384. MultiMaterial.prototype.getChildren = function () {
  66385. return this.subMaterials;
  66386. };
  66387. MultiMaterial.prototype._hookArray = function (array) {
  66388. var _this = this;
  66389. var oldPush = array.push;
  66390. array.push = function () {
  66391. var items = [];
  66392. for (var _i = 0; _i < arguments.length; _i++) {
  66393. items[_i] = arguments[_i];
  66394. }
  66395. var result = oldPush.apply(array, items);
  66396. _this._markAllSubMeshesAsTexturesDirty();
  66397. return result;
  66398. };
  66399. var oldSplice = array.splice;
  66400. array.splice = function (index, deleteCount) {
  66401. var deleted = oldSplice.apply(array, [index, deleteCount]);
  66402. _this._markAllSubMeshesAsTexturesDirty();
  66403. return deleted;
  66404. };
  66405. };
  66406. /**
  66407. * Get one of the submaterial by its index in the submaterials array
  66408. * @param index The index to look the sub material at
  66409. * @returns The Material if the index has been defined
  66410. */
  66411. MultiMaterial.prototype.getSubMaterial = function (index) {
  66412. if (index < 0 || index >= this.subMaterials.length) {
  66413. return this.getScene().defaultMaterial;
  66414. }
  66415. return this.subMaterials[index];
  66416. };
  66417. /**
  66418. * Get the list of active textures for the whole sub materials list.
  66419. * @returns All the textures that will be used during the rendering
  66420. */
  66421. MultiMaterial.prototype.getActiveTextures = function () {
  66422. var _a;
  66423. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  66424. if (subMaterial) {
  66425. return subMaterial.getActiveTextures();
  66426. }
  66427. else {
  66428. return [];
  66429. }
  66430. }));
  66431. };
  66432. /**
  66433. * Gets the current class name of the material e.g. "MultiMaterial"
  66434. * Mainly use in serialization.
  66435. * @returns the class name
  66436. */
  66437. MultiMaterial.prototype.getClassName = function () {
  66438. return "MultiMaterial";
  66439. };
  66440. /**
  66441. * Checks if the material is ready to render the requested sub mesh
  66442. * @param mesh Define the mesh the submesh belongs to
  66443. * @param subMesh Define the sub mesh to look readyness for
  66444. * @param useInstances Define whether or not the material is used with instances
  66445. * @returns true if ready, otherwise false
  66446. */
  66447. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  66448. for (var index = 0; index < this.subMaterials.length; index++) {
  66449. var subMaterial = this.subMaterials[index];
  66450. if (subMaterial) {
  66451. if (subMaterial._storeEffectOnSubMeshes) {
  66452. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  66453. return false;
  66454. }
  66455. continue;
  66456. }
  66457. if (!subMaterial.isReady(mesh)) {
  66458. return false;
  66459. }
  66460. }
  66461. }
  66462. return true;
  66463. };
  66464. /**
  66465. * Clones the current material and its related sub materials
  66466. * @param name Define the name of the newly cloned material
  66467. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66468. * @returns the cloned material
  66469. */
  66470. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  66471. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  66472. for (var index = 0; index < this.subMaterials.length; index++) {
  66473. var subMaterial = null;
  66474. var current = this.subMaterials[index];
  66475. if (cloneChildren && current) {
  66476. subMaterial = current.clone(name + "-" + current.name);
  66477. }
  66478. else {
  66479. subMaterial = this.subMaterials[index];
  66480. }
  66481. newMultiMaterial.subMaterials.push(subMaterial);
  66482. }
  66483. return newMultiMaterial;
  66484. };
  66485. /**
  66486. * Serializes the materials into a JSON representation.
  66487. * @returns the JSON representation
  66488. */
  66489. MultiMaterial.prototype.serialize = function () {
  66490. var serializationObject = {};
  66491. serializationObject.name = this.name;
  66492. serializationObject.id = this.id;
  66493. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  66494. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  66495. }
  66496. serializationObject.materials = [];
  66497. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  66498. var subMat = this.subMaterials[matIndex];
  66499. if (subMat) {
  66500. serializationObject.materials.push(subMat.id);
  66501. }
  66502. else {
  66503. serializationObject.materials.push(null);
  66504. }
  66505. }
  66506. return serializationObject;
  66507. };
  66508. /**
  66509. * Dispose the material and release its associated resources
  66510. * @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)
  66511. * @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)
  66512. * @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)
  66513. */
  66514. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  66515. var scene = this.getScene();
  66516. if (!scene) {
  66517. return;
  66518. }
  66519. if (forceDisposeChildren) {
  66520. for (var index = 0; index < this.subMaterials.length; index++) {
  66521. var subMaterial = this.subMaterials[index];
  66522. if (subMaterial) {
  66523. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  66524. }
  66525. }
  66526. }
  66527. var index = scene.multiMaterials.indexOf(this);
  66528. if (index >= 0) {
  66529. scene.multiMaterials.splice(index, 1);
  66530. }
  66531. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66532. };
  66533. /**
  66534. * Creates a MultiMaterial from parsed MultiMaterial data.
  66535. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66536. * @param scene defines the hosting scene
  66537. * @returns a new MultiMaterial
  66538. */
  66539. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  66540. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  66541. multiMaterial.id = parsedMultiMaterial.id;
  66542. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  66543. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  66544. }
  66545. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  66546. var subMatId = parsedMultiMaterial.materials[matIndex];
  66547. if (subMatId) {
  66548. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  66549. }
  66550. else {
  66551. multiMaterial.subMaterials.push(null);
  66552. }
  66553. }
  66554. return multiMaterial;
  66555. };
  66556. return MultiMaterial;
  66557. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  66558. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  66559. /***/ }),
  66560. /***/ "./Materials/pushMaterial.ts":
  66561. /*!***********************************!*\
  66562. !*** ./Materials/pushMaterial.ts ***!
  66563. \***********************************/
  66564. /*! exports provided: PushMaterial */
  66565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66566. "use strict";
  66567. __webpack_require__.r(__webpack_exports__);
  66568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  66569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66570. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66571. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  66572. /**
  66573. * Base class of materials working in push mode in babylon JS
  66574. * @hidden
  66575. */
  66576. var PushMaterial = /** @class */ (function (_super) {
  66577. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  66578. function PushMaterial(name, scene) {
  66579. var _this = _super.call(this, name, scene) || this;
  66580. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  66581. /**
  66582. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  66583. * This means that the material can keep using a previous shader while a new one is being compiled.
  66584. * This is mostly used when shader parallel compilation is supported (true by default)
  66585. */
  66586. _this.allowShaderHotSwapping = true;
  66587. _this._storeEffectOnSubMeshes = true;
  66588. return _this;
  66589. }
  66590. PushMaterial.prototype.getEffect = function () {
  66591. return this._activeEffect;
  66592. };
  66593. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  66594. if (!mesh) {
  66595. return false;
  66596. }
  66597. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  66598. return true;
  66599. }
  66600. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  66601. };
  66602. /**
  66603. * Binds the given world matrix to the active effect
  66604. *
  66605. * @param world the matrix to bind
  66606. */
  66607. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  66608. this._activeEffect.setMatrix("world", world);
  66609. };
  66610. /**
  66611. * Binds the given normal matrix to the active effect
  66612. *
  66613. * @param normalMatrix the matrix to bind
  66614. */
  66615. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  66616. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  66617. };
  66618. PushMaterial.prototype.bind = function (world, mesh) {
  66619. if (!mesh) {
  66620. return;
  66621. }
  66622. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  66623. };
  66624. PushMaterial.prototype._afterBind = function (mesh, effect) {
  66625. if (effect === void 0) { effect = null; }
  66626. _super.prototype._afterBind.call(this, mesh);
  66627. this.getScene()._cachedEffect = effect;
  66628. };
  66629. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  66630. if (visibility === void 0) { visibility = 1; }
  66631. return scene.isCachedMaterialInvalid(this, effect, visibility);
  66632. };
  66633. return PushMaterial;
  66634. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  66635. /***/ }),
  66636. /***/ "./Materials/shaderMaterial.ts":
  66637. /*!*************************************!*\
  66638. !*** ./Materials/shaderMaterial.ts ***!
  66639. \*************************************/
  66640. /*! exports provided: ShaderMaterial */
  66641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66642. "use strict";
  66643. __webpack_require__.r(__webpack_exports__);
  66644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  66645. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66646. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  66647. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66648. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  66649. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  66650. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  66651. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  66652. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  66653. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  66654. /**
  66655. * 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.
  66656. *
  66657. * This returned material effects how the mesh will look based on the code in the shaders.
  66658. *
  66659. * @see http://doc.babylonjs.com/how_to/shader_material
  66660. */
  66661. var ShaderMaterial = /** @class */ (function (_super) {
  66662. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  66663. /**
  66664. * Instantiate a new shader material.
  66665. * 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.
  66666. * This returned material effects how the mesh will look based on the code in the shaders.
  66667. * @see http://doc.babylonjs.com/how_to/shader_material
  66668. * @param name Define the name of the material in the scene
  66669. * @param scene Define the scene the material belongs to
  66670. * @param shaderPath Defines the route to the shader code in one of three ways:
  66671. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  66672. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  66673. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  66674. * @param options Define the options used to create the shader
  66675. */
  66676. function ShaderMaterial(name, scene, shaderPath, options) {
  66677. if (options === void 0) { options = {}; }
  66678. var _this = _super.call(this, name, scene) || this;
  66679. _this._textures = {};
  66680. _this._textureArrays = {};
  66681. _this._floats = {};
  66682. _this._ints = {};
  66683. _this._floatsArrays = {};
  66684. _this._colors3 = {};
  66685. _this._colors3Arrays = {};
  66686. _this._colors4 = {};
  66687. _this._vectors2 = {};
  66688. _this._vectors3 = {};
  66689. _this._vectors4 = {};
  66690. _this._matrices = {};
  66691. _this._matrices3x3 = {};
  66692. _this._matrices2x2 = {};
  66693. _this._vectors2Arrays = {};
  66694. _this._vectors3Arrays = {};
  66695. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  66696. _this._shaderPath = shaderPath;
  66697. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  66698. return _this;
  66699. }
  66700. Object.defineProperty(ShaderMaterial.prototype, "options", {
  66701. /**
  66702. * Gets the options used to compile the shader.
  66703. * They can be modified to trigger a new compilation
  66704. */
  66705. get: function () {
  66706. return this._options;
  66707. },
  66708. enumerable: true,
  66709. configurable: true
  66710. });
  66711. /**
  66712. * Gets the current class name of the material e.g. "ShaderMaterial"
  66713. * Mainly use in serialization.
  66714. * @returns the class name
  66715. */
  66716. ShaderMaterial.prototype.getClassName = function () {
  66717. return "ShaderMaterial";
  66718. };
  66719. /**
  66720. * Specifies if the material will require alpha blending
  66721. * @returns a boolean specifying if alpha blending is needed
  66722. */
  66723. ShaderMaterial.prototype.needAlphaBlending = function () {
  66724. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  66725. };
  66726. /**
  66727. * Specifies if this material should be rendered in alpha test mode
  66728. * @returns a boolean specifying if an alpha test is needed.
  66729. */
  66730. ShaderMaterial.prototype.needAlphaTesting = function () {
  66731. return this._options.needAlphaTesting;
  66732. };
  66733. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  66734. if (this._options.uniforms.indexOf(uniformName) === -1) {
  66735. this._options.uniforms.push(uniformName);
  66736. }
  66737. };
  66738. /**
  66739. * Set a texture in the shader.
  66740. * @param name Define the name of the uniform samplers as defined in the shader
  66741. * @param texture Define the texture to bind to this sampler
  66742. * @return the material itself allowing "fluent" like uniform updates
  66743. */
  66744. ShaderMaterial.prototype.setTexture = function (name, texture) {
  66745. if (this._options.samplers.indexOf(name) === -1) {
  66746. this._options.samplers.push(name);
  66747. }
  66748. this._textures[name] = texture;
  66749. return this;
  66750. };
  66751. /**
  66752. * Set a texture array in the shader.
  66753. * @param name Define the name of the uniform sampler array as defined in the shader
  66754. * @param textures Define the list of textures to bind to this sampler
  66755. * @return the material itself allowing "fluent" like uniform updates
  66756. */
  66757. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  66758. if (this._options.samplers.indexOf(name) === -1) {
  66759. this._options.samplers.push(name);
  66760. }
  66761. this._checkUniform(name);
  66762. this._textureArrays[name] = textures;
  66763. return this;
  66764. };
  66765. /**
  66766. * Set a float in the shader.
  66767. * @param name Define the name of the uniform as defined in the shader
  66768. * @param value Define the value to give to the uniform
  66769. * @return the material itself allowing "fluent" like uniform updates
  66770. */
  66771. ShaderMaterial.prototype.setFloat = function (name, value) {
  66772. this._checkUniform(name);
  66773. this._floats[name] = value;
  66774. return this;
  66775. };
  66776. /**
  66777. * Set a int in the shader.
  66778. * @param name Define the name of the uniform as defined in the shader
  66779. * @param value Define the value to give to the uniform
  66780. * @return the material itself allowing "fluent" like uniform updates
  66781. */
  66782. ShaderMaterial.prototype.setInt = function (name, value) {
  66783. this._checkUniform(name);
  66784. this._ints[name] = value;
  66785. return this;
  66786. };
  66787. /**
  66788. * Set an array of floats in the shader.
  66789. * @param name Define the name of the uniform as defined in the shader
  66790. * @param value Define the value to give to the uniform
  66791. * @return the material itself allowing "fluent" like uniform updates
  66792. */
  66793. ShaderMaterial.prototype.setFloats = function (name, value) {
  66794. this._checkUniform(name);
  66795. this._floatsArrays[name] = value;
  66796. return this;
  66797. };
  66798. /**
  66799. * Set a vec3 in the shader from a Color3.
  66800. * @param name Define the name of the uniform as defined in the shader
  66801. * @param value Define the value to give to the uniform
  66802. * @return the material itself allowing "fluent" like uniform updates
  66803. */
  66804. ShaderMaterial.prototype.setColor3 = function (name, value) {
  66805. this._checkUniform(name);
  66806. this._colors3[name] = value;
  66807. return this;
  66808. };
  66809. /**
  66810. * Set a vec3 array in the shader from a Color3 array.
  66811. * @param name Define the name of the uniform as defined in the shader
  66812. * @param value Define the value to give to the uniform
  66813. * @return the material itself allowing "fluent" like uniform updates
  66814. */
  66815. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  66816. this._checkUniform(name);
  66817. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  66818. color.toArray(arr, arr.length);
  66819. return arr;
  66820. }, []);
  66821. return this;
  66822. };
  66823. /**
  66824. * Set a vec4 in the shader from a Color4.
  66825. * @param name Define the name of the uniform as defined in the shader
  66826. * @param value Define the value to give to the uniform
  66827. * @return the material itself allowing "fluent" like uniform updates
  66828. */
  66829. ShaderMaterial.prototype.setColor4 = function (name, value) {
  66830. this._checkUniform(name);
  66831. this._colors4[name] = value;
  66832. return this;
  66833. };
  66834. /**
  66835. * Set a vec2 in the shader from a Vector2.
  66836. * @param name Define the name of the uniform as defined in the shader
  66837. * @param value Define the value to give to the uniform
  66838. * @return the material itself allowing "fluent" like uniform updates
  66839. */
  66840. ShaderMaterial.prototype.setVector2 = function (name, value) {
  66841. this._checkUniform(name);
  66842. this._vectors2[name] = value;
  66843. return this;
  66844. };
  66845. /**
  66846. * Set a vec3 in the shader from a Vector3.
  66847. * @param name Define the name of the uniform as defined in the shader
  66848. * @param value Define the value to give to the uniform
  66849. * @return the material itself allowing "fluent" like uniform updates
  66850. */
  66851. ShaderMaterial.prototype.setVector3 = function (name, value) {
  66852. this._checkUniform(name);
  66853. this._vectors3[name] = value;
  66854. return this;
  66855. };
  66856. /**
  66857. * Set a vec4 in the shader from a Vector4.
  66858. * @param name Define the name of the uniform as defined in the shader
  66859. * @param value Define the value to give to the uniform
  66860. * @return the material itself allowing "fluent" like uniform updates
  66861. */
  66862. ShaderMaterial.prototype.setVector4 = function (name, value) {
  66863. this._checkUniform(name);
  66864. this._vectors4[name] = value;
  66865. return this;
  66866. };
  66867. /**
  66868. * Set a mat4 in the shader from a Matrix.
  66869. * @param name Define the name of the uniform as defined in the shader
  66870. * @param value Define the value to give to the uniform
  66871. * @return the material itself allowing "fluent" like uniform updates
  66872. */
  66873. ShaderMaterial.prototype.setMatrix = function (name, value) {
  66874. this._checkUniform(name);
  66875. this._matrices[name] = value;
  66876. return this;
  66877. };
  66878. /**
  66879. * Set a mat3 in the shader from a Float32Array.
  66880. * @param name Define the name of the uniform as defined in the shader
  66881. * @param value Define the value to give to the uniform
  66882. * @return the material itself allowing "fluent" like uniform updates
  66883. */
  66884. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  66885. this._checkUniform(name);
  66886. this._matrices3x3[name] = value;
  66887. return this;
  66888. };
  66889. /**
  66890. * Set a mat2 in the shader from a Float32Array.
  66891. * @param name Define the name of the uniform as defined in the shader
  66892. * @param value Define the value to give to the uniform
  66893. * @return the material itself allowing "fluent" like uniform updates
  66894. */
  66895. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  66896. this._checkUniform(name);
  66897. this._matrices2x2[name] = value;
  66898. return this;
  66899. };
  66900. /**
  66901. * Set a vec2 array in the shader from a number array.
  66902. * @param name Define the name of the uniform as defined in the shader
  66903. * @param value Define the value to give to the uniform
  66904. * @return the material itself allowing "fluent" like uniform updates
  66905. */
  66906. ShaderMaterial.prototype.setArray2 = function (name, value) {
  66907. this._checkUniform(name);
  66908. this._vectors2Arrays[name] = value;
  66909. return this;
  66910. };
  66911. /**
  66912. * Set a vec3 array in the shader from a number array.
  66913. * @param name Define the name of the uniform as defined in the shader
  66914. * @param value Define the value to give to the uniform
  66915. * @return the material itself allowing "fluent" like uniform updates
  66916. */
  66917. ShaderMaterial.prototype.setArray3 = function (name, value) {
  66918. this._checkUniform(name);
  66919. this._vectors3Arrays[name] = value;
  66920. return this;
  66921. };
  66922. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  66923. if (!mesh) {
  66924. return true;
  66925. }
  66926. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  66927. return false;
  66928. }
  66929. return false;
  66930. };
  66931. /**
  66932. * Checks if the material is ready to render the requested mesh
  66933. * @param mesh Define the mesh to render
  66934. * @param useInstances Define whether or not the material is used with instances
  66935. * @returns true if ready, otherwise false
  66936. */
  66937. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  66938. var scene = this.getScene();
  66939. var engine = scene.getEngine();
  66940. if (!this.checkReadyOnEveryCall) {
  66941. if (this._renderId === scene.getRenderId()) {
  66942. if (this._checkCache(mesh, useInstances)) {
  66943. return true;
  66944. }
  66945. }
  66946. }
  66947. // Instances
  66948. var defines = [];
  66949. var attribs = [];
  66950. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  66951. for (var index = 0; index < this._options.defines.length; index++) {
  66952. defines.push(this._options.defines[index]);
  66953. }
  66954. for (var index = 0; index < this._options.attributes.length; index++) {
  66955. attribs.push(this._options.attributes[index]);
  66956. }
  66957. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  66958. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  66959. defines.push("#define VERTEXCOLOR");
  66960. }
  66961. if (useInstances) {
  66962. defines.push("#define INSTANCES");
  66963. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  66964. }
  66965. // Bones
  66966. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66967. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  66968. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  66969. if (mesh.numBoneInfluencers > 4) {
  66970. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  66971. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  66972. }
  66973. var skeleton = mesh.skeleton;
  66974. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  66975. fallbacks.addCPUSkinningFallback(0, mesh);
  66976. if (skeleton.isUsingTextureForMatrices) {
  66977. defines.push("#define BONETEXTURE");
  66978. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  66979. this._options.uniforms.push("boneTextureWidth");
  66980. }
  66981. if (this._options.samplers.indexOf("boneSampler") === -1) {
  66982. this._options.samplers.push("boneSampler");
  66983. }
  66984. }
  66985. else {
  66986. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  66987. if (this._options.uniforms.indexOf("mBones") === -1) {
  66988. this._options.uniforms.push("mBones");
  66989. }
  66990. }
  66991. }
  66992. else {
  66993. defines.push("#define NUM_BONE_INFLUENCERS 0");
  66994. }
  66995. // Textures
  66996. for (var name in this._textures) {
  66997. if (!this._textures[name].isReady()) {
  66998. return false;
  66999. }
  67000. }
  67001. // Alpha test
  67002. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  67003. defines.push("#define ALPHATEST");
  67004. }
  67005. var previousEffect = this._effect;
  67006. var join = defines.join("\n");
  67007. this._effect = engine.createEffect(this._shaderPath, {
  67008. attributes: attribs,
  67009. uniformsNames: this._options.uniforms,
  67010. uniformBuffersNames: this._options.uniformBuffers,
  67011. samplers: this._options.samplers,
  67012. defines: join,
  67013. fallbacks: fallbacks,
  67014. onCompiled: this.onCompiled,
  67015. onError: this.onError
  67016. }, engine);
  67017. if (!this._effect.isReady()) {
  67018. return false;
  67019. }
  67020. if (previousEffect !== this._effect) {
  67021. scene.resetCachedMaterial();
  67022. }
  67023. this._renderId = scene.getRenderId();
  67024. return true;
  67025. };
  67026. /**
  67027. * Binds the world matrix to the material
  67028. * @param world defines the world transformation matrix
  67029. */
  67030. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  67031. var scene = this.getScene();
  67032. if (!this._effect) {
  67033. return;
  67034. }
  67035. if (this._options.uniforms.indexOf("world") !== -1) {
  67036. this._effect.setMatrix("world", world);
  67037. }
  67038. if (this._options.uniforms.indexOf("worldView") !== -1) {
  67039. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  67040. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  67041. }
  67042. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  67043. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  67044. }
  67045. };
  67046. /**
  67047. * Binds the material to the mesh
  67048. * @param world defines the world transformation matrix
  67049. * @param mesh defines the mesh to bind the material to
  67050. */
  67051. ShaderMaterial.prototype.bind = function (world, mesh) {
  67052. // Std values
  67053. this.bindOnlyWorldMatrix(world);
  67054. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  67055. if (this._options.uniforms.indexOf("view") !== -1) {
  67056. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  67057. }
  67058. if (this._options.uniforms.indexOf("projection") !== -1) {
  67059. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  67060. }
  67061. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  67062. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  67063. }
  67064. // Bones
  67065. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  67066. var name;
  67067. // Texture
  67068. for (name in this._textures) {
  67069. this._effect.setTexture(name, this._textures[name]);
  67070. }
  67071. // Texture arrays
  67072. for (name in this._textureArrays) {
  67073. this._effect.setTextureArray(name, this._textureArrays[name]);
  67074. }
  67075. // Int
  67076. for (name in this._ints) {
  67077. this._effect.setInt(name, this._ints[name]);
  67078. }
  67079. // Float
  67080. for (name in this._floats) {
  67081. this._effect.setFloat(name, this._floats[name]);
  67082. }
  67083. // Floats
  67084. for (name in this._floatsArrays) {
  67085. this._effect.setArray(name, this._floatsArrays[name]);
  67086. }
  67087. // Color3
  67088. for (name in this._colors3) {
  67089. this._effect.setColor3(name, this._colors3[name]);
  67090. }
  67091. for (name in this._colors3Arrays) {
  67092. this._effect.setArray3(name, this._colors3Arrays[name]);
  67093. }
  67094. // Color4
  67095. for (name in this._colors4) {
  67096. var color = this._colors4[name];
  67097. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  67098. }
  67099. // Vector2
  67100. for (name in this._vectors2) {
  67101. this._effect.setVector2(name, this._vectors2[name]);
  67102. }
  67103. // Vector3
  67104. for (name in this._vectors3) {
  67105. this._effect.setVector3(name, this._vectors3[name]);
  67106. }
  67107. // Vector4
  67108. for (name in this._vectors4) {
  67109. this._effect.setVector4(name, this._vectors4[name]);
  67110. }
  67111. // Matrix
  67112. for (name in this._matrices) {
  67113. this._effect.setMatrix(name, this._matrices[name]);
  67114. }
  67115. // Matrix 3x3
  67116. for (name in this._matrices3x3) {
  67117. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  67118. }
  67119. // Matrix 2x2
  67120. for (name in this._matrices2x2) {
  67121. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  67122. }
  67123. // Vector2Array
  67124. for (name in this._vectors2Arrays) {
  67125. this._effect.setArray2(name, this._vectors2Arrays[name]);
  67126. }
  67127. // Vector3Array
  67128. for (name in this._vectors3Arrays) {
  67129. this._effect.setArray3(name, this._vectors3Arrays[name]);
  67130. }
  67131. }
  67132. this._afterBind(mesh);
  67133. };
  67134. /**
  67135. * Gets the active textures from the material
  67136. * @returns an array of textures
  67137. */
  67138. ShaderMaterial.prototype.getActiveTextures = function () {
  67139. var activeTextures = _super.prototype.getActiveTextures.call(this);
  67140. for (var name in this._textures) {
  67141. activeTextures.push(this._textures[name]);
  67142. }
  67143. for (var name in this._textureArrays) {
  67144. var array = this._textureArrays[name];
  67145. for (var index = 0; index < array.length; index++) {
  67146. activeTextures.push(array[index]);
  67147. }
  67148. }
  67149. return activeTextures;
  67150. };
  67151. /**
  67152. * Specifies if the material uses a texture
  67153. * @param texture defines the texture to check against the material
  67154. * @returns a boolean specifying if the material uses the texture
  67155. */
  67156. ShaderMaterial.prototype.hasTexture = function (texture) {
  67157. if (_super.prototype.hasTexture.call(this, texture)) {
  67158. return true;
  67159. }
  67160. for (var name in this._textures) {
  67161. if (this._textures[name] === texture) {
  67162. return true;
  67163. }
  67164. }
  67165. for (var name in this._textureArrays) {
  67166. var array = this._textureArrays[name];
  67167. for (var index = 0; index < array.length; index++) {
  67168. if (array[index] === texture) {
  67169. return true;
  67170. }
  67171. }
  67172. }
  67173. return false;
  67174. };
  67175. /**
  67176. * Makes a duplicate of the material, and gives it a new name
  67177. * @param name defines the new name for the duplicated material
  67178. * @returns the cloned material
  67179. */
  67180. ShaderMaterial.prototype.clone = function (name) {
  67181. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  67182. return newShaderMaterial;
  67183. };
  67184. /**
  67185. * Disposes the material
  67186. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67187. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  67188. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  67189. */
  67190. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  67191. if (forceDisposeTextures) {
  67192. var name;
  67193. for (name in this._textures) {
  67194. this._textures[name].dispose();
  67195. }
  67196. for (name in this._textureArrays) {
  67197. var array = this._textureArrays[name];
  67198. for (var index = 0; index < array.length; index++) {
  67199. array[index].dispose();
  67200. }
  67201. }
  67202. }
  67203. this._textures = {};
  67204. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  67205. };
  67206. /**
  67207. * Serializes this material in a JSON representation
  67208. * @returns the serialized material object
  67209. */
  67210. ShaderMaterial.prototype.serialize = function () {
  67211. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  67212. serializationObject.customType = "ShaderMaterial";
  67213. serializationObject.options = this._options;
  67214. serializationObject.shaderPath = this._shaderPath;
  67215. var name;
  67216. // Texture
  67217. serializationObject.textures = {};
  67218. for (name in this._textures) {
  67219. serializationObject.textures[name] = this._textures[name].serialize();
  67220. }
  67221. // Texture arrays
  67222. serializationObject.textureArrays = {};
  67223. for (name in this._textureArrays) {
  67224. serializationObject.textureArrays[name] = [];
  67225. var array = this._textureArrays[name];
  67226. for (var index = 0; index < array.length; index++) {
  67227. serializationObject.textureArrays[name].push(array[index].serialize());
  67228. }
  67229. }
  67230. // Float
  67231. serializationObject.floats = {};
  67232. for (name in this._floats) {
  67233. serializationObject.floats[name] = this._floats[name];
  67234. }
  67235. // Float s
  67236. serializationObject.FloatArrays = {};
  67237. for (name in this._floatsArrays) {
  67238. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  67239. }
  67240. // Color3
  67241. serializationObject.colors3 = {};
  67242. for (name in this._colors3) {
  67243. serializationObject.colors3[name] = this._colors3[name].asArray();
  67244. }
  67245. // Color3 array
  67246. serializationObject.colors3Arrays = {};
  67247. for (name in this._colors3Arrays) {
  67248. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  67249. }
  67250. // Color4
  67251. serializationObject.colors4 = {};
  67252. for (name in this._colors4) {
  67253. serializationObject.colors4[name] = this._colors4[name].asArray();
  67254. }
  67255. // Vector2
  67256. serializationObject.vectors2 = {};
  67257. for (name in this._vectors2) {
  67258. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  67259. }
  67260. // Vector3
  67261. serializationObject.vectors3 = {};
  67262. for (name in this._vectors3) {
  67263. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  67264. }
  67265. // Vector4
  67266. serializationObject.vectors4 = {};
  67267. for (name in this._vectors4) {
  67268. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  67269. }
  67270. // Matrix
  67271. serializationObject.matrices = {};
  67272. for (name in this._matrices) {
  67273. serializationObject.matrices[name] = this._matrices[name].asArray();
  67274. }
  67275. // Matrix 3x3
  67276. serializationObject.matrices3x3 = {};
  67277. for (name in this._matrices3x3) {
  67278. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  67279. }
  67280. // Matrix 2x2
  67281. serializationObject.matrices2x2 = {};
  67282. for (name in this._matrices2x2) {
  67283. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  67284. }
  67285. // Vector2Array
  67286. serializationObject.vectors2Arrays = {};
  67287. for (name in this._vectors2Arrays) {
  67288. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  67289. }
  67290. // Vector3Array
  67291. serializationObject.vectors3Arrays = {};
  67292. for (name in this._vectors3Arrays) {
  67293. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  67294. }
  67295. return serializationObject;
  67296. };
  67297. /**
  67298. * Creates a shader material from parsed shader material data
  67299. * @param source defines the JSON represnetation of the material
  67300. * @param scene defines the hosting scene
  67301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67302. * @returns a new material
  67303. */
  67304. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  67305. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  67306. var name;
  67307. // Texture
  67308. for (name in source.textures) {
  67309. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  67310. }
  67311. // Texture arrays
  67312. for (name in source.textureArrays) {
  67313. var array = source.textureArrays[name];
  67314. var textureArray = new Array();
  67315. for (var index = 0; index < array.length; index++) {
  67316. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  67317. }
  67318. material.setTextureArray(name, textureArray);
  67319. }
  67320. // Float
  67321. for (name in source.floats) {
  67322. material.setFloat(name, source.floats[name]);
  67323. }
  67324. // Float s
  67325. for (name in source.floatsArrays) {
  67326. material.setFloats(name, source.floatsArrays[name]);
  67327. }
  67328. // Color3
  67329. for (name in source.colors3) {
  67330. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  67331. }
  67332. // Color3 arrays
  67333. for (name in source.colors3Arrays) {
  67334. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  67335. if (i % 3 === 0) {
  67336. arr.push([num]);
  67337. }
  67338. else {
  67339. arr[arr.length - 1].push(num);
  67340. }
  67341. return arr;
  67342. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  67343. material.setColor3Array(name, colors);
  67344. }
  67345. // Color4
  67346. for (name in source.colors4) {
  67347. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  67348. }
  67349. // Vector2
  67350. for (name in source.vectors2) {
  67351. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  67352. }
  67353. // Vector3
  67354. for (name in source.vectors3) {
  67355. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  67356. }
  67357. // Vector4
  67358. for (name in source.vectors4) {
  67359. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  67360. }
  67361. // Matrix
  67362. for (name in source.matrices) {
  67363. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  67364. }
  67365. // Matrix 3x3
  67366. for (name in source.matrices3x3) {
  67367. material.setMatrix3x3(name, source.matrices3x3[name]);
  67368. }
  67369. // Matrix 2x2
  67370. for (name in source.matrices2x2) {
  67371. material.setMatrix2x2(name, source.matrices2x2[name]);
  67372. }
  67373. // Vector2Array
  67374. for (name in source.vectors2Arrays) {
  67375. material.setArray2(name, source.vectors2Arrays[name]);
  67376. }
  67377. // Vector3Array
  67378. for (name in source.vectors3Arrays) {
  67379. material.setArray3(name, source.vectors3Arrays[name]);
  67380. }
  67381. return material;
  67382. };
  67383. return ShaderMaterial;
  67384. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  67385. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  67386. /***/ }),
  67387. /***/ "./Materials/standardMaterial.ts":
  67388. /*!***************************************!*\
  67389. !*** ./Materials/standardMaterial.ts ***!
  67390. \***************************************/
  67391. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  67392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67393. "use strict";
  67394. __webpack_require__.r(__webpack_exports__);
  67395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  67396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  67397. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67398. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  67399. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  67400. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  67401. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67402. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  67403. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  67404. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  67405. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  67406. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  67407. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  67408. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67409. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67410. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  67411. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  67412. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  67413. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  67414. /** @hidden */
  67415. var StandardMaterialDefines = /** @class */ (function (_super) {
  67416. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  67417. function StandardMaterialDefines() {
  67418. var _this = _super.call(this) || this;
  67419. _this.MAINUV1 = false;
  67420. _this.MAINUV2 = false;
  67421. _this.DIFFUSE = false;
  67422. _this.DIFFUSEDIRECTUV = 0;
  67423. _this.AMBIENT = false;
  67424. _this.AMBIENTDIRECTUV = 0;
  67425. _this.OPACITY = false;
  67426. _this.OPACITYDIRECTUV = 0;
  67427. _this.OPACITYRGB = false;
  67428. _this.REFLECTION = false;
  67429. _this.EMISSIVE = false;
  67430. _this.EMISSIVEDIRECTUV = 0;
  67431. _this.SPECULAR = false;
  67432. _this.SPECULARDIRECTUV = 0;
  67433. _this.BUMP = false;
  67434. _this.BUMPDIRECTUV = 0;
  67435. _this.PARALLAX = false;
  67436. _this.PARALLAXOCCLUSION = false;
  67437. _this.SPECULAROVERALPHA = false;
  67438. _this.CLIPPLANE = false;
  67439. _this.CLIPPLANE2 = false;
  67440. _this.CLIPPLANE3 = false;
  67441. _this.CLIPPLANE4 = false;
  67442. _this.ALPHATEST = false;
  67443. _this.DEPTHPREPASS = false;
  67444. _this.ALPHAFROMDIFFUSE = false;
  67445. _this.POINTSIZE = false;
  67446. _this.FOG = false;
  67447. _this.SPECULARTERM = false;
  67448. _this.DIFFUSEFRESNEL = false;
  67449. _this.OPACITYFRESNEL = false;
  67450. _this.REFLECTIONFRESNEL = false;
  67451. _this.REFRACTIONFRESNEL = false;
  67452. _this.EMISSIVEFRESNEL = false;
  67453. _this.FRESNEL = false;
  67454. _this.NORMAL = false;
  67455. _this.UV1 = false;
  67456. _this.UV2 = false;
  67457. _this.VERTEXCOLOR = false;
  67458. _this.VERTEXALPHA = false;
  67459. _this.NUM_BONE_INFLUENCERS = 0;
  67460. _this.BonesPerMesh = 0;
  67461. _this.BONETEXTURE = false;
  67462. _this.INSTANCES = false;
  67463. _this.GLOSSINESS = false;
  67464. _this.ROUGHNESS = false;
  67465. _this.EMISSIVEASILLUMINATION = false;
  67466. _this.LINKEMISSIVEWITHDIFFUSE = false;
  67467. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  67468. _this.LIGHTMAP = false;
  67469. _this.LIGHTMAPDIRECTUV = 0;
  67470. _this.OBJECTSPACE_NORMALMAP = false;
  67471. _this.USELIGHTMAPASSHADOWMAP = false;
  67472. _this.REFLECTIONMAP_3D = false;
  67473. _this.REFLECTIONMAP_SPHERICAL = false;
  67474. _this.REFLECTIONMAP_PLANAR = false;
  67475. _this.REFLECTIONMAP_CUBIC = false;
  67476. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  67477. _this.REFLECTIONMAP_PROJECTION = false;
  67478. _this.REFLECTIONMAP_SKYBOX = false;
  67479. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  67480. _this.REFLECTIONMAP_EXPLICIT = false;
  67481. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  67482. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  67483. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  67484. _this.INVERTCUBICMAP = false;
  67485. _this.LOGARITHMICDEPTH = false;
  67486. _this.REFRACTION = false;
  67487. _this.REFRACTIONMAP_3D = false;
  67488. _this.REFLECTIONOVERALPHA = false;
  67489. _this.TWOSIDEDLIGHTING = false;
  67490. _this.SHADOWFLOAT = false;
  67491. _this.MORPHTARGETS = false;
  67492. _this.MORPHTARGETS_NORMAL = false;
  67493. _this.MORPHTARGETS_TANGENT = false;
  67494. _this.NUM_MORPH_INFLUENCERS = 0;
  67495. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  67496. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  67497. _this.IMAGEPROCESSING = false;
  67498. _this.VIGNETTE = false;
  67499. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  67500. _this.VIGNETTEBLENDMODEOPAQUE = false;
  67501. _this.TONEMAPPING = false;
  67502. _this.TONEMAPPING_ACES = false;
  67503. _this.CONTRAST = false;
  67504. _this.COLORCURVES = false;
  67505. _this.COLORGRADING = false;
  67506. _this.COLORGRADING3D = false;
  67507. _this.SAMPLER3DGREENDEPTH = false;
  67508. _this.SAMPLER3DBGRMAP = false;
  67509. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  67510. /**
  67511. * If the reflection texture on this material is in linear color space
  67512. * @hidden
  67513. */
  67514. _this.IS_REFLECTION_LINEAR = false;
  67515. /**
  67516. * If the refraction texture on this material is in linear color space
  67517. * @hidden
  67518. */
  67519. _this.IS_REFRACTION_LINEAR = false;
  67520. _this.EXPOSURE = false;
  67521. _this.rebuild();
  67522. return _this;
  67523. }
  67524. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  67525. var modes = [
  67526. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  67527. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  67528. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  67529. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  67530. ];
  67531. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  67532. var mode = modes_1[_i];
  67533. this[mode] = (mode === modeToEnable);
  67534. }
  67535. };
  67536. return StandardMaterialDefines;
  67537. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  67538. /**
  67539. * This is the default material used in Babylon. It is the best trade off between quality
  67540. * and performances.
  67541. * @see http://doc.babylonjs.com/babylon101/materials
  67542. */
  67543. var StandardMaterial = /** @class */ (function (_super) {
  67544. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  67545. /**
  67546. * Instantiates a new standard material.
  67547. * This is the default material used in Babylon. It is the best trade off between quality
  67548. * and performances.
  67549. * @see http://doc.babylonjs.com/babylon101/materials
  67550. * @param name Define the name of the material in the scene
  67551. * @param scene Define the scene the material belong to
  67552. */
  67553. function StandardMaterial(name, scene) {
  67554. var _this = _super.call(this, name, scene) || this;
  67555. /**
  67556. * The color of the material lit by the environmental background lighting.
  67557. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  67558. */
  67559. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67560. /**
  67561. * The basic color of the material as viewed under a light.
  67562. */
  67563. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  67564. /**
  67565. * Define how the color and intensity of the highlight given by the light in the material.
  67566. */
  67567. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  67568. /**
  67569. * Define the color of the material as if self lit.
  67570. * This will be mixed in the final result even in the absence of light.
  67571. */
  67572. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67573. /**
  67574. * Defines how sharp are the highlights in the material.
  67575. * The bigger the value the sharper giving a more glossy feeling to the result.
  67576. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  67577. */
  67578. _this.specularPower = 64;
  67579. _this._useAlphaFromDiffuseTexture = false;
  67580. _this._useEmissiveAsIllumination = false;
  67581. _this._linkEmissiveWithDiffuse = false;
  67582. _this._useSpecularOverAlpha = false;
  67583. _this._useReflectionOverAlpha = false;
  67584. _this._disableLighting = false;
  67585. _this._useObjectSpaceNormalMap = false;
  67586. _this._useParallax = false;
  67587. _this._useParallaxOcclusion = false;
  67588. /**
  67589. * 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.
  67590. */
  67591. _this.parallaxScaleBias = 0.05;
  67592. _this._roughness = 0;
  67593. /**
  67594. * In case of refraction, define the value of the indice of refraction.
  67595. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  67596. */
  67597. _this.indexOfRefraction = 0.98;
  67598. /**
  67599. * Invert the refraction texture alongside the y axis.
  67600. * It can be useful with procedural textures or probe for instance.
  67601. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  67602. */
  67603. _this.invertRefractionY = true;
  67604. /**
  67605. * Defines the alpha limits in alpha test mode.
  67606. */
  67607. _this.alphaCutOff = 0.4;
  67608. _this._useLightmapAsShadowmap = false;
  67609. _this._useReflectionFresnelFromSpecular = false;
  67610. _this._useGlossinessFromSpecularMapAlpha = false;
  67611. _this._maxSimultaneousLights = 4;
  67612. _this._invertNormalMapX = false;
  67613. _this._invertNormalMapY = false;
  67614. _this._twoSidedLighting = false;
  67615. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  67616. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  67617. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67618. // Setup the default processing configuration to the scene.
  67619. _this._attachImageProcessingConfiguration(null);
  67620. _this.getRenderTargetTextures = function () {
  67621. _this._renderTargets.reset();
  67622. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  67623. _this._renderTargets.push(_this._reflectionTexture);
  67624. }
  67625. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  67626. _this._renderTargets.push(_this._refractionTexture);
  67627. }
  67628. return _this._renderTargets;
  67629. };
  67630. return _this;
  67631. }
  67632. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  67633. /**
  67634. * Gets the image processing configuration used either in this material.
  67635. */
  67636. get: function () {
  67637. return this._imageProcessingConfiguration;
  67638. },
  67639. /**
  67640. * Sets the Default image processing configuration used either in the this material.
  67641. *
  67642. * If sets to null, the scene one is in use.
  67643. */
  67644. set: function (value) {
  67645. this._attachImageProcessingConfiguration(value);
  67646. // Ensure the effect will be rebuilt.
  67647. this._markAllSubMeshesAsTexturesDirty();
  67648. },
  67649. enumerable: true,
  67650. configurable: true
  67651. });
  67652. /**
  67653. * Attaches a new image processing configuration to the Standard Material.
  67654. * @param configuration
  67655. */
  67656. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  67657. var _this = this;
  67658. if (configuration === this._imageProcessingConfiguration) {
  67659. return;
  67660. }
  67661. // Detaches observer.
  67662. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  67663. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  67664. }
  67665. // Pick the scene configuration if needed.
  67666. if (!configuration) {
  67667. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  67668. }
  67669. else {
  67670. this._imageProcessingConfiguration = configuration;
  67671. }
  67672. // Attaches observer.
  67673. if (this._imageProcessingConfiguration) {
  67674. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  67675. _this._markAllSubMeshesAsImageProcessingDirty();
  67676. });
  67677. }
  67678. };
  67679. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  67680. /**
  67681. * Gets wether the color curves effect is enabled.
  67682. */
  67683. get: function () {
  67684. return this.imageProcessingConfiguration.colorCurvesEnabled;
  67685. },
  67686. /**
  67687. * Sets wether the color curves effect is enabled.
  67688. */
  67689. set: function (value) {
  67690. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  67691. },
  67692. enumerable: true,
  67693. configurable: true
  67694. });
  67695. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  67696. /**
  67697. * Gets wether the color grading effect is enabled.
  67698. */
  67699. get: function () {
  67700. return this.imageProcessingConfiguration.colorGradingEnabled;
  67701. },
  67702. /**
  67703. * Gets wether the color grading effect is enabled.
  67704. */
  67705. set: function (value) {
  67706. this.imageProcessingConfiguration.colorGradingEnabled = value;
  67707. },
  67708. enumerable: true,
  67709. configurable: true
  67710. });
  67711. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  67712. /**
  67713. * Gets wether tonemapping is enabled or not.
  67714. */
  67715. get: function () {
  67716. return this._imageProcessingConfiguration.toneMappingEnabled;
  67717. },
  67718. /**
  67719. * Sets wether tonemapping is enabled or not
  67720. */
  67721. set: function (value) {
  67722. this._imageProcessingConfiguration.toneMappingEnabled = value;
  67723. },
  67724. enumerable: true,
  67725. configurable: true
  67726. });
  67727. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  67728. /**
  67729. * The camera exposure used on this material.
  67730. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  67731. * This corresponds to a photographic exposure.
  67732. */
  67733. get: function () {
  67734. return this._imageProcessingConfiguration.exposure;
  67735. },
  67736. /**
  67737. * The camera exposure used on this material.
  67738. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  67739. * This corresponds to a photographic exposure.
  67740. */
  67741. set: function (value) {
  67742. this._imageProcessingConfiguration.exposure = value;
  67743. },
  67744. enumerable: true,
  67745. configurable: true
  67746. });
  67747. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  67748. /**
  67749. * Gets The camera contrast used on this material.
  67750. */
  67751. get: function () {
  67752. return this._imageProcessingConfiguration.contrast;
  67753. },
  67754. /**
  67755. * Sets The camera contrast used on this material.
  67756. */
  67757. set: function (value) {
  67758. this._imageProcessingConfiguration.contrast = value;
  67759. },
  67760. enumerable: true,
  67761. configurable: true
  67762. });
  67763. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  67764. /**
  67765. * Gets the Color Grading 2D Lookup Texture.
  67766. */
  67767. get: function () {
  67768. return this._imageProcessingConfiguration.colorGradingTexture;
  67769. },
  67770. /**
  67771. * Sets the Color Grading 2D Lookup Texture.
  67772. */
  67773. set: function (value) {
  67774. this._imageProcessingConfiguration.colorGradingTexture = value;
  67775. },
  67776. enumerable: true,
  67777. configurable: true
  67778. });
  67779. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  67780. /**
  67781. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  67782. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  67783. * 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;
  67784. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  67785. */
  67786. get: function () {
  67787. return this._imageProcessingConfiguration.colorCurves;
  67788. },
  67789. /**
  67790. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  67791. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  67792. * 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;
  67793. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  67794. */
  67795. set: function (value) {
  67796. this._imageProcessingConfiguration.colorCurves = value;
  67797. },
  67798. enumerable: true,
  67799. configurable: true
  67800. });
  67801. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  67802. /**
  67803. * Gets a boolean indicating that current material needs to register RTT
  67804. */
  67805. get: function () {
  67806. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  67807. return true;
  67808. }
  67809. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  67810. return true;
  67811. }
  67812. return false;
  67813. },
  67814. enumerable: true,
  67815. configurable: true
  67816. });
  67817. /**
  67818. * Gets the current class name of the material e.g. "StandardMaterial"
  67819. * Mainly use in serialization.
  67820. * @returns the class name
  67821. */
  67822. StandardMaterial.prototype.getClassName = function () {
  67823. return "StandardMaterial";
  67824. };
  67825. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  67826. /**
  67827. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  67828. * You can try switching to logarithmic depth.
  67829. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  67830. */
  67831. get: function () {
  67832. return this._useLogarithmicDepth;
  67833. },
  67834. set: function (value) {
  67835. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  67836. this._markAllSubMeshesAsMiscDirty();
  67837. },
  67838. enumerable: true,
  67839. configurable: true
  67840. });
  67841. /**
  67842. * Specifies if the material will require alpha blending
  67843. * @returns a boolean specifying if alpha blending is needed
  67844. */
  67845. StandardMaterial.prototype.needAlphaBlending = function () {
  67846. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  67847. };
  67848. /**
  67849. * Specifies if this material should be rendered in alpha test mode
  67850. * @returns a boolean specifying if an alpha test is needed.
  67851. */
  67852. StandardMaterial.prototype.needAlphaTesting = function () {
  67853. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  67854. };
  67855. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  67856. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  67857. };
  67858. /**
  67859. * Get the texture used for alpha test purpose.
  67860. * @returns the diffuse texture in case of the standard material.
  67861. */
  67862. StandardMaterial.prototype.getAlphaTestTexture = function () {
  67863. return this._diffuseTexture;
  67864. };
  67865. /**
  67866. * Get if the submesh is ready to be used and all its information available.
  67867. * Child classes can use it to update shaders
  67868. * @param mesh defines the mesh to check
  67869. * @param subMesh defines which submesh to check
  67870. * @param useInstances specifies that instances should be used
  67871. * @returns a boolean indicating that the submesh is ready or not
  67872. */
  67873. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67874. if (useInstances === void 0) { useInstances = false; }
  67875. if (subMesh.effect && this.isFrozen) {
  67876. if (this._wasPreviouslyReady) {
  67877. return true;
  67878. }
  67879. }
  67880. if (!subMesh._materialDefines) {
  67881. subMesh._materialDefines = new StandardMaterialDefines();
  67882. }
  67883. var scene = this.getScene();
  67884. var defines = subMesh._materialDefines;
  67885. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  67886. if (defines._renderId === scene.getRenderId()) {
  67887. return true;
  67888. }
  67889. }
  67890. var engine = scene.getEngine();
  67891. // Lights
  67892. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  67893. // Textures
  67894. if (defines._areTexturesDirty) {
  67895. defines._needUVs = false;
  67896. defines.MAINUV1 = false;
  67897. defines.MAINUV2 = false;
  67898. if (scene.texturesEnabled) {
  67899. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  67900. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  67901. return false;
  67902. }
  67903. else {
  67904. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  67905. }
  67906. }
  67907. else {
  67908. defines.DIFFUSE = false;
  67909. }
  67910. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  67911. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  67912. return false;
  67913. }
  67914. else {
  67915. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  67916. }
  67917. }
  67918. else {
  67919. defines.AMBIENT = false;
  67920. }
  67921. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  67922. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  67923. return false;
  67924. }
  67925. else {
  67926. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  67927. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  67928. }
  67929. }
  67930. else {
  67931. defines.OPACITY = false;
  67932. }
  67933. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  67934. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  67935. return false;
  67936. }
  67937. else {
  67938. defines._needNormals = true;
  67939. defines.REFLECTION = true;
  67940. defines.ROUGHNESS = (this._roughness > 0);
  67941. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  67942. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  67943. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  67944. switch (this._reflectionTexture.coordinatesMode) {
  67945. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  67946. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  67947. break;
  67948. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  67949. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  67950. break;
  67951. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  67952. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  67953. break;
  67954. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  67955. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  67956. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  67957. break;
  67958. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  67959. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  67960. break;
  67961. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  67962. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  67963. break;
  67964. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  67965. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  67966. break;
  67967. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  67968. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  67969. break;
  67970. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  67971. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  67972. default:
  67973. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  67974. break;
  67975. }
  67976. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  67977. }
  67978. }
  67979. else {
  67980. defines.REFLECTION = false;
  67981. }
  67982. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  67983. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  67984. return false;
  67985. }
  67986. else {
  67987. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  67988. }
  67989. }
  67990. else {
  67991. defines.EMISSIVE = false;
  67992. }
  67993. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  67994. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  67995. return false;
  67996. }
  67997. else {
  67998. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  67999. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  68000. }
  68001. }
  68002. else {
  68003. defines.LIGHTMAP = false;
  68004. }
  68005. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68006. if (!this._specularTexture.isReadyOrNotBlocking()) {
  68007. return false;
  68008. }
  68009. else {
  68010. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  68011. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  68012. }
  68013. }
  68014. else {
  68015. defines.SPECULAR = false;
  68016. }
  68017. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  68018. // Bump texure can not be not blocking.
  68019. if (!this._bumpTexture.isReady()) {
  68020. return false;
  68021. }
  68022. else {
  68023. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  68024. defines.PARALLAX = this._useParallax;
  68025. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  68026. }
  68027. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  68028. }
  68029. else {
  68030. defines.BUMP = false;
  68031. }
  68032. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68033. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  68034. return false;
  68035. }
  68036. else {
  68037. defines._needUVs = true;
  68038. defines.REFRACTION = true;
  68039. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  68040. }
  68041. }
  68042. else {
  68043. defines.REFRACTION = false;
  68044. }
  68045. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  68046. }
  68047. else {
  68048. defines.DIFFUSE = false;
  68049. defines.AMBIENT = false;
  68050. defines.OPACITY = false;
  68051. defines.REFLECTION = false;
  68052. defines.EMISSIVE = false;
  68053. defines.LIGHTMAP = false;
  68054. defines.BUMP = false;
  68055. defines.REFRACTION = false;
  68056. }
  68057. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  68058. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  68059. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  68060. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  68061. 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);
  68062. }
  68063. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  68064. if (!this._imageProcessingConfiguration.isReady()) {
  68065. return false;
  68066. }
  68067. this._imageProcessingConfiguration.prepareDefines(defines);
  68068. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  68069. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  68070. }
  68071. if (defines._areFresnelDirty) {
  68072. if (StandardMaterial.FresnelEnabled) {
  68073. // Fresnel
  68074. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  68075. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  68076. this._reflectionFresnelParameters) {
  68077. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  68078. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  68079. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  68080. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  68081. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  68082. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  68083. defines._needNormals = true;
  68084. defines.FRESNEL = true;
  68085. }
  68086. }
  68087. else {
  68088. defines.FRESNEL = false;
  68089. }
  68090. }
  68091. // Misc.
  68092. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  68093. // Attribs
  68094. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  68095. // Values that need to be evaluated on every frame
  68096. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  68097. // Get correct effect
  68098. if (defines.isDirty) {
  68099. defines.markAsProcessed();
  68100. // Fallbacks
  68101. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  68102. if (defines.REFLECTION) {
  68103. fallbacks.addFallback(0, "REFLECTION");
  68104. }
  68105. if (defines.SPECULAR) {
  68106. fallbacks.addFallback(0, "SPECULAR");
  68107. }
  68108. if (defines.BUMP) {
  68109. fallbacks.addFallback(0, "BUMP");
  68110. }
  68111. if (defines.PARALLAX) {
  68112. fallbacks.addFallback(1, "PARALLAX");
  68113. }
  68114. if (defines.PARALLAXOCCLUSION) {
  68115. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  68116. }
  68117. if (defines.SPECULAROVERALPHA) {
  68118. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  68119. }
  68120. if (defines.FOG) {
  68121. fallbacks.addFallback(1, "FOG");
  68122. }
  68123. if (defines.POINTSIZE) {
  68124. fallbacks.addFallback(0, "POINTSIZE");
  68125. }
  68126. if (defines.LOGARITHMICDEPTH) {
  68127. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  68128. }
  68129. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  68130. if (defines.SPECULARTERM) {
  68131. fallbacks.addFallback(0, "SPECULARTERM");
  68132. }
  68133. if (defines.DIFFUSEFRESNEL) {
  68134. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  68135. }
  68136. if (defines.OPACITYFRESNEL) {
  68137. fallbacks.addFallback(2, "OPACITYFRESNEL");
  68138. }
  68139. if (defines.REFLECTIONFRESNEL) {
  68140. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  68141. }
  68142. if (defines.EMISSIVEFRESNEL) {
  68143. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  68144. }
  68145. if (defines.FRESNEL) {
  68146. fallbacks.addFallback(4, "FRESNEL");
  68147. }
  68148. //Attributes
  68149. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  68150. if (defines.NORMAL) {
  68151. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  68152. }
  68153. if (defines.UV1) {
  68154. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  68155. }
  68156. if (defines.UV2) {
  68157. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  68158. }
  68159. if (defines.VERTEXCOLOR) {
  68160. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  68161. }
  68162. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  68163. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  68164. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  68165. var shaderName = "default";
  68166. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  68167. "vFogInfos", "vFogColor", "pointSize",
  68168. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  68169. "mBones",
  68170. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  68171. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  68172. "vReflectionPosition", "vReflectionSize",
  68173. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  68174. ];
  68175. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  68176. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  68177. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  68178. var uniformBuffers = ["Material", "Scene"];
  68179. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  68180. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  68181. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  68182. }
  68183. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  68184. uniformsNames: uniforms,
  68185. uniformBuffersNames: uniformBuffers,
  68186. samplers: samplers,
  68187. defines: defines,
  68188. maxSimultaneousLights: this._maxSimultaneousLights
  68189. });
  68190. if (this.customShaderNameResolve) {
  68191. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  68192. }
  68193. var join = defines.toString();
  68194. var previousEffect = subMesh.effect;
  68195. var effect = scene.getEngine().createEffect(shaderName, {
  68196. attributes: attribs,
  68197. uniformsNames: uniforms,
  68198. uniformBuffersNames: uniformBuffers,
  68199. samplers: samplers,
  68200. defines: join,
  68201. fallbacks: fallbacks,
  68202. onCompiled: this.onCompiled,
  68203. onError: this.onError,
  68204. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  68205. }, engine);
  68206. if (effect) {
  68207. // Use previous effect while new one is compiling
  68208. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  68209. effect = previousEffect;
  68210. defines.markAsUnprocessed();
  68211. }
  68212. else {
  68213. scene.resetCachedMaterial();
  68214. subMesh.setEffect(effect, defines);
  68215. this.buildUniformLayout();
  68216. }
  68217. }
  68218. }
  68219. if (!subMesh.effect || !subMesh.effect.isReady()) {
  68220. return false;
  68221. }
  68222. defines._renderId = scene.getRenderId();
  68223. this._wasPreviouslyReady = true;
  68224. return true;
  68225. };
  68226. /**
  68227. * Builds the material UBO layouts.
  68228. * Used internally during the effect preparation.
  68229. */
  68230. StandardMaterial.prototype.buildUniformLayout = function () {
  68231. // Order is important !
  68232. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  68233. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  68234. this._uniformBuffer.addUniform("opacityParts", 4);
  68235. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  68236. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  68237. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  68238. this._uniformBuffer.addUniform("refractionRightColor", 4);
  68239. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  68240. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  68241. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  68242. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  68243. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  68244. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  68245. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  68246. this._uniformBuffer.addUniform("vReflectionSize", 3);
  68247. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  68248. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  68249. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  68250. this._uniformBuffer.addUniform("vBumpInfos", 3);
  68251. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  68252. this._uniformBuffer.addUniform("ambientMatrix", 16);
  68253. this._uniformBuffer.addUniform("opacityMatrix", 16);
  68254. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  68255. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  68256. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  68257. this._uniformBuffer.addUniform("specularMatrix", 16);
  68258. this._uniformBuffer.addUniform("bumpMatrix", 16);
  68259. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  68260. this._uniformBuffer.addUniform("refractionMatrix", 16);
  68261. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  68262. this._uniformBuffer.addUniform("vSpecularColor", 4);
  68263. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  68264. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  68265. this._uniformBuffer.addUniform("pointSize", 1);
  68266. this._uniformBuffer.create();
  68267. };
  68268. /**
  68269. * Unbinds the material from the mesh
  68270. */
  68271. StandardMaterial.prototype.unbind = function () {
  68272. if (this._activeEffect) {
  68273. var needFlag = false;
  68274. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  68275. this._activeEffect.setTexture("reflection2DSampler", null);
  68276. needFlag = true;
  68277. }
  68278. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  68279. this._activeEffect.setTexture("refraction2DSampler", null);
  68280. needFlag = true;
  68281. }
  68282. if (needFlag) {
  68283. this._markAllSubMeshesAsTexturesDirty();
  68284. }
  68285. }
  68286. _super.prototype.unbind.call(this);
  68287. };
  68288. /**
  68289. * Binds the submesh to this material by preparing the effect and shader to draw
  68290. * @param world defines the world transformation matrix
  68291. * @param mesh defines the mesh containing the submesh
  68292. * @param subMesh defines the submesh to bind the material to
  68293. */
  68294. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  68295. var scene = this.getScene();
  68296. var defines = subMesh._materialDefines;
  68297. if (!defines) {
  68298. return;
  68299. }
  68300. var effect = subMesh.effect;
  68301. if (!effect) {
  68302. return;
  68303. }
  68304. this._activeEffect = effect;
  68305. // Matrices
  68306. this.bindOnlyWorldMatrix(world);
  68307. // Normal Matrix
  68308. if (defines.OBJECTSPACE_NORMALMAP) {
  68309. world.toNormalMatrix(this._normalMatrix);
  68310. this.bindOnlyNormalMatrix(this._normalMatrix);
  68311. }
  68312. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  68313. // Bones
  68314. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  68315. if (mustRebind) {
  68316. this._uniformBuffer.bindToEffect(effect, "Material");
  68317. this.bindViewProjection(effect);
  68318. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  68319. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  68320. // Fresnel
  68321. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  68322. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  68323. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  68324. }
  68325. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  68326. 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);
  68327. }
  68328. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  68329. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  68330. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  68331. }
  68332. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  68333. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  68334. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  68335. }
  68336. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  68337. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  68338. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  68339. }
  68340. }
  68341. // Textures
  68342. if (scene.texturesEnabled) {
  68343. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68344. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  68345. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  68346. if (this._diffuseTexture.hasAlpha) {
  68347. effect.setFloat("alphaCutOff", this.alphaCutOff);
  68348. }
  68349. }
  68350. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  68351. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  68352. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  68353. }
  68354. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  68355. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  68356. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  68357. }
  68358. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  68359. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  68360. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  68361. if (this._reflectionTexture.boundingBoxSize) {
  68362. var cubeTexture = this._reflectionTexture;
  68363. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  68364. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  68365. }
  68366. }
  68367. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  68368. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  68369. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  68370. }
  68371. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  68372. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  68373. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  68374. }
  68375. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68376. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  68377. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  68378. }
  68379. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  68380. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  68381. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  68382. if (scene._mirroredCameraPosition) {
  68383. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  68384. }
  68385. else {
  68386. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  68387. }
  68388. }
  68389. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68390. var depth = 1.0;
  68391. if (!this._refractionTexture.isCube) {
  68392. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  68393. if (this._refractionTexture.depth) {
  68394. depth = this._refractionTexture.depth;
  68395. }
  68396. }
  68397. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  68398. }
  68399. }
  68400. // Point size
  68401. if (this.pointsCloud) {
  68402. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  68403. }
  68404. if (defines.SPECULARTERM) {
  68405. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  68406. }
  68407. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  68408. // Diffuse
  68409. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  68410. }
  68411. // Textures
  68412. if (scene.texturesEnabled) {
  68413. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68414. effect.setTexture("diffuseSampler", this._diffuseTexture);
  68415. }
  68416. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  68417. effect.setTexture("ambientSampler", this._ambientTexture);
  68418. }
  68419. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  68420. effect.setTexture("opacitySampler", this._opacityTexture);
  68421. }
  68422. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  68423. if (this._reflectionTexture.isCube) {
  68424. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  68425. }
  68426. else {
  68427. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  68428. }
  68429. }
  68430. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  68431. effect.setTexture("emissiveSampler", this._emissiveTexture);
  68432. }
  68433. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  68434. effect.setTexture("lightmapSampler", this._lightmapTexture);
  68435. }
  68436. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68437. effect.setTexture("specularSampler", this._specularTexture);
  68438. }
  68439. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  68440. effect.setTexture("bumpSampler", this._bumpTexture);
  68441. }
  68442. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68443. var depth = 1.0;
  68444. if (this._refractionTexture.isCube) {
  68445. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  68446. }
  68447. else {
  68448. effect.setTexture("refraction2DSampler", this._refractionTexture);
  68449. }
  68450. }
  68451. }
  68452. // Clip plane
  68453. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  68454. // Colors
  68455. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  68456. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  68457. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  68458. }
  68459. if (mustRebind || !this.isFrozen) {
  68460. // Lights
  68461. if (scene.lightsEnabled && !this._disableLighting) {
  68462. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  68463. }
  68464. // View
  68465. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  68466. this.bindView(effect);
  68467. }
  68468. // Fog
  68469. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  68470. // Morph targets
  68471. if (defines.NUM_MORPH_INFLUENCERS) {
  68472. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  68473. }
  68474. // Log. depth
  68475. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  68476. // image processing
  68477. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  68478. this._imageProcessingConfiguration.bind(this._activeEffect);
  68479. }
  68480. }
  68481. this._uniformBuffer.update();
  68482. this._afterBind(mesh, this._activeEffect);
  68483. };
  68484. /**
  68485. * Get the list of animatables in the material.
  68486. * @returns the list of animatables object used in the material
  68487. */
  68488. StandardMaterial.prototype.getAnimatables = function () {
  68489. var results = [];
  68490. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  68491. results.push(this._diffuseTexture);
  68492. }
  68493. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  68494. results.push(this._ambientTexture);
  68495. }
  68496. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  68497. results.push(this._opacityTexture);
  68498. }
  68499. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  68500. results.push(this._reflectionTexture);
  68501. }
  68502. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  68503. results.push(this._emissiveTexture);
  68504. }
  68505. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  68506. results.push(this._specularTexture);
  68507. }
  68508. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  68509. results.push(this._bumpTexture);
  68510. }
  68511. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  68512. results.push(this._lightmapTexture);
  68513. }
  68514. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  68515. results.push(this._refractionTexture);
  68516. }
  68517. return results;
  68518. };
  68519. /**
  68520. * Gets the active textures from the material
  68521. * @returns an array of textures
  68522. */
  68523. StandardMaterial.prototype.getActiveTextures = function () {
  68524. var activeTextures = _super.prototype.getActiveTextures.call(this);
  68525. if (this._diffuseTexture) {
  68526. activeTextures.push(this._diffuseTexture);
  68527. }
  68528. if (this._ambientTexture) {
  68529. activeTextures.push(this._ambientTexture);
  68530. }
  68531. if (this._opacityTexture) {
  68532. activeTextures.push(this._opacityTexture);
  68533. }
  68534. if (this._reflectionTexture) {
  68535. activeTextures.push(this._reflectionTexture);
  68536. }
  68537. if (this._emissiveTexture) {
  68538. activeTextures.push(this._emissiveTexture);
  68539. }
  68540. if (this._specularTexture) {
  68541. activeTextures.push(this._specularTexture);
  68542. }
  68543. if (this._bumpTexture) {
  68544. activeTextures.push(this._bumpTexture);
  68545. }
  68546. if (this._lightmapTexture) {
  68547. activeTextures.push(this._lightmapTexture);
  68548. }
  68549. if (this._refractionTexture) {
  68550. activeTextures.push(this._refractionTexture);
  68551. }
  68552. return activeTextures;
  68553. };
  68554. /**
  68555. * Specifies if the material uses a texture
  68556. * @param texture defines the texture to check against the material
  68557. * @returns a boolean specifying if the material uses the texture
  68558. */
  68559. StandardMaterial.prototype.hasTexture = function (texture) {
  68560. if (_super.prototype.hasTexture.call(this, texture)) {
  68561. return true;
  68562. }
  68563. if (this._diffuseTexture === texture) {
  68564. return true;
  68565. }
  68566. if (this._ambientTexture === texture) {
  68567. return true;
  68568. }
  68569. if (this._opacityTexture === texture) {
  68570. return true;
  68571. }
  68572. if (this._reflectionTexture === texture) {
  68573. return true;
  68574. }
  68575. if (this._emissiveTexture === texture) {
  68576. return true;
  68577. }
  68578. if (this._specularTexture === texture) {
  68579. return true;
  68580. }
  68581. if (this._bumpTexture === texture) {
  68582. return true;
  68583. }
  68584. if (this._lightmapTexture === texture) {
  68585. return true;
  68586. }
  68587. if (this._refractionTexture === texture) {
  68588. return true;
  68589. }
  68590. return false;
  68591. };
  68592. /**
  68593. * Disposes the material
  68594. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68595. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  68596. */
  68597. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  68598. if (forceDisposeTextures) {
  68599. if (this._diffuseTexture) {
  68600. this._diffuseTexture.dispose();
  68601. }
  68602. if (this._ambientTexture) {
  68603. this._ambientTexture.dispose();
  68604. }
  68605. if (this._opacityTexture) {
  68606. this._opacityTexture.dispose();
  68607. }
  68608. if (this._reflectionTexture) {
  68609. this._reflectionTexture.dispose();
  68610. }
  68611. if (this._emissiveTexture) {
  68612. this._emissiveTexture.dispose();
  68613. }
  68614. if (this._specularTexture) {
  68615. this._specularTexture.dispose();
  68616. }
  68617. if (this._bumpTexture) {
  68618. this._bumpTexture.dispose();
  68619. }
  68620. if (this._lightmapTexture) {
  68621. this._lightmapTexture.dispose();
  68622. }
  68623. if (this._refractionTexture) {
  68624. this._refractionTexture.dispose();
  68625. }
  68626. }
  68627. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  68628. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  68629. }
  68630. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  68631. };
  68632. /**
  68633. * Makes a duplicate of the material, and gives it a new name
  68634. * @param name defines the new name for the duplicated material
  68635. * @returns the cloned material
  68636. */
  68637. StandardMaterial.prototype.clone = function (name) {
  68638. var _this = this;
  68639. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  68640. result.name = name;
  68641. result.id = name;
  68642. return result;
  68643. };
  68644. /**
  68645. * Serializes this material in a JSON representation
  68646. * @returns the serialized material object
  68647. */
  68648. StandardMaterial.prototype.serialize = function () {
  68649. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  68650. };
  68651. /**
  68652. * Creates a standard material from parsed material data
  68653. * @param source defines the JSON representation of the material
  68654. * @param scene defines the hosting scene
  68655. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68656. * @returns a new standard material
  68657. */
  68658. StandardMaterial.Parse = function (source, scene, rootUrl) {
  68659. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  68660. };
  68661. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  68662. // Flags used to enable or disable a type of texture for all Standard Materials
  68663. /**
  68664. * Are diffuse textures enabled in the application.
  68665. */
  68666. get: function () {
  68667. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  68668. },
  68669. set: function (value) {
  68670. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  68671. },
  68672. enumerable: true,
  68673. configurable: true
  68674. });
  68675. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  68676. /**
  68677. * Are ambient textures enabled in the application.
  68678. */
  68679. get: function () {
  68680. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  68681. },
  68682. set: function (value) {
  68683. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  68684. },
  68685. enumerable: true,
  68686. configurable: true
  68687. });
  68688. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  68689. /**
  68690. * Are opacity textures enabled in the application.
  68691. */
  68692. get: function () {
  68693. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  68694. },
  68695. set: function (value) {
  68696. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  68697. },
  68698. enumerable: true,
  68699. configurable: true
  68700. });
  68701. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  68702. /**
  68703. * Are reflection textures enabled in the application.
  68704. */
  68705. get: function () {
  68706. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  68707. },
  68708. set: function (value) {
  68709. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  68710. },
  68711. enumerable: true,
  68712. configurable: true
  68713. });
  68714. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  68715. /**
  68716. * Are emissive textures enabled in the application.
  68717. */
  68718. get: function () {
  68719. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  68720. },
  68721. set: function (value) {
  68722. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  68723. },
  68724. enumerable: true,
  68725. configurable: true
  68726. });
  68727. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  68728. /**
  68729. * Are specular textures enabled in the application.
  68730. */
  68731. get: function () {
  68732. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  68733. },
  68734. set: function (value) {
  68735. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  68736. },
  68737. enumerable: true,
  68738. configurable: true
  68739. });
  68740. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  68741. /**
  68742. * Are bump textures enabled in the application.
  68743. */
  68744. get: function () {
  68745. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  68746. },
  68747. set: function (value) {
  68748. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  68749. },
  68750. enumerable: true,
  68751. configurable: true
  68752. });
  68753. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  68754. /**
  68755. * Are lightmap textures enabled in the application.
  68756. */
  68757. get: function () {
  68758. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  68759. },
  68760. set: function (value) {
  68761. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  68762. },
  68763. enumerable: true,
  68764. configurable: true
  68765. });
  68766. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  68767. /**
  68768. * Are refraction textures enabled in the application.
  68769. */
  68770. get: function () {
  68771. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  68772. },
  68773. set: function (value) {
  68774. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  68775. },
  68776. enumerable: true,
  68777. configurable: true
  68778. });
  68779. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  68780. /**
  68781. * Are color grading textures enabled in the application.
  68782. */
  68783. get: function () {
  68784. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  68785. },
  68786. set: function (value) {
  68787. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  68788. },
  68789. enumerable: true,
  68790. configurable: true
  68791. });
  68792. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  68793. /**
  68794. * Are fresnels enabled in the application.
  68795. */
  68796. get: function () {
  68797. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  68798. },
  68799. set: function (value) {
  68800. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  68801. },
  68802. enumerable: true,
  68803. configurable: true
  68804. });
  68805. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  68807. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  68808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  68810. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  68811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  68813. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  68814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68816. ], StandardMaterial.prototype, "ambientTexture", void 0);
  68817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  68819. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  68820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  68822. ], StandardMaterial.prototype, "opacityTexture", void 0);
  68823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  68825. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  68826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68828. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  68829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  68831. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  68832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68834. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  68835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  68837. ], StandardMaterial.prototype, "_specularTexture", void 0);
  68838. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68839. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68840. ], StandardMaterial.prototype, "specularTexture", void 0);
  68841. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  68843. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  68844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68846. ], StandardMaterial.prototype, "bumpTexture", void 0);
  68847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  68849. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  68850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68852. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  68853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  68855. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  68856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68858. ], StandardMaterial.prototype, "refractionTexture", void 0);
  68859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  68861. ], StandardMaterial.prototype, "ambientColor", void 0);
  68862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  68864. ], StandardMaterial.prototype, "diffuseColor", void 0);
  68865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  68867. ], StandardMaterial.prototype, "specularColor", void 0);
  68868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  68870. ], StandardMaterial.prototype, "emissiveColor", void 0);
  68871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68873. ], StandardMaterial.prototype, "specularPower", void 0);
  68874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  68876. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  68877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68879. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  68880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  68882. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  68883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68885. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  68886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  68888. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  68889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68891. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  68892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  68894. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  68895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68897. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  68898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  68900. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  68901. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68903. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  68904. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  68906. ], StandardMaterial.prototype, "_disableLighting", void 0);
  68907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  68909. ], StandardMaterial.prototype, "disableLighting", void 0);
  68910. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68911. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  68912. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  68913. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68914. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68915. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  68916. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68917. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  68918. ], StandardMaterial.prototype, "_useParallax", void 0);
  68919. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68920. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68921. ], StandardMaterial.prototype, "useParallax", void 0);
  68922. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  68924. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  68925. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68927. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  68928. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68930. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  68931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  68933. ], StandardMaterial.prototype, "_roughness", void 0);
  68934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68936. ], StandardMaterial.prototype, "roughness", void 0);
  68937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68939. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  68940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68942. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  68943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68945. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  68946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  68948. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  68949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68951. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  68952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  68954. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  68955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68957. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  68958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  68960. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  68961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  68963. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  68964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  68966. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  68967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68969. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  68970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  68972. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  68973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68975. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  68976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  68978. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  68979. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68981. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  68982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  68984. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  68985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68987. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  68988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  68990. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  68991. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68993. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  68994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  68996. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  68997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  68999. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  69000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  69002. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  69003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69005. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  69006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  69008. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  69009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69011. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  69012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  69014. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  69015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69017. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  69018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69020. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  69021. return StandardMaterial;
  69022. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  69023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  69024. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  69025. return new StandardMaterial("default material", scene);
  69026. };
  69027. /***/ }),
  69028. /***/ "./Materials/uniformBuffer.ts":
  69029. /*!************************************!*\
  69030. !*** ./Materials/uniformBuffer.ts ***!
  69031. \************************************/
  69032. /*! exports provided: UniformBuffer */
  69033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69034. "use strict";
  69035. __webpack_require__.r(__webpack_exports__);
  69036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  69037. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  69038. /**
  69039. * Uniform buffer objects.
  69040. *
  69041. * Handles blocks of uniform on the GPU.
  69042. *
  69043. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  69044. *
  69045. * For more information, please refer to :
  69046. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  69047. */
  69048. var UniformBuffer = /** @class */ (function () {
  69049. /**
  69050. * Instantiates a new Uniform buffer objects.
  69051. *
  69052. * Handles blocks of uniform on the GPU.
  69053. *
  69054. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  69055. *
  69056. * For more information, please refer to :
  69057. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  69058. * @param engine Define the engine the buffer is associated with
  69059. * @param data Define the data contained in the buffer
  69060. * @param dynamic Define if the buffer is updatable
  69061. */
  69062. function UniformBuffer(engine, data, dynamic) {
  69063. this._engine = engine;
  69064. this._noUBO = !engine.supportsUniformBuffers;
  69065. this._dynamic = dynamic;
  69066. this._data = data || [];
  69067. this._uniformLocations = {};
  69068. this._uniformSizes = {};
  69069. this._uniformLocationPointer = 0;
  69070. this._needSync = false;
  69071. if (this._noUBO) {
  69072. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  69073. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  69074. this.updateFloat = this._updateFloatForEffect;
  69075. this.updateFloat2 = this._updateFloat2ForEffect;
  69076. this.updateFloat3 = this._updateFloat3ForEffect;
  69077. this.updateFloat4 = this._updateFloat4ForEffect;
  69078. this.updateMatrix = this._updateMatrixForEffect;
  69079. this.updateVector3 = this._updateVector3ForEffect;
  69080. this.updateVector4 = this._updateVector4ForEffect;
  69081. this.updateColor3 = this._updateColor3ForEffect;
  69082. this.updateColor4 = this._updateColor4ForEffect;
  69083. }
  69084. else {
  69085. this._engine._uniformBuffers.push(this);
  69086. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  69087. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  69088. this.updateFloat = this._updateFloatForUniform;
  69089. this.updateFloat2 = this._updateFloat2ForUniform;
  69090. this.updateFloat3 = this._updateFloat3ForUniform;
  69091. this.updateFloat4 = this._updateFloat4ForUniform;
  69092. this.updateMatrix = this._updateMatrixForUniform;
  69093. this.updateVector3 = this._updateVector3ForUniform;
  69094. this.updateVector4 = this._updateVector4ForUniform;
  69095. this.updateColor3 = this._updateColor3ForUniform;
  69096. this.updateColor4 = this._updateColor4ForUniform;
  69097. }
  69098. }
  69099. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  69100. /**
  69101. * Indicates if the buffer is using the WebGL2 UBO implementation,
  69102. * or just falling back on setUniformXXX calls.
  69103. */
  69104. get: function () {
  69105. return !this._noUBO;
  69106. },
  69107. enumerable: true,
  69108. configurable: true
  69109. });
  69110. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  69111. /**
  69112. * Indicates if the WebGL underlying uniform buffer is in sync
  69113. * with the javascript cache data.
  69114. */
  69115. get: function () {
  69116. return !this._needSync;
  69117. },
  69118. enumerable: true,
  69119. configurable: true
  69120. });
  69121. /**
  69122. * Indicates if the WebGL underlying uniform buffer is dynamic.
  69123. * Also, a dynamic UniformBuffer will disable cache verification and always
  69124. * update the underlying WebGL uniform buffer to the GPU.
  69125. * @returns if Dynamic, otherwise false
  69126. */
  69127. UniformBuffer.prototype.isDynamic = function () {
  69128. return this._dynamic !== undefined;
  69129. };
  69130. /**
  69131. * The data cache on JS side.
  69132. * @returns the underlying data as a float array
  69133. */
  69134. UniformBuffer.prototype.getData = function () {
  69135. return this._bufferData;
  69136. };
  69137. /**
  69138. * The underlying WebGL Uniform buffer.
  69139. * @returns the webgl buffer
  69140. */
  69141. UniformBuffer.prototype.getBuffer = function () {
  69142. return this._buffer;
  69143. };
  69144. /**
  69145. * std140 layout specifies how to align data within an UBO structure.
  69146. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  69147. * for specs.
  69148. */
  69149. UniformBuffer.prototype._fillAlignment = function (size) {
  69150. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  69151. // and 4x4 matrices
  69152. // TODO : change if other types are used
  69153. var alignment;
  69154. if (size <= 2) {
  69155. alignment = size;
  69156. }
  69157. else {
  69158. alignment = 4;
  69159. }
  69160. if ((this._uniformLocationPointer % alignment) !== 0) {
  69161. var oldPointer = this._uniformLocationPointer;
  69162. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  69163. var diff = this._uniformLocationPointer - oldPointer;
  69164. for (var i = 0; i < diff; i++) {
  69165. this._data.push(0);
  69166. }
  69167. }
  69168. };
  69169. /**
  69170. * Adds an uniform in the buffer.
  69171. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  69172. * for the layout to be correct !
  69173. * @param name Name of the uniform, as used in the uniform block in the shader.
  69174. * @param size Data size, or data directly.
  69175. */
  69176. UniformBuffer.prototype.addUniform = function (name, size) {
  69177. if (this._noUBO) {
  69178. return;
  69179. }
  69180. if (this._uniformLocations[name] !== undefined) {
  69181. // Already existing uniform
  69182. return;
  69183. }
  69184. // This function must be called in the order of the shader layout !
  69185. // size can be the size of the uniform, or data directly
  69186. var data;
  69187. if (size instanceof Array) {
  69188. data = size;
  69189. size = data.length;
  69190. }
  69191. else {
  69192. size = size;
  69193. data = [];
  69194. // Fill with zeros
  69195. for (var i = 0; i < size; i++) {
  69196. data.push(0);
  69197. }
  69198. }
  69199. this._fillAlignment(size);
  69200. this._uniformSizes[name] = size;
  69201. this._uniformLocations[name] = this._uniformLocationPointer;
  69202. this._uniformLocationPointer += size;
  69203. for (var i = 0; i < size; i++) {
  69204. this._data.push(data[i]);
  69205. }
  69206. this._needSync = true;
  69207. };
  69208. /**
  69209. * Adds a Matrix 4x4 to the uniform buffer.
  69210. * @param name Name of the uniform, as used in the uniform block in the shader.
  69211. * @param mat A 4x4 matrix.
  69212. */
  69213. UniformBuffer.prototype.addMatrix = function (name, mat) {
  69214. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  69215. };
  69216. /**
  69217. * Adds a vec2 to the uniform buffer.
  69218. * @param name Name of the uniform, as used in the uniform block in the shader.
  69219. * @param x Define the x component value of the vec2
  69220. * @param y Define the y component value of the vec2
  69221. */
  69222. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  69223. var temp = [x, y];
  69224. this.addUniform(name, temp);
  69225. };
  69226. /**
  69227. * Adds a vec3 to the uniform buffer.
  69228. * @param name Name of the uniform, as used in the uniform block in the shader.
  69229. * @param x Define the x component value of the vec3
  69230. * @param y Define the y component value of the vec3
  69231. * @param z Define the z component value of the vec3
  69232. */
  69233. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  69234. var temp = [x, y, z];
  69235. this.addUniform(name, temp);
  69236. };
  69237. /**
  69238. * Adds a vec3 to the uniform buffer.
  69239. * @param name Name of the uniform, as used in the uniform block in the shader.
  69240. * @param color Define the vec3 from a Color
  69241. */
  69242. UniformBuffer.prototype.addColor3 = function (name, color) {
  69243. var temp = new Array();
  69244. color.toArray(temp);
  69245. this.addUniform(name, temp);
  69246. };
  69247. /**
  69248. * Adds a vec4 to the uniform buffer.
  69249. * @param name Name of the uniform, as used in the uniform block in the shader.
  69250. * @param color Define the rgb components from a Color
  69251. * @param alpha Define the a component of the vec4
  69252. */
  69253. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  69254. var temp = new Array();
  69255. color.toArray(temp);
  69256. temp.push(alpha);
  69257. this.addUniform(name, temp);
  69258. };
  69259. /**
  69260. * Adds a vec3 to the uniform buffer.
  69261. * @param name Name of the uniform, as used in the uniform block in the shader.
  69262. * @param vector Define the vec3 components from a Vector
  69263. */
  69264. UniformBuffer.prototype.addVector3 = function (name, vector) {
  69265. var temp = new Array();
  69266. vector.toArray(temp);
  69267. this.addUniform(name, temp);
  69268. };
  69269. /**
  69270. * Adds a Matrix 3x3 to the uniform buffer.
  69271. * @param name Name of the uniform, as used in the uniform block in the shader.
  69272. */
  69273. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  69274. this.addUniform(name, 12);
  69275. };
  69276. /**
  69277. * Adds a Matrix 2x2 to the uniform buffer.
  69278. * @param name Name of the uniform, as used in the uniform block in the shader.
  69279. */
  69280. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  69281. this.addUniform(name, 8);
  69282. };
  69283. /**
  69284. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  69285. */
  69286. UniformBuffer.prototype.create = function () {
  69287. if (this._noUBO) {
  69288. return;
  69289. }
  69290. if (this._buffer) {
  69291. return; // nothing to do
  69292. }
  69293. // See spec, alignment must be filled as a vec4
  69294. this._fillAlignment(4);
  69295. this._bufferData = new Float32Array(this._data);
  69296. this._rebuild();
  69297. this._needSync = true;
  69298. };
  69299. /** @hidden */
  69300. UniformBuffer.prototype._rebuild = function () {
  69301. if (this._noUBO) {
  69302. return;
  69303. }
  69304. if (this._dynamic) {
  69305. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  69306. }
  69307. else {
  69308. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  69309. }
  69310. };
  69311. /**
  69312. * Updates the WebGL Uniform Buffer on the GPU.
  69313. * If the `dynamic` flag is set to true, no cache comparison is done.
  69314. * Otherwise, the buffer will be updated only if the cache differs.
  69315. */
  69316. UniformBuffer.prototype.update = function () {
  69317. if (!this._buffer) {
  69318. this.create();
  69319. return;
  69320. }
  69321. if (!this._dynamic && !this._needSync) {
  69322. return;
  69323. }
  69324. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  69325. this._needSync = false;
  69326. };
  69327. /**
  69328. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  69329. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  69330. * @param data Define the flattened data
  69331. * @param size Define the size of the data.
  69332. */
  69333. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  69334. var location = this._uniformLocations[uniformName];
  69335. if (location === undefined) {
  69336. if (this._buffer) {
  69337. // Cannot add an uniform if the buffer is already created
  69338. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  69339. return;
  69340. }
  69341. this.addUniform(uniformName, size);
  69342. location = this._uniformLocations[uniformName];
  69343. }
  69344. if (!this._buffer) {
  69345. this.create();
  69346. }
  69347. if (!this._dynamic) {
  69348. // Cache for static uniform buffers
  69349. var changed = false;
  69350. for (var i = 0; i < size; i++) {
  69351. if (this._bufferData[location + i] !== data[i]) {
  69352. changed = true;
  69353. this._bufferData[location + i] = data[i];
  69354. }
  69355. }
  69356. this._needSync = this._needSync || changed;
  69357. }
  69358. else {
  69359. // No cache for dynamic
  69360. for (var i = 0; i < size; i++) {
  69361. this._bufferData[location + i] = data[i];
  69362. }
  69363. }
  69364. };
  69365. // Update methods
  69366. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  69367. // To match std140, matrix must be realigned
  69368. for (var i = 0; i < 3; i++) {
  69369. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  69370. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  69371. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  69372. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  69373. }
  69374. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  69375. };
  69376. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  69377. this._currentEffect.setMatrix3x3(name, matrix);
  69378. };
  69379. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  69380. this._currentEffect.setMatrix2x2(name, matrix);
  69381. };
  69382. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  69383. // To match std140, matrix must be realigned
  69384. for (var i = 0; i < 2; i++) {
  69385. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  69386. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  69387. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  69388. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  69389. }
  69390. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  69391. };
  69392. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  69393. this._currentEffect.setFloat(name, x);
  69394. };
  69395. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  69396. UniformBuffer._tempBuffer[0] = x;
  69397. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  69398. };
  69399. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  69400. if (suffix === void 0) { suffix = ""; }
  69401. this._currentEffect.setFloat2(name + suffix, x, y);
  69402. };
  69403. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  69404. UniformBuffer._tempBuffer[0] = x;
  69405. UniformBuffer._tempBuffer[1] = y;
  69406. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  69407. };
  69408. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  69409. if (suffix === void 0) { suffix = ""; }
  69410. this._currentEffect.setFloat3(name + suffix, x, y, z);
  69411. };
  69412. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  69413. UniformBuffer._tempBuffer[0] = x;
  69414. UniformBuffer._tempBuffer[1] = y;
  69415. UniformBuffer._tempBuffer[2] = z;
  69416. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69417. };
  69418. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  69419. if (suffix === void 0) { suffix = ""; }
  69420. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  69421. };
  69422. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  69423. UniformBuffer._tempBuffer[0] = x;
  69424. UniformBuffer._tempBuffer[1] = y;
  69425. UniformBuffer._tempBuffer[2] = z;
  69426. UniformBuffer._tempBuffer[3] = w;
  69427. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69428. };
  69429. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  69430. this._currentEffect.setMatrix(name, mat);
  69431. };
  69432. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  69433. this.updateUniform(name, mat.toArray(), 16);
  69434. };
  69435. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  69436. this._currentEffect.setVector3(name, vector);
  69437. };
  69438. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  69439. vector.toArray(UniformBuffer._tempBuffer);
  69440. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69441. };
  69442. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  69443. this._currentEffect.setVector4(name, vector);
  69444. };
  69445. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  69446. vector.toArray(UniformBuffer._tempBuffer);
  69447. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69448. };
  69449. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  69450. if (suffix === void 0) { suffix = ""; }
  69451. this._currentEffect.setColor3(name + suffix, color);
  69452. };
  69453. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  69454. color.toArray(UniformBuffer._tempBuffer);
  69455. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69456. };
  69457. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  69458. if (suffix === void 0) { suffix = ""; }
  69459. this._currentEffect.setColor4(name + suffix, color, alpha);
  69460. };
  69461. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  69462. color.toArray(UniformBuffer._tempBuffer);
  69463. UniformBuffer._tempBuffer[3] = alpha;
  69464. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69465. };
  69466. /**
  69467. * Sets a sampler uniform on the effect.
  69468. * @param name Define the name of the sampler.
  69469. * @param texture Define the texture to set in the sampler
  69470. */
  69471. UniformBuffer.prototype.setTexture = function (name, texture) {
  69472. this._currentEffect.setTexture(name, texture);
  69473. };
  69474. /**
  69475. * Directly updates the value of the uniform in the cache AND on the GPU.
  69476. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  69477. * @param data Define the flattened data
  69478. */
  69479. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  69480. this.updateUniform(uniformName, data, data.length);
  69481. this.update();
  69482. };
  69483. /**
  69484. * Binds this uniform buffer to an effect.
  69485. * @param effect Define the effect to bind the buffer to
  69486. * @param name Name of the uniform block in the shader.
  69487. */
  69488. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  69489. this._currentEffect = effect;
  69490. if (this._noUBO || !this._buffer) {
  69491. return;
  69492. }
  69493. effect.bindUniformBuffer(this._buffer, name);
  69494. };
  69495. /**
  69496. * Disposes the uniform buffer.
  69497. */
  69498. UniformBuffer.prototype.dispose = function () {
  69499. if (this._noUBO) {
  69500. return;
  69501. }
  69502. var uniformBuffers = this._engine._uniformBuffers;
  69503. var index = uniformBuffers.indexOf(this);
  69504. if (index !== -1) {
  69505. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  69506. uniformBuffers.pop();
  69507. }
  69508. if (!this._buffer) {
  69509. return;
  69510. }
  69511. if (this._engine._releaseBuffer(this._buffer)) {
  69512. this._buffer = null;
  69513. }
  69514. };
  69515. // Pool for avoiding memory leaks
  69516. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  69517. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  69518. return UniformBuffer;
  69519. }());
  69520. /***/ }),
  69521. /***/ "./Maths/index.ts":
  69522. /*!************************!*\
  69523. !*** ./Maths/index.ts ***!
  69524. \************************/
  69525. /*! 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 */
  69526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69527. "use strict";
  69528. __webpack_require__.r(__webpack_exports__);
  69529. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  69530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  69531. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  69532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  69533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  69534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  69535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  69536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  69537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  69538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  69539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  69540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  69541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  69542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  69543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  69544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  69545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  69546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  69547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  69548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  69549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  69550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  69551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  69552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  69553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  69554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  69555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  69556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  69557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  69558. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  69559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  69560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  69561. /***/ }),
  69562. /***/ "./Maths/math.scalar.ts":
  69563. /*!******************************!*\
  69564. !*** ./Maths/math.scalar.ts ***!
  69565. \******************************/
  69566. /*! exports provided: Scalar */
  69567. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69568. "use strict";
  69569. __webpack_require__.r(__webpack_exports__);
  69570. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  69571. /**
  69572. * Scalar computation library
  69573. */
  69574. var Scalar = /** @class */ (function () {
  69575. function Scalar() {
  69576. }
  69577. /**
  69578. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69579. * @param a number
  69580. * @param b number
  69581. * @param epsilon (default = 1.401298E-45)
  69582. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69583. */
  69584. Scalar.WithinEpsilon = function (a, b, epsilon) {
  69585. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  69586. var num = a - b;
  69587. return -epsilon <= num && num <= epsilon;
  69588. };
  69589. /**
  69590. * Returns a string : the upper case translation of the number i to hexadecimal.
  69591. * @param i number
  69592. * @returns the upper case translation of the number i to hexadecimal.
  69593. */
  69594. Scalar.ToHex = function (i) {
  69595. var str = i.toString(16);
  69596. if (i <= 15) {
  69597. return ("0" + str).toUpperCase();
  69598. }
  69599. return str.toUpperCase();
  69600. };
  69601. /**
  69602. * Returns -1 if value is negative and +1 is value is positive.
  69603. * @param value the value
  69604. * @returns the value itself if it's equal to zero.
  69605. */
  69606. Scalar.Sign = function (value) {
  69607. value = +value; // convert to a number
  69608. if (value === 0 || isNaN(value)) {
  69609. return value;
  69610. }
  69611. return value > 0 ? 1 : -1;
  69612. };
  69613. /**
  69614. * Returns the value itself if it's between min and max.
  69615. * Returns min if the value is lower than min.
  69616. * Returns max if the value is greater than max.
  69617. * @param value the value to clmap
  69618. * @param min the min value to clamp to (default: 0)
  69619. * @param max the max value to clamp to (default: 1)
  69620. * @returns the clamped value
  69621. */
  69622. Scalar.Clamp = function (value, min, max) {
  69623. if (min === void 0) { min = 0; }
  69624. if (max === void 0) { max = 1; }
  69625. return Math.min(max, Math.max(min, value));
  69626. };
  69627. /**
  69628. * the log2 of value.
  69629. * @param value the value to compute log2 of
  69630. * @returns the log2 of value.
  69631. */
  69632. Scalar.Log2 = function (value) {
  69633. return Math.log(value) * Math.LOG2E;
  69634. };
  69635. /**
  69636. * Loops the value, so that it is never larger than length and never smaller than 0.
  69637. *
  69638. * This is similar to the modulo operator but it works with floating point numbers.
  69639. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69640. * With t = 5 and length = 2.5, the result would be 0.0.
  69641. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69642. * @param value the value
  69643. * @param length the length
  69644. * @returns the looped value
  69645. */
  69646. Scalar.Repeat = function (value, length) {
  69647. return value - Math.floor(value / length) * length;
  69648. };
  69649. /**
  69650. * Normalize the value between 0.0 and 1.0 using min and max values
  69651. * @param value value to normalize
  69652. * @param min max to normalize between
  69653. * @param max min to normalize between
  69654. * @returns the normalized value
  69655. */
  69656. Scalar.Normalize = function (value, min, max) {
  69657. return (value - min) / (max - min);
  69658. };
  69659. /**
  69660. * Denormalize the value from 0.0 and 1.0 using min and max values
  69661. * @param normalized value to denormalize
  69662. * @param min max to denormalize between
  69663. * @param max min to denormalize between
  69664. * @returns the denormalized value
  69665. */
  69666. Scalar.Denormalize = function (normalized, min, max) {
  69667. return (normalized * (max - min) + min);
  69668. };
  69669. /**
  69670. * Calculates the shortest difference between two given angles given in degrees.
  69671. * @param current current angle in degrees
  69672. * @param target target angle in degrees
  69673. * @returns the delta
  69674. */
  69675. Scalar.DeltaAngle = function (current, target) {
  69676. var num = Scalar.Repeat(target - current, 360.0);
  69677. if (num > 180.0) {
  69678. num -= 360.0;
  69679. }
  69680. return num;
  69681. };
  69682. /**
  69683. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69684. * @param tx value
  69685. * @param length length
  69686. * @returns The returned value will move back and forth between 0 and length
  69687. */
  69688. Scalar.PingPong = function (tx, length) {
  69689. var t = Scalar.Repeat(tx, length * 2.0);
  69690. return length - Math.abs(t - length);
  69691. };
  69692. /**
  69693. * Interpolates between min and max with smoothing at the limits.
  69694. *
  69695. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69696. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69697. * @param from from
  69698. * @param to to
  69699. * @param tx value
  69700. * @returns the smooth stepped value
  69701. */
  69702. Scalar.SmoothStep = function (from, to, tx) {
  69703. var t = Scalar.Clamp(tx);
  69704. t = -2.0 * t * t * t + 3.0 * t * t;
  69705. return to * t + from * (1.0 - t);
  69706. };
  69707. /**
  69708. * Moves a value current towards target.
  69709. *
  69710. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69711. * Negative values of maxDelta pushes the value away from target.
  69712. * @param current current value
  69713. * @param target target value
  69714. * @param maxDelta max distance to move
  69715. * @returns resulting value
  69716. */
  69717. Scalar.MoveTowards = function (current, target, maxDelta) {
  69718. var result = 0;
  69719. if (Math.abs(target - current) <= maxDelta) {
  69720. result = target;
  69721. }
  69722. else {
  69723. result = current + Scalar.Sign(target - current) * maxDelta;
  69724. }
  69725. return result;
  69726. };
  69727. /**
  69728. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69729. *
  69730. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69731. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69732. * @param current current value
  69733. * @param target target value
  69734. * @param maxDelta max distance to move
  69735. * @returns resulting angle
  69736. */
  69737. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  69738. var num = Scalar.DeltaAngle(current, target);
  69739. var result = 0;
  69740. if (-maxDelta < num && num < maxDelta) {
  69741. result = target;
  69742. }
  69743. else {
  69744. target = current + num;
  69745. result = Scalar.MoveTowards(current, target, maxDelta);
  69746. }
  69747. return result;
  69748. };
  69749. /**
  69750. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69751. * @param start start value
  69752. * @param end target value
  69753. * @param amount amount to lerp between
  69754. * @returns the lerped value
  69755. */
  69756. Scalar.Lerp = function (start, end, amount) {
  69757. return start + ((end - start) * amount);
  69758. };
  69759. /**
  69760. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69761. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69762. * @param start start value
  69763. * @param end target value
  69764. * @param amount amount to lerp between
  69765. * @returns the lerped value
  69766. */
  69767. Scalar.LerpAngle = function (start, end, amount) {
  69768. var num = Scalar.Repeat(end - start, 360.0);
  69769. if (num > 180.0) {
  69770. num -= 360.0;
  69771. }
  69772. return start + num * Scalar.Clamp(amount);
  69773. };
  69774. /**
  69775. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69776. * @param a start value
  69777. * @param b target value
  69778. * @param value value between a and b
  69779. * @returns the inverseLerp value
  69780. */
  69781. Scalar.InverseLerp = function (a, b, value) {
  69782. var result = 0;
  69783. if (a != b) {
  69784. result = Scalar.Clamp((value - a) / (b - a));
  69785. }
  69786. else {
  69787. result = 0.0;
  69788. }
  69789. return result;
  69790. };
  69791. /**
  69792. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69793. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69794. * @param value1 spline value
  69795. * @param tangent1 spline value
  69796. * @param value2 spline value
  69797. * @param tangent2 spline value
  69798. * @param amount input value
  69799. * @returns hermite result
  69800. */
  69801. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69802. var squared = amount * amount;
  69803. var cubed = amount * squared;
  69804. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69805. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69806. var part3 = (cubed - (2.0 * squared)) + amount;
  69807. var part4 = cubed - squared;
  69808. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  69809. };
  69810. /**
  69811. * Returns a random float number between and min and max values
  69812. * @param min min value of random
  69813. * @param max max value of random
  69814. * @returns random value
  69815. */
  69816. Scalar.RandomRange = function (min, max) {
  69817. if (min === max) {
  69818. return min;
  69819. }
  69820. return ((Math.random() * (max - min)) + min);
  69821. };
  69822. /**
  69823. * This function returns percentage of a number in a given range.
  69824. *
  69825. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69826. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69827. * @param number to convert to percentage
  69828. * @param min min range
  69829. * @param max max range
  69830. * @returns the percentage
  69831. */
  69832. Scalar.RangeToPercent = function (number, min, max) {
  69833. return ((number - min) / (max - min));
  69834. };
  69835. /**
  69836. * This function returns number that corresponds to the percentage in a given range.
  69837. *
  69838. * PercentToRange(0.34,0,100) will return 34.
  69839. * @param percent to convert to number
  69840. * @param min min range
  69841. * @param max max range
  69842. * @returns the number
  69843. */
  69844. Scalar.PercentToRange = function (percent, min, max) {
  69845. return ((max - min) * percent + min);
  69846. };
  69847. /**
  69848. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69849. * @param angle The angle to normalize in radian.
  69850. * @return The converted angle.
  69851. */
  69852. Scalar.NormalizeRadians = function (angle) {
  69853. // More precise but slower version kept for reference.
  69854. // angle = angle % Tools.TwoPi;
  69855. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  69856. //if (angle > Math.PI) {
  69857. // angle -= Tools.TwoPi;
  69858. //}
  69859. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  69860. return angle;
  69861. };
  69862. /**
  69863. * Two pi constants convenient for computation.
  69864. */
  69865. Scalar.TwoPi = Math.PI * 2;
  69866. return Scalar;
  69867. }());
  69868. /***/ }),
  69869. /***/ "./Maths/math.ts":
  69870. /*!***********************!*\
  69871. !*** ./Maths/math.ts ***!
  69872. \***********************/
  69873. /*! 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 */
  69874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69875. "use strict";
  69876. __webpack_require__.r(__webpack_exports__);
  69877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  69878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  69879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  69880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  69881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  69882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  69883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  69884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  69885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  69886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  69887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  69888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  69889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  69890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  69891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  69892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  69893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  69894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  69895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  69896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  69897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  69898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  69899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  69900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  69901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  69902. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  69903. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  69904. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  69905. /**
  69906. * Constant used to convert a value to gamma space
  69907. * @ignorenaming
  69908. */
  69909. var ToGammaSpace = 1 / 2.2;
  69910. /**
  69911. * Constant used to convert a value to linear space
  69912. * @ignorenaming
  69913. */
  69914. var ToLinearSpace = 2.2;
  69915. /**
  69916. * Constant used to define the minimal number value in Babylon.js
  69917. * @ignorenaming
  69918. */
  69919. var Epsilon = 0.001;
  69920. /**
  69921. * Class used to hold a RBG color
  69922. */
  69923. var Color3 = /** @class */ (function () {
  69924. /**
  69925. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69926. * @param r defines the red component (between 0 and 1, default is 0)
  69927. * @param g defines the green component (between 0 and 1, default is 0)
  69928. * @param b defines the blue component (between 0 and 1, default is 0)
  69929. */
  69930. function Color3(
  69931. /**
  69932. * Defines the red component (between 0 and 1, default is 0)
  69933. */
  69934. r,
  69935. /**
  69936. * Defines the green component (between 0 and 1, default is 0)
  69937. */
  69938. g,
  69939. /**
  69940. * Defines the blue component (between 0 and 1, default is 0)
  69941. */
  69942. b) {
  69943. if (r === void 0) { r = 0; }
  69944. if (g === void 0) { g = 0; }
  69945. if (b === void 0) { b = 0; }
  69946. this.r = r;
  69947. this.g = g;
  69948. this.b = b;
  69949. }
  69950. /**
  69951. * Creates a string with the Color3 current values
  69952. * @returns the string representation of the Color3 object
  69953. */
  69954. Color3.prototype.toString = function () {
  69955. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  69956. };
  69957. /**
  69958. * Returns the string "Color3"
  69959. * @returns "Color3"
  69960. */
  69961. Color3.prototype.getClassName = function () {
  69962. return "Color3";
  69963. };
  69964. /**
  69965. * Compute the Color3 hash code
  69966. * @returns an unique number that can be used to hash Color3 objects
  69967. */
  69968. Color3.prototype.getHashCode = function () {
  69969. var hash = this.r || 0;
  69970. hash = (hash * 397) ^ (this.g || 0);
  69971. hash = (hash * 397) ^ (this.b || 0);
  69972. return hash;
  69973. };
  69974. // Operators
  69975. /**
  69976. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69977. * @param array defines the array where to store the r,g,b components
  69978. * @param index defines an optional index in the target array to define where to start storing values
  69979. * @returns the current Color3 object
  69980. */
  69981. Color3.prototype.toArray = function (array, index) {
  69982. if (index === void 0) { index = 0; }
  69983. array[index] = this.r;
  69984. array[index + 1] = this.g;
  69985. array[index + 2] = this.b;
  69986. return this;
  69987. };
  69988. /**
  69989. * Returns a new Color4 object from the current Color3 and the given alpha
  69990. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69991. * @returns a new Color4 object
  69992. */
  69993. Color3.prototype.toColor4 = function (alpha) {
  69994. if (alpha === void 0) { alpha = 1; }
  69995. return new Color4(this.r, this.g, this.b, alpha);
  69996. };
  69997. /**
  69998. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69999. * @returns the new array
  70000. */
  70001. Color3.prototype.asArray = function () {
  70002. var result = new Array();
  70003. this.toArray(result, 0);
  70004. return result;
  70005. };
  70006. /**
  70007. * Returns the luminance value
  70008. * @returns a float value
  70009. */
  70010. Color3.prototype.toLuminance = function () {
  70011. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  70012. };
  70013. /**
  70014. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70015. * @param otherColor defines the second operand
  70016. * @returns the new Color3 object
  70017. */
  70018. Color3.prototype.multiply = function (otherColor) {
  70019. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  70020. };
  70021. /**
  70022. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70023. * @param otherColor defines the second operand
  70024. * @param result defines the Color3 object where to store the result
  70025. * @returns the current Color3
  70026. */
  70027. Color3.prototype.multiplyToRef = function (otherColor, result) {
  70028. result.r = this.r * otherColor.r;
  70029. result.g = this.g * otherColor.g;
  70030. result.b = this.b * otherColor.b;
  70031. return this;
  70032. };
  70033. /**
  70034. * Determines equality between Color3 objects
  70035. * @param otherColor defines the second operand
  70036. * @returns true if the rgb values are equal to the given ones
  70037. */
  70038. Color3.prototype.equals = function (otherColor) {
  70039. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  70040. };
  70041. /**
  70042. * Determines equality between the current Color3 object and a set of r,b,g values
  70043. * @param r defines the red component to check
  70044. * @param g defines the green component to check
  70045. * @param b defines the blue component to check
  70046. * @returns true if the rgb values are equal to the given ones
  70047. */
  70048. Color3.prototype.equalsFloats = function (r, g, b) {
  70049. return this.r === r && this.g === g && this.b === b;
  70050. };
  70051. /**
  70052. * Multiplies in place each rgb value by scale
  70053. * @param scale defines the scaling factor
  70054. * @returns the updated Color3
  70055. */
  70056. Color3.prototype.scale = function (scale) {
  70057. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  70058. };
  70059. /**
  70060. * Multiplies the rgb values by scale and stores the result into "result"
  70061. * @param scale defines the scaling factor
  70062. * @param result defines the Color3 object where to store the result
  70063. * @returns the unmodified current Color3
  70064. */
  70065. Color3.prototype.scaleToRef = function (scale, result) {
  70066. result.r = this.r * scale;
  70067. result.g = this.g * scale;
  70068. result.b = this.b * scale;
  70069. return this;
  70070. };
  70071. /**
  70072. * Scale the current Color3 values by a factor and add the result to a given Color3
  70073. * @param scale defines the scale factor
  70074. * @param result defines color to store the result into
  70075. * @returns the unmodified current Color3
  70076. */
  70077. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  70078. result.r += this.r * scale;
  70079. result.g += this.g * scale;
  70080. result.b += this.b * scale;
  70081. return this;
  70082. };
  70083. /**
  70084. * Clamps the rgb values by the min and max values and stores the result into "result"
  70085. * @param min defines minimum clamping value (default is 0)
  70086. * @param max defines maximum clamping value (default is 1)
  70087. * @param result defines color to store the result into
  70088. * @returns the original Color3
  70089. */
  70090. Color3.prototype.clampToRef = function (min, max, result) {
  70091. if (min === void 0) { min = 0; }
  70092. if (max === void 0) { max = 1; }
  70093. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  70094. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  70095. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  70096. return this;
  70097. };
  70098. /**
  70099. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70100. * @param otherColor defines the second operand
  70101. * @returns the new Color3
  70102. */
  70103. Color3.prototype.add = function (otherColor) {
  70104. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  70105. };
  70106. /**
  70107. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70108. * @param otherColor defines the second operand
  70109. * @param result defines Color3 object to store the result into
  70110. * @returns the unmodified current Color3
  70111. */
  70112. Color3.prototype.addToRef = function (otherColor, result) {
  70113. result.r = this.r + otherColor.r;
  70114. result.g = this.g + otherColor.g;
  70115. result.b = this.b + otherColor.b;
  70116. return this;
  70117. };
  70118. /**
  70119. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70120. * @param otherColor defines the second operand
  70121. * @returns the new Color3
  70122. */
  70123. Color3.prototype.subtract = function (otherColor) {
  70124. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  70125. };
  70126. /**
  70127. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70128. * @param otherColor defines the second operand
  70129. * @param result defines Color3 object to store the result into
  70130. * @returns the unmodified current Color3
  70131. */
  70132. Color3.prototype.subtractToRef = function (otherColor, result) {
  70133. result.r = this.r - otherColor.r;
  70134. result.g = this.g - otherColor.g;
  70135. result.b = this.b - otherColor.b;
  70136. return this;
  70137. };
  70138. /**
  70139. * Copy the current object
  70140. * @returns a new Color3 copied the current one
  70141. */
  70142. Color3.prototype.clone = function () {
  70143. return new Color3(this.r, this.g, this.b);
  70144. };
  70145. /**
  70146. * Copies the rgb values from the source in the current Color3
  70147. * @param source defines the source Color3 object
  70148. * @returns the updated Color3 object
  70149. */
  70150. Color3.prototype.copyFrom = function (source) {
  70151. this.r = source.r;
  70152. this.g = source.g;
  70153. this.b = source.b;
  70154. return this;
  70155. };
  70156. /**
  70157. * Updates the Color3 rgb values from the given floats
  70158. * @param r defines the red component to read from
  70159. * @param g defines the green component to read from
  70160. * @param b defines the blue component to read from
  70161. * @returns the current Color3 object
  70162. */
  70163. Color3.prototype.copyFromFloats = function (r, g, b) {
  70164. this.r = r;
  70165. this.g = g;
  70166. this.b = b;
  70167. return this;
  70168. };
  70169. /**
  70170. * Updates the Color3 rgb values from the given floats
  70171. * @param r defines the red component to read from
  70172. * @param g defines the green component to read from
  70173. * @param b defines the blue component to read from
  70174. * @returns the current Color3 object
  70175. */
  70176. Color3.prototype.set = function (r, g, b) {
  70177. return this.copyFromFloats(r, g, b);
  70178. };
  70179. /**
  70180. * Compute the Color3 hexadecimal code as a string
  70181. * @returns a string containing the hexadecimal representation of the Color3 object
  70182. */
  70183. Color3.prototype.toHexString = function () {
  70184. var intR = (this.r * 255) | 0;
  70185. var intG = (this.g * 255) | 0;
  70186. var intB = (this.b * 255) | 0;
  70187. 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);
  70188. };
  70189. /**
  70190. * Computes a new Color3 converted from the current one to linear space
  70191. * @returns a new Color3 object
  70192. */
  70193. Color3.prototype.toLinearSpace = function () {
  70194. var convertedColor = new Color3();
  70195. this.toLinearSpaceToRef(convertedColor);
  70196. return convertedColor;
  70197. };
  70198. /**
  70199. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70200. * @param convertedColor defines the Color3 object where to store the linear space version
  70201. * @returns the unmodified Color3
  70202. */
  70203. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  70204. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  70205. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  70206. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  70207. return this;
  70208. };
  70209. /**
  70210. * Computes a new Color3 converted from the current one to gamma space
  70211. * @returns a new Color3 object
  70212. */
  70213. Color3.prototype.toGammaSpace = function () {
  70214. var convertedColor = new Color3();
  70215. this.toGammaSpaceToRef(convertedColor);
  70216. return convertedColor;
  70217. };
  70218. /**
  70219. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70220. * @param convertedColor defines the Color3 object where to store the gamma space version
  70221. * @returns the unmodified Color3
  70222. */
  70223. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  70224. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  70225. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  70226. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  70227. return this;
  70228. };
  70229. /**
  70230. * Creates a new Color3 from the string containing valid hexadecimal values
  70231. * @param hex defines a string containing valid hexadecimal values
  70232. * @returns a new Color3 object
  70233. */
  70234. Color3.FromHexString = function (hex) {
  70235. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  70236. return new Color3(0, 0, 0);
  70237. }
  70238. var r = parseInt(hex.substring(1, 3), 16);
  70239. var g = parseInt(hex.substring(3, 5), 16);
  70240. var b = parseInt(hex.substring(5, 7), 16);
  70241. return Color3.FromInts(r, g, b);
  70242. };
  70243. /**
  70244. * Creates a new Vector3 from the starting index of the given array
  70245. * @param array defines the source array
  70246. * @param offset defines an offset in the source array
  70247. * @returns a new Color3 object
  70248. */
  70249. Color3.FromArray = function (array, offset) {
  70250. if (offset === void 0) { offset = 0; }
  70251. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  70252. };
  70253. /**
  70254. * Creates a new Color3 from integer values (< 256)
  70255. * @param r defines the red component to read from (value between 0 and 255)
  70256. * @param g defines the green component to read from (value between 0 and 255)
  70257. * @param b defines the blue component to read from (value between 0 and 255)
  70258. * @returns a new Color3 object
  70259. */
  70260. Color3.FromInts = function (r, g, b) {
  70261. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  70262. };
  70263. /**
  70264. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70265. * @param start defines the start Color3 value
  70266. * @param end defines the end Color3 value
  70267. * @param amount defines the gradient value between start and end
  70268. * @returns a new Color3 object
  70269. */
  70270. Color3.Lerp = function (start, end, amount) {
  70271. var result = new Color3(0.0, 0.0, 0.0);
  70272. Color3.LerpToRef(start, end, amount, result);
  70273. return result;
  70274. };
  70275. /**
  70276. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70277. * @param left defines the start value
  70278. * @param right defines the end value
  70279. * @param amount defines the gradient factor
  70280. * @param result defines the Color3 object where to store the result
  70281. */
  70282. Color3.LerpToRef = function (left, right, amount, result) {
  70283. result.r = left.r + ((right.r - left.r) * amount);
  70284. result.g = left.g + ((right.g - left.g) * amount);
  70285. result.b = left.b + ((right.b - left.b) * amount);
  70286. };
  70287. /**
  70288. * Returns a Color3 value containing a red color
  70289. * @returns a new Color3 object
  70290. */
  70291. Color3.Red = function () { return new Color3(1, 0, 0); };
  70292. /**
  70293. * Returns a Color3 value containing a green color
  70294. * @returns a new Color3 object
  70295. */
  70296. Color3.Green = function () { return new Color3(0, 1, 0); };
  70297. /**
  70298. * Returns a Color3 value containing a blue color
  70299. * @returns a new Color3 object
  70300. */
  70301. Color3.Blue = function () { return new Color3(0, 0, 1); };
  70302. /**
  70303. * Returns a Color3 value containing a black color
  70304. * @returns a new Color3 object
  70305. */
  70306. Color3.Black = function () { return new Color3(0, 0, 0); };
  70307. Object.defineProperty(Color3, "BlackReadOnly", {
  70308. /**
  70309. * Gets a Color3 value containing a black color that must not be updated
  70310. */
  70311. get: function () {
  70312. return Color3._BlackReadOnly;
  70313. },
  70314. enumerable: true,
  70315. configurable: true
  70316. });
  70317. /**
  70318. * Returns a Color3 value containing a white color
  70319. * @returns a new Color3 object
  70320. */
  70321. Color3.White = function () { return new Color3(1, 1, 1); };
  70322. /**
  70323. * Returns a Color3 value containing a purple color
  70324. * @returns a new Color3 object
  70325. */
  70326. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  70327. /**
  70328. * Returns a Color3 value containing a magenta color
  70329. * @returns a new Color3 object
  70330. */
  70331. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  70332. /**
  70333. * Returns a Color3 value containing a yellow color
  70334. * @returns a new Color3 object
  70335. */
  70336. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  70337. /**
  70338. * Returns a Color3 value containing a gray color
  70339. * @returns a new Color3 object
  70340. */
  70341. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  70342. /**
  70343. * Returns a Color3 value containing a teal color
  70344. * @returns a new Color3 object
  70345. */
  70346. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  70347. /**
  70348. * Returns a Color3 value containing a random color
  70349. * @returns a new Color3 object
  70350. */
  70351. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  70352. // Statics
  70353. Color3._BlackReadOnly = Color3.Black();
  70354. return Color3;
  70355. }());
  70356. /**
  70357. * Class used to hold a RBGA color
  70358. */
  70359. var Color4 = /** @class */ (function () {
  70360. /**
  70361. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70362. * @param r defines the red component (between 0 and 1, default is 0)
  70363. * @param g defines the green component (between 0 and 1, default is 0)
  70364. * @param b defines the blue component (between 0 and 1, default is 0)
  70365. * @param a defines the alpha component (between 0 and 1, default is 1)
  70366. */
  70367. function Color4(
  70368. /**
  70369. * Defines the red component (between 0 and 1, default is 0)
  70370. */
  70371. r,
  70372. /**
  70373. * Defines the green component (between 0 and 1, default is 0)
  70374. */
  70375. g,
  70376. /**
  70377. * Defines the blue component (between 0 and 1, default is 0)
  70378. */
  70379. b,
  70380. /**
  70381. * Defines the alpha component (between 0 and 1, default is 1)
  70382. */
  70383. a) {
  70384. if (r === void 0) { r = 0; }
  70385. if (g === void 0) { g = 0; }
  70386. if (b === void 0) { b = 0; }
  70387. if (a === void 0) { a = 1; }
  70388. this.r = r;
  70389. this.g = g;
  70390. this.b = b;
  70391. this.a = a;
  70392. }
  70393. // Operators
  70394. /**
  70395. * Adds in place the given Color4 values to the current Color4 object
  70396. * @param right defines the second operand
  70397. * @returns the current updated Color4 object
  70398. */
  70399. Color4.prototype.addInPlace = function (right) {
  70400. this.r += right.r;
  70401. this.g += right.g;
  70402. this.b += right.b;
  70403. this.a += right.a;
  70404. return this;
  70405. };
  70406. /**
  70407. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70408. * @returns the new array
  70409. */
  70410. Color4.prototype.asArray = function () {
  70411. var result = new Array();
  70412. this.toArray(result, 0);
  70413. return result;
  70414. };
  70415. /**
  70416. * Stores from the starting index in the given array the Color4 successive values
  70417. * @param array defines the array where to store the r,g,b components
  70418. * @param index defines an optional index in the target array to define where to start storing values
  70419. * @returns the current Color4 object
  70420. */
  70421. Color4.prototype.toArray = function (array, index) {
  70422. if (index === void 0) { index = 0; }
  70423. array[index] = this.r;
  70424. array[index + 1] = this.g;
  70425. array[index + 2] = this.b;
  70426. array[index + 3] = this.a;
  70427. return this;
  70428. };
  70429. /**
  70430. * Determines equality between Color4 objects
  70431. * @param otherColor defines the second operand
  70432. * @returns true if the rgba values are equal to the given ones
  70433. */
  70434. Color4.prototype.equals = function (otherColor) {
  70435. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  70436. };
  70437. /**
  70438. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70439. * @param right defines the second operand
  70440. * @returns a new Color4 object
  70441. */
  70442. Color4.prototype.add = function (right) {
  70443. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  70444. };
  70445. /**
  70446. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70447. * @param right defines the second operand
  70448. * @returns a new Color4 object
  70449. */
  70450. Color4.prototype.subtract = function (right) {
  70451. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  70452. };
  70453. /**
  70454. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70455. * @param right defines the second operand
  70456. * @param result defines the Color4 object where to store the result
  70457. * @returns the current Color4 object
  70458. */
  70459. Color4.prototype.subtractToRef = function (right, result) {
  70460. result.r = this.r - right.r;
  70461. result.g = this.g - right.g;
  70462. result.b = this.b - right.b;
  70463. result.a = this.a - right.a;
  70464. return this;
  70465. };
  70466. /**
  70467. * Creates a new Color4 with the current Color4 values multiplied by scale
  70468. * @param scale defines the scaling factor to apply
  70469. * @returns a new Color4 object
  70470. */
  70471. Color4.prototype.scale = function (scale) {
  70472. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  70473. };
  70474. /**
  70475. * Multiplies the current Color4 values by scale and stores the result in "result"
  70476. * @param scale defines the scaling factor to apply
  70477. * @param result defines the Color4 object where to store the result
  70478. * @returns the current unmodified Color4
  70479. */
  70480. Color4.prototype.scaleToRef = function (scale, result) {
  70481. result.r = this.r * scale;
  70482. result.g = this.g * scale;
  70483. result.b = this.b * scale;
  70484. result.a = this.a * scale;
  70485. return this;
  70486. };
  70487. /**
  70488. * Scale the current Color4 values by a factor and add the result to a given Color4
  70489. * @param scale defines the scale factor
  70490. * @param result defines the Color4 object where to store the result
  70491. * @returns the unmodified current Color4
  70492. */
  70493. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  70494. result.r += this.r * scale;
  70495. result.g += this.g * scale;
  70496. result.b += this.b * scale;
  70497. result.a += this.a * scale;
  70498. return this;
  70499. };
  70500. /**
  70501. * Clamps the rgb values by the min and max values and stores the result into "result"
  70502. * @param min defines minimum clamping value (default is 0)
  70503. * @param max defines maximum clamping value (default is 1)
  70504. * @param result defines color to store the result into.
  70505. * @returns the cuurent Color4
  70506. */
  70507. Color4.prototype.clampToRef = function (min, max, result) {
  70508. if (min === void 0) { min = 0; }
  70509. if (max === void 0) { max = 1; }
  70510. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  70511. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  70512. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  70513. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  70514. return this;
  70515. };
  70516. /**
  70517. * Multipy an Color4 value by another and return a new Color4 object
  70518. * @param color defines the Color4 value to multiply by
  70519. * @returns a new Color4 object
  70520. */
  70521. Color4.prototype.multiply = function (color) {
  70522. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  70523. };
  70524. /**
  70525. * Multipy a Color4 value by another and push the result in a reference value
  70526. * @param color defines the Color4 value to multiply by
  70527. * @param result defines the Color4 to fill the result in
  70528. * @returns the result Color4
  70529. */
  70530. Color4.prototype.multiplyToRef = function (color, result) {
  70531. result.r = this.r * color.r;
  70532. result.g = this.g * color.g;
  70533. result.b = this.b * color.b;
  70534. result.a = this.a * color.a;
  70535. return result;
  70536. };
  70537. /**
  70538. * Creates a string with the Color4 current values
  70539. * @returns the string representation of the Color4 object
  70540. */
  70541. Color4.prototype.toString = function () {
  70542. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  70543. };
  70544. /**
  70545. * Returns the string "Color4"
  70546. * @returns "Color4"
  70547. */
  70548. Color4.prototype.getClassName = function () {
  70549. return "Color4";
  70550. };
  70551. /**
  70552. * Compute the Color4 hash code
  70553. * @returns an unique number that can be used to hash Color4 objects
  70554. */
  70555. Color4.prototype.getHashCode = function () {
  70556. var hash = this.r || 0;
  70557. hash = (hash * 397) ^ (this.g || 0);
  70558. hash = (hash * 397) ^ (this.b || 0);
  70559. hash = (hash * 397) ^ (this.a || 0);
  70560. return hash;
  70561. };
  70562. /**
  70563. * Creates a new Color4 copied from the current one
  70564. * @returns a new Color4 object
  70565. */
  70566. Color4.prototype.clone = function () {
  70567. return new Color4(this.r, this.g, this.b, this.a);
  70568. };
  70569. /**
  70570. * Copies the given Color4 values into the current one
  70571. * @param source defines the source Color4 object
  70572. * @returns the current updated Color4 object
  70573. */
  70574. Color4.prototype.copyFrom = function (source) {
  70575. this.r = source.r;
  70576. this.g = source.g;
  70577. this.b = source.b;
  70578. this.a = source.a;
  70579. return this;
  70580. };
  70581. /**
  70582. * Copies the given float values into the current one
  70583. * @param r defines the red component to read from
  70584. * @param g defines the green component to read from
  70585. * @param b defines the blue component to read from
  70586. * @param a defines the alpha component to read from
  70587. * @returns the current updated Color4 object
  70588. */
  70589. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  70590. this.r = r;
  70591. this.g = g;
  70592. this.b = b;
  70593. this.a = a;
  70594. return this;
  70595. };
  70596. /**
  70597. * Copies the given float values into the current one
  70598. * @param r defines the red component to read from
  70599. * @param g defines the green component to read from
  70600. * @param b defines the blue component to read from
  70601. * @param a defines the alpha component to read from
  70602. * @returns the current updated Color4 object
  70603. */
  70604. Color4.prototype.set = function (r, g, b, a) {
  70605. return this.copyFromFloats(r, g, b, a);
  70606. };
  70607. /**
  70608. * Compute the Color4 hexadecimal code as a string
  70609. * @returns a string containing the hexadecimal representation of the Color4 object
  70610. */
  70611. Color4.prototype.toHexString = function () {
  70612. var intR = (this.r * 255) | 0;
  70613. var intG = (this.g * 255) | 0;
  70614. var intB = (this.b * 255) | 0;
  70615. var intA = (this.a * 255) | 0;
  70616. 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);
  70617. };
  70618. /**
  70619. * Computes a new Color4 converted from the current one to linear space
  70620. * @returns a new Color4 object
  70621. */
  70622. Color4.prototype.toLinearSpace = function () {
  70623. var convertedColor = new Color4();
  70624. this.toLinearSpaceToRef(convertedColor);
  70625. return convertedColor;
  70626. };
  70627. /**
  70628. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70629. * @param convertedColor defines the Color4 object where to store the linear space version
  70630. * @returns the unmodified Color4
  70631. */
  70632. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  70633. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  70634. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  70635. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  70636. convertedColor.a = this.a;
  70637. return this;
  70638. };
  70639. /**
  70640. * Computes a new Color4 converted from the current one to gamma space
  70641. * @returns a new Color4 object
  70642. */
  70643. Color4.prototype.toGammaSpace = function () {
  70644. var convertedColor = new Color4();
  70645. this.toGammaSpaceToRef(convertedColor);
  70646. return convertedColor;
  70647. };
  70648. /**
  70649. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70650. * @param convertedColor defines the Color4 object where to store the gamma space version
  70651. * @returns the unmodified Color4
  70652. */
  70653. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  70654. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  70655. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  70656. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  70657. convertedColor.a = this.a;
  70658. return this;
  70659. };
  70660. // Statics
  70661. /**
  70662. * Creates a new Color4 from the string containing valid hexadecimal values
  70663. * @param hex defines a string containing valid hexadecimal values
  70664. * @returns a new Color4 object
  70665. */
  70666. Color4.FromHexString = function (hex) {
  70667. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  70668. return new Color4(0.0, 0.0, 0.0, 0.0);
  70669. }
  70670. var r = parseInt(hex.substring(1, 3), 16);
  70671. var g = parseInt(hex.substring(3, 5), 16);
  70672. var b = parseInt(hex.substring(5, 7), 16);
  70673. var a = parseInt(hex.substring(7, 9), 16);
  70674. return Color4.FromInts(r, g, b, a);
  70675. };
  70676. /**
  70677. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70678. * @param left defines the start value
  70679. * @param right defines the end value
  70680. * @param amount defines the gradient factor
  70681. * @returns a new Color4 object
  70682. */
  70683. Color4.Lerp = function (left, right, amount) {
  70684. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  70685. Color4.LerpToRef(left, right, amount, result);
  70686. return result;
  70687. };
  70688. /**
  70689. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70690. * @param left defines the start value
  70691. * @param right defines the end value
  70692. * @param amount defines the gradient factor
  70693. * @param result defines the Color4 object where to store data
  70694. */
  70695. Color4.LerpToRef = function (left, right, amount, result) {
  70696. result.r = left.r + (right.r - left.r) * amount;
  70697. result.g = left.g + (right.g - left.g) * amount;
  70698. result.b = left.b + (right.b - left.b) * amount;
  70699. result.a = left.a + (right.a - left.a) * amount;
  70700. };
  70701. /**
  70702. * Creates a new Color4 from a Color3 and an alpha value
  70703. * @param color3 defines the source Color3 to read from
  70704. * @param alpha defines the alpha component (1.0 by default)
  70705. * @returns a new Color4 object
  70706. */
  70707. Color4.FromColor3 = function (color3, alpha) {
  70708. if (alpha === void 0) { alpha = 1.0; }
  70709. return new Color4(color3.r, color3.g, color3.b, alpha);
  70710. };
  70711. /**
  70712. * Creates a new Color4 from the starting index element of the given array
  70713. * @param array defines the source array to read from
  70714. * @param offset defines the offset in the source array
  70715. * @returns a new Color4 object
  70716. */
  70717. Color4.FromArray = function (array, offset) {
  70718. if (offset === void 0) { offset = 0; }
  70719. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70720. };
  70721. /**
  70722. * Creates a new Color3 from integer values (< 256)
  70723. * @param r defines the red component to read from (value between 0 and 255)
  70724. * @param g defines the green component to read from (value between 0 and 255)
  70725. * @param b defines the blue component to read from (value between 0 and 255)
  70726. * @param a defines the alpha component to read from (value between 0 and 255)
  70727. * @returns a new Color3 object
  70728. */
  70729. Color4.FromInts = function (r, g, b, a) {
  70730. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  70731. };
  70732. /**
  70733. * Check the content of a given array and convert it to an array containing RGBA data
  70734. * If the original array was already containing count * 4 values then it is returned directly
  70735. * @param colors defines the array to check
  70736. * @param count defines the number of RGBA data to expect
  70737. * @returns an array containing count * 4 values (RGBA)
  70738. */
  70739. Color4.CheckColors4 = function (colors, count) {
  70740. // Check if color3 was used
  70741. if (colors.length === count * 3) {
  70742. var colors4 = [];
  70743. for (var index = 0; index < colors.length; index += 3) {
  70744. var newIndex = (index / 3) * 4;
  70745. colors4[newIndex] = colors[index];
  70746. colors4[newIndex + 1] = colors[index + 1];
  70747. colors4[newIndex + 2] = colors[index + 2];
  70748. colors4[newIndex + 3] = 1.0;
  70749. }
  70750. return colors4;
  70751. }
  70752. return colors;
  70753. };
  70754. return Color4;
  70755. }());
  70756. /**
  70757. * Class representing a vector containing 2 coordinates
  70758. */
  70759. var Vector2 = /** @class */ (function () {
  70760. /**
  70761. * Creates a new Vector2 from the given x and y coordinates
  70762. * @param x defines the first coordinate
  70763. * @param y defines the second coordinate
  70764. */
  70765. function Vector2(
  70766. /** defines the first coordinate */
  70767. x,
  70768. /** defines the second coordinate */
  70769. y) {
  70770. if (x === void 0) { x = 0; }
  70771. if (y === void 0) { y = 0; }
  70772. this.x = x;
  70773. this.y = y;
  70774. }
  70775. /**
  70776. * Gets a string with the Vector2 coordinates
  70777. * @returns a string with the Vector2 coordinates
  70778. */
  70779. Vector2.prototype.toString = function () {
  70780. return "{X: " + this.x + " Y:" + this.y + "}";
  70781. };
  70782. /**
  70783. * Gets class name
  70784. * @returns the string "Vector2"
  70785. */
  70786. Vector2.prototype.getClassName = function () {
  70787. return "Vector2";
  70788. };
  70789. /**
  70790. * Gets current vector hash code
  70791. * @returns the Vector2 hash code as a number
  70792. */
  70793. Vector2.prototype.getHashCode = function () {
  70794. var hash = this.x || 0;
  70795. hash = (hash * 397) ^ (this.y || 0);
  70796. return hash;
  70797. };
  70798. // Operators
  70799. /**
  70800. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70801. * @param array defines the source array
  70802. * @param index defines the offset in source array
  70803. * @returns the current Vector2
  70804. */
  70805. Vector2.prototype.toArray = function (array, index) {
  70806. if (index === void 0) { index = 0; }
  70807. array[index] = this.x;
  70808. array[index + 1] = this.y;
  70809. return this;
  70810. };
  70811. /**
  70812. * Copy the current vector to an array
  70813. * @returns a new array with 2 elements: the Vector2 coordinates.
  70814. */
  70815. Vector2.prototype.asArray = function () {
  70816. var result = new Array();
  70817. this.toArray(result, 0);
  70818. return result;
  70819. };
  70820. /**
  70821. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70822. * @param source defines the source Vector2
  70823. * @returns the current updated Vector2
  70824. */
  70825. Vector2.prototype.copyFrom = function (source) {
  70826. this.x = source.x;
  70827. this.y = source.y;
  70828. return this;
  70829. };
  70830. /**
  70831. * Sets the Vector2 coordinates with the given floats
  70832. * @param x defines the first coordinate
  70833. * @param y defines the second coordinate
  70834. * @returns the current updated Vector2
  70835. */
  70836. Vector2.prototype.copyFromFloats = function (x, y) {
  70837. this.x = x;
  70838. this.y = y;
  70839. return this;
  70840. };
  70841. /**
  70842. * Sets the Vector2 coordinates with the given floats
  70843. * @param x defines the first coordinate
  70844. * @param y defines the second coordinate
  70845. * @returns the current updated Vector2
  70846. */
  70847. Vector2.prototype.set = function (x, y) {
  70848. return this.copyFromFloats(x, y);
  70849. };
  70850. /**
  70851. * Add another vector with the current one
  70852. * @param otherVector defines the other vector
  70853. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70854. */
  70855. Vector2.prototype.add = function (otherVector) {
  70856. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  70857. };
  70858. /**
  70859. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70860. * @param otherVector defines the other vector
  70861. * @param result defines the target vector
  70862. * @returns the unmodified current Vector2
  70863. */
  70864. Vector2.prototype.addToRef = function (otherVector, result) {
  70865. result.x = this.x + otherVector.x;
  70866. result.y = this.y + otherVector.y;
  70867. return this;
  70868. };
  70869. /**
  70870. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70871. * @param otherVector defines the other vector
  70872. * @returns the current updated Vector2
  70873. */
  70874. Vector2.prototype.addInPlace = function (otherVector) {
  70875. this.x += otherVector.x;
  70876. this.y += otherVector.y;
  70877. return this;
  70878. };
  70879. /**
  70880. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70881. * @param otherVector defines the other vector
  70882. * @returns a new Vector2
  70883. */
  70884. Vector2.prototype.addVector3 = function (otherVector) {
  70885. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  70886. };
  70887. /**
  70888. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70889. * @param otherVector defines the other vector
  70890. * @returns a new Vector2
  70891. */
  70892. Vector2.prototype.subtract = function (otherVector) {
  70893. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  70894. };
  70895. /**
  70896. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70897. * @param otherVector defines the other vector
  70898. * @param result defines the target vector
  70899. * @returns the unmodified current Vector2
  70900. */
  70901. Vector2.prototype.subtractToRef = function (otherVector, result) {
  70902. result.x = this.x - otherVector.x;
  70903. result.y = this.y - otherVector.y;
  70904. return this;
  70905. };
  70906. /**
  70907. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70908. * @param otherVector defines the other vector
  70909. * @returns the current updated Vector2
  70910. */
  70911. Vector2.prototype.subtractInPlace = function (otherVector) {
  70912. this.x -= otherVector.x;
  70913. this.y -= otherVector.y;
  70914. return this;
  70915. };
  70916. /**
  70917. * Multiplies in place the current Vector2 coordinates by the given ones
  70918. * @param otherVector defines the other vector
  70919. * @returns the current updated Vector2
  70920. */
  70921. Vector2.prototype.multiplyInPlace = function (otherVector) {
  70922. this.x *= otherVector.x;
  70923. this.y *= otherVector.y;
  70924. return this;
  70925. };
  70926. /**
  70927. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70928. * @param otherVector defines the other vector
  70929. * @returns a new Vector2
  70930. */
  70931. Vector2.prototype.multiply = function (otherVector) {
  70932. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  70933. };
  70934. /**
  70935. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70936. * @param otherVector defines the other vector
  70937. * @param result defines the target vector
  70938. * @returns the unmodified current Vector2
  70939. */
  70940. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  70941. result.x = this.x * otherVector.x;
  70942. result.y = this.y * otherVector.y;
  70943. return this;
  70944. };
  70945. /**
  70946. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70947. * @param x defines the first coordinate
  70948. * @param y defines the second coordinate
  70949. * @returns a new Vector2
  70950. */
  70951. Vector2.prototype.multiplyByFloats = function (x, y) {
  70952. return new Vector2(this.x * x, this.y * y);
  70953. };
  70954. /**
  70955. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70956. * @param otherVector defines the other vector
  70957. * @returns a new Vector2
  70958. */
  70959. Vector2.prototype.divide = function (otherVector) {
  70960. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  70961. };
  70962. /**
  70963. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70964. * @param otherVector defines the other vector
  70965. * @param result defines the target vector
  70966. * @returns the unmodified current Vector2
  70967. */
  70968. Vector2.prototype.divideToRef = function (otherVector, result) {
  70969. result.x = this.x / otherVector.x;
  70970. result.y = this.y / otherVector.y;
  70971. return this;
  70972. };
  70973. /**
  70974. * Divides the current Vector2 coordinates by the given ones
  70975. * @param otherVector defines the other vector
  70976. * @returns the current updated Vector2
  70977. */
  70978. Vector2.prototype.divideInPlace = function (otherVector) {
  70979. return this.divideToRef(otherVector, this);
  70980. };
  70981. /**
  70982. * Gets a new Vector2 with current Vector2 negated coordinates
  70983. * @returns a new Vector2
  70984. */
  70985. Vector2.prototype.negate = function () {
  70986. return new Vector2(-this.x, -this.y);
  70987. };
  70988. /**
  70989. * Multiply the Vector2 coordinates by scale
  70990. * @param scale defines the scaling factor
  70991. * @returns the current updated Vector2
  70992. */
  70993. Vector2.prototype.scaleInPlace = function (scale) {
  70994. this.x *= scale;
  70995. this.y *= scale;
  70996. return this;
  70997. };
  70998. /**
  70999. * Returns a new Vector2 scaled by "scale" from the current Vector2
  71000. * @param scale defines the scaling factor
  71001. * @returns a new Vector2
  71002. */
  71003. Vector2.prototype.scale = function (scale) {
  71004. var result = new Vector2(0, 0);
  71005. this.scaleToRef(scale, result);
  71006. return result;
  71007. };
  71008. /**
  71009. * Scale the current Vector2 values by a factor to a given Vector2
  71010. * @param scale defines the scale factor
  71011. * @param result defines the Vector2 object where to store the result
  71012. * @returns the unmodified current Vector2
  71013. */
  71014. Vector2.prototype.scaleToRef = function (scale, result) {
  71015. result.x = this.x * scale;
  71016. result.y = this.y * scale;
  71017. return this;
  71018. };
  71019. /**
  71020. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71021. * @param scale defines the scale factor
  71022. * @param result defines the Vector2 object where to store the result
  71023. * @returns the unmodified current Vector2
  71024. */
  71025. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  71026. result.x += this.x * scale;
  71027. result.y += this.y * scale;
  71028. return this;
  71029. };
  71030. /**
  71031. * Gets a boolean if two vectors are equals
  71032. * @param otherVector defines the other vector
  71033. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71034. */
  71035. Vector2.prototype.equals = function (otherVector) {
  71036. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  71037. };
  71038. /**
  71039. * Gets a boolean if two vectors are equals (using an epsilon value)
  71040. * @param otherVector defines the other vector
  71041. * @param epsilon defines the minimal distance to consider equality
  71042. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71043. */
  71044. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  71045. if (epsilon === void 0) { epsilon = Epsilon; }
  71046. 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);
  71047. };
  71048. /**
  71049. * Gets a new Vector2 from current Vector2 floored values
  71050. * @returns a new Vector2
  71051. */
  71052. Vector2.prototype.floor = function () {
  71053. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  71054. };
  71055. /**
  71056. * Gets a new Vector2 from current Vector2 floored values
  71057. * @returns a new Vector2
  71058. */
  71059. Vector2.prototype.fract = function () {
  71060. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  71061. };
  71062. // Properties
  71063. /**
  71064. * Gets the length of the vector
  71065. * @returns the vector length (float)
  71066. */
  71067. Vector2.prototype.length = function () {
  71068. return Math.sqrt(this.x * this.x + this.y * this.y);
  71069. };
  71070. /**
  71071. * Gets the vector squared length
  71072. * @returns the vector squared length (float)
  71073. */
  71074. Vector2.prototype.lengthSquared = function () {
  71075. return (this.x * this.x + this.y * this.y);
  71076. };
  71077. // Methods
  71078. /**
  71079. * Normalize the vector
  71080. * @returns the current updated Vector2
  71081. */
  71082. Vector2.prototype.normalize = function () {
  71083. var len = this.length();
  71084. if (len === 0) {
  71085. return this;
  71086. }
  71087. var num = 1.0 / len;
  71088. this.x *= num;
  71089. this.y *= num;
  71090. return this;
  71091. };
  71092. /**
  71093. * Gets a new Vector2 copied from the Vector2
  71094. * @returns a new Vector2
  71095. */
  71096. Vector2.prototype.clone = function () {
  71097. return new Vector2(this.x, this.y);
  71098. };
  71099. // Statics
  71100. /**
  71101. * Gets a new Vector2(0, 0)
  71102. * @returns a new Vector2
  71103. */
  71104. Vector2.Zero = function () {
  71105. return new Vector2(0, 0);
  71106. };
  71107. /**
  71108. * Gets a new Vector2(1, 1)
  71109. * @returns a new Vector2
  71110. */
  71111. Vector2.One = function () {
  71112. return new Vector2(1, 1);
  71113. };
  71114. /**
  71115. * Gets a new Vector2 set from the given index element of the given array
  71116. * @param array defines the data source
  71117. * @param offset defines the offset in the data source
  71118. * @returns a new Vector2
  71119. */
  71120. Vector2.FromArray = function (array, offset) {
  71121. if (offset === void 0) { offset = 0; }
  71122. return new Vector2(array[offset], array[offset + 1]);
  71123. };
  71124. /**
  71125. * Sets "result" from the given index element of the given array
  71126. * @param array defines the data source
  71127. * @param offset defines the offset in the data source
  71128. * @param result defines the target vector
  71129. */
  71130. Vector2.FromArrayToRef = function (array, offset, result) {
  71131. result.x = array[offset];
  71132. result.y = array[offset + 1];
  71133. };
  71134. /**
  71135. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71136. * @param value1 defines 1st point of control
  71137. * @param value2 defines 2nd point of control
  71138. * @param value3 defines 3rd point of control
  71139. * @param value4 defines 4th point of control
  71140. * @param amount defines the interpolation factor
  71141. * @returns a new Vector2
  71142. */
  71143. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  71144. var squared = amount * amount;
  71145. var cubed = amount * squared;
  71146. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  71147. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  71148. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  71149. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  71150. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  71151. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  71152. return new Vector2(x, y);
  71153. };
  71154. /**
  71155. * 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".
  71156. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71157. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71158. * @param value defines the value to clamp
  71159. * @param min defines the lower limit
  71160. * @param max defines the upper limit
  71161. * @returns a new Vector2
  71162. */
  71163. Vector2.Clamp = function (value, min, max) {
  71164. var x = value.x;
  71165. x = (x > max.x) ? max.x : x;
  71166. x = (x < min.x) ? min.x : x;
  71167. var y = value.y;
  71168. y = (y > max.y) ? max.y : y;
  71169. y = (y < min.y) ? min.y : y;
  71170. return new Vector2(x, y);
  71171. };
  71172. /**
  71173. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71174. * @param value1 defines the 1st control point
  71175. * @param tangent1 defines the outgoing tangent
  71176. * @param value2 defines the 2nd control point
  71177. * @param tangent2 defines the incoming tangent
  71178. * @param amount defines the interpolation factor
  71179. * @returns a new Vector2
  71180. */
  71181. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71182. var squared = amount * amount;
  71183. var cubed = amount * squared;
  71184. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71185. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71186. var part3 = (cubed - (2.0 * squared)) + amount;
  71187. var part4 = cubed - squared;
  71188. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71189. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71190. return new Vector2(x, y);
  71191. };
  71192. /**
  71193. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71194. * @param start defines the start vector
  71195. * @param end defines the end vector
  71196. * @param amount defines the interpolation factor
  71197. * @returns a new Vector2
  71198. */
  71199. Vector2.Lerp = function (start, end, amount) {
  71200. var x = start.x + ((end.x - start.x) * amount);
  71201. var y = start.y + ((end.y - start.y) * amount);
  71202. return new Vector2(x, y);
  71203. };
  71204. /**
  71205. * Gets the dot product of the vector "left" and the vector "right"
  71206. * @param left defines first vector
  71207. * @param right defines second vector
  71208. * @returns the dot product (float)
  71209. */
  71210. Vector2.Dot = function (left, right) {
  71211. return left.x * right.x + left.y * right.y;
  71212. };
  71213. /**
  71214. * Returns a new Vector2 equal to the normalized given vector
  71215. * @param vector defines the vector to normalize
  71216. * @returns a new Vector2
  71217. */
  71218. Vector2.Normalize = function (vector) {
  71219. var newVector = vector.clone();
  71220. newVector.normalize();
  71221. return newVector;
  71222. };
  71223. /**
  71224. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71225. * @param left defines 1st vector
  71226. * @param right defines 2nd vector
  71227. * @returns a new Vector2
  71228. */
  71229. Vector2.Minimize = function (left, right) {
  71230. var x = (left.x < right.x) ? left.x : right.x;
  71231. var y = (left.y < right.y) ? left.y : right.y;
  71232. return new Vector2(x, y);
  71233. };
  71234. /**
  71235. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71236. * @param left defines 1st vector
  71237. * @param right defines 2nd vector
  71238. * @returns a new Vector2
  71239. */
  71240. Vector2.Maximize = function (left, right) {
  71241. var x = (left.x > right.x) ? left.x : right.x;
  71242. var y = (left.y > right.y) ? left.y : right.y;
  71243. return new Vector2(x, y);
  71244. };
  71245. /**
  71246. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71247. * @param vector defines the vector to transform
  71248. * @param transformation defines the matrix to apply
  71249. * @returns a new Vector2
  71250. */
  71251. Vector2.Transform = function (vector, transformation) {
  71252. var r = Vector2.Zero();
  71253. Vector2.TransformToRef(vector, transformation, r);
  71254. return r;
  71255. };
  71256. /**
  71257. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71258. * @param vector defines the vector to transform
  71259. * @param transformation defines the matrix to apply
  71260. * @param result defines the target vector
  71261. */
  71262. Vector2.TransformToRef = function (vector, transformation, result) {
  71263. var m = transformation.m;
  71264. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  71265. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  71266. result.x = x;
  71267. result.y = y;
  71268. };
  71269. /**
  71270. * Determines if a given vector is included in a triangle
  71271. * @param p defines the vector to test
  71272. * @param p0 defines 1st triangle point
  71273. * @param p1 defines 2nd triangle point
  71274. * @param p2 defines 3rd triangle point
  71275. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71276. */
  71277. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  71278. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  71279. var sign = a < 0 ? -1 : 1;
  71280. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  71281. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  71282. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  71283. };
  71284. /**
  71285. * Gets the distance between the vectors "value1" and "value2"
  71286. * @param value1 defines first vector
  71287. * @param value2 defines second vector
  71288. * @returns the distance between vectors
  71289. */
  71290. Vector2.Distance = function (value1, value2) {
  71291. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  71292. };
  71293. /**
  71294. * Returns the squared distance between the vectors "value1" and "value2"
  71295. * @param value1 defines first vector
  71296. * @param value2 defines second vector
  71297. * @returns the squared distance between vectors
  71298. */
  71299. Vector2.DistanceSquared = function (value1, value2) {
  71300. var x = value1.x - value2.x;
  71301. var y = value1.y - value2.y;
  71302. return (x * x) + (y * y);
  71303. };
  71304. /**
  71305. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71306. * @param value1 defines first vector
  71307. * @param value2 defines second vector
  71308. * @returns a new Vector2
  71309. */
  71310. Vector2.Center = function (value1, value2) {
  71311. var center = value1.add(value2);
  71312. center.scaleInPlace(0.5);
  71313. return center;
  71314. };
  71315. /**
  71316. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71317. * @param p defines the middle point
  71318. * @param segA defines one point of the segment
  71319. * @param segB defines the other point of the segment
  71320. * @returns the shortest distance
  71321. */
  71322. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  71323. var l2 = Vector2.DistanceSquared(segA, segB);
  71324. if (l2 === 0.0) {
  71325. return Vector2.Distance(p, segA);
  71326. }
  71327. var v = segB.subtract(segA);
  71328. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  71329. var proj = segA.add(v.multiplyByFloats(t, t));
  71330. return Vector2.Distance(p, proj);
  71331. };
  71332. return Vector2;
  71333. }());
  71334. /**
  71335. * Classed used to store (x,y,z) vector representation
  71336. * A Vector3 is the main object used in 3D geometry
  71337. * It can represent etiher the coordinates of a point the space, either a direction
  71338. * Reminder: js uses a left handed forward facing system
  71339. */
  71340. var Vector3 = /** @class */ (function () {
  71341. /**
  71342. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71343. * @param x defines the first coordinates (on X axis)
  71344. * @param y defines the second coordinates (on Y axis)
  71345. * @param z defines the third coordinates (on Z axis)
  71346. */
  71347. function Vector3(
  71348. /**
  71349. * Defines the first coordinates (on X axis)
  71350. */
  71351. x,
  71352. /**
  71353. * Defines the second coordinates (on Y axis)
  71354. */
  71355. y,
  71356. /**
  71357. * Defines the third coordinates (on Z axis)
  71358. */
  71359. z) {
  71360. if (x === void 0) { x = 0; }
  71361. if (y === void 0) { y = 0; }
  71362. if (z === void 0) { z = 0; }
  71363. this.x = x;
  71364. this.y = y;
  71365. this.z = z;
  71366. }
  71367. /**
  71368. * Creates a string representation of the Vector3
  71369. * @returns a string with the Vector3 coordinates.
  71370. */
  71371. Vector3.prototype.toString = function () {
  71372. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  71373. };
  71374. /**
  71375. * Gets the class name
  71376. * @returns the string "Vector3"
  71377. */
  71378. Vector3.prototype.getClassName = function () {
  71379. return "Vector3";
  71380. };
  71381. /**
  71382. * Creates the Vector3 hash code
  71383. * @returns a number which tends to be unique between Vector3 instances
  71384. */
  71385. Vector3.prototype.getHashCode = function () {
  71386. var hash = this.x || 0;
  71387. hash = (hash * 397) ^ (this.y || 0);
  71388. hash = (hash * 397) ^ (this.z || 0);
  71389. return hash;
  71390. };
  71391. // Operators
  71392. /**
  71393. * Creates an array containing three elements : the coordinates of the Vector3
  71394. * @returns a new array of numbers
  71395. */
  71396. Vector3.prototype.asArray = function () {
  71397. var result = [];
  71398. this.toArray(result, 0);
  71399. return result;
  71400. };
  71401. /**
  71402. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71403. * @param array defines the destination array
  71404. * @param index defines the offset in the destination array
  71405. * @returns the current Vector3
  71406. */
  71407. Vector3.prototype.toArray = function (array, index) {
  71408. if (index === void 0) { index = 0; }
  71409. array[index] = this.x;
  71410. array[index + 1] = this.y;
  71411. array[index + 2] = this.z;
  71412. return this;
  71413. };
  71414. /**
  71415. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71416. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71417. */
  71418. Vector3.prototype.toQuaternion = function () {
  71419. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  71420. };
  71421. /**
  71422. * Adds the given vector to the current Vector3
  71423. * @param otherVector defines the second operand
  71424. * @returns the current updated Vector3
  71425. */
  71426. Vector3.prototype.addInPlace = function (otherVector) {
  71427. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  71428. };
  71429. /**
  71430. * Adds the given coordinates to the current Vector3
  71431. * @param x defines the x coordinate of the operand
  71432. * @param y defines the y coordinate of the operand
  71433. * @param z defines the z coordinate of the operand
  71434. * @returns the current updated Vector3
  71435. */
  71436. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  71437. this.x += x;
  71438. this.y += y;
  71439. this.z += z;
  71440. return this;
  71441. };
  71442. /**
  71443. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71444. * @param otherVector defines the second operand
  71445. * @returns the resulting Vector3
  71446. */
  71447. Vector3.prototype.add = function (otherVector) {
  71448. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  71449. };
  71450. /**
  71451. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71452. * @param otherVector defines the second operand
  71453. * @param result defines the Vector3 object where to store the result
  71454. * @returns the current Vector3
  71455. */
  71456. Vector3.prototype.addToRef = function (otherVector, result) {
  71457. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  71458. };
  71459. /**
  71460. * Subtract the given vector from the current Vector3
  71461. * @param otherVector defines the second operand
  71462. * @returns the current updated Vector3
  71463. */
  71464. Vector3.prototype.subtractInPlace = function (otherVector) {
  71465. this.x -= otherVector.x;
  71466. this.y -= otherVector.y;
  71467. this.z -= otherVector.z;
  71468. return this;
  71469. };
  71470. /**
  71471. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71472. * @param otherVector defines the second operand
  71473. * @returns the resulting Vector3
  71474. */
  71475. Vector3.prototype.subtract = function (otherVector) {
  71476. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  71477. };
  71478. /**
  71479. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71480. * @param otherVector defines the second operand
  71481. * @param result defines the Vector3 object where to store the result
  71482. * @returns the current Vector3
  71483. */
  71484. Vector3.prototype.subtractToRef = function (otherVector, result) {
  71485. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  71486. };
  71487. /**
  71488. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71489. * @param x defines the x coordinate of the operand
  71490. * @param y defines the y coordinate of the operand
  71491. * @param z defines the z coordinate of the operand
  71492. * @returns the resulting Vector3
  71493. */
  71494. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  71495. return new Vector3(this.x - x, this.y - y, this.z - z);
  71496. };
  71497. /**
  71498. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71499. * @param x defines the x coordinate of the operand
  71500. * @param y defines the y coordinate of the operand
  71501. * @param z defines the z coordinate of the operand
  71502. * @param result defines the Vector3 object where to store the result
  71503. * @returns the current Vector3
  71504. */
  71505. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  71506. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  71507. };
  71508. /**
  71509. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71510. * @returns a new Vector3
  71511. */
  71512. Vector3.prototype.negate = function () {
  71513. return new Vector3(-this.x, -this.y, -this.z);
  71514. };
  71515. /**
  71516. * Multiplies the Vector3 coordinates by the float "scale"
  71517. * @param scale defines the multiplier factor
  71518. * @returns the current updated Vector3
  71519. */
  71520. Vector3.prototype.scaleInPlace = function (scale) {
  71521. this.x *= scale;
  71522. this.y *= scale;
  71523. this.z *= scale;
  71524. return this;
  71525. };
  71526. /**
  71527. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71528. * @param scale defines the multiplier factor
  71529. * @returns a new Vector3
  71530. */
  71531. Vector3.prototype.scale = function (scale) {
  71532. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  71533. };
  71534. /**
  71535. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71536. * @param scale defines the multiplier factor
  71537. * @param result defines the Vector3 object where to store the result
  71538. * @returns the current Vector3
  71539. */
  71540. Vector3.prototype.scaleToRef = function (scale, result) {
  71541. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  71542. };
  71543. /**
  71544. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71545. * @param scale defines the scale factor
  71546. * @param result defines the Vector3 object where to store the result
  71547. * @returns the unmodified current Vector3
  71548. */
  71549. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  71550. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  71551. };
  71552. /**
  71553. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71554. * @param otherVector defines the second operand
  71555. * @returns true if both vectors are equals
  71556. */
  71557. Vector3.prototype.equals = function (otherVector) {
  71558. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  71559. };
  71560. /**
  71561. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71562. * @param otherVector defines the second operand
  71563. * @param epsilon defines the minimal distance to define values as equals
  71564. * @returns true if both vectors are distant less than epsilon
  71565. */
  71566. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  71567. if (epsilon === void 0) { epsilon = Epsilon; }
  71568. 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);
  71569. };
  71570. /**
  71571. * Returns true if the current Vector3 coordinates equals the given floats
  71572. * @param x defines the x coordinate of the operand
  71573. * @param y defines the y coordinate of the operand
  71574. * @param z defines the z coordinate of the operand
  71575. * @returns true if both vectors are equals
  71576. */
  71577. Vector3.prototype.equalsToFloats = function (x, y, z) {
  71578. return this.x === x && this.y === y && this.z === z;
  71579. };
  71580. /**
  71581. * Multiplies the current Vector3 coordinates by the given ones
  71582. * @param otherVector defines the second operand
  71583. * @returns the current updated Vector3
  71584. */
  71585. Vector3.prototype.multiplyInPlace = function (otherVector) {
  71586. this.x *= otherVector.x;
  71587. this.y *= otherVector.y;
  71588. this.z *= otherVector.z;
  71589. return this;
  71590. };
  71591. /**
  71592. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71593. * @param otherVector defines the second operand
  71594. * @returns the new Vector3
  71595. */
  71596. Vector3.prototype.multiply = function (otherVector) {
  71597. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  71598. };
  71599. /**
  71600. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71601. * @param otherVector defines the second operand
  71602. * @param result defines the Vector3 object where to store the result
  71603. * @returns the current Vector3
  71604. */
  71605. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  71606. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  71607. };
  71608. /**
  71609. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71610. * @param x defines the x coordinate of the operand
  71611. * @param y defines the y coordinate of the operand
  71612. * @param z defines the z coordinate of the operand
  71613. * @returns the new Vector3
  71614. */
  71615. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  71616. return new Vector3(this.x * x, this.y * y, this.z * z);
  71617. };
  71618. /**
  71619. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71620. * @param otherVector defines the second operand
  71621. * @returns the new Vector3
  71622. */
  71623. Vector3.prototype.divide = function (otherVector) {
  71624. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  71625. };
  71626. /**
  71627. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71628. * @param otherVector defines the second operand
  71629. * @param result defines the Vector3 object where to store the result
  71630. * @returns the current Vector3
  71631. */
  71632. Vector3.prototype.divideToRef = function (otherVector, result) {
  71633. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  71634. };
  71635. /**
  71636. * Divides the current Vector3 coordinates by the given ones.
  71637. * @param otherVector defines the second operand
  71638. * @returns the current updated Vector3
  71639. */
  71640. Vector3.prototype.divideInPlace = function (otherVector) {
  71641. return this.divideToRef(otherVector, this);
  71642. };
  71643. /**
  71644. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71645. * @param other defines the second operand
  71646. * @returns the current updated Vector3
  71647. */
  71648. Vector3.prototype.minimizeInPlace = function (other) {
  71649. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  71650. };
  71651. /**
  71652. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71653. * @param other defines the second operand
  71654. * @returns the current updated Vector3
  71655. */
  71656. Vector3.prototype.maximizeInPlace = function (other) {
  71657. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  71658. };
  71659. /**
  71660. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71661. * @param x defines the x coordinate of the operand
  71662. * @param y defines the y coordinate of the operand
  71663. * @param z defines the z coordinate of the operand
  71664. * @returns the current updated Vector3
  71665. */
  71666. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  71667. if (x < this.x) {
  71668. this.x = x;
  71669. }
  71670. if (y < this.y) {
  71671. this.y = y;
  71672. }
  71673. if (z < this.z) {
  71674. this.z = z;
  71675. }
  71676. return this;
  71677. };
  71678. /**
  71679. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71680. * @param x defines the x coordinate of the operand
  71681. * @param y defines the y coordinate of the operand
  71682. * @param z defines the z coordinate of the operand
  71683. * @returns the current updated Vector3
  71684. */
  71685. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  71686. if (x > this.x) {
  71687. this.x = x;
  71688. }
  71689. if (y > this.y) {
  71690. this.y = y;
  71691. }
  71692. if (z > this.z) {
  71693. this.z = z;
  71694. }
  71695. return this;
  71696. };
  71697. /**
  71698. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71699. * Check if is non uniform within a certain amount of decimal places to account for this
  71700. * @param epsilon the amount the values can differ
  71701. * @returns if the the vector is non uniform to a certain number of decimal places
  71702. */
  71703. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  71704. var absX = Math.abs(this.x);
  71705. var absY = Math.abs(this.y);
  71706. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  71707. return true;
  71708. }
  71709. var absZ = Math.abs(this.z);
  71710. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  71711. return true;
  71712. }
  71713. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  71714. return true;
  71715. }
  71716. return false;
  71717. };
  71718. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  71719. /**
  71720. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71721. */
  71722. get: function () {
  71723. var absX = Math.abs(this.x);
  71724. var absY = Math.abs(this.y);
  71725. if (absX !== absY) {
  71726. return true;
  71727. }
  71728. var absZ = Math.abs(this.z);
  71729. if (absX !== absZ) {
  71730. return true;
  71731. }
  71732. if (absY !== absZ) {
  71733. return true;
  71734. }
  71735. return false;
  71736. },
  71737. enumerable: true,
  71738. configurable: true
  71739. });
  71740. /**
  71741. * Gets a new Vector3 from current Vector3 floored values
  71742. * @returns a new Vector3
  71743. */
  71744. Vector3.prototype.floor = function () {
  71745. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  71746. };
  71747. /**
  71748. * Gets a new Vector3 from current Vector3 floored values
  71749. * @returns a new Vector3
  71750. */
  71751. Vector3.prototype.fract = function () {
  71752. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  71753. };
  71754. // Properties
  71755. /**
  71756. * Gets the length of the Vector3
  71757. * @returns the length of the Vecto3
  71758. */
  71759. Vector3.prototype.length = function () {
  71760. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  71761. };
  71762. /**
  71763. * Gets the squared length of the Vector3
  71764. * @returns squared length of the Vector3
  71765. */
  71766. Vector3.prototype.lengthSquared = function () {
  71767. return (this.x * this.x + this.y * this.y + this.z * this.z);
  71768. };
  71769. /**
  71770. * Normalize the current Vector3.
  71771. * Please note that this is an in place operation.
  71772. * @returns the current updated Vector3
  71773. */
  71774. Vector3.prototype.normalize = function () {
  71775. return this.normalizeFromLength(this.length());
  71776. };
  71777. /**
  71778. * Reorders the x y z properties of the vector in place
  71779. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71780. * @returns the current updated vector
  71781. */
  71782. Vector3.prototype.reorderInPlace = function (order) {
  71783. var _this = this;
  71784. order = order.toLowerCase();
  71785. if (order === "xyz") {
  71786. return this;
  71787. }
  71788. MathTmp.Vector3[0].copyFrom(this);
  71789. ["x", "y", "z"].forEach(function (val, i) {
  71790. _this[val] = MathTmp.Vector3[0][order[i]];
  71791. });
  71792. return this;
  71793. };
  71794. /**
  71795. * Rotates the vector around 0,0,0 by a quaternion
  71796. * @param quaternion the rotation quaternion
  71797. * @param result vector to store the result
  71798. * @returns the resulting vector
  71799. */
  71800. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  71801. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  71802. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  71803. return result;
  71804. };
  71805. /**
  71806. * Rotates a vector around a given point
  71807. * @param quaternion the rotation quaternion
  71808. * @param point the point to rotate around
  71809. * @param result vector to store the result
  71810. * @returns the resulting vector
  71811. */
  71812. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  71813. this.subtractToRef(point, MathTmp.Vector3[0]);
  71814. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  71815. point.addToRef(MathTmp.Vector3[0], result);
  71816. return result;
  71817. };
  71818. /**
  71819. * Normalize the current Vector3 with the given input length.
  71820. * Please note that this is an in place operation.
  71821. * @param len the length of the vector
  71822. * @returns the current updated Vector3
  71823. */
  71824. Vector3.prototype.normalizeFromLength = function (len) {
  71825. if (len === 0 || len === 1.0) {
  71826. return this;
  71827. }
  71828. return this.scaleInPlace(1.0 / len);
  71829. };
  71830. /**
  71831. * Normalize the current Vector3 to a new vector
  71832. * @returns the new Vector3
  71833. */
  71834. Vector3.prototype.normalizeToNew = function () {
  71835. var normalized = new Vector3(0, 0, 0);
  71836. this.normalizeToRef(normalized);
  71837. return normalized;
  71838. };
  71839. /**
  71840. * Normalize the current Vector3 to the reference
  71841. * @param reference define the Vector3 to update
  71842. * @returns the updated Vector3
  71843. */
  71844. Vector3.prototype.normalizeToRef = function (reference) {
  71845. var len = this.length();
  71846. if (len === 0 || len === 1.0) {
  71847. return reference.copyFromFloats(this.x, this.y, this.z);
  71848. }
  71849. return this.scaleToRef(1.0 / len, reference);
  71850. };
  71851. /**
  71852. * Creates a new Vector3 copied from the current Vector3
  71853. * @returns the new Vector3
  71854. */
  71855. Vector3.prototype.clone = function () {
  71856. return new Vector3(this.x, this.y, this.z);
  71857. };
  71858. /**
  71859. * Copies the given vector coordinates to the current Vector3 ones
  71860. * @param source defines the source Vector3
  71861. * @returns the current updated Vector3
  71862. */
  71863. Vector3.prototype.copyFrom = function (source) {
  71864. return this.copyFromFloats(source.x, source.y, source.z);
  71865. };
  71866. /**
  71867. * Copies the given floats to the current Vector3 coordinates
  71868. * @param x defines the x coordinate of the operand
  71869. * @param y defines the y coordinate of the operand
  71870. * @param z defines the z coordinate of the operand
  71871. * @returns the current updated Vector3
  71872. */
  71873. Vector3.prototype.copyFromFloats = function (x, y, z) {
  71874. this.x = x;
  71875. this.y = y;
  71876. this.z = z;
  71877. return this;
  71878. };
  71879. /**
  71880. * Copies the given floats to the current Vector3 coordinates
  71881. * @param x defines the x coordinate of the operand
  71882. * @param y defines the y coordinate of the operand
  71883. * @param z defines the z coordinate of the operand
  71884. * @returns the current updated Vector3
  71885. */
  71886. Vector3.prototype.set = function (x, y, z) {
  71887. return this.copyFromFloats(x, y, z);
  71888. };
  71889. /**
  71890. * Copies the given float to the current Vector3 coordinates
  71891. * @param v defines the x, y and z coordinates of the operand
  71892. * @returns the current updated Vector3
  71893. */
  71894. Vector3.prototype.setAll = function (v) {
  71895. this.x = this.y = this.z = v;
  71896. return this;
  71897. };
  71898. // Statics
  71899. /**
  71900. * Get the clip factor between two vectors
  71901. * @param vector0 defines the first operand
  71902. * @param vector1 defines the second operand
  71903. * @param axis defines the axis to use
  71904. * @param size defines the size along the axis
  71905. * @returns the clip factor
  71906. */
  71907. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  71908. var d0 = Vector3.Dot(vector0, axis) - size;
  71909. var d1 = Vector3.Dot(vector1, axis) - size;
  71910. var s = d0 / (d0 - d1);
  71911. return s;
  71912. };
  71913. /**
  71914. * Get angle between two vectors
  71915. * @param vector0 angle between vector0 and vector1
  71916. * @param vector1 angle between vector0 and vector1
  71917. * @param normal direction of the normal
  71918. * @return the angle between vector0 and vector1
  71919. */
  71920. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  71921. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  71922. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  71923. var dot = Vector3.Dot(v0, v1);
  71924. var n = MathTmp.Vector3[3];
  71925. Vector3.CrossToRef(v0, v1, n);
  71926. if (Vector3.Dot(n, normal) > 0) {
  71927. return Math.acos(dot);
  71928. }
  71929. return -Math.acos(dot);
  71930. };
  71931. /**
  71932. * Returns a new Vector3 set from the index "offset" of the given array
  71933. * @param array defines the source array
  71934. * @param offset defines the offset in the source array
  71935. * @returns the new Vector3
  71936. */
  71937. Vector3.FromArray = function (array, offset) {
  71938. if (offset === void 0) { offset = 0; }
  71939. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  71940. };
  71941. /**
  71942. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71943. * This function is deprecated. Use FromArray instead
  71944. * @param array defines the source array
  71945. * @param offset defines the offset in the source array
  71946. * @returns the new Vector3
  71947. */
  71948. Vector3.FromFloatArray = function (array, offset) {
  71949. return Vector3.FromArray(array, offset);
  71950. };
  71951. /**
  71952. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71953. * @param array defines the source array
  71954. * @param offset defines the offset in the source array
  71955. * @param result defines the Vector3 where to store the result
  71956. */
  71957. Vector3.FromArrayToRef = function (array, offset, result) {
  71958. result.x = array[offset];
  71959. result.y = array[offset + 1];
  71960. result.z = array[offset + 2];
  71961. };
  71962. /**
  71963. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71964. * This function is deprecated. Use FromArrayToRef instead.
  71965. * @param array defines the source array
  71966. * @param offset defines the offset in the source array
  71967. * @param result defines the Vector3 where to store the result
  71968. */
  71969. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  71970. return Vector3.FromArrayToRef(array, offset, result);
  71971. };
  71972. /**
  71973. * Sets the given vector "result" with the given floats.
  71974. * @param x defines the x coordinate of the source
  71975. * @param y defines the y coordinate of the source
  71976. * @param z defines the z coordinate of the source
  71977. * @param result defines the Vector3 where to store the result
  71978. */
  71979. Vector3.FromFloatsToRef = function (x, y, z, result) {
  71980. result.copyFromFloats(x, y, z);
  71981. };
  71982. /**
  71983. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71984. * @returns a new empty Vector3
  71985. */
  71986. Vector3.Zero = function () {
  71987. return new Vector3(0.0, 0.0, 0.0);
  71988. };
  71989. /**
  71990. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71991. * @returns a new unit Vector3
  71992. */
  71993. Vector3.One = function () {
  71994. return new Vector3(1.0, 1.0, 1.0);
  71995. };
  71996. /**
  71997. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71998. * @returns a new up Vector3
  71999. */
  72000. Vector3.Up = function () {
  72001. return new Vector3(0.0, 1.0, 0.0);
  72002. };
  72003. Object.defineProperty(Vector3, "UpReadOnly", {
  72004. /**
  72005. * Gets a up Vector3 that must not be updated
  72006. */
  72007. get: function () {
  72008. return Vector3._UpReadOnly;
  72009. },
  72010. enumerable: true,
  72011. configurable: true
  72012. });
  72013. /**
  72014. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  72015. * @returns a new down Vector3
  72016. */
  72017. Vector3.Down = function () {
  72018. return new Vector3(0.0, -1.0, 0.0);
  72019. };
  72020. /**
  72021. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  72022. * @returns a new forward Vector3
  72023. */
  72024. Vector3.Forward = function () {
  72025. return new Vector3(0.0, 0.0, 1.0);
  72026. };
  72027. /**
  72028. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  72029. * @returns a new forward Vector3
  72030. */
  72031. Vector3.Backward = function () {
  72032. return new Vector3(0.0, 0.0, -1.0);
  72033. };
  72034. /**
  72035. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  72036. * @returns a new right Vector3
  72037. */
  72038. Vector3.Right = function () {
  72039. return new Vector3(1.0, 0.0, 0.0);
  72040. };
  72041. /**
  72042. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  72043. * @returns a new left Vector3
  72044. */
  72045. Vector3.Left = function () {
  72046. return new Vector3(-1.0, 0.0, 0.0);
  72047. };
  72048. /**
  72049. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  72050. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72051. * @param vector defines the Vector3 to transform
  72052. * @param transformation defines the transformation matrix
  72053. * @returns the transformed Vector3
  72054. */
  72055. Vector3.TransformCoordinates = function (vector, transformation) {
  72056. var result = Vector3.Zero();
  72057. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  72058. return result;
  72059. };
  72060. /**
  72061. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  72062. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72063. * @param vector defines the Vector3 to transform
  72064. * @param transformation defines the transformation matrix
  72065. * @param result defines the Vector3 where to store the result
  72066. */
  72067. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  72068. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  72069. };
  72070. /**
  72071. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  72072. * This method computes tranformed coordinates only, not transformed direction vectors
  72073. * @param x define the x coordinate of the source vector
  72074. * @param y define the y coordinate of the source vector
  72075. * @param z define the z coordinate of the source vector
  72076. * @param transformation defines the transformation matrix
  72077. * @param result defines the Vector3 where to store the result
  72078. */
  72079. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  72080. var m = transformation.m;
  72081. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  72082. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  72083. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  72084. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  72085. result.x = rx * rw;
  72086. result.y = ry * rw;
  72087. result.z = rz * rw;
  72088. };
  72089. /**
  72090. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  72091. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72092. * @param vector defines the Vector3 to transform
  72093. * @param transformation defines the transformation matrix
  72094. * @returns the new Vector3
  72095. */
  72096. Vector3.TransformNormal = function (vector, transformation) {
  72097. var result = Vector3.Zero();
  72098. Vector3.TransformNormalToRef(vector, transformation, result);
  72099. return result;
  72100. };
  72101. /**
  72102. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  72103. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72104. * @param vector defines the Vector3 to transform
  72105. * @param transformation defines the transformation matrix
  72106. * @param result defines the Vector3 where to store the result
  72107. */
  72108. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  72109. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  72110. };
  72111. /**
  72112. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  72113. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72114. * @param x define the x coordinate of the source vector
  72115. * @param y define the y coordinate of the source vector
  72116. * @param z define the z coordinate of the source vector
  72117. * @param transformation defines the transformation matrix
  72118. * @param result defines the Vector3 where to store the result
  72119. */
  72120. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  72121. var m = transformation.m;
  72122. result.x = x * m[0] + y * m[4] + z * m[8];
  72123. result.y = x * m[1] + y * m[5] + z * m[9];
  72124. result.z = x * m[2] + y * m[6] + z * m[10];
  72125. };
  72126. /**
  72127. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  72128. * @param value1 defines the first control point
  72129. * @param value2 defines the second control point
  72130. * @param value3 defines the third control point
  72131. * @param value4 defines the fourth control point
  72132. * @param amount defines the amount on the spline to use
  72133. * @returns the new Vector3
  72134. */
  72135. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  72136. var squared = amount * amount;
  72137. var cubed = amount * squared;
  72138. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  72139. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  72140. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  72141. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  72142. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  72143. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  72144. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  72145. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  72146. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  72147. return new Vector3(x, y, z);
  72148. };
  72149. /**
  72150. * 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"
  72151. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72152. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72153. * @param value defines the current value
  72154. * @param min defines the lower range value
  72155. * @param max defines the upper range value
  72156. * @returns the new Vector3
  72157. */
  72158. Vector3.Clamp = function (value, min, max) {
  72159. var v = new Vector3();
  72160. Vector3.ClampToRef(value, min, max, v);
  72161. return v;
  72162. };
  72163. /**
  72164. * 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"
  72165. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72166. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72167. * @param value defines the current value
  72168. * @param min defines the lower range value
  72169. * @param max defines the upper range value
  72170. * @param result defines the Vector3 where to store the result
  72171. */
  72172. Vector3.ClampToRef = function (value, min, max, result) {
  72173. var x = value.x;
  72174. x = (x > max.x) ? max.x : x;
  72175. x = (x < min.x) ? min.x : x;
  72176. var y = value.y;
  72177. y = (y > max.y) ? max.y : y;
  72178. y = (y < min.y) ? min.y : y;
  72179. var z = value.z;
  72180. z = (z > max.z) ? max.z : z;
  72181. z = (z < min.z) ? min.z : z;
  72182. result.copyFromFloats(x, y, z);
  72183. };
  72184. /**
  72185. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  72186. * @param value1 defines the first control point
  72187. * @param tangent1 defines the first tangent vector
  72188. * @param value2 defines the second control point
  72189. * @param tangent2 defines the second tangent vector
  72190. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  72191. * @returns the new Vector3
  72192. */
  72193. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  72194. var squared = amount * amount;
  72195. var cubed = amount * squared;
  72196. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  72197. var part2 = (-2.0 * cubed) + (3.0 * squared);
  72198. var part3 = (cubed - (2.0 * squared)) + amount;
  72199. var part4 = cubed - squared;
  72200. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  72201. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  72202. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  72203. return new Vector3(x, y, z);
  72204. };
  72205. /**
  72206. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  72207. * @param start defines the start value
  72208. * @param end defines the end value
  72209. * @param amount max defines amount between both (between 0 and 1)
  72210. * @returns the new Vector3
  72211. */
  72212. Vector3.Lerp = function (start, end, amount) {
  72213. var result = new Vector3(0, 0, 0);
  72214. Vector3.LerpToRef(start, end, amount, result);
  72215. return result;
  72216. };
  72217. /**
  72218. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  72219. * @param start defines the start value
  72220. * @param end defines the end value
  72221. * @param amount max defines amount between both (between 0 and 1)
  72222. * @param result defines the Vector3 where to store the result
  72223. */
  72224. Vector3.LerpToRef = function (start, end, amount, result) {
  72225. result.x = start.x + ((end.x - start.x) * amount);
  72226. result.y = start.y + ((end.y - start.y) * amount);
  72227. result.z = start.z + ((end.z - start.z) * amount);
  72228. };
  72229. /**
  72230. * Returns the dot product (float) between the vectors "left" and "right"
  72231. * @param left defines the left operand
  72232. * @param right defines the right operand
  72233. * @returns the dot product
  72234. */
  72235. Vector3.Dot = function (left, right) {
  72236. return (left.x * right.x + left.y * right.y + left.z * right.z);
  72237. };
  72238. /**
  72239. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  72240. * The cross product is then orthogonal to both "left" and "right"
  72241. * @param left defines the left operand
  72242. * @param right defines the right operand
  72243. * @returns the cross product
  72244. */
  72245. Vector3.Cross = function (left, right) {
  72246. var result = Vector3.Zero();
  72247. Vector3.CrossToRef(left, right, result);
  72248. return result;
  72249. };
  72250. /**
  72251. * Sets the given vector "result" with the cross product of "left" and "right"
  72252. * The cross product is then orthogonal to both "left" and "right"
  72253. * @param left defines the left operand
  72254. * @param right defines the right operand
  72255. * @param result defines the Vector3 where to store the result
  72256. */
  72257. Vector3.CrossToRef = function (left, right, result) {
  72258. var x = left.y * right.z - left.z * right.y;
  72259. var y = left.z * right.x - left.x * right.z;
  72260. var z = left.x * right.y - left.y * right.x;
  72261. result.copyFromFloats(x, y, z);
  72262. };
  72263. /**
  72264. * Returns a new Vector3 as the normalization of the given vector
  72265. * @param vector defines the Vector3 to normalize
  72266. * @returns the new Vector3
  72267. */
  72268. Vector3.Normalize = function (vector) {
  72269. var result = Vector3.Zero();
  72270. Vector3.NormalizeToRef(vector, result);
  72271. return result;
  72272. };
  72273. /**
  72274. * Sets the given vector "result" with the normalization of the given first vector
  72275. * @param vector defines the Vector3 to normalize
  72276. * @param result defines the Vector3 where to store the result
  72277. */
  72278. Vector3.NormalizeToRef = function (vector, result) {
  72279. vector.normalizeToRef(result);
  72280. };
  72281. /**
  72282. * Project a Vector3 onto screen space
  72283. * @param vector defines the Vector3 to project
  72284. * @param world defines the world matrix to use
  72285. * @param transform defines the transform (view x projection) matrix to use
  72286. * @param viewport defines the screen viewport to use
  72287. * @returns the new Vector3
  72288. */
  72289. Vector3.Project = function (vector, world, transform, viewport) {
  72290. var cw = viewport.width;
  72291. var ch = viewport.height;
  72292. var cx = viewport.x;
  72293. var cy = viewport.y;
  72294. var viewportMatrix = MathTmp.Matrix[1];
  72295. 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);
  72296. var matrix = MathTmp.Matrix[0];
  72297. world.multiplyToRef(transform, matrix);
  72298. matrix.multiplyToRef(viewportMatrix, matrix);
  72299. return Vector3.TransformCoordinates(vector, matrix);
  72300. };
  72301. /** @hidden */
  72302. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  72303. Vector3.TransformCoordinatesToRef(source, matrix, result);
  72304. var m = matrix.m;
  72305. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  72306. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  72307. result.scaleInPlace(1.0 / num);
  72308. }
  72309. };
  72310. /**
  72311. * Unproject from screen space to object space
  72312. * @param source defines the screen space Vector3 to use
  72313. * @param viewportWidth defines the current width of the viewport
  72314. * @param viewportHeight defines the current height of the viewport
  72315. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72316. * @param transform defines the transform (view x projection) matrix to use
  72317. * @returns the new Vector3
  72318. */
  72319. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  72320. var matrix = MathTmp.Matrix[0];
  72321. world.multiplyToRef(transform, matrix);
  72322. matrix.invert();
  72323. source.x = source.x / viewportWidth * 2 - 1;
  72324. source.y = -(source.y / viewportHeight * 2 - 1);
  72325. var vector = new Vector3();
  72326. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  72327. return vector;
  72328. };
  72329. /**
  72330. * Unproject from screen space to object space
  72331. * @param source defines the screen space Vector3 to use
  72332. * @param viewportWidth defines the current width of the viewport
  72333. * @param viewportHeight defines the current height of the viewport
  72334. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72335. * @param view defines the view matrix to use
  72336. * @param projection defines the projection matrix to use
  72337. * @returns the new Vector3
  72338. */
  72339. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  72340. var result = Vector3.Zero();
  72341. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  72342. return result;
  72343. };
  72344. /**
  72345. * Unproject from screen space to object space
  72346. * @param source defines the screen space Vector3 to use
  72347. * @param viewportWidth defines the current width of the viewport
  72348. * @param viewportHeight defines the current height of the viewport
  72349. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72350. * @param view defines the view matrix to use
  72351. * @param projection defines the projection matrix to use
  72352. * @param result defines the Vector3 where to store the result
  72353. */
  72354. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  72355. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  72356. };
  72357. /**
  72358. * Unproject from screen space to object space
  72359. * @param sourceX defines the screen space x coordinate to use
  72360. * @param sourceY defines the screen space y coordinate to use
  72361. * @param sourceZ defines the screen space z coordinate to use
  72362. * @param viewportWidth defines the current width of the viewport
  72363. * @param viewportHeight defines the current height of the viewport
  72364. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72365. * @param view defines the view matrix to use
  72366. * @param projection defines the projection matrix to use
  72367. * @param result defines the Vector3 where to store the result
  72368. */
  72369. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  72370. var matrix = MathTmp.Matrix[0];
  72371. world.multiplyToRef(view, matrix);
  72372. matrix.multiplyToRef(projection, matrix);
  72373. matrix.invert();
  72374. var screenSource = MathTmp.Vector3[0];
  72375. screenSource.x = sourceX / viewportWidth * 2 - 1;
  72376. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  72377. screenSource.z = 2 * sourceZ - 1.0;
  72378. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  72379. };
  72380. /**
  72381. * Gets the minimal coordinate values between two Vector3
  72382. * @param left defines the first operand
  72383. * @param right defines the second operand
  72384. * @returns the new Vector3
  72385. */
  72386. Vector3.Minimize = function (left, right) {
  72387. var min = left.clone();
  72388. min.minimizeInPlace(right);
  72389. return min;
  72390. };
  72391. /**
  72392. * Gets the maximal coordinate values between two Vector3
  72393. * @param left defines the first operand
  72394. * @param right defines the second operand
  72395. * @returns the new Vector3
  72396. */
  72397. Vector3.Maximize = function (left, right) {
  72398. var max = left.clone();
  72399. max.maximizeInPlace(right);
  72400. return max;
  72401. };
  72402. /**
  72403. * Returns the distance between the vectors "value1" and "value2"
  72404. * @param value1 defines the first operand
  72405. * @param value2 defines the second operand
  72406. * @returns the distance
  72407. */
  72408. Vector3.Distance = function (value1, value2) {
  72409. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  72410. };
  72411. /**
  72412. * Returns the squared distance between the vectors "value1" and "value2"
  72413. * @param value1 defines the first operand
  72414. * @param value2 defines the second operand
  72415. * @returns the squared distance
  72416. */
  72417. Vector3.DistanceSquared = function (value1, value2) {
  72418. var x = value1.x - value2.x;
  72419. var y = value1.y - value2.y;
  72420. var z = value1.z - value2.z;
  72421. return (x * x) + (y * y) + (z * z);
  72422. };
  72423. /**
  72424. * Returns a new Vector3 located at the center between "value1" and "value2"
  72425. * @param value1 defines the first operand
  72426. * @param value2 defines the second operand
  72427. * @returns the new Vector3
  72428. */
  72429. Vector3.Center = function (value1, value2) {
  72430. var center = value1.add(value2);
  72431. center.scaleInPlace(0.5);
  72432. return center;
  72433. };
  72434. /**
  72435. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  72436. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  72437. * to something in order to rotate it from its local system to the given target system
  72438. * Note: axis1, axis2 and axis3 are normalized during this operation
  72439. * @param axis1 defines the first axis
  72440. * @param axis2 defines the second axis
  72441. * @param axis3 defines the third axis
  72442. * @returns a new Vector3
  72443. */
  72444. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  72445. var rotation = Vector3.Zero();
  72446. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  72447. return rotation;
  72448. };
  72449. /**
  72450. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  72451. * @param axis1 defines the first axis
  72452. * @param axis2 defines the second axis
  72453. * @param axis3 defines the third axis
  72454. * @param ref defines the Vector3 where to store the result
  72455. */
  72456. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  72457. var quat = MathTmp.Quaternion[0];
  72458. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  72459. quat.toEulerAnglesToRef(ref);
  72460. };
  72461. Vector3._UpReadOnly = Vector3.Up();
  72462. return Vector3;
  72463. }());
  72464. /**
  72465. * Vector4 class created for EulerAngle class conversion to Quaternion
  72466. */
  72467. var Vector4 = /** @class */ (function () {
  72468. /**
  72469. * Creates a Vector4 object from the given floats.
  72470. * @param x x value of the vector
  72471. * @param y y value of the vector
  72472. * @param z z value of the vector
  72473. * @param w w value of the vector
  72474. */
  72475. function Vector4(
  72476. /** x value of the vector */
  72477. x,
  72478. /** y value of the vector */
  72479. y,
  72480. /** z value of the vector */
  72481. z,
  72482. /** w value of the vector */
  72483. w) {
  72484. this.x = x;
  72485. this.y = y;
  72486. this.z = z;
  72487. this.w = w;
  72488. }
  72489. /**
  72490. * Returns the string with the Vector4 coordinates.
  72491. * @returns a string containing all the vector values
  72492. */
  72493. Vector4.prototype.toString = function () {
  72494. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  72495. };
  72496. /**
  72497. * Returns the string "Vector4".
  72498. * @returns "Vector4"
  72499. */
  72500. Vector4.prototype.getClassName = function () {
  72501. return "Vector4";
  72502. };
  72503. /**
  72504. * Returns the Vector4 hash code.
  72505. * @returns a unique hash code
  72506. */
  72507. Vector4.prototype.getHashCode = function () {
  72508. var hash = this.x || 0;
  72509. hash = (hash * 397) ^ (this.y || 0);
  72510. hash = (hash * 397) ^ (this.z || 0);
  72511. hash = (hash * 397) ^ (this.w || 0);
  72512. return hash;
  72513. };
  72514. // Operators
  72515. /**
  72516. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  72517. * @returns the resulting array
  72518. */
  72519. Vector4.prototype.asArray = function () {
  72520. var result = new Array();
  72521. this.toArray(result, 0);
  72522. return result;
  72523. };
  72524. /**
  72525. * Populates the given array from the given index with the Vector4 coordinates.
  72526. * @param array array to populate
  72527. * @param index index of the array to start at (default: 0)
  72528. * @returns the Vector4.
  72529. */
  72530. Vector4.prototype.toArray = function (array, index) {
  72531. if (index === undefined) {
  72532. index = 0;
  72533. }
  72534. array[index] = this.x;
  72535. array[index + 1] = this.y;
  72536. array[index + 2] = this.z;
  72537. array[index + 3] = this.w;
  72538. return this;
  72539. };
  72540. /**
  72541. * Adds the given vector to the current Vector4.
  72542. * @param otherVector the vector to add
  72543. * @returns the updated Vector4.
  72544. */
  72545. Vector4.prototype.addInPlace = function (otherVector) {
  72546. this.x += otherVector.x;
  72547. this.y += otherVector.y;
  72548. this.z += otherVector.z;
  72549. this.w += otherVector.w;
  72550. return this;
  72551. };
  72552. /**
  72553. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72554. * @param otherVector the vector to add
  72555. * @returns the resulting vector
  72556. */
  72557. Vector4.prototype.add = function (otherVector) {
  72558. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  72559. };
  72560. /**
  72561. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72562. * @param otherVector the vector to add
  72563. * @param result the vector to store the result
  72564. * @returns the current Vector4.
  72565. */
  72566. Vector4.prototype.addToRef = function (otherVector, result) {
  72567. result.x = this.x + otherVector.x;
  72568. result.y = this.y + otherVector.y;
  72569. result.z = this.z + otherVector.z;
  72570. result.w = this.w + otherVector.w;
  72571. return this;
  72572. };
  72573. /**
  72574. * Subtract in place the given vector from the current Vector4.
  72575. * @param otherVector the vector to subtract
  72576. * @returns the updated Vector4.
  72577. */
  72578. Vector4.prototype.subtractInPlace = function (otherVector) {
  72579. this.x -= otherVector.x;
  72580. this.y -= otherVector.y;
  72581. this.z -= otherVector.z;
  72582. this.w -= otherVector.w;
  72583. return this;
  72584. };
  72585. /**
  72586. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72587. * @param otherVector the vector to add
  72588. * @returns the new vector with the result
  72589. */
  72590. Vector4.prototype.subtract = function (otherVector) {
  72591. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  72592. };
  72593. /**
  72594. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72595. * @param otherVector the vector to subtract
  72596. * @param result the vector to store the result
  72597. * @returns the current Vector4.
  72598. */
  72599. Vector4.prototype.subtractToRef = function (otherVector, result) {
  72600. result.x = this.x - otherVector.x;
  72601. result.y = this.y - otherVector.y;
  72602. result.z = this.z - otherVector.z;
  72603. result.w = this.w - otherVector.w;
  72604. return this;
  72605. };
  72606. /**
  72607. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72608. */
  72609. /**
  72610. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72611. * @param x value to subtract
  72612. * @param y value to subtract
  72613. * @param z value to subtract
  72614. * @param w value to subtract
  72615. * @returns new vector containing the result
  72616. */
  72617. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  72618. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  72619. };
  72620. /**
  72621. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72622. * @param x value to subtract
  72623. * @param y value to subtract
  72624. * @param z value to subtract
  72625. * @param w value to subtract
  72626. * @param result the vector to store the result in
  72627. * @returns the current Vector4.
  72628. */
  72629. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  72630. result.x = this.x - x;
  72631. result.y = this.y - y;
  72632. result.z = this.z - z;
  72633. result.w = this.w - w;
  72634. return this;
  72635. };
  72636. /**
  72637. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72638. * @returns a new vector with the negated values
  72639. */
  72640. Vector4.prototype.negate = function () {
  72641. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  72642. };
  72643. /**
  72644. * Multiplies the current Vector4 coordinates by scale (float).
  72645. * @param scale the number to scale with
  72646. * @returns the updated Vector4.
  72647. */
  72648. Vector4.prototype.scaleInPlace = function (scale) {
  72649. this.x *= scale;
  72650. this.y *= scale;
  72651. this.z *= scale;
  72652. this.w *= scale;
  72653. return this;
  72654. };
  72655. /**
  72656. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72657. * @param scale the number to scale with
  72658. * @returns a new vector with the result
  72659. */
  72660. Vector4.prototype.scale = function (scale) {
  72661. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  72662. };
  72663. /**
  72664. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72665. * @param scale the number to scale with
  72666. * @param result a vector to store the result in
  72667. * @returns the current Vector4.
  72668. */
  72669. Vector4.prototype.scaleToRef = function (scale, result) {
  72670. result.x = this.x * scale;
  72671. result.y = this.y * scale;
  72672. result.z = this.z * scale;
  72673. result.w = this.w * scale;
  72674. return this;
  72675. };
  72676. /**
  72677. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72678. * @param scale defines the scale factor
  72679. * @param result defines the Vector4 object where to store the result
  72680. * @returns the unmodified current Vector4
  72681. */
  72682. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  72683. result.x += this.x * scale;
  72684. result.y += this.y * scale;
  72685. result.z += this.z * scale;
  72686. result.w += this.w * scale;
  72687. return this;
  72688. };
  72689. /**
  72690. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72691. * @param otherVector the vector to compare against
  72692. * @returns true if they are equal
  72693. */
  72694. Vector4.prototype.equals = function (otherVector) {
  72695. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  72696. };
  72697. /**
  72698. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72699. * @param otherVector vector to compare against
  72700. * @param epsilon (Default: very small number)
  72701. * @returns true if they are equal
  72702. */
  72703. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  72704. if (epsilon === void 0) { epsilon = Epsilon; }
  72705. return otherVector
  72706. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  72707. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  72708. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  72709. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  72710. };
  72711. /**
  72712. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72713. * @param x x value to compare against
  72714. * @param y y value to compare against
  72715. * @param z z value to compare against
  72716. * @param w w value to compare against
  72717. * @returns true if equal
  72718. */
  72719. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  72720. return this.x === x && this.y === y && this.z === z && this.w === w;
  72721. };
  72722. /**
  72723. * Multiplies in place the current Vector4 by the given one.
  72724. * @param otherVector vector to multiple with
  72725. * @returns the updated Vector4.
  72726. */
  72727. Vector4.prototype.multiplyInPlace = function (otherVector) {
  72728. this.x *= otherVector.x;
  72729. this.y *= otherVector.y;
  72730. this.z *= otherVector.z;
  72731. this.w *= otherVector.w;
  72732. return this;
  72733. };
  72734. /**
  72735. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72736. * @param otherVector vector to multiple with
  72737. * @returns resulting new vector
  72738. */
  72739. Vector4.prototype.multiply = function (otherVector) {
  72740. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  72741. };
  72742. /**
  72743. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72744. * @param otherVector vector to multiple with
  72745. * @param result vector to store the result
  72746. * @returns the current Vector4.
  72747. */
  72748. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  72749. result.x = this.x * otherVector.x;
  72750. result.y = this.y * otherVector.y;
  72751. result.z = this.z * otherVector.z;
  72752. result.w = this.w * otherVector.w;
  72753. return this;
  72754. };
  72755. /**
  72756. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72757. * @param x x value multiply with
  72758. * @param y y value multiply with
  72759. * @param z z value multiply with
  72760. * @param w w value multiply with
  72761. * @returns resulting new vector
  72762. */
  72763. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  72764. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  72765. };
  72766. /**
  72767. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72768. * @param otherVector vector to devide with
  72769. * @returns resulting new vector
  72770. */
  72771. Vector4.prototype.divide = function (otherVector) {
  72772. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  72773. };
  72774. /**
  72775. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72776. * @param otherVector vector to devide with
  72777. * @param result vector to store the result
  72778. * @returns the current Vector4.
  72779. */
  72780. Vector4.prototype.divideToRef = function (otherVector, result) {
  72781. result.x = this.x / otherVector.x;
  72782. result.y = this.y / otherVector.y;
  72783. result.z = this.z / otherVector.z;
  72784. result.w = this.w / otherVector.w;
  72785. return this;
  72786. };
  72787. /**
  72788. * Divides the current Vector3 coordinates by the given ones.
  72789. * @param otherVector vector to devide with
  72790. * @returns the updated Vector3.
  72791. */
  72792. Vector4.prototype.divideInPlace = function (otherVector) {
  72793. return this.divideToRef(otherVector, this);
  72794. };
  72795. /**
  72796. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72797. * @param other defines the second operand
  72798. * @returns the current updated Vector4
  72799. */
  72800. Vector4.prototype.minimizeInPlace = function (other) {
  72801. if (other.x < this.x) {
  72802. this.x = other.x;
  72803. }
  72804. if (other.y < this.y) {
  72805. this.y = other.y;
  72806. }
  72807. if (other.z < this.z) {
  72808. this.z = other.z;
  72809. }
  72810. if (other.w < this.w) {
  72811. this.w = other.w;
  72812. }
  72813. return this;
  72814. };
  72815. /**
  72816. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72817. * @param other defines the second operand
  72818. * @returns the current updated Vector4
  72819. */
  72820. Vector4.prototype.maximizeInPlace = function (other) {
  72821. if (other.x > this.x) {
  72822. this.x = other.x;
  72823. }
  72824. if (other.y > this.y) {
  72825. this.y = other.y;
  72826. }
  72827. if (other.z > this.z) {
  72828. this.z = other.z;
  72829. }
  72830. if (other.w > this.w) {
  72831. this.w = other.w;
  72832. }
  72833. return this;
  72834. };
  72835. /**
  72836. * Gets a new Vector4 from current Vector4 floored values
  72837. * @returns a new Vector4
  72838. */
  72839. Vector4.prototype.floor = function () {
  72840. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  72841. };
  72842. /**
  72843. * Gets a new Vector4 from current Vector3 floored values
  72844. * @returns a new Vector4
  72845. */
  72846. Vector4.prototype.fract = function () {
  72847. 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));
  72848. };
  72849. // Properties
  72850. /**
  72851. * Returns the Vector4 length (float).
  72852. * @returns the length
  72853. */
  72854. Vector4.prototype.length = function () {
  72855. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  72856. };
  72857. /**
  72858. * Returns the Vector4 squared length (float).
  72859. * @returns the length squared
  72860. */
  72861. Vector4.prototype.lengthSquared = function () {
  72862. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  72863. };
  72864. // Methods
  72865. /**
  72866. * Normalizes in place the Vector4.
  72867. * @returns the updated Vector4.
  72868. */
  72869. Vector4.prototype.normalize = function () {
  72870. var len = this.length();
  72871. if (len === 0) {
  72872. return this;
  72873. }
  72874. return this.scaleInPlace(1.0 / len);
  72875. };
  72876. /**
  72877. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72878. * @returns this converted to a new vector3
  72879. */
  72880. Vector4.prototype.toVector3 = function () {
  72881. return new Vector3(this.x, this.y, this.z);
  72882. };
  72883. /**
  72884. * Returns a new Vector4 copied from the current one.
  72885. * @returns the new cloned vector
  72886. */
  72887. Vector4.prototype.clone = function () {
  72888. return new Vector4(this.x, this.y, this.z, this.w);
  72889. };
  72890. /**
  72891. * Updates the current Vector4 with the given one coordinates.
  72892. * @param source the source vector to copy from
  72893. * @returns the updated Vector4.
  72894. */
  72895. Vector4.prototype.copyFrom = function (source) {
  72896. this.x = source.x;
  72897. this.y = source.y;
  72898. this.z = source.z;
  72899. this.w = source.w;
  72900. return this;
  72901. };
  72902. /**
  72903. * Updates the current Vector4 coordinates with the given floats.
  72904. * @param x float to copy from
  72905. * @param y float to copy from
  72906. * @param z float to copy from
  72907. * @param w float to copy from
  72908. * @returns the updated Vector4.
  72909. */
  72910. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  72911. this.x = x;
  72912. this.y = y;
  72913. this.z = z;
  72914. this.w = w;
  72915. return this;
  72916. };
  72917. /**
  72918. * Updates the current Vector4 coordinates with the given floats.
  72919. * @param x float to set from
  72920. * @param y float to set from
  72921. * @param z float to set from
  72922. * @param w float to set from
  72923. * @returns the updated Vector4.
  72924. */
  72925. Vector4.prototype.set = function (x, y, z, w) {
  72926. return this.copyFromFloats(x, y, z, w);
  72927. };
  72928. /**
  72929. * Copies the given float to the current Vector3 coordinates
  72930. * @param v defines the x, y, z and w coordinates of the operand
  72931. * @returns the current updated Vector3
  72932. */
  72933. Vector4.prototype.setAll = function (v) {
  72934. this.x = this.y = this.z = this.w = v;
  72935. return this;
  72936. };
  72937. // Statics
  72938. /**
  72939. * Returns a new Vector4 set from the starting index of the given array.
  72940. * @param array the array to pull values from
  72941. * @param offset the offset into the array to start at
  72942. * @returns the new vector
  72943. */
  72944. Vector4.FromArray = function (array, offset) {
  72945. if (!offset) {
  72946. offset = 0;
  72947. }
  72948. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  72949. };
  72950. /**
  72951. * Updates the given vector "result" from the starting index of the given array.
  72952. * @param array the array to pull values from
  72953. * @param offset the offset into the array to start at
  72954. * @param result the vector to store the result in
  72955. */
  72956. Vector4.FromArrayToRef = function (array, offset, result) {
  72957. result.x = array[offset];
  72958. result.y = array[offset + 1];
  72959. result.z = array[offset + 2];
  72960. result.w = array[offset + 3];
  72961. };
  72962. /**
  72963. * Updates the given vector "result" from the starting index of the given Float32Array.
  72964. * @param array the array to pull values from
  72965. * @param offset the offset into the array to start at
  72966. * @param result the vector to store the result in
  72967. */
  72968. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  72969. Vector4.FromArrayToRef(array, offset, result);
  72970. };
  72971. /**
  72972. * Updates the given vector "result" coordinates from the given floats.
  72973. * @param x float to set from
  72974. * @param y float to set from
  72975. * @param z float to set from
  72976. * @param w float to set from
  72977. * @param result the vector to the floats in
  72978. */
  72979. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  72980. result.x = x;
  72981. result.y = y;
  72982. result.z = z;
  72983. result.w = w;
  72984. };
  72985. /**
  72986. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72987. * @returns the new vector
  72988. */
  72989. Vector4.Zero = function () {
  72990. return new Vector4(0.0, 0.0, 0.0, 0.0);
  72991. };
  72992. /**
  72993. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72994. * @returns the new vector
  72995. */
  72996. Vector4.One = function () {
  72997. return new Vector4(1.0, 1.0, 1.0, 1.0);
  72998. };
  72999. /**
  73000. * Returns a new normalized Vector4 from the given one.
  73001. * @param vector the vector to normalize
  73002. * @returns the vector
  73003. */
  73004. Vector4.Normalize = function (vector) {
  73005. var result = Vector4.Zero();
  73006. Vector4.NormalizeToRef(vector, result);
  73007. return result;
  73008. };
  73009. /**
  73010. * Updates the given vector "result" from the normalization of the given one.
  73011. * @param vector the vector to normalize
  73012. * @param result the vector to store the result in
  73013. */
  73014. Vector4.NormalizeToRef = function (vector, result) {
  73015. result.copyFrom(vector);
  73016. result.normalize();
  73017. };
  73018. /**
  73019. * Returns a vector with the minimum values from the left and right vectors
  73020. * @param left left vector to minimize
  73021. * @param right right vector to minimize
  73022. * @returns a new vector with the minimum of the left and right vector values
  73023. */
  73024. Vector4.Minimize = function (left, right) {
  73025. var min = left.clone();
  73026. min.minimizeInPlace(right);
  73027. return min;
  73028. };
  73029. /**
  73030. * Returns a vector with the maximum values from the left and right vectors
  73031. * @param left left vector to maximize
  73032. * @param right right vector to maximize
  73033. * @returns a new vector with the maximum of the left and right vector values
  73034. */
  73035. Vector4.Maximize = function (left, right) {
  73036. var max = left.clone();
  73037. max.maximizeInPlace(right);
  73038. return max;
  73039. };
  73040. /**
  73041. * Returns the distance (float) between the vectors "value1" and "value2".
  73042. * @param value1 value to calulate the distance between
  73043. * @param value2 value to calulate the distance between
  73044. * @return the distance between the two vectors
  73045. */
  73046. Vector4.Distance = function (value1, value2) {
  73047. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  73048. };
  73049. /**
  73050. * Returns the squared distance (float) between the vectors "value1" and "value2".
  73051. * @param value1 value to calulate the distance between
  73052. * @param value2 value to calulate the distance between
  73053. * @return the distance between the two vectors squared
  73054. */
  73055. Vector4.DistanceSquared = function (value1, value2) {
  73056. var x = value1.x - value2.x;
  73057. var y = value1.y - value2.y;
  73058. var z = value1.z - value2.z;
  73059. var w = value1.w - value2.w;
  73060. return (x * x) + (y * y) + (z * z) + (w * w);
  73061. };
  73062. /**
  73063. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  73064. * @param value1 value to calulate the center between
  73065. * @param value2 value to calulate the center between
  73066. * @return the center between the two vectors
  73067. */
  73068. Vector4.Center = function (value1, value2) {
  73069. var center = value1.add(value2);
  73070. center.scaleInPlace(0.5);
  73071. return center;
  73072. };
  73073. /**
  73074. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  73075. * This methods computes transformed normalized direction vectors only.
  73076. * @param vector the vector to transform
  73077. * @param transformation the transformation matrix to apply
  73078. * @returns the new vector
  73079. */
  73080. Vector4.TransformNormal = function (vector, transformation) {
  73081. var result = Vector4.Zero();
  73082. Vector4.TransformNormalToRef(vector, transformation, result);
  73083. return result;
  73084. };
  73085. /**
  73086. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  73087. * This methods computes transformed normalized direction vectors only.
  73088. * @param vector the vector to transform
  73089. * @param transformation the transformation matrix to apply
  73090. * @param result the vector to store the result in
  73091. */
  73092. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  73093. var m = transformation.m;
  73094. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  73095. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  73096. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  73097. result.x = x;
  73098. result.y = y;
  73099. result.z = z;
  73100. result.w = vector.w;
  73101. };
  73102. /**
  73103. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  73104. * This methods computes transformed normalized direction vectors only.
  73105. * @param x value to transform
  73106. * @param y value to transform
  73107. * @param z value to transform
  73108. * @param w value to transform
  73109. * @param transformation the transformation matrix to apply
  73110. * @param result the vector to store the results in
  73111. */
  73112. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  73113. var m = transformation.m;
  73114. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  73115. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  73116. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  73117. result.w = w;
  73118. };
  73119. /**
  73120. * Creates a new Vector4 from a Vector3
  73121. * @param source defines the source data
  73122. * @param w defines the 4th component (default is 0)
  73123. * @returns a new Vector4
  73124. */
  73125. Vector4.FromVector3 = function (source, w) {
  73126. if (w === void 0) { w = 0; }
  73127. return new Vector4(source.x, source.y, source.z, w);
  73128. };
  73129. return Vector4;
  73130. }());
  73131. /**
  73132. * Size containing widht and height
  73133. */
  73134. var Size = /** @class */ (function () {
  73135. /**
  73136. * Creates a Size object from the given width and height (floats).
  73137. * @param width width of the new size
  73138. * @param height height of the new size
  73139. */
  73140. function Size(width, height) {
  73141. this.width = width;
  73142. this.height = height;
  73143. }
  73144. /**
  73145. * Returns a string with the Size width and height
  73146. * @returns a string with the Size width and height
  73147. */
  73148. Size.prototype.toString = function () {
  73149. return "{W: " + this.width + ", H: " + this.height + "}";
  73150. };
  73151. /**
  73152. * "Size"
  73153. * @returns the string "Size"
  73154. */
  73155. Size.prototype.getClassName = function () {
  73156. return "Size";
  73157. };
  73158. /**
  73159. * Returns the Size hash code.
  73160. * @returns a hash code for a unique width and height
  73161. */
  73162. Size.prototype.getHashCode = function () {
  73163. var hash = this.width || 0;
  73164. hash = (hash * 397) ^ (this.height || 0);
  73165. return hash;
  73166. };
  73167. /**
  73168. * Updates the current size from the given one.
  73169. * @param src the given size
  73170. */
  73171. Size.prototype.copyFrom = function (src) {
  73172. this.width = src.width;
  73173. this.height = src.height;
  73174. };
  73175. /**
  73176. * Updates in place the current Size from the given floats.
  73177. * @param width width of the new size
  73178. * @param height height of the new size
  73179. * @returns the updated Size.
  73180. */
  73181. Size.prototype.copyFromFloats = function (width, height) {
  73182. this.width = width;
  73183. this.height = height;
  73184. return this;
  73185. };
  73186. /**
  73187. * Updates in place the current Size from the given floats.
  73188. * @param width width to set
  73189. * @param height height to set
  73190. * @returns the updated Size.
  73191. */
  73192. Size.prototype.set = function (width, height) {
  73193. return this.copyFromFloats(width, height);
  73194. };
  73195. /**
  73196. * Multiplies the width and height by numbers
  73197. * @param w factor to multiple the width by
  73198. * @param h factor to multiple the height by
  73199. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  73200. */
  73201. Size.prototype.multiplyByFloats = function (w, h) {
  73202. return new Size(this.width * w, this.height * h);
  73203. };
  73204. /**
  73205. * Clones the size
  73206. * @returns a new Size copied from the given one.
  73207. */
  73208. Size.prototype.clone = function () {
  73209. return new Size(this.width, this.height);
  73210. };
  73211. /**
  73212. * True if the current Size and the given one width and height are strictly equal.
  73213. * @param other the other size to compare against
  73214. * @returns True if the current Size and the given one width and height are strictly equal.
  73215. */
  73216. Size.prototype.equals = function (other) {
  73217. if (!other) {
  73218. return false;
  73219. }
  73220. return (this.width === other.width) && (this.height === other.height);
  73221. };
  73222. Object.defineProperty(Size.prototype, "surface", {
  73223. /**
  73224. * The surface of the Size : width * height (float).
  73225. */
  73226. get: function () {
  73227. return this.width * this.height;
  73228. },
  73229. enumerable: true,
  73230. configurable: true
  73231. });
  73232. /**
  73233. * Create a new size of zero
  73234. * @returns a new Size set to (0.0, 0.0)
  73235. */
  73236. Size.Zero = function () {
  73237. return new Size(0.0, 0.0);
  73238. };
  73239. /**
  73240. * Sums the width and height of two sizes
  73241. * @param otherSize size to add to this size
  73242. * @returns a new Size set as the addition result of the current Size and the given one.
  73243. */
  73244. Size.prototype.add = function (otherSize) {
  73245. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  73246. return r;
  73247. };
  73248. /**
  73249. * Subtracts the width and height of two
  73250. * @param otherSize size to subtract to this size
  73251. * @returns a new Size set as the subtraction result of the given one from the current Size.
  73252. */
  73253. Size.prototype.subtract = function (otherSize) {
  73254. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  73255. return r;
  73256. };
  73257. /**
  73258. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  73259. * @param start starting size to lerp between
  73260. * @param end end size to lerp between
  73261. * @param amount amount to lerp between the start and end values
  73262. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  73263. */
  73264. Size.Lerp = function (start, end, amount) {
  73265. var w = start.width + ((end.width - start.width) * amount);
  73266. var h = start.height + ((end.height - start.height) * amount);
  73267. return new Size(w, h);
  73268. };
  73269. return Size;
  73270. }());
  73271. /**
  73272. * Class used to store quaternion data
  73273. * @see https://en.wikipedia.org/wiki/Quaternion
  73274. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  73275. */
  73276. var Quaternion = /** @class */ (function () {
  73277. /**
  73278. * Creates a new Quaternion from the given floats
  73279. * @param x defines the first component (0 by default)
  73280. * @param y defines the second component (0 by default)
  73281. * @param z defines the third component (0 by default)
  73282. * @param w defines the fourth component (1.0 by default)
  73283. */
  73284. function Quaternion(
  73285. /** defines the first component (0 by default) */
  73286. x,
  73287. /** defines the second component (0 by default) */
  73288. y,
  73289. /** defines the third component (0 by default) */
  73290. z,
  73291. /** defines the fourth component (1.0 by default) */
  73292. w) {
  73293. if (x === void 0) { x = 0.0; }
  73294. if (y === void 0) { y = 0.0; }
  73295. if (z === void 0) { z = 0.0; }
  73296. if (w === void 0) { w = 1.0; }
  73297. this.x = x;
  73298. this.y = y;
  73299. this.z = z;
  73300. this.w = w;
  73301. }
  73302. /**
  73303. * Gets a string representation for the current quaternion
  73304. * @returns a string with the Quaternion coordinates
  73305. */
  73306. Quaternion.prototype.toString = function () {
  73307. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  73308. };
  73309. /**
  73310. * Gets the class name of the quaternion
  73311. * @returns the string "Quaternion"
  73312. */
  73313. Quaternion.prototype.getClassName = function () {
  73314. return "Quaternion";
  73315. };
  73316. /**
  73317. * Gets a hash code for this quaternion
  73318. * @returns the quaternion hash code
  73319. */
  73320. Quaternion.prototype.getHashCode = function () {
  73321. var hash = this.x || 0;
  73322. hash = (hash * 397) ^ (this.y || 0);
  73323. hash = (hash * 397) ^ (this.z || 0);
  73324. hash = (hash * 397) ^ (this.w || 0);
  73325. return hash;
  73326. };
  73327. /**
  73328. * Copy the quaternion to an array
  73329. * @returns a new array populated with 4 elements from the quaternion coordinates
  73330. */
  73331. Quaternion.prototype.asArray = function () {
  73332. return [this.x, this.y, this.z, this.w];
  73333. };
  73334. /**
  73335. * Check if two quaternions are equals
  73336. * @param otherQuaternion defines the second operand
  73337. * @return true if the current quaternion and the given one coordinates are strictly equals
  73338. */
  73339. Quaternion.prototype.equals = function (otherQuaternion) {
  73340. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  73341. };
  73342. /**
  73343. * Clone the current quaternion
  73344. * @returns a new quaternion copied from the current one
  73345. */
  73346. Quaternion.prototype.clone = function () {
  73347. return new Quaternion(this.x, this.y, this.z, this.w);
  73348. };
  73349. /**
  73350. * Copy a quaternion to the current one
  73351. * @param other defines the other quaternion
  73352. * @returns the updated current quaternion
  73353. */
  73354. Quaternion.prototype.copyFrom = function (other) {
  73355. this.x = other.x;
  73356. this.y = other.y;
  73357. this.z = other.z;
  73358. this.w = other.w;
  73359. return this;
  73360. };
  73361. /**
  73362. * Updates the current quaternion with the given float coordinates
  73363. * @param x defines the x coordinate
  73364. * @param y defines the y coordinate
  73365. * @param z defines the z coordinate
  73366. * @param w defines the w coordinate
  73367. * @returns the updated current quaternion
  73368. */
  73369. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  73370. this.x = x;
  73371. this.y = y;
  73372. this.z = z;
  73373. this.w = w;
  73374. return this;
  73375. };
  73376. /**
  73377. * Updates the current quaternion from the given float coordinates
  73378. * @param x defines the x coordinate
  73379. * @param y defines the y coordinate
  73380. * @param z defines the z coordinate
  73381. * @param w defines the w coordinate
  73382. * @returns the updated current quaternion
  73383. */
  73384. Quaternion.prototype.set = function (x, y, z, w) {
  73385. return this.copyFromFloats(x, y, z, w);
  73386. };
  73387. /**
  73388. * Adds two quaternions
  73389. * @param other defines the second operand
  73390. * @returns a new quaternion as the addition result of the given one and the current quaternion
  73391. */
  73392. Quaternion.prototype.add = function (other) {
  73393. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  73394. };
  73395. /**
  73396. * Add a quaternion to the current one
  73397. * @param other defines the quaternion to add
  73398. * @returns the current quaternion
  73399. */
  73400. Quaternion.prototype.addInPlace = function (other) {
  73401. this.x += other.x;
  73402. this.y += other.y;
  73403. this.z += other.z;
  73404. this.w += other.w;
  73405. return this;
  73406. };
  73407. /**
  73408. * Subtract two quaternions
  73409. * @param other defines the second operand
  73410. * @returns a new quaternion as the subtraction result of the given one from the current one
  73411. */
  73412. Quaternion.prototype.subtract = function (other) {
  73413. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  73414. };
  73415. /**
  73416. * Multiplies the current quaternion by a scale factor
  73417. * @param value defines the scale factor
  73418. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  73419. */
  73420. Quaternion.prototype.scale = function (value) {
  73421. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  73422. };
  73423. /**
  73424. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  73425. * @param scale defines the scale factor
  73426. * @param result defines the Quaternion object where to store the result
  73427. * @returns the unmodified current quaternion
  73428. */
  73429. Quaternion.prototype.scaleToRef = function (scale, result) {
  73430. result.x = this.x * scale;
  73431. result.y = this.y * scale;
  73432. result.z = this.z * scale;
  73433. result.w = this.w * scale;
  73434. return this;
  73435. };
  73436. /**
  73437. * Multiplies in place the current quaternion by a scale factor
  73438. * @param value defines the scale factor
  73439. * @returns the current modified quaternion
  73440. */
  73441. Quaternion.prototype.scaleInPlace = function (value) {
  73442. this.x *= value;
  73443. this.y *= value;
  73444. this.z *= value;
  73445. this.w *= value;
  73446. return this;
  73447. };
  73448. /**
  73449. * Scale the current quaternion values by a factor and add the result to a given quaternion
  73450. * @param scale defines the scale factor
  73451. * @param result defines the Quaternion object where to store the result
  73452. * @returns the unmodified current quaternion
  73453. */
  73454. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  73455. result.x += this.x * scale;
  73456. result.y += this.y * scale;
  73457. result.z += this.z * scale;
  73458. result.w += this.w * scale;
  73459. return this;
  73460. };
  73461. /**
  73462. * Multiplies two quaternions
  73463. * @param q1 defines the second operand
  73464. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  73465. */
  73466. Quaternion.prototype.multiply = function (q1) {
  73467. var result = new Quaternion(0, 0, 0, 1.0);
  73468. this.multiplyToRef(q1, result);
  73469. return result;
  73470. };
  73471. /**
  73472. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  73473. * @param q1 defines the second operand
  73474. * @param result defines the target quaternion
  73475. * @returns the current quaternion
  73476. */
  73477. Quaternion.prototype.multiplyToRef = function (q1, result) {
  73478. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  73479. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  73480. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  73481. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  73482. result.copyFromFloats(x, y, z, w);
  73483. return this;
  73484. };
  73485. /**
  73486. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  73487. * @param q1 defines the second operand
  73488. * @returns the currentupdated quaternion
  73489. */
  73490. Quaternion.prototype.multiplyInPlace = function (q1) {
  73491. this.multiplyToRef(q1, this);
  73492. return this;
  73493. };
  73494. /**
  73495. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  73496. * @param ref defines the target quaternion
  73497. * @returns the current quaternion
  73498. */
  73499. Quaternion.prototype.conjugateToRef = function (ref) {
  73500. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  73501. return this;
  73502. };
  73503. /**
  73504. * Conjugates in place (1-q) the current quaternion
  73505. * @returns the current updated quaternion
  73506. */
  73507. Quaternion.prototype.conjugateInPlace = function () {
  73508. this.x *= -1;
  73509. this.y *= -1;
  73510. this.z *= -1;
  73511. return this;
  73512. };
  73513. /**
  73514. * Conjugates in place (1-q) the current quaternion
  73515. * @returns a new quaternion
  73516. */
  73517. Quaternion.prototype.conjugate = function () {
  73518. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  73519. return result;
  73520. };
  73521. /**
  73522. * Gets length of current quaternion
  73523. * @returns the quaternion length (float)
  73524. */
  73525. Quaternion.prototype.length = function () {
  73526. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  73527. };
  73528. /**
  73529. * Normalize in place the current quaternion
  73530. * @returns the current updated quaternion
  73531. */
  73532. Quaternion.prototype.normalize = function () {
  73533. var len = this.length();
  73534. if (len === 0) {
  73535. return this;
  73536. }
  73537. var inv = 1.0 / len;
  73538. this.x *= inv;
  73539. this.y *= inv;
  73540. this.z *= inv;
  73541. this.w *= inv;
  73542. return this;
  73543. };
  73544. /**
  73545. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  73546. * @param order is a reserved parameter and is ignore for now
  73547. * @returns a new Vector3 containing the Euler angles
  73548. */
  73549. Quaternion.prototype.toEulerAngles = function (order) {
  73550. if (order === void 0) { order = "YZX"; }
  73551. var result = Vector3.Zero();
  73552. this.toEulerAnglesToRef(result);
  73553. return result;
  73554. };
  73555. /**
  73556. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  73557. * @param result defines the vector which will be filled with the Euler angles
  73558. * @param order is a reserved parameter and is ignore for now
  73559. * @returns the current unchanged quaternion
  73560. */
  73561. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  73562. var qz = this.z;
  73563. var qx = this.x;
  73564. var qy = this.y;
  73565. var qw = this.w;
  73566. var sqw = qw * qw;
  73567. var sqz = qz * qz;
  73568. var sqx = qx * qx;
  73569. var sqy = qy * qy;
  73570. var zAxisY = qy * qz - qx * qw;
  73571. var limit = .4999999;
  73572. if (zAxisY < -limit) {
  73573. result.y = 2 * Math.atan2(qy, qw);
  73574. result.x = Math.PI / 2;
  73575. result.z = 0;
  73576. }
  73577. else if (zAxisY > limit) {
  73578. result.y = 2 * Math.atan2(qy, qw);
  73579. result.x = -Math.PI / 2;
  73580. result.z = 0;
  73581. }
  73582. else {
  73583. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  73584. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  73585. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  73586. }
  73587. return this;
  73588. };
  73589. /**
  73590. * Updates the given rotation matrix with the current quaternion values
  73591. * @param result defines the target matrix
  73592. * @returns the current unchanged quaternion
  73593. */
  73594. Quaternion.prototype.toRotationMatrix = function (result) {
  73595. Matrix.FromQuaternionToRef(this, result);
  73596. return this;
  73597. };
  73598. /**
  73599. * Updates the current quaternion from the given rotation matrix values
  73600. * @param matrix defines the source matrix
  73601. * @returns the current updated quaternion
  73602. */
  73603. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  73604. Quaternion.FromRotationMatrixToRef(matrix, this);
  73605. return this;
  73606. };
  73607. // Statics
  73608. /**
  73609. * Creates a new quaternion from a rotation matrix
  73610. * @param matrix defines the source matrix
  73611. * @returns a new quaternion created from the given rotation matrix values
  73612. */
  73613. Quaternion.FromRotationMatrix = function (matrix) {
  73614. var result = new Quaternion();
  73615. Quaternion.FromRotationMatrixToRef(matrix, result);
  73616. return result;
  73617. };
  73618. /**
  73619. * Updates the given quaternion with the given rotation matrix values
  73620. * @param matrix defines the source matrix
  73621. * @param result defines the target quaternion
  73622. */
  73623. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  73624. var data = matrix.m;
  73625. var m11 = data[0], m12 = data[4], m13 = data[8];
  73626. var m21 = data[1], m22 = data[5], m23 = data[9];
  73627. var m31 = data[2], m32 = data[6], m33 = data[10];
  73628. var trace = m11 + m22 + m33;
  73629. var s;
  73630. if (trace > 0) {
  73631. s = 0.5 / Math.sqrt(trace + 1.0);
  73632. result.w = 0.25 / s;
  73633. result.x = (m32 - m23) * s;
  73634. result.y = (m13 - m31) * s;
  73635. result.z = (m21 - m12) * s;
  73636. }
  73637. else if (m11 > m22 && m11 > m33) {
  73638. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  73639. result.w = (m32 - m23) / s;
  73640. result.x = 0.25 * s;
  73641. result.y = (m12 + m21) / s;
  73642. result.z = (m13 + m31) / s;
  73643. }
  73644. else if (m22 > m33) {
  73645. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  73646. result.w = (m13 - m31) / s;
  73647. result.x = (m12 + m21) / s;
  73648. result.y = 0.25 * s;
  73649. result.z = (m23 + m32) / s;
  73650. }
  73651. else {
  73652. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  73653. result.w = (m21 - m12) / s;
  73654. result.x = (m13 + m31) / s;
  73655. result.y = (m23 + m32) / s;
  73656. result.z = 0.25 * s;
  73657. }
  73658. };
  73659. /**
  73660. * Returns the dot product (float) between the quaternions "left" and "right"
  73661. * @param left defines the left operand
  73662. * @param right defines the right operand
  73663. * @returns the dot product
  73664. */
  73665. Quaternion.Dot = function (left, right) {
  73666. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  73667. };
  73668. /**
  73669. * Checks if the two quaternions are close to each other
  73670. * @param quat0 defines the first quaternion to check
  73671. * @param quat1 defines the second quaternion to check
  73672. * @returns true if the two quaternions are close to each other
  73673. */
  73674. Quaternion.AreClose = function (quat0, quat1) {
  73675. var dot = Quaternion.Dot(quat0, quat1);
  73676. return dot >= 0;
  73677. };
  73678. /**
  73679. * Creates an empty quaternion
  73680. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  73681. */
  73682. Quaternion.Zero = function () {
  73683. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  73684. };
  73685. /**
  73686. * Inverse a given quaternion
  73687. * @param q defines the source quaternion
  73688. * @returns a new quaternion as the inverted current quaternion
  73689. */
  73690. Quaternion.Inverse = function (q) {
  73691. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  73692. };
  73693. /**
  73694. * Inverse a given quaternion
  73695. * @param q defines the source quaternion
  73696. * @param result the quaternion the result will be stored in
  73697. * @returns the result quaternion
  73698. */
  73699. Quaternion.InverseToRef = function (q, result) {
  73700. result.set(-q.x, -q.y, -q.z, q.w);
  73701. return result;
  73702. };
  73703. /**
  73704. * Creates an identity quaternion
  73705. * @returns the identity quaternion
  73706. */
  73707. Quaternion.Identity = function () {
  73708. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  73709. };
  73710. /**
  73711. * Gets a boolean indicating if the given quaternion is identity
  73712. * @param quaternion defines the quaternion to check
  73713. * @returns true if the quaternion is identity
  73714. */
  73715. Quaternion.IsIdentity = function (quaternion) {
  73716. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  73717. };
  73718. /**
  73719. * Creates a quaternion from a rotation around an axis
  73720. * @param axis defines the axis to use
  73721. * @param angle defines the angle to use
  73722. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  73723. */
  73724. Quaternion.RotationAxis = function (axis, angle) {
  73725. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  73726. };
  73727. /**
  73728. * Creates a rotation around an axis and stores it into the given quaternion
  73729. * @param axis defines the axis to use
  73730. * @param angle defines the angle to use
  73731. * @param result defines the target quaternion
  73732. * @returns the target quaternion
  73733. */
  73734. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  73735. var sin = Math.sin(angle / 2);
  73736. axis.normalize();
  73737. result.w = Math.cos(angle / 2);
  73738. result.x = axis.x * sin;
  73739. result.y = axis.y * sin;
  73740. result.z = axis.z * sin;
  73741. return result;
  73742. };
  73743. /**
  73744. * Creates a new quaternion from data stored into an array
  73745. * @param array defines the data source
  73746. * @param offset defines the offset in the source array where the data starts
  73747. * @returns a new quaternion
  73748. */
  73749. Quaternion.FromArray = function (array, offset) {
  73750. if (!offset) {
  73751. offset = 0;
  73752. }
  73753. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  73754. };
  73755. /**
  73756. * Create a quaternion from Euler rotation angles
  73757. * @param x Pitch
  73758. * @param y Yaw
  73759. * @param z Roll
  73760. * @returns the new Quaternion
  73761. */
  73762. Quaternion.FromEulerAngles = function (x, y, z) {
  73763. var q = new Quaternion();
  73764. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  73765. return q;
  73766. };
  73767. /**
  73768. * Updates a quaternion from Euler rotation angles
  73769. * @param x Pitch
  73770. * @param y Yaw
  73771. * @param z Roll
  73772. * @param result the quaternion to store the result
  73773. * @returns the updated quaternion
  73774. */
  73775. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  73776. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  73777. return result;
  73778. };
  73779. /**
  73780. * Create a quaternion from Euler rotation vector
  73781. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73782. * @returns the new Quaternion
  73783. */
  73784. Quaternion.FromEulerVector = function (vec) {
  73785. var q = new Quaternion();
  73786. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  73787. return q;
  73788. };
  73789. /**
  73790. * Updates a quaternion from Euler rotation vector
  73791. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73792. * @param result the quaternion to store the result
  73793. * @returns the updated quaternion
  73794. */
  73795. Quaternion.FromEulerVectorToRef = function (vec, result) {
  73796. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  73797. return result;
  73798. };
  73799. /**
  73800. * Creates a new quaternion from the given Euler float angles (y, x, z)
  73801. * @param yaw defines the rotation around Y axis
  73802. * @param pitch defines the rotation around X axis
  73803. * @param roll defines the rotation around Z axis
  73804. * @returns the new quaternion
  73805. */
  73806. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  73807. var q = new Quaternion();
  73808. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  73809. return q;
  73810. };
  73811. /**
  73812. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  73813. * @param yaw defines the rotation around Y axis
  73814. * @param pitch defines the rotation around X axis
  73815. * @param roll defines the rotation around Z axis
  73816. * @param result defines the target quaternion
  73817. */
  73818. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  73819. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  73820. var halfRoll = roll * 0.5;
  73821. var halfPitch = pitch * 0.5;
  73822. var halfYaw = yaw * 0.5;
  73823. var sinRoll = Math.sin(halfRoll);
  73824. var cosRoll = Math.cos(halfRoll);
  73825. var sinPitch = Math.sin(halfPitch);
  73826. var cosPitch = Math.cos(halfPitch);
  73827. var sinYaw = Math.sin(halfYaw);
  73828. var cosYaw = Math.cos(halfYaw);
  73829. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  73830. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  73831. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  73832. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  73833. };
  73834. /**
  73835. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  73836. * @param alpha defines the rotation around first axis
  73837. * @param beta defines the rotation around second axis
  73838. * @param gamma defines the rotation around third axis
  73839. * @returns the new quaternion
  73840. */
  73841. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  73842. var result = new Quaternion();
  73843. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  73844. return result;
  73845. };
  73846. /**
  73847. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  73848. * @param alpha defines the rotation around first axis
  73849. * @param beta defines the rotation around second axis
  73850. * @param gamma defines the rotation around third axis
  73851. * @param result defines the target quaternion
  73852. */
  73853. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  73854. // Produces a quaternion from Euler angles in the z-x-z orientation
  73855. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  73856. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  73857. var halfBeta = beta * 0.5;
  73858. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  73859. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  73860. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  73861. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  73862. };
  73863. /**
  73864. * 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)
  73865. * @param axis1 defines the first axis
  73866. * @param axis2 defines the second axis
  73867. * @param axis3 defines the third axis
  73868. * @returns the new quaternion
  73869. */
  73870. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  73871. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  73872. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  73873. return quat;
  73874. };
  73875. /**
  73876. * 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
  73877. * @param axis1 defines the first axis
  73878. * @param axis2 defines the second axis
  73879. * @param axis3 defines the third axis
  73880. * @param ref defines the target quaternion
  73881. */
  73882. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  73883. var rotMat = MathTmp.Matrix[0];
  73884. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  73885. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  73886. };
  73887. /**
  73888. * Interpolates between two quaternions
  73889. * @param left defines first quaternion
  73890. * @param right defines second quaternion
  73891. * @param amount defines the gradient to use
  73892. * @returns the new interpolated quaternion
  73893. */
  73894. Quaternion.Slerp = function (left, right, amount) {
  73895. var result = Quaternion.Identity();
  73896. Quaternion.SlerpToRef(left, right, amount, result);
  73897. return result;
  73898. };
  73899. /**
  73900. * Interpolates between two quaternions and stores it into a target quaternion
  73901. * @param left defines first quaternion
  73902. * @param right defines second quaternion
  73903. * @param amount defines the gradient to use
  73904. * @param result defines the target quaternion
  73905. */
  73906. Quaternion.SlerpToRef = function (left, right, amount, result) {
  73907. var num2;
  73908. var num3;
  73909. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  73910. var flag = false;
  73911. if (num4 < 0) {
  73912. flag = true;
  73913. num4 = -num4;
  73914. }
  73915. if (num4 > 0.999999) {
  73916. num3 = 1 - amount;
  73917. num2 = flag ? -amount : amount;
  73918. }
  73919. else {
  73920. var num5 = Math.acos(num4);
  73921. var num6 = (1.0 / Math.sin(num5));
  73922. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  73923. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  73924. }
  73925. result.x = (num3 * left.x) + (num2 * right.x);
  73926. result.y = (num3 * left.y) + (num2 * right.y);
  73927. result.z = (num3 * left.z) + (num2 * right.z);
  73928. result.w = (num3 * left.w) + (num2 * right.w);
  73929. };
  73930. /**
  73931. * Interpolate between two quaternions using Hermite interpolation
  73932. * @param value1 defines first quaternion
  73933. * @param tangent1 defines the incoming tangent
  73934. * @param value2 defines second quaternion
  73935. * @param tangent2 defines the outgoing tangent
  73936. * @param amount defines the target quaternion
  73937. * @returns the new interpolated quaternion
  73938. */
  73939. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  73940. var squared = amount * amount;
  73941. var cubed = amount * squared;
  73942. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  73943. var part2 = (-2.0 * cubed) + (3.0 * squared);
  73944. var part3 = (cubed - (2.0 * squared)) + amount;
  73945. var part4 = cubed - squared;
  73946. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  73947. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  73948. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  73949. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  73950. return new Quaternion(x, y, z, w);
  73951. };
  73952. return Quaternion;
  73953. }());
  73954. /**
  73955. * Class used to store matrix data (4x4)
  73956. */
  73957. var Matrix = /** @class */ (function () {
  73958. /**
  73959. * Creates an empty matrix (filled with zeros)
  73960. */
  73961. function Matrix() {
  73962. this._isIdentity = false;
  73963. this._isIdentityDirty = true;
  73964. this._isIdentity3x2 = true;
  73965. this._isIdentity3x2Dirty = true;
  73966. this._m = new Float32Array(16);
  73967. this._updateIdentityStatus(false);
  73968. }
  73969. Object.defineProperty(Matrix.prototype, "m", {
  73970. /**
  73971. * Gets the internal data of the matrix
  73972. */
  73973. get: function () { return this._m; },
  73974. enumerable: true,
  73975. configurable: true
  73976. });
  73977. /** @hidden */
  73978. Matrix.prototype._markAsUpdated = function () {
  73979. this.updateFlag = Matrix._updateFlagSeed++;
  73980. this._isIdentity = false;
  73981. this._isIdentity3x2 = false;
  73982. this._isIdentityDirty = true;
  73983. this._isIdentity3x2Dirty = true;
  73984. };
  73985. /** @hidden */
  73986. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  73987. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  73988. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  73989. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  73990. this.updateFlag = Matrix._updateFlagSeed++;
  73991. this._isIdentity = isIdentity;
  73992. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  73993. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  73994. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  73995. };
  73996. // Properties
  73997. /**
  73998. * Check if the current matrix is identity
  73999. * @returns true is the matrix is the identity matrix
  74000. */
  74001. Matrix.prototype.isIdentity = function () {
  74002. if (this._isIdentityDirty) {
  74003. this._isIdentityDirty = false;
  74004. var m = this._m;
  74005. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  74006. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  74007. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  74008. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  74009. }
  74010. return this._isIdentity;
  74011. };
  74012. /**
  74013. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74014. * @returns true is the matrix is the identity matrix
  74015. */
  74016. Matrix.prototype.isIdentityAs3x2 = function () {
  74017. if (this._isIdentity3x2Dirty) {
  74018. this._isIdentity3x2Dirty = false;
  74019. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  74020. this._isIdentity3x2 = false;
  74021. }
  74022. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  74023. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  74024. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  74025. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  74026. this._isIdentity3x2 = false;
  74027. }
  74028. else {
  74029. this._isIdentity3x2 = true;
  74030. }
  74031. }
  74032. return this._isIdentity3x2;
  74033. };
  74034. /**
  74035. * Gets the determinant of the matrix
  74036. * @returns the matrix determinant
  74037. */
  74038. Matrix.prototype.determinant = function () {
  74039. if (this._isIdentity === true) {
  74040. return 1;
  74041. }
  74042. var m = this._m;
  74043. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  74044. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  74045. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  74046. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  74047. // https://en.wikipedia.org/wiki/Laplace_expansion
  74048. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  74049. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  74050. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  74051. // where
  74052. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  74053. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  74054. //
  74055. // Here we do that for the 1st row.
  74056. var det_22_33 = m22 * m33 - m32 * m23;
  74057. var det_21_33 = m21 * m33 - m31 * m23;
  74058. var det_21_32 = m21 * m32 - m31 * m22;
  74059. var det_20_33 = m20 * m33 - m30 * m23;
  74060. var det_20_32 = m20 * m32 - m22 * m30;
  74061. var det_20_31 = m20 * m31 - m30 * m21;
  74062. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  74063. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  74064. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  74065. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  74066. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  74067. };
  74068. // Methods
  74069. /**
  74070. * Returns the matrix as a Float32Array
  74071. * @returns the matrix underlying array
  74072. */
  74073. Matrix.prototype.toArray = function () {
  74074. return this._m;
  74075. };
  74076. /**
  74077. * Returns the matrix as a Float32Array
  74078. * @returns the matrix underlying array.
  74079. */
  74080. Matrix.prototype.asArray = function () {
  74081. return this._m;
  74082. };
  74083. /**
  74084. * Inverts the current matrix in place
  74085. * @returns the current inverted matrix
  74086. */
  74087. Matrix.prototype.invert = function () {
  74088. this.invertToRef(this);
  74089. return this;
  74090. };
  74091. /**
  74092. * Sets all the matrix elements to zero
  74093. * @returns the current matrix
  74094. */
  74095. Matrix.prototype.reset = function () {
  74096. 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);
  74097. this._updateIdentityStatus(false);
  74098. return this;
  74099. };
  74100. /**
  74101. * Adds the current matrix with a second one
  74102. * @param other defines the matrix to add
  74103. * @returns a new matrix as the addition of the current matrix and the given one
  74104. */
  74105. Matrix.prototype.add = function (other) {
  74106. var result = new Matrix();
  74107. this.addToRef(other, result);
  74108. return result;
  74109. };
  74110. /**
  74111. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74112. * @param other defines the matrix to add
  74113. * @param result defines the target matrix
  74114. * @returns the current matrix
  74115. */
  74116. Matrix.prototype.addToRef = function (other, result) {
  74117. var m = this._m;
  74118. var resultM = result._m;
  74119. var otherM = other.m;
  74120. for (var index = 0; index < 16; index++) {
  74121. resultM[index] = m[index] + otherM[index];
  74122. }
  74123. result._markAsUpdated();
  74124. return this;
  74125. };
  74126. /**
  74127. * Adds in place the given matrix to the current matrix
  74128. * @param other defines the second operand
  74129. * @returns the current updated matrix
  74130. */
  74131. Matrix.prototype.addToSelf = function (other) {
  74132. var m = this._m;
  74133. var otherM = other.m;
  74134. for (var index = 0; index < 16; index++) {
  74135. m[index] += otherM[index];
  74136. }
  74137. this._markAsUpdated();
  74138. return this;
  74139. };
  74140. /**
  74141. * Sets the given matrix to the current inverted Matrix
  74142. * @param other defines the target matrix
  74143. * @returns the unmodified current matrix
  74144. */
  74145. Matrix.prototype.invertToRef = function (other) {
  74146. if (this._isIdentity === true) {
  74147. Matrix.IdentityToRef(other);
  74148. return this;
  74149. }
  74150. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  74151. var m = this._m;
  74152. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  74153. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  74154. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  74155. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  74156. var det_22_33 = m22 * m33 - m32 * m23;
  74157. var det_21_33 = m21 * m33 - m31 * m23;
  74158. var det_21_32 = m21 * m32 - m31 * m22;
  74159. var det_20_33 = m20 * m33 - m30 * m23;
  74160. var det_20_32 = m20 * m32 - m22 * m30;
  74161. var det_20_31 = m20 * m31 - m30 * m21;
  74162. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  74163. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  74164. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  74165. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  74166. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  74167. if (det === 0) {
  74168. // not invertible
  74169. other.copyFrom(this);
  74170. return this;
  74171. }
  74172. var detInv = 1 / det;
  74173. var det_12_33 = m12 * m33 - m32 * m13;
  74174. var det_11_33 = m11 * m33 - m31 * m13;
  74175. var det_11_32 = m11 * m32 - m31 * m12;
  74176. var det_10_33 = m10 * m33 - m30 * m13;
  74177. var det_10_32 = m10 * m32 - m30 * m12;
  74178. var det_10_31 = m10 * m31 - m30 * m11;
  74179. var det_12_23 = m12 * m23 - m22 * m13;
  74180. var det_11_23 = m11 * m23 - m21 * m13;
  74181. var det_11_22 = m11 * m22 - m21 * m12;
  74182. var det_10_23 = m10 * m23 - m20 * m13;
  74183. var det_10_22 = m10 * m22 - m20 * m12;
  74184. var det_10_21 = m10 * m21 - m20 * m11;
  74185. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  74186. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  74187. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  74188. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  74189. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  74190. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  74191. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  74192. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  74193. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  74194. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  74195. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  74196. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  74197. 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);
  74198. return this;
  74199. };
  74200. /**
  74201. * add a value at the specified position in the current Matrix
  74202. * @param index the index of the value within the matrix. between 0 and 15.
  74203. * @param value the value to be added
  74204. * @returns the current updated matrix
  74205. */
  74206. Matrix.prototype.addAtIndex = function (index, value) {
  74207. this._m[index] += value;
  74208. this._markAsUpdated();
  74209. return this;
  74210. };
  74211. /**
  74212. * mutiply the specified position in the current Matrix by a value
  74213. * @param index the index of the value within the matrix. between 0 and 15.
  74214. * @param value the value to be added
  74215. * @returns the current updated matrix
  74216. */
  74217. Matrix.prototype.multiplyAtIndex = function (index, value) {
  74218. this._m[index] *= value;
  74219. this._markAsUpdated();
  74220. return this;
  74221. };
  74222. /**
  74223. * Inserts the translation vector (using 3 floats) in the current matrix
  74224. * @param x defines the 1st component of the translation
  74225. * @param y defines the 2nd component of the translation
  74226. * @param z defines the 3rd component of the translation
  74227. * @returns the current updated matrix
  74228. */
  74229. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  74230. this._m[12] = x;
  74231. this._m[13] = y;
  74232. this._m[14] = z;
  74233. this._markAsUpdated();
  74234. return this;
  74235. };
  74236. /**
  74237. * Inserts the translation vector in the current matrix
  74238. * @param vector3 defines the translation to insert
  74239. * @returns the current updated matrix
  74240. */
  74241. Matrix.prototype.setTranslation = function (vector3) {
  74242. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  74243. };
  74244. /**
  74245. * Gets the translation value of the current matrix
  74246. * @returns a new Vector3 as the extracted translation from the matrix
  74247. */
  74248. Matrix.prototype.getTranslation = function () {
  74249. return new Vector3(this._m[12], this._m[13], this._m[14]);
  74250. };
  74251. /**
  74252. * Fill a Vector3 with the extracted translation from the matrix
  74253. * @param result defines the Vector3 where to store the translation
  74254. * @returns the current matrix
  74255. */
  74256. Matrix.prototype.getTranslationToRef = function (result) {
  74257. result.x = this._m[12];
  74258. result.y = this._m[13];
  74259. result.z = this._m[14];
  74260. return this;
  74261. };
  74262. /**
  74263. * Remove rotation and scaling part from the matrix
  74264. * @returns the updated matrix
  74265. */
  74266. Matrix.prototype.removeRotationAndScaling = function () {
  74267. var m = this.m;
  74268. 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);
  74269. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  74270. return this;
  74271. };
  74272. /**
  74273. * Multiply two matrices
  74274. * @param other defines the second operand
  74275. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74276. */
  74277. Matrix.prototype.multiply = function (other) {
  74278. var result = new Matrix();
  74279. this.multiplyToRef(other, result);
  74280. return result;
  74281. };
  74282. /**
  74283. * Copy the current matrix from the given one
  74284. * @param other defines the source matrix
  74285. * @returns the current updated matrix
  74286. */
  74287. Matrix.prototype.copyFrom = function (other) {
  74288. other.copyToArray(this._m);
  74289. var o = other;
  74290. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  74291. return this;
  74292. };
  74293. /**
  74294. * Populates the given array from the starting index with the current matrix values
  74295. * @param array defines the target array
  74296. * @param offset defines the offset in the target array where to start storing values
  74297. * @returns the current matrix
  74298. */
  74299. Matrix.prototype.copyToArray = function (array, offset) {
  74300. if (offset === void 0) { offset = 0; }
  74301. for (var index = 0; index < 16; index++) {
  74302. array[offset + index] = this._m[index];
  74303. }
  74304. return this;
  74305. };
  74306. /**
  74307. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74308. * @param other defines the second operand
  74309. * @param result defines the matrix where to store the multiplication
  74310. * @returns the current matrix
  74311. */
  74312. Matrix.prototype.multiplyToRef = function (other, result) {
  74313. if (this._isIdentity) {
  74314. result.copyFrom(other);
  74315. return this;
  74316. }
  74317. if (other._isIdentity) {
  74318. result.copyFrom(this);
  74319. return this;
  74320. }
  74321. this.multiplyToArray(other, result._m, 0);
  74322. result._markAsUpdated();
  74323. return this;
  74324. };
  74325. /**
  74326. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74327. * @param other defines the second operand
  74328. * @param result defines the array where to store the multiplication
  74329. * @param offset defines the offset in the target array where to start storing values
  74330. * @returns the current matrix
  74331. */
  74332. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  74333. var m = this._m;
  74334. var otherM = other.m;
  74335. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  74336. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  74337. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  74338. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  74339. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  74340. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  74341. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  74342. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  74343. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  74344. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  74345. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  74346. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  74347. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  74348. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  74349. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  74350. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  74351. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  74352. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  74353. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  74354. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  74355. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  74356. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  74357. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  74358. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  74359. return this;
  74360. };
  74361. /**
  74362. * Check equality between this matrix and a second one
  74363. * @param value defines the second matrix to compare
  74364. * @returns true is the current matrix and the given one values are strictly equal
  74365. */
  74366. Matrix.prototype.equals = function (value) {
  74367. var other = value;
  74368. if (!other) {
  74369. return false;
  74370. }
  74371. if (this._isIdentity || other._isIdentity) {
  74372. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  74373. return this._isIdentity && other._isIdentity;
  74374. }
  74375. }
  74376. var m = this.m;
  74377. var om = other.m;
  74378. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  74379. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  74380. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  74381. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  74382. };
  74383. /**
  74384. * Clone the current matrix
  74385. * @returns a new matrix from the current matrix
  74386. */
  74387. Matrix.prototype.clone = function () {
  74388. var matrix = new Matrix();
  74389. matrix.copyFrom(this);
  74390. return matrix;
  74391. };
  74392. /**
  74393. * Returns the name of the current matrix class
  74394. * @returns the string "Matrix"
  74395. */
  74396. Matrix.prototype.getClassName = function () {
  74397. return "Matrix";
  74398. };
  74399. /**
  74400. * Gets the hash code of the current matrix
  74401. * @returns the hash code
  74402. */
  74403. Matrix.prototype.getHashCode = function () {
  74404. var hash = this._m[0] || 0;
  74405. for (var i = 1; i < 16; i++) {
  74406. hash = (hash * 397) ^ (this._m[i] || 0);
  74407. }
  74408. return hash;
  74409. };
  74410. /**
  74411. * Decomposes the current Matrix into a translation, rotation and scaling components
  74412. * @param scale defines the scale vector3 given as a reference to update
  74413. * @param rotation defines the rotation quaternion given as a reference to update
  74414. * @param translation defines the translation vector3 given as a reference to update
  74415. * @returns true if operation was successful
  74416. */
  74417. Matrix.prototype.decompose = function (scale, rotation, translation) {
  74418. if (this._isIdentity) {
  74419. if (translation) {
  74420. translation.setAll(0);
  74421. }
  74422. if (scale) {
  74423. scale.setAll(1);
  74424. }
  74425. if (rotation) {
  74426. rotation.copyFromFloats(0, 0, 0, 1);
  74427. }
  74428. return true;
  74429. }
  74430. var m = this._m;
  74431. if (translation) {
  74432. translation.copyFromFloats(m[12], m[13], m[14]);
  74433. }
  74434. scale = scale || MathTmp.Vector3[0];
  74435. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  74436. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  74437. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  74438. if (this.determinant() <= 0) {
  74439. scale.y *= -1;
  74440. }
  74441. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  74442. if (rotation) {
  74443. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  74444. }
  74445. return false;
  74446. }
  74447. if (rotation) {
  74448. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  74449. 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]);
  74450. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  74451. }
  74452. return true;
  74453. };
  74454. /**
  74455. * Gets specific row of the matrix
  74456. * @param index defines the number of the row to get
  74457. * @returns the index-th row of the current matrix as a new Vector4
  74458. */
  74459. Matrix.prototype.getRow = function (index) {
  74460. if (index < 0 || index > 3) {
  74461. return null;
  74462. }
  74463. var i = index * 4;
  74464. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  74465. };
  74466. /**
  74467. * Sets the index-th row of the current matrix to the vector4 values
  74468. * @param index defines the number of the row to set
  74469. * @param row defines the target vector4
  74470. * @returns the updated current matrix
  74471. */
  74472. Matrix.prototype.setRow = function (index, row) {
  74473. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  74474. };
  74475. /**
  74476. * Compute the transpose of the matrix
  74477. * @returns the new transposed matrix
  74478. */
  74479. Matrix.prototype.transpose = function () {
  74480. return Matrix.Transpose(this);
  74481. };
  74482. /**
  74483. * Compute the transpose of the matrix and store it in a given matrix
  74484. * @param result defines the target matrix
  74485. * @returns the current matrix
  74486. */
  74487. Matrix.prototype.transposeToRef = function (result) {
  74488. Matrix.TransposeToRef(this, result);
  74489. return this;
  74490. };
  74491. /**
  74492. * Sets the index-th row of the current matrix with the given 4 x float values
  74493. * @param index defines the row index
  74494. * @param x defines the x component to set
  74495. * @param y defines the y component to set
  74496. * @param z defines the z component to set
  74497. * @param w defines the w component to set
  74498. * @returns the updated current matrix
  74499. */
  74500. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  74501. if (index < 0 || index > 3) {
  74502. return this;
  74503. }
  74504. var i = index * 4;
  74505. this._m[i + 0] = x;
  74506. this._m[i + 1] = y;
  74507. this._m[i + 2] = z;
  74508. this._m[i + 3] = w;
  74509. this._markAsUpdated();
  74510. return this;
  74511. };
  74512. /**
  74513. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74514. * @param scale defines the scale factor
  74515. * @returns a new matrix
  74516. */
  74517. Matrix.prototype.scale = function (scale) {
  74518. var result = new Matrix();
  74519. this.scaleToRef(scale, result);
  74520. return result;
  74521. };
  74522. /**
  74523. * Scale the current matrix values by a factor to a given result matrix
  74524. * @param scale defines the scale factor
  74525. * @param result defines the matrix to store the result
  74526. * @returns the current matrix
  74527. */
  74528. Matrix.prototype.scaleToRef = function (scale, result) {
  74529. for (var index = 0; index < 16; index++) {
  74530. result._m[index] = this._m[index] * scale;
  74531. }
  74532. result._markAsUpdated();
  74533. return this;
  74534. };
  74535. /**
  74536. * Scale the current matrix values by a factor and add the result to a given matrix
  74537. * @param scale defines the scale factor
  74538. * @param result defines the Matrix to store the result
  74539. * @returns the current matrix
  74540. */
  74541. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  74542. for (var index = 0; index < 16; index++) {
  74543. result._m[index] += this._m[index] * scale;
  74544. }
  74545. result._markAsUpdated();
  74546. return this;
  74547. };
  74548. /**
  74549. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74550. * @param ref matrix to store the result
  74551. */
  74552. Matrix.prototype.toNormalMatrix = function (ref) {
  74553. var tmp = MathTmp.Matrix[0];
  74554. this.invertToRef(tmp);
  74555. tmp.transposeToRef(ref);
  74556. var m = ref._m;
  74557. 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);
  74558. };
  74559. /**
  74560. * Gets only rotation part of the current matrix
  74561. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74562. */
  74563. Matrix.prototype.getRotationMatrix = function () {
  74564. var result = new Matrix();
  74565. this.getRotationMatrixToRef(result);
  74566. return result;
  74567. };
  74568. /**
  74569. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74570. * @param result defines the target matrix to store data to
  74571. * @returns the current matrix
  74572. */
  74573. Matrix.prototype.getRotationMatrixToRef = function (result) {
  74574. var scale = MathTmp.Vector3[0];
  74575. if (!this.decompose(scale)) {
  74576. Matrix.IdentityToRef(result);
  74577. return this;
  74578. }
  74579. var m = this._m;
  74580. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  74581. 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);
  74582. return this;
  74583. };
  74584. /**
  74585. * Toggles model matrix from being right handed to left handed in place and vice versa
  74586. */
  74587. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  74588. var m = this._m;
  74589. m[2] *= -1;
  74590. m[6] *= -1;
  74591. m[8] *= -1;
  74592. m[9] *= -1;
  74593. m[14] *= -1;
  74594. this._markAsUpdated();
  74595. };
  74596. /**
  74597. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74598. */
  74599. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  74600. var m = this._m;
  74601. m[8] *= -1;
  74602. m[9] *= -1;
  74603. m[10] *= -1;
  74604. m[11] *= -1;
  74605. this._markAsUpdated();
  74606. };
  74607. // Statics
  74608. /**
  74609. * Creates a matrix from an array
  74610. * @param array defines the source array
  74611. * @param offset defines an offset in the source array
  74612. * @returns a new Matrix set from the starting index of the given array
  74613. */
  74614. Matrix.FromArray = function (array, offset) {
  74615. if (offset === void 0) { offset = 0; }
  74616. var result = new Matrix();
  74617. Matrix.FromArrayToRef(array, offset, result);
  74618. return result;
  74619. };
  74620. /**
  74621. * Copy the content of an array into a given matrix
  74622. * @param array defines the source array
  74623. * @param offset defines an offset in the source array
  74624. * @param result defines the target matrix
  74625. */
  74626. Matrix.FromArrayToRef = function (array, offset, result) {
  74627. for (var index = 0; index < 16; index++) {
  74628. result._m[index] = array[index + offset];
  74629. }
  74630. result._markAsUpdated();
  74631. };
  74632. /**
  74633. * Stores an array into a matrix after having multiplied each component by a given factor
  74634. * @param array defines the source array
  74635. * @param offset defines the offset in the source array
  74636. * @param scale defines the scaling factor
  74637. * @param result defines the target matrix
  74638. */
  74639. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  74640. for (var index = 0; index < 16; index++) {
  74641. result._m[index] = array[index + offset] * scale;
  74642. }
  74643. result._markAsUpdated();
  74644. };
  74645. Object.defineProperty(Matrix, "IdentityReadOnly", {
  74646. /**
  74647. * Gets an identity matrix that must not be updated
  74648. */
  74649. get: function () {
  74650. return Matrix._identityReadOnly;
  74651. },
  74652. enumerable: true,
  74653. configurable: true
  74654. });
  74655. /**
  74656. * Stores a list of values (16) inside a given matrix
  74657. * @param initialM11 defines 1st value of 1st row
  74658. * @param initialM12 defines 2nd value of 1st row
  74659. * @param initialM13 defines 3rd value of 1st row
  74660. * @param initialM14 defines 4th value of 1st row
  74661. * @param initialM21 defines 1st value of 2nd row
  74662. * @param initialM22 defines 2nd value of 2nd row
  74663. * @param initialM23 defines 3rd value of 2nd row
  74664. * @param initialM24 defines 4th value of 2nd row
  74665. * @param initialM31 defines 1st value of 3rd row
  74666. * @param initialM32 defines 2nd value of 3rd row
  74667. * @param initialM33 defines 3rd value of 3rd row
  74668. * @param initialM34 defines 4th value of 3rd row
  74669. * @param initialM41 defines 1st value of 4th row
  74670. * @param initialM42 defines 2nd value of 4th row
  74671. * @param initialM43 defines 3rd value of 4th row
  74672. * @param initialM44 defines 4th value of 4th row
  74673. * @param result defines the target matrix
  74674. */
  74675. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  74676. var m = result._m;
  74677. m[0] = initialM11;
  74678. m[1] = initialM12;
  74679. m[2] = initialM13;
  74680. m[3] = initialM14;
  74681. m[4] = initialM21;
  74682. m[5] = initialM22;
  74683. m[6] = initialM23;
  74684. m[7] = initialM24;
  74685. m[8] = initialM31;
  74686. m[9] = initialM32;
  74687. m[10] = initialM33;
  74688. m[11] = initialM34;
  74689. m[12] = initialM41;
  74690. m[13] = initialM42;
  74691. m[14] = initialM43;
  74692. m[15] = initialM44;
  74693. result._markAsUpdated();
  74694. };
  74695. /**
  74696. * Creates new matrix from a list of values (16)
  74697. * @param initialM11 defines 1st value of 1st row
  74698. * @param initialM12 defines 2nd value of 1st row
  74699. * @param initialM13 defines 3rd value of 1st row
  74700. * @param initialM14 defines 4th value of 1st row
  74701. * @param initialM21 defines 1st value of 2nd row
  74702. * @param initialM22 defines 2nd value of 2nd row
  74703. * @param initialM23 defines 3rd value of 2nd row
  74704. * @param initialM24 defines 4th value of 2nd row
  74705. * @param initialM31 defines 1st value of 3rd row
  74706. * @param initialM32 defines 2nd value of 3rd row
  74707. * @param initialM33 defines 3rd value of 3rd row
  74708. * @param initialM34 defines 4th value of 3rd row
  74709. * @param initialM41 defines 1st value of 4th row
  74710. * @param initialM42 defines 2nd value of 4th row
  74711. * @param initialM43 defines 3rd value of 4th row
  74712. * @param initialM44 defines 4th value of 4th row
  74713. * @returns the new matrix
  74714. */
  74715. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  74716. var result = new Matrix();
  74717. var m = result._m;
  74718. m[0] = initialM11;
  74719. m[1] = initialM12;
  74720. m[2] = initialM13;
  74721. m[3] = initialM14;
  74722. m[4] = initialM21;
  74723. m[5] = initialM22;
  74724. m[6] = initialM23;
  74725. m[7] = initialM24;
  74726. m[8] = initialM31;
  74727. m[9] = initialM32;
  74728. m[10] = initialM33;
  74729. m[11] = initialM34;
  74730. m[12] = initialM41;
  74731. m[13] = initialM42;
  74732. m[14] = initialM43;
  74733. m[15] = initialM44;
  74734. result._markAsUpdated();
  74735. return result;
  74736. };
  74737. /**
  74738. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74739. * @param scale defines the scale vector3
  74740. * @param rotation defines the rotation quaternion
  74741. * @param translation defines the translation vector3
  74742. * @returns a new matrix
  74743. */
  74744. Matrix.Compose = function (scale, rotation, translation) {
  74745. var result = new Matrix();
  74746. Matrix.ComposeToRef(scale, rotation, translation, result);
  74747. return result;
  74748. };
  74749. /**
  74750. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74751. * @param scale defines the scale vector3
  74752. * @param rotation defines the rotation quaternion
  74753. * @param translation defines the translation vector3
  74754. * @param result defines the target matrix
  74755. */
  74756. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  74757. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  74758. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  74759. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  74760. result.setTranslation(translation);
  74761. };
  74762. /**
  74763. * Creates a new identity matrix
  74764. * @returns a new identity matrix
  74765. */
  74766. Matrix.Identity = function () {
  74767. 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);
  74768. identity._updateIdentityStatus(true);
  74769. return identity;
  74770. };
  74771. /**
  74772. * Creates a new identity matrix and stores the result in a given matrix
  74773. * @param result defines the target matrix
  74774. */
  74775. Matrix.IdentityToRef = function (result) {
  74776. 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);
  74777. result._updateIdentityStatus(true);
  74778. };
  74779. /**
  74780. * Creates a new zero matrix
  74781. * @returns a new zero matrix
  74782. */
  74783. Matrix.Zero = function () {
  74784. 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);
  74785. zero._updateIdentityStatus(false);
  74786. return zero;
  74787. };
  74788. /**
  74789. * Creates a new rotation matrix for "angle" radians around the X axis
  74790. * @param angle defines the angle (in radians) to use
  74791. * @return the new matrix
  74792. */
  74793. Matrix.RotationX = function (angle) {
  74794. var result = new Matrix();
  74795. Matrix.RotationXToRef(angle, result);
  74796. return result;
  74797. };
  74798. /**
  74799. * Creates a new matrix as the invert of a given matrix
  74800. * @param source defines the source matrix
  74801. * @returns the new matrix
  74802. */
  74803. Matrix.Invert = function (source) {
  74804. var result = new Matrix();
  74805. source.invertToRef(result);
  74806. return result;
  74807. };
  74808. /**
  74809. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74810. * @param angle defines the angle (in radians) to use
  74811. * @param result defines the target matrix
  74812. */
  74813. Matrix.RotationXToRef = function (angle, result) {
  74814. var s = Math.sin(angle);
  74815. var c = Math.cos(angle);
  74816. 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);
  74817. result._updateIdentityStatus(c === 1 && s === 0);
  74818. };
  74819. /**
  74820. * Creates a new rotation matrix for "angle" radians around the Y axis
  74821. * @param angle defines the angle (in radians) to use
  74822. * @return the new matrix
  74823. */
  74824. Matrix.RotationY = function (angle) {
  74825. var result = new Matrix();
  74826. Matrix.RotationYToRef(angle, result);
  74827. return result;
  74828. };
  74829. /**
  74830. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74831. * @param angle defines the angle (in radians) to use
  74832. * @param result defines the target matrix
  74833. */
  74834. Matrix.RotationYToRef = function (angle, result) {
  74835. var s = Math.sin(angle);
  74836. var c = Math.cos(angle);
  74837. 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);
  74838. result._updateIdentityStatus(c === 1 && s === 0);
  74839. };
  74840. /**
  74841. * Creates a new rotation matrix for "angle" radians around the Z axis
  74842. * @param angle defines the angle (in radians) to use
  74843. * @return the new matrix
  74844. */
  74845. Matrix.RotationZ = function (angle) {
  74846. var result = new Matrix();
  74847. Matrix.RotationZToRef(angle, result);
  74848. return result;
  74849. };
  74850. /**
  74851. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74852. * @param angle defines the angle (in radians) to use
  74853. * @param result defines the target matrix
  74854. */
  74855. Matrix.RotationZToRef = function (angle, result) {
  74856. var s = Math.sin(angle);
  74857. var c = Math.cos(angle);
  74858. 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);
  74859. result._updateIdentityStatus(c === 1 && s === 0);
  74860. };
  74861. /**
  74862. * Creates a new rotation matrix for "angle" radians around the given axis
  74863. * @param axis defines the axis to use
  74864. * @param angle defines the angle (in radians) to use
  74865. * @return the new matrix
  74866. */
  74867. Matrix.RotationAxis = function (axis, angle) {
  74868. var result = new Matrix();
  74869. Matrix.RotationAxisToRef(axis, angle, result);
  74870. return result;
  74871. };
  74872. /**
  74873. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74874. * @param axis defines the axis to use
  74875. * @param angle defines the angle (in radians) to use
  74876. * @param result defines the target matrix
  74877. */
  74878. Matrix.RotationAxisToRef = function (axis, angle, result) {
  74879. var s = Math.sin(-angle);
  74880. var c = Math.cos(-angle);
  74881. var c1 = 1 - c;
  74882. axis.normalize();
  74883. var m = result._m;
  74884. m[0] = (axis.x * axis.x) * c1 + c;
  74885. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  74886. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  74887. m[3] = 0.0;
  74888. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  74889. m[5] = (axis.y * axis.y) * c1 + c;
  74890. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  74891. m[7] = 0.0;
  74892. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  74893. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  74894. m[10] = (axis.z * axis.z) * c1 + c;
  74895. m[11] = 0.0;
  74896. m[12] = 0.0;
  74897. m[13] = 0.0;
  74898. m[14] = 0.0;
  74899. m[15] = 1.0;
  74900. result._markAsUpdated();
  74901. };
  74902. /**
  74903. * Creates a rotation matrix
  74904. * @param yaw defines the yaw angle in radians (Y axis)
  74905. * @param pitch defines the pitch angle in radians (X axis)
  74906. * @param roll defines the roll angle in radians (X axis)
  74907. * @returns the new rotation matrix
  74908. */
  74909. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  74910. var result = new Matrix();
  74911. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  74912. return result;
  74913. };
  74914. /**
  74915. * Creates a rotation matrix and stores it in a given matrix
  74916. * @param yaw defines the yaw angle in radians (Y axis)
  74917. * @param pitch defines the pitch angle in radians (X axis)
  74918. * @param roll defines the roll angle in radians (X axis)
  74919. * @param result defines the target matrix
  74920. */
  74921. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  74922. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  74923. MathTmp.Quaternion[0].toRotationMatrix(result);
  74924. };
  74925. /**
  74926. * Creates a scaling matrix
  74927. * @param x defines the scale factor on X axis
  74928. * @param y defines the scale factor on Y axis
  74929. * @param z defines the scale factor on Z axis
  74930. * @returns the new matrix
  74931. */
  74932. Matrix.Scaling = function (x, y, z) {
  74933. var result = new Matrix();
  74934. Matrix.ScalingToRef(x, y, z, result);
  74935. return result;
  74936. };
  74937. /**
  74938. * Creates a scaling matrix and stores it in a given matrix
  74939. * @param x defines the scale factor on X axis
  74940. * @param y defines the scale factor on Y axis
  74941. * @param z defines the scale factor on Z axis
  74942. * @param result defines the target matrix
  74943. */
  74944. Matrix.ScalingToRef = function (x, y, z, result) {
  74945. 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);
  74946. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  74947. };
  74948. /**
  74949. * Creates a translation matrix
  74950. * @param x defines the translation on X axis
  74951. * @param y defines the translation on Y axis
  74952. * @param z defines the translationon Z axis
  74953. * @returns the new matrix
  74954. */
  74955. Matrix.Translation = function (x, y, z) {
  74956. var result = new Matrix();
  74957. Matrix.TranslationToRef(x, y, z, result);
  74958. return result;
  74959. };
  74960. /**
  74961. * Creates a translation matrix and stores it in a given matrix
  74962. * @param x defines the translation on X axis
  74963. * @param y defines the translation on Y axis
  74964. * @param z defines the translationon Z axis
  74965. * @param result defines the target matrix
  74966. */
  74967. Matrix.TranslationToRef = function (x, y, z, result) {
  74968. 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);
  74969. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  74970. };
  74971. /**
  74972. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74973. * @param startValue defines the start value
  74974. * @param endValue defines the end value
  74975. * @param gradient defines the gradient factor
  74976. * @returns the new matrix
  74977. */
  74978. Matrix.Lerp = function (startValue, endValue, gradient) {
  74979. var result = new Matrix();
  74980. Matrix.LerpToRef(startValue, endValue, gradient, result);
  74981. return result;
  74982. };
  74983. /**
  74984. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74985. * @param startValue defines the start value
  74986. * @param endValue defines the end value
  74987. * @param gradient defines the gradient factor
  74988. * @param result defines the Matrix object where to store data
  74989. */
  74990. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  74991. var resultM = result._m;
  74992. var startM = startValue.m;
  74993. var endM = endValue.m;
  74994. for (var index = 0; index < 16; index++) {
  74995. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  74996. }
  74997. result._markAsUpdated();
  74998. };
  74999. /**
  75000. * Builds a new matrix whose values are computed by:
  75001. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75002. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75003. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75004. * @param startValue defines the first matrix
  75005. * @param endValue defines the second matrix
  75006. * @param gradient defines the gradient between the two matrices
  75007. * @returns the new matrix
  75008. */
  75009. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  75010. var result = new Matrix();
  75011. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  75012. return result;
  75013. };
  75014. /**
  75015. * Update a matrix to values which are computed by:
  75016. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75017. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75018. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75019. * @param startValue defines the first matrix
  75020. * @param endValue defines the second matrix
  75021. * @param gradient defines the gradient between the two matrices
  75022. * @param result defines the target matrix
  75023. */
  75024. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  75025. var startScale = MathTmp.Vector3[0];
  75026. var startRotation = MathTmp.Quaternion[0];
  75027. var startTranslation = MathTmp.Vector3[1];
  75028. startValue.decompose(startScale, startRotation, startTranslation);
  75029. var endScale = MathTmp.Vector3[2];
  75030. var endRotation = MathTmp.Quaternion[1];
  75031. var endTranslation = MathTmp.Vector3[3];
  75032. endValue.decompose(endScale, endRotation, endTranslation);
  75033. var resultScale = MathTmp.Vector3[4];
  75034. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  75035. var resultRotation = MathTmp.Quaternion[2];
  75036. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  75037. var resultTranslation = MathTmp.Vector3[5];
  75038. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  75039. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  75040. };
  75041. /**
  75042. * 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"
  75043. * This function works in left handed mode
  75044. * @param eye defines the final position of the entity
  75045. * @param target defines where the entity should look at
  75046. * @param up defines the up vector for the entity
  75047. * @returns the new matrix
  75048. */
  75049. Matrix.LookAtLH = function (eye, target, up) {
  75050. var result = new Matrix();
  75051. Matrix.LookAtLHToRef(eye, target, up, result);
  75052. return result;
  75053. };
  75054. /**
  75055. * 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".
  75056. * This function works in left handed mode
  75057. * @param eye defines the final position of the entity
  75058. * @param target defines where the entity should look at
  75059. * @param up defines the up vector for the entity
  75060. * @param result defines the target matrix
  75061. */
  75062. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  75063. var xAxis = MathTmp.Vector3[0];
  75064. var yAxis = MathTmp.Vector3[1];
  75065. var zAxis = MathTmp.Vector3[2];
  75066. // Z axis
  75067. target.subtractToRef(eye, zAxis);
  75068. zAxis.normalize();
  75069. // X axis
  75070. Vector3.CrossToRef(up, zAxis, xAxis);
  75071. var xSquareLength = xAxis.lengthSquared();
  75072. if (xSquareLength === 0) {
  75073. xAxis.x = 1.0;
  75074. }
  75075. else {
  75076. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  75077. }
  75078. // Y axis
  75079. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  75080. yAxis.normalize();
  75081. // Eye angles
  75082. var ex = -Vector3.Dot(xAxis, eye);
  75083. var ey = -Vector3.Dot(yAxis, eye);
  75084. var ez = -Vector3.Dot(zAxis, eye);
  75085. 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);
  75086. };
  75087. /**
  75088. * 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"
  75089. * This function works in right handed mode
  75090. * @param eye defines the final position of the entity
  75091. * @param target defines where the entity should look at
  75092. * @param up defines the up vector for the entity
  75093. * @returns the new matrix
  75094. */
  75095. Matrix.LookAtRH = function (eye, target, up) {
  75096. var result = new Matrix();
  75097. Matrix.LookAtRHToRef(eye, target, up, result);
  75098. return result;
  75099. };
  75100. /**
  75101. * 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".
  75102. * This function works in right handed mode
  75103. * @param eye defines the final position of the entity
  75104. * @param target defines where the entity should look at
  75105. * @param up defines the up vector for the entity
  75106. * @param result defines the target matrix
  75107. */
  75108. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  75109. var xAxis = MathTmp.Vector3[0];
  75110. var yAxis = MathTmp.Vector3[1];
  75111. var zAxis = MathTmp.Vector3[2];
  75112. // Z axis
  75113. eye.subtractToRef(target, zAxis);
  75114. zAxis.normalize();
  75115. // X axis
  75116. Vector3.CrossToRef(up, zAxis, xAxis);
  75117. var xSquareLength = xAxis.lengthSquared();
  75118. if (xSquareLength === 0) {
  75119. xAxis.x = 1.0;
  75120. }
  75121. else {
  75122. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  75123. }
  75124. // Y axis
  75125. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  75126. yAxis.normalize();
  75127. // Eye angles
  75128. var ex = -Vector3.Dot(xAxis, eye);
  75129. var ey = -Vector3.Dot(yAxis, eye);
  75130. var ez = -Vector3.Dot(zAxis, eye);
  75131. 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);
  75132. };
  75133. /**
  75134. * Create a left-handed orthographic projection matrix
  75135. * @param width defines the viewport width
  75136. * @param height defines the viewport height
  75137. * @param znear defines the near clip plane
  75138. * @param zfar defines the far clip plane
  75139. * @returns a new matrix as a left-handed orthographic projection matrix
  75140. */
  75141. Matrix.OrthoLH = function (width, height, znear, zfar) {
  75142. var matrix = new Matrix();
  75143. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  75144. return matrix;
  75145. };
  75146. /**
  75147. * Store a left-handed orthographic projection to a given matrix
  75148. * @param width defines the viewport width
  75149. * @param height defines the viewport height
  75150. * @param znear defines the near clip plane
  75151. * @param zfar defines the far clip plane
  75152. * @param result defines the target matrix
  75153. */
  75154. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  75155. var n = znear;
  75156. var f = zfar;
  75157. var a = 2.0 / width;
  75158. var b = 2.0 / height;
  75159. var c = 2.0 / (f - n);
  75160. var d = -(f + n) / (f - n);
  75161. 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);
  75162. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  75163. };
  75164. /**
  75165. * Create a left-handed orthographic projection matrix
  75166. * @param left defines the viewport left coordinate
  75167. * @param right defines the viewport right coordinate
  75168. * @param bottom defines the viewport bottom coordinate
  75169. * @param top defines the viewport top coordinate
  75170. * @param znear defines the near clip plane
  75171. * @param zfar defines the far clip plane
  75172. * @returns a new matrix as a left-handed orthographic projection matrix
  75173. */
  75174. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  75175. var matrix = new Matrix();
  75176. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  75177. return matrix;
  75178. };
  75179. /**
  75180. * Stores a left-handed orthographic projection into a given matrix
  75181. * @param left defines the viewport left coordinate
  75182. * @param right defines the viewport right coordinate
  75183. * @param bottom defines the viewport bottom coordinate
  75184. * @param top defines the viewport top coordinate
  75185. * @param znear defines the near clip plane
  75186. * @param zfar defines the far clip plane
  75187. * @param result defines the target matrix
  75188. */
  75189. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  75190. var n = znear;
  75191. var f = zfar;
  75192. var a = 2.0 / (right - left);
  75193. var b = 2.0 / (top - bottom);
  75194. var c = 2.0 / (f - n);
  75195. var d = -(f + n) / (f - n);
  75196. var i0 = (left + right) / (left - right);
  75197. var i1 = (top + bottom) / (bottom - top);
  75198. 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);
  75199. result._markAsUpdated();
  75200. };
  75201. /**
  75202. * Creates a right-handed orthographic projection matrix
  75203. * @param left defines the viewport left coordinate
  75204. * @param right defines the viewport right coordinate
  75205. * @param bottom defines the viewport bottom coordinate
  75206. * @param top defines the viewport top coordinate
  75207. * @param znear defines the near clip plane
  75208. * @param zfar defines the far clip plane
  75209. * @returns a new matrix as a right-handed orthographic projection matrix
  75210. */
  75211. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  75212. var matrix = new Matrix();
  75213. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  75214. return matrix;
  75215. };
  75216. /**
  75217. * Stores a right-handed orthographic projection into a given matrix
  75218. * @param left defines the viewport left coordinate
  75219. * @param right defines the viewport right coordinate
  75220. * @param bottom defines the viewport bottom coordinate
  75221. * @param top defines the viewport top coordinate
  75222. * @param znear defines the near clip plane
  75223. * @param zfar defines the far clip plane
  75224. * @param result defines the target matrix
  75225. */
  75226. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  75227. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  75228. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  75229. };
  75230. /**
  75231. * Creates a left-handed perspective projection matrix
  75232. * @param width defines the viewport width
  75233. * @param height defines the viewport height
  75234. * @param znear defines the near clip plane
  75235. * @param zfar defines the far clip plane
  75236. * @returns a new matrix as a left-handed perspective projection matrix
  75237. */
  75238. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  75239. var matrix = new Matrix();
  75240. var n = znear;
  75241. var f = zfar;
  75242. var a = 2.0 * n / width;
  75243. var b = 2.0 * n / height;
  75244. var c = (f + n) / (f - n);
  75245. var d = -2.0 * f * n / (f - n);
  75246. 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);
  75247. matrix._updateIdentityStatus(false);
  75248. return matrix;
  75249. };
  75250. /**
  75251. * Creates a left-handed perspective projection matrix
  75252. * @param fov defines the horizontal field of view
  75253. * @param aspect defines the aspect ratio
  75254. * @param znear defines the near clip plane
  75255. * @param zfar defines the far clip plane
  75256. * @returns a new matrix as a left-handed perspective projection matrix
  75257. */
  75258. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  75259. var matrix = new Matrix();
  75260. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  75261. return matrix;
  75262. };
  75263. /**
  75264. * Stores a left-handed perspective projection into a given matrix
  75265. * @param fov defines the horizontal field of view
  75266. * @param aspect defines the aspect ratio
  75267. * @param znear defines the near clip plane
  75268. * @param zfar defines the far clip plane
  75269. * @param result defines the target matrix
  75270. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75271. */
  75272. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  75273. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  75274. var n = znear;
  75275. var f = zfar;
  75276. var t = 1.0 / (Math.tan(fov * 0.5));
  75277. var a = isVerticalFovFixed ? (t / aspect) : t;
  75278. var b = isVerticalFovFixed ? t : (t * aspect);
  75279. var c = (f + n) / (f - n);
  75280. var d = -2.0 * f * n / (f - n);
  75281. 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);
  75282. result._updateIdentityStatus(false);
  75283. };
  75284. /**
  75285. * Creates a right-handed perspective projection matrix
  75286. * @param fov defines the horizontal field of view
  75287. * @param aspect defines the aspect ratio
  75288. * @param znear defines the near clip plane
  75289. * @param zfar defines the far clip plane
  75290. * @returns a new matrix as a right-handed perspective projection matrix
  75291. */
  75292. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  75293. var matrix = new Matrix();
  75294. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  75295. return matrix;
  75296. };
  75297. /**
  75298. * Stores a right-handed perspective projection into a given matrix
  75299. * @param fov defines the horizontal field of view
  75300. * @param aspect defines the aspect ratio
  75301. * @param znear defines the near clip plane
  75302. * @param zfar defines the far clip plane
  75303. * @param result defines the target matrix
  75304. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75305. */
  75306. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  75307. //alternatively this could be expressed as:
  75308. // m = PerspectiveFovLHToRef
  75309. // m[10] *= -1.0;
  75310. // m[11] *= -1.0;
  75311. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  75312. var n = znear;
  75313. var f = zfar;
  75314. var t = 1.0 / (Math.tan(fov * 0.5));
  75315. var a = isVerticalFovFixed ? (t / aspect) : t;
  75316. var b = isVerticalFovFixed ? t : (t * aspect);
  75317. var c = -(f + n) / (f - n);
  75318. var d = -2 * f * n / (f - n);
  75319. 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);
  75320. result._updateIdentityStatus(false);
  75321. };
  75322. /**
  75323. * Stores a perspective projection for WebVR info a given matrix
  75324. * @param fov defines the field of view
  75325. * @param znear defines the near clip plane
  75326. * @param zfar defines the far clip plane
  75327. * @param result defines the target matrix
  75328. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75329. */
  75330. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  75331. if (rightHanded === void 0) { rightHanded = false; }
  75332. var rightHandedFactor = rightHanded ? -1 : 1;
  75333. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  75334. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  75335. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  75336. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  75337. var xScale = 2.0 / (leftTan + rightTan);
  75338. var yScale = 2.0 / (upTan + downTan);
  75339. var m = result._m;
  75340. m[0] = xScale;
  75341. m[1] = m[2] = m[3] = m[4] = 0.0;
  75342. m[5] = yScale;
  75343. m[6] = m[7] = 0.0;
  75344. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  75345. m[9] = -((upTan - downTan) * yScale * 0.5);
  75346. m[10] = -zfar / (znear - zfar);
  75347. m[11] = 1.0 * rightHandedFactor;
  75348. m[12] = m[13] = m[15] = 0.0;
  75349. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  75350. result._markAsUpdated();
  75351. };
  75352. /**
  75353. * Computes a complete transformation matrix
  75354. * @param viewport defines the viewport to use
  75355. * @param world defines the world matrix
  75356. * @param view defines the view matrix
  75357. * @param projection defines the projection matrix
  75358. * @param zmin defines the near clip plane
  75359. * @param zmax defines the far clip plane
  75360. * @returns the transformation matrix
  75361. */
  75362. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  75363. var cw = viewport.width;
  75364. var ch = viewport.height;
  75365. var cx = viewport.x;
  75366. var cy = viewport.y;
  75367. 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);
  75368. var matrix = MathTmp.Matrix[0];
  75369. world.multiplyToRef(view, matrix);
  75370. matrix.multiplyToRef(projection, matrix);
  75371. return matrix.multiply(viewportMatrix);
  75372. };
  75373. /**
  75374. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75375. * @param matrix defines the matrix to use
  75376. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75377. */
  75378. Matrix.GetAsMatrix2x2 = function (matrix) {
  75379. var m = matrix.m;
  75380. return new Float32Array([m[0], m[1], m[4], m[5]]);
  75381. };
  75382. /**
  75383. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75384. * @param matrix defines the matrix to use
  75385. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75386. */
  75387. Matrix.GetAsMatrix3x3 = function (matrix) {
  75388. var m = matrix.m;
  75389. return new Float32Array([
  75390. m[0], m[1], m[2],
  75391. m[4], m[5], m[6],
  75392. m[8], m[9], m[10]
  75393. ]);
  75394. };
  75395. /**
  75396. * Compute the transpose of a given matrix
  75397. * @param matrix defines the matrix to transpose
  75398. * @returns the new matrix
  75399. */
  75400. Matrix.Transpose = function (matrix) {
  75401. var result = new Matrix();
  75402. Matrix.TransposeToRef(matrix, result);
  75403. return result;
  75404. };
  75405. /**
  75406. * Compute the transpose of a matrix and store it in a target matrix
  75407. * @param matrix defines the matrix to transpose
  75408. * @param result defines the target matrix
  75409. */
  75410. Matrix.TransposeToRef = function (matrix, result) {
  75411. var rm = result._m;
  75412. var mm = matrix.m;
  75413. rm[0] = mm[0];
  75414. rm[1] = mm[4];
  75415. rm[2] = mm[8];
  75416. rm[3] = mm[12];
  75417. rm[4] = mm[1];
  75418. rm[5] = mm[5];
  75419. rm[6] = mm[9];
  75420. rm[7] = mm[13];
  75421. rm[8] = mm[2];
  75422. rm[9] = mm[6];
  75423. rm[10] = mm[10];
  75424. rm[11] = mm[14];
  75425. rm[12] = mm[3];
  75426. rm[13] = mm[7];
  75427. rm[14] = mm[11];
  75428. rm[15] = mm[15];
  75429. // identity-ness does not change when transposing
  75430. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  75431. };
  75432. /**
  75433. * Computes a reflection matrix from a plane
  75434. * @param plane defines the reflection plane
  75435. * @returns a new matrix
  75436. */
  75437. Matrix.Reflection = function (plane) {
  75438. var matrix = new Matrix();
  75439. Matrix.ReflectionToRef(plane, matrix);
  75440. return matrix;
  75441. };
  75442. /**
  75443. * Computes a reflection matrix from a plane
  75444. * @param plane defines the reflection plane
  75445. * @param result defines the target matrix
  75446. */
  75447. Matrix.ReflectionToRef = function (plane, result) {
  75448. plane.normalize();
  75449. var x = plane.normal.x;
  75450. var y = plane.normal.y;
  75451. var z = plane.normal.z;
  75452. var temp = -2 * x;
  75453. var temp2 = -2 * y;
  75454. var temp3 = -2 * z;
  75455. 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);
  75456. };
  75457. /**
  75458. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75459. * @param xaxis defines the value of the 1st axis
  75460. * @param yaxis defines the value of the 2nd axis
  75461. * @param zaxis defines the value of the 3rd axis
  75462. * @param result defines the target matrix
  75463. */
  75464. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  75465. 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);
  75466. };
  75467. /**
  75468. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75469. * @param quat defines the quaternion to use
  75470. * @param result defines the target matrix
  75471. */
  75472. Matrix.FromQuaternionToRef = function (quat, result) {
  75473. var xx = quat.x * quat.x;
  75474. var yy = quat.y * quat.y;
  75475. var zz = quat.z * quat.z;
  75476. var xy = quat.x * quat.y;
  75477. var zw = quat.z * quat.w;
  75478. var zx = quat.z * quat.x;
  75479. var yw = quat.y * quat.w;
  75480. var yz = quat.y * quat.z;
  75481. var xw = quat.x * quat.w;
  75482. result._m[0] = 1.0 - (2.0 * (yy + zz));
  75483. result._m[1] = 2.0 * (xy + zw);
  75484. result._m[2] = 2.0 * (zx - yw);
  75485. result._m[3] = 0.0;
  75486. result._m[4] = 2.0 * (xy - zw);
  75487. result._m[5] = 1.0 - (2.0 * (zz + xx));
  75488. result._m[6] = 2.0 * (yz + xw);
  75489. result._m[7] = 0.0;
  75490. result._m[8] = 2.0 * (zx + yw);
  75491. result._m[9] = 2.0 * (yz - xw);
  75492. result._m[10] = 1.0 - (2.0 * (yy + xx));
  75493. result._m[11] = 0.0;
  75494. result._m[12] = 0.0;
  75495. result._m[13] = 0.0;
  75496. result._m[14] = 0.0;
  75497. result._m[15] = 1.0;
  75498. result._markAsUpdated();
  75499. };
  75500. Matrix._updateFlagSeed = 0;
  75501. Matrix._identityReadOnly = Matrix.Identity();
  75502. return Matrix;
  75503. }());
  75504. /**
  75505. * Represens a plane by the equation ax + by + cz + d = 0
  75506. */
  75507. var Plane = /** @class */ (function () {
  75508. /**
  75509. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75510. * @param a a component of the plane
  75511. * @param b b component of the plane
  75512. * @param c c component of the plane
  75513. * @param d d component of the plane
  75514. */
  75515. function Plane(a, b, c, d) {
  75516. this.normal = new Vector3(a, b, c);
  75517. this.d = d;
  75518. }
  75519. /**
  75520. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75521. */
  75522. Plane.prototype.asArray = function () {
  75523. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  75524. };
  75525. // Methods
  75526. /**
  75527. * @returns a new plane copied from the current Plane.
  75528. */
  75529. Plane.prototype.clone = function () {
  75530. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  75531. };
  75532. /**
  75533. * @returns the string "Plane".
  75534. */
  75535. Plane.prototype.getClassName = function () {
  75536. return "Plane";
  75537. };
  75538. /**
  75539. * @returns the Plane hash code.
  75540. */
  75541. Plane.prototype.getHashCode = function () {
  75542. var hash = this.normal.getHashCode();
  75543. hash = (hash * 397) ^ (this.d || 0);
  75544. return hash;
  75545. };
  75546. /**
  75547. * Normalize the current Plane in place.
  75548. * @returns the updated Plane.
  75549. */
  75550. Plane.prototype.normalize = function () {
  75551. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  75552. var magnitude = 0.0;
  75553. if (norm !== 0) {
  75554. magnitude = 1.0 / norm;
  75555. }
  75556. this.normal.x *= magnitude;
  75557. this.normal.y *= magnitude;
  75558. this.normal.z *= magnitude;
  75559. this.d *= magnitude;
  75560. return this;
  75561. };
  75562. /**
  75563. * Applies a transformation the plane and returns the result
  75564. * @param transformation the transformation matrix to be applied to the plane
  75565. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75566. */
  75567. Plane.prototype.transform = function (transformation) {
  75568. var transposedMatrix = MathTmp.Matrix[0];
  75569. Matrix.TransposeToRef(transformation, transposedMatrix);
  75570. var m = transposedMatrix.m;
  75571. var x = this.normal.x;
  75572. var y = this.normal.y;
  75573. var z = this.normal.z;
  75574. var d = this.d;
  75575. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  75576. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  75577. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  75578. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  75579. return new Plane(normalX, normalY, normalZ, finalD);
  75580. };
  75581. /**
  75582. * Calcualtte the dot product between the point and the plane normal
  75583. * @param point point to calculate the dot product with
  75584. * @returns the dot product (float) of the point coordinates and the plane normal.
  75585. */
  75586. Plane.prototype.dotCoordinate = function (point) {
  75587. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  75588. };
  75589. /**
  75590. * Updates the current Plane from the plane defined by the three given points.
  75591. * @param point1 one of the points used to contruct the plane
  75592. * @param point2 one of the points used to contruct the plane
  75593. * @param point3 one of the points used to contruct the plane
  75594. * @returns the updated Plane.
  75595. */
  75596. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  75597. var x1 = point2.x - point1.x;
  75598. var y1 = point2.y - point1.y;
  75599. var z1 = point2.z - point1.z;
  75600. var x2 = point3.x - point1.x;
  75601. var y2 = point3.y - point1.y;
  75602. var z2 = point3.z - point1.z;
  75603. var yz = (y1 * z2) - (z1 * y2);
  75604. var xz = (z1 * x2) - (x1 * z2);
  75605. var xy = (x1 * y2) - (y1 * x2);
  75606. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  75607. var invPyth;
  75608. if (pyth !== 0) {
  75609. invPyth = 1.0 / pyth;
  75610. }
  75611. else {
  75612. invPyth = 0.0;
  75613. }
  75614. this.normal.x = yz * invPyth;
  75615. this.normal.y = xz * invPyth;
  75616. this.normal.z = xy * invPyth;
  75617. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  75618. return this;
  75619. };
  75620. /**
  75621. * Checks if the plane is facing a given direction
  75622. * @param direction the direction to check if the plane is facing
  75623. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75624. * @returns True is the vector "direction" is the same side than the plane normal.
  75625. */
  75626. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  75627. var dot = Vector3.Dot(this.normal, direction);
  75628. return (dot <= epsilon);
  75629. };
  75630. /**
  75631. * Calculates the distance to a point
  75632. * @param point point to calculate distance to
  75633. * @returns the signed distance (float) from the given point to the Plane.
  75634. */
  75635. Plane.prototype.signedDistanceTo = function (point) {
  75636. return Vector3.Dot(point, this.normal) + this.d;
  75637. };
  75638. // Statics
  75639. /**
  75640. * Creates a plane from an array
  75641. * @param array the array to create a plane from
  75642. * @returns a new Plane from the given array.
  75643. */
  75644. Plane.FromArray = function (array) {
  75645. return new Plane(array[0], array[1], array[2], array[3]);
  75646. };
  75647. /**
  75648. * Creates a plane from three points
  75649. * @param point1 point used to create the plane
  75650. * @param point2 point used to create the plane
  75651. * @param point3 point used to create the plane
  75652. * @returns a new Plane defined by the three given points.
  75653. */
  75654. Plane.FromPoints = function (point1, point2, point3) {
  75655. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  75656. result.copyFromPoints(point1, point2, point3);
  75657. return result;
  75658. };
  75659. /**
  75660. * Creates a plane from an origin point and a normal
  75661. * @param origin origin of the plane to be constructed
  75662. * @param normal normal of the plane to be constructed
  75663. * @returns a new Plane the normal vector to this plane at the given origin point.
  75664. * Note : the vector "normal" is updated because normalized.
  75665. */
  75666. Plane.FromPositionAndNormal = function (origin, normal) {
  75667. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  75668. normal.normalize();
  75669. result.normal = normal;
  75670. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  75671. return result;
  75672. };
  75673. /**
  75674. * Calculates the distance from a plane and a point
  75675. * @param origin origin of the plane to be constructed
  75676. * @param normal normal of the plane to be constructed
  75677. * @param point point to calculate distance to
  75678. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75679. */
  75680. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  75681. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  75682. return Vector3.Dot(point, normal) + d;
  75683. };
  75684. return Plane;
  75685. }());
  75686. /**
  75687. * Class used to represent a viewport on screen
  75688. */
  75689. var Viewport = /** @class */ (function () {
  75690. /**
  75691. * Creates a Viewport object located at (x, y) and sized (width, height)
  75692. * @param x defines viewport left coordinate
  75693. * @param y defines viewport top coordinate
  75694. * @param width defines the viewport width
  75695. * @param height defines the viewport height
  75696. */
  75697. function Viewport(
  75698. /** viewport left coordinate */
  75699. x,
  75700. /** viewport top coordinate */
  75701. y,
  75702. /**viewport width */
  75703. width,
  75704. /** viewport height */
  75705. height) {
  75706. this.x = x;
  75707. this.y = y;
  75708. this.width = width;
  75709. this.height = height;
  75710. }
  75711. /**
  75712. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75713. * @param renderWidth defines the rendering width
  75714. * @param renderHeight defines the rendering height
  75715. * @returns a new Viewport
  75716. */
  75717. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  75718. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  75719. };
  75720. /**
  75721. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75722. * @param renderWidth defines the rendering width
  75723. * @param renderHeight defines the rendering height
  75724. * @param ref defines the target viewport
  75725. * @returns the current viewport
  75726. */
  75727. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  75728. ref.x = this.x * renderWidth;
  75729. ref.y = this.y * renderHeight;
  75730. ref.width = this.width * renderWidth;
  75731. ref.height = this.height * renderHeight;
  75732. return this;
  75733. };
  75734. /**
  75735. * Returns a new Viewport copied from the current one
  75736. * @returns a new Viewport
  75737. */
  75738. Viewport.prototype.clone = function () {
  75739. return new Viewport(this.x, this.y, this.width, this.height);
  75740. };
  75741. return Viewport;
  75742. }());
  75743. /**
  75744. * Reprasents a camera frustum
  75745. */
  75746. var Frustum = /** @class */ (function () {
  75747. function Frustum() {
  75748. }
  75749. /**
  75750. * Gets the planes representing the frustum
  75751. * @param transform matrix to be applied to the returned planes
  75752. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  75753. */
  75754. Frustum.GetPlanes = function (transform) {
  75755. var frustumPlanes = [];
  75756. for (var index = 0; index < 6; index++) {
  75757. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  75758. }
  75759. Frustum.GetPlanesToRef(transform, frustumPlanes);
  75760. return frustumPlanes;
  75761. };
  75762. /**
  75763. * Gets the near frustum plane transformed by the transform matrix
  75764. * @param transform transformation matrix to be applied to the resulting frustum plane
  75765. * @param frustumPlane the resuling frustum plane
  75766. */
  75767. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  75768. var m = transform.m;
  75769. frustumPlane.normal.x = m[3] + m[2];
  75770. frustumPlane.normal.y = m[7] + m[6];
  75771. frustumPlane.normal.z = m[11] + m[10];
  75772. frustumPlane.d = m[15] + m[14];
  75773. frustumPlane.normalize();
  75774. };
  75775. /**
  75776. * Gets the far frustum plane transformed by the transform matrix
  75777. * @param transform transformation matrix to be applied to the resulting frustum plane
  75778. * @param frustumPlane the resuling frustum plane
  75779. */
  75780. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  75781. var m = transform.m;
  75782. frustumPlane.normal.x = m[3] - m[2];
  75783. frustumPlane.normal.y = m[7] - m[6];
  75784. frustumPlane.normal.z = m[11] - m[10];
  75785. frustumPlane.d = m[15] - m[14];
  75786. frustumPlane.normalize();
  75787. };
  75788. /**
  75789. * Gets the left frustum plane transformed by the transform matrix
  75790. * @param transform transformation matrix to be applied to the resulting frustum plane
  75791. * @param frustumPlane the resuling frustum plane
  75792. */
  75793. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  75794. var m = transform.m;
  75795. frustumPlane.normal.x = m[3] + m[0];
  75796. frustumPlane.normal.y = m[7] + m[4];
  75797. frustumPlane.normal.z = m[11] + m[8];
  75798. frustumPlane.d = m[15] + m[12];
  75799. frustumPlane.normalize();
  75800. };
  75801. /**
  75802. * Gets the right frustum plane transformed by the transform matrix
  75803. * @param transform transformation matrix to be applied to the resulting frustum plane
  75804. * @param frustumPlane the resuling frustum plane
  75805. */
  75806. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  75807. var m = transform.m;
  75808. frustumPlane.normal.x = m[3] - m[0];
  75809. frustumPlane.normal.y = m[7] - m[4];
  75810. frustumPlane.normal.z = m[11] - m[8];
  75811. frustumPlane.d = m[15] - m[12];
  75812. frustumPlane.normalize();
  75813. };
  75814. /**
  75815. * Gets the top frustum plane transformed by the transform matrix
  75816. * @param transform transformation matrix to be applied to the resulting frustum plane
  75817. * @param frustumPlane the resuling frustum plane
  75818. */
  75819. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  75820. var m = transform.m;
  75821. frustumPlane.normal.x = m[3] - m[1];
  75822. frustumPlane.normal.y = m[7] - m[5];
  75823. frustumPlane.normal.z = m[11] - m[9];
  75824. frustumPlane.d = m[15] - m[13];
  75825. frustumPlane.normalize();
  75826. };
  75827. /**
  75828. * Gets the bottom frustum plane transformed by the transform matrix
  75829. * @param transform transformation matrix to be applied to the resulting frustum plane
  75830. * @param frustumPlane the resuling frustum plane
  75831. */
  75832. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  75833. var m = transform.m;
  75834. frustumPlane.normal.x = m[3] + m[1];
  75835. frustumPlane.normal.y = m[7] + m[5];
  75836. frustumPlane.normal.z = m[11] + m[9];
  75837. frustumPlane.d = m[15] + m[13];
  75838. frustumPlane.normalize();
  75839. };
  75840. /**
  75841. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  75842. * @param transform transformation matrix to be applied to the resulting frustum planes
  75843. * @param frustumPlanes the resuling frustum planes
  75844. */
  75845. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  75846. // Near
  75847. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  75848. // Far
  75849. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  75850. // Left
  75851. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  75852. // Right
  75853. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  75854. // Top
  75855. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  75856. // Bottom
  75857. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  75858. };
  75859. return Frustum;
  75860. }());
  75861. /** Defines supported spaces */
  75862. var Space;
  75863. (function (Space) {
  75864. /** Local (object) space */
  75865. Space[Space["LOCAL"] = 0] = "LOCAL";
  75866. /** World space */
  75867. Space[Space["WORLD"] = 1] = "WORLD";
  75868. /** Bone space */
  75869. Space[Space["BONE"] = 2] = "BONE";
  75870. })(Space || (Space = {}));
  75871. /** Defines the 3 main axes */
  75872. var Axis = /** @class */ (function () {
  75873. function Axis() {
  75874. }
  75875. /** X axis */
  75876. Axis.X = new Vector3(1.0, 0.0, 0.0);
  75877. /** Y axis */
  75878. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  75879. /** Z axis */
  75880. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  75881. return Axis;
  75882. }());
  75883. /** Class used to represent a Bezier curve */
  75884. var BezierCurve = /** @class */ (function () {
  75885. function BezierCurve() {
  75886. }
  75887. /**
  75888. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75889. * @param t defines the time
  75890. * @param x1 defines the left coordinate on X axis
  75891. * @param y1 defines the left coordinate on Y axis
  75892. * @param x2 defines the right coordinate on X axis
  75893. * @param y2 defines the right coordinate on Y axis
  75894. * @returns the interpolated value
  75895. */
  75896. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  75897. // Extract X (which is equal to time here)
  75898. var f0 = 1 - 3 * x2 + 3 * x1;
  75899. var f1 = 3 * x2 - 6 * x1;
  75900. var f2 = 3 * x1;
  75901. var refinedT = t;
  75902. for (var i = 0; i < 5; i++) {
  75903. var refinedT2 = refinedT * refinedT;
  75904. var refinedT3 = refinedT2 * refinedT;
  75905. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  75906. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  75907. refinedT -= (x - t) * slope;
  75908. refinedT = Math.min(1, Math.max(0, refinedT));
  75909. }
  75910. // Resolve cubic bezier for the given x
  75911. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  75912. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  75913. Math.pow(refinedT, 3);
  75914. };
  75915. return BezierCurve;
  75916. }());
  75917. /**
  75918. * Defines potential orientation for back face culling
  75919. */
  75920. var Orientation;
  75921. (function (Orientation) {
  75922. /**
  75923. * Clockwise
  75924. */
  75925. Orientation[Orientation["CW"] = 0] = "CW";
  75926. /** Counter clockwise */
  75927. Orientation[Orientation["CCW"] = 1] = "CCW";
  75928. })(Orientation || (Orientation = {}));
  75929. /**
  75930. * Defines angle representation
  75931. */
  75932. var Angle = /** @class */ (function () {
  75933. /**
  75934. * Creates an Angle object of "radians" radians (float).
  75935. * @param radians the angle in radians
  75936. */
  75937. function Angle(radians) {
  75938. this._radians = radians;
  75939. if (this._radians < 0.0) {
  75940. this._radians += (2.0 * Math.PI);
  75941. }
  75942. }
  75943. /**
  75944. * Get value in degrees
  75945. * @returns the Angle value in degrees (float)
  75946. */
  75947. Angle.prototype.degrees = function () {
  75948. return this._radians * 180.0 / Math.PI;
  75949. };
  75950. /**
  75951. * Get value in radians
  75952. * @returns the Angle value in radians (float)
  75953. */
  75954. Angle.prototype.radians = function () {
  75955. return this._radians;
  75956. };
  75957. /**
  75958. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75959. * @param a defines first vector
  75960. * @param b defines second vector
  75961. * @returns a new Angle
  75962. */
  75963. Angle.BetweenTwoPoints = function (a, b) {
  75964. var delta = b.subtract(a);
  75965. var theta = Math.atan2(delta.y, delta.x);
  75966. return new Angle(theta);
  75967. };
  75968. /**
  75969. * Gets a new Angle object from the given float in radians
  75970. * @param radians defines the angle value in radians
  75971. * @returns a new Angle
  75972. */
  75973. Angle.FromRadians = function (radians) {
  75974. return new Angle(radians);
  75975. };
  75976. /**
  75977. * Gets a new Angle object from the given float in degrees
  75978. * @param degrees defines the angle value in degrees
  75979. * @returns a new Angle
  75980. */
  75981. Angle.FromDegrees = function (degrees) {
  75982. return new Angle(degrees * Math.PI / 180.0);
  75983. };
  75984. return Angle;
  75985. }());
  75986. /**
  75987. * This represents an arc in a 2d space.
  75988. */
  75989. var Arc2 = /** @class */ (function () {
  75990. /**
  75991. * Creates an Arc object from the three given points : start, middle and end.
  75992. * @param startPoint Defines the start point of the arc
  75993. * @param midPoint Defines the midlle point of the arc
  75994. * @param endPoint Defines the end point of the arc
  75995. */
  75996. function Arc2(
  75997. /** Defines the start point of the arc */
  75998. startPoint,
  75999. /** Defines the mid point of the arc */
  76000. midPoint,
  76001. /** Defines the end point of the arc */
  76002. endPoint) {
  76003. this.startPoint = startPoint;
  76004. this.midPoint = midPoint;
  76005. this.endPoint = endPoint;
  76006. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  76007. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  76008. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  76009. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  76010. 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);
  76011. this.radius = this.centerPoint.subtract(this.startPoint).length();
  76012. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  76013. var a1 = this.startAngle.degrees();
  76014. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  76015. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  76016. // angles correction
  76017. if (a2 - a1 > +180.0) {
  76018. a2 -= 360.0;
  76019. }
  76020. if (a2 - a1 < -180.0) {
  76021. a2 += 360.0;
  76022. }
  76023. if (a3 - a2 > +180.0) {
  76024. a3 -= 360.0;
  76025. }
  76026. if (a3 - a2 < -180.0) {
  76027. a3 += 360.0;
  76028. }
  76029. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  76030. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  76031. }
  76032. return Arc2;
  76033. }());
  76034. /**
  76035. * Represents a 2D path made up of multiple 2D points
  76036. */
  76037. var Path2 = /** @class */ (function () {
  76038. /**
  76039. * Creates a Path2 object from the starting 2D coordinates x and y.
  76040. * @param x the starting points x value
  76041. * @param y the starting points y value
  76042. */
  76043. function Path2(x, y) {
  76044. this._points = new Array();
  76045. this._length = 0.0;
  76046. /**
  76047. * If the path start and end point are the same
  76048. */
  76049. this.closed = false;
  76050. this._points.push(new Vector2(x, y));
  76051. }
  76052. /**
  76053. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  76054. * @param x the added points x value
  76055. * @param y the added points y value
  76056. * @returns the updated Path2.
  76057. */
  76058. Path2.prototype.addLineTo = function (x, y) {
  76059. if (this.closed) {
  76060. return this;
  76061. }
  76062. var newPoint = new Vector2(x, y);
  76063. var previousPoint = this._points[this._points.length - 1];
  76064. this._points.push(newPoint);
  76065. this._length += newPoint.subtract(previousPoint).length();
  76066. return this;
  76067. };
  76068. /**
  76069. * 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.
  76070. * @param midX middle point x value
  76071. * @param midY middle point y value
  76072. * @param endX end point x value
  76073. * @param endY end point y value
  76074. * @param numberOfSegments (default: 36)
  76075. * @returns the updated Path2.
  76076. */
  76077. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  76078. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  76079. if (this.closed) {
  76080. return this;
  76081. }
  76082. var startPoint = this._points[this._points.length - 1];
  76083. var midPoint = new Vector2(midX, midY);
  76084. var endPoint = new Vector2(endX, endY);
  76085. var arc = new Arc2(startPoint, midPoint, endPoint);
  76086. var increment = arc.angle.radians() / numberOfSegments;
  76087. if (arc.orientation === Orientation.CW) {
  76088. increment *= -1;
  76089. }
  76090. var currentAngle = arc.startAngle.radians() + increment;
  76091. for (var i = 0; i < numberOfSegments; i++) {
  76092. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  76093. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  76094. this.addLineTo(x, y);
  76095. currentAngle += increment;
  76096. }
  76097. return this;
  76098. };
  76099. /**
  76100. * Closes the Path2.
  76101. * @returns the Path2.
  76102. */
  76103. Path2.prototype.close = function () {
  76104. this.closed = true;
  76105. return this;
  76106. };
  76107. /**
  76108. * Gets the sum of the distance between each sequential point in the path
  76109. * @returns the Path2 total length (float).
  76110. */
  76111. Path2.prototype.length = function () {
  76112. var result = this._length;
  76113. if (!this.closed) {
  76114. var lastPoint = this._points[this._points.length - 1];
  76115. var firstPoint = this._points[0];
  76116. result += (firstPoint.subtract(lastPoint).length());
  76117. }
  76118. return result;
  76119. };
  76120. /**
  76121. * Gets the points which construct the path
  76122. * @returns the Path2 internal array of points.
  76123. */
  76124. Path2.prototype.getPoints = function () {
  76125. return this._points;
  76126. };
  76127. /**
  76128. * Retreives the point at the distance aways from the starting point
  76129. * @param normalizedLengthPosition the length along the path to retreive the point from
  76130. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  76131. */
  76132. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  76133. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  76134. return Vector2.Zero();
  76135. }
  76136. var lengthPosition = normalizedLengthPosition * this.length();
  76137. var previousOffset = 0;
  76138. for (var i = 0; i < this._points.length; i++) {
  76139. var j = (i + 1) % this._points.length;
  76140. var a = this._points[i];
  76141. var b = this._points[j];
  76142. var bToA = b.subtract(a);
  76143. var nextOffset = (bToA.length() + previousOffset);
  76144. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  76145. var dir = bToA.normalize();
  76146. var localOffset = lengthPosition - previousOffset;
  76147. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  76148. }
  76149. previousOffset = nextOffset;
  76150. }
  76151. return Vector2.Zero();
  76152. };
  76153. /**
  76154. * Creates a new path starting from an x and y position
  76155. * @param x starting x value
  76156. * @param y starting y value
  76157. * @returns a new Path2 starting at the coordinates (x, y).
  76158. */
  76159. Path2.StartingAt = function (x, y) {
  76160. return new Path2(x, y);
  76161. };
  76162. return Path2;
  76163. }());
  76164. /**
  76165. * Represents a 3D path made up of multiple 3D points
  76166. */
  76167. var Path3D = /** @class */ (function () {
  76168. /**
  76169. * new Path3D(path, normal, raw)
  76170. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  76171. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  76172. * @param path an array of Vector3, the curve axis of the Path3D
  76173. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  76174. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  76175. */
  76176. function Path3D(
  76177. /**
  76178. * an array of Vector3, the curve axis of the Path3D
  76179. */
  76180. path, firstNormal, raw) {
  76181. if (firstNormal === void 0) { firstNormal = null; }
  76182. this.path = path;
  76183. this._curve = new Array();
  76184. this._distances = new Array();
  76185. this._tangents = new Array();
  76186. this._normals = new Array();
  76187. this._binormals = new Array();
  76188. for (var p = 0; p < path.length; p++) {
  76189. this._curve[p] = path[p].clone(); // hard copy
  76190. }
  76191. this._raw = raw || false;
  76192. this._compute(firstNormal);
  76193. }
  76194. /**
  76195. * Returns the Path3D array of successive Vector3 designing its curve.
  76196. * @returns the Path3D array of successive Vector3 designing its curve.
  76197. */
  76198. Path3D.prototype.getCurve = function () {
  76199. return this._curve;
  76200. };
  76201. /**
  76202. * Returns an array populated with tangent vectors on each Path3D curve point.
  76203. * @returns an array populated with tangent vectors on each Path3D curve point.
  76204. */
  76205. Path3D.prototype.getTangents = function () {
  76206. return this._tangents;
  76207. };
  76208. /**
  76209. * Returns an array populated with normal vectors on each Path3D curve point.
  76210. * @returns an array populated with normal vectors on each Path3D curve point.
  76211. */
  76212. Path3D.prototype.getNormals = function () {
  76213. return this._normals;
  76214. };
  76215. /**
  76216. * Returns an array populated with binormal vectors on each Path3D curve point.
  76217. * @returns an array populated with binormal vectors on each Path3D curve point.
  76218. */
  76219. Path3D.prototype.getBinormals = function () {
  76220. return this._binormals;
  76221. };
  76222. /**
  76223. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  76224. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  76225. */
  76226. Path3D.prototype.getDistances = function () {
  76227. return this._distances;
  76228. };
  76229. /**
  76230. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  76231. * @param path path which all values are copied into the curves points
  76232. * @param firstNormal which should be projected onto the curve
  76233. * @returns the same object updated.
  76234. */
  76235. Path3D.prototype.update = function (path, firstNormal) {
  76236. if (firstNormal === void 0) { firstNormal = null; }
  76237. for (var p = 0; p < path.length; p++) {
  76238. this._curve[p].x = path[p].x;
  76239. this._curve[p].y = path[p].y;
  76240. this._curve[p].z = path[p].z;
  76241. }
  76242. this._compute(firstNormal);
  76243. return this;
  76244. };
  76245. // private function compute() : computes tangents, normals and binormals
  76246. Path3D.prototype._compute = function (firstNormal) {
  76247. var l = this._curve.length;
  76248. // first and last tangents
  76249. this._tangents[0] = this._getFirstNonNullVector(0);
  76250. if (!this._raw) {
  76251. this._tangents[0].normalize();
  76252. }
  76253. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  76254. if (!this._raw) {
  76255. this._tangents[l - 1].normalize();
  76256. }
  76257. // normals and binormals at first point : arbitrary vector with _normalVector()
  76258. var tg0 = this._tangents[0];
  76259. var pp0 = this._normalVector(tg0, firstNormal);
  76260. this._normals[0] = pp0;
  76261. if (!this._raw) {
  76262. this._normals[0].normalize();
  76263. }
  76264. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  76265. if (!this._raw) {
  76266. this._binormals[0].normalize();
  76267. }
  76268. this._distances[0] = 0.0;
  76269. // normals and binormals : next points
  76270. var prev; // previous vector (segment)
  76271. var cur; // current vector (segment)
  76272. var curTang; // current tangent
  76273. // previous normal
  76274. var prevBinor; // previous binormal
  76275. for (var i = 1; i < l; i++) {
  76276. // tangents
  76277. prev = this._getLastNonNullVector(i);
  76278. if (i < l - 1) {
  76279. cur = this._getFirstNonNullVector(i);
  76280. this._tangents[i] = prev.add(cur);
  76281. this._tangents[i].normalize();
  76282. }
  76283. this._distances[i] = this._distances[i - 1] + prev.length();
  76284. // normals and binormals
  76285. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  76286. curTang = this._tangents[i];
  76287. prevBinor = this._binormals[i - 1];
  76288. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  76289. if (!this._raw) {
  76290. this._normals[i].normalize();
  76291. }
  76292. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  76293. if (!this._raw) {
  76294. this._binormals[i].normalize();
  76295. }
  76296. }
  76297. };
  76298. // private function getFirstNonNullVector(index)
  76299. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  76300. Path3D.prototype._getFirstNonNullVector = function (index) {
  76301. var i = 1;
  76302. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  76303. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  76304. i++;
  76305. nNVector = this._curve[index + i].subtract(this._curve[index]);
  76306. }
  76307. return nNVector;
  76308. };
  76309. // private function getLastNonNullVector(index)
  76310. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  76311. Path3D.prototype._getLastNonNullVector = function (index) {
  76312. var i = 1;
  76313. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  76314. while (nLVector.length() === 0 && index > i + 1) {
  76315. i++;
  76316. nLVector = this._curve[index].subtract(this._curve[index - i]);
  76317. }
  76318. return nLVector;
  76319. };
  76320. // private function normalVector(v0, vt, va) :
  76321. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  76322. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  76323. Path3D.prototype._normalVector = function (vt, va) {
  76324. var normal0;
  76325. var tgl = vt.length();
  76326. if (tgl === 0.0) {
  76327. tgl = 1.0;
  76328. }
  76329. if (va === undefined || va === null) {
  76330. var point;
  76331. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  76332. point = new Vector3(0.0, -1.0, 0.0);
  76333. }
  76334. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  76335. point = new Vector3(1.0, 0.0, 0.0);
  76336. }
  76337. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  76338. point = new Vector3(0.0, 0.0, 1.0);
  76339. }
  76340. else {
  76341. point = Vector3.Zero();
  76342. }
  76343. normal0 = Vector3.Cross(vt, point);
  76344. }
  76345. else {
  76346. normal0 = Vector3.Cross(vt, va);
  76347. Vector3.CrossToRef(normal0, vt, normal0);
  76348. }
  76349. normal0.normalize();
  76350. return normal0;
  76351. };
  76352. return Path3D;
  76353. }());
  76354. /**
  76355. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76356. * A Curve3 is designed from a series of successive Vector3.
  76357. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  76358. */
  76359. var Curve3 = /** @class */ (function () {
  76360. /**
  76361. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76362. * A Curve3 is designed from a series of successive Vector3.
  76363. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  76364. * @param points points which make up the curve
  76365. */
  76366. function Curve3(points) {
  76367. this._length = 0.0;
  76368. this._points = points;
  76369. this._length = this._computeLength(points);
  76370. }
  76371. /**
  76372. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  76373. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  76374. * @param v1 (Vector3) the control point
  76375. * @param v2 (Vector3) the end point of the Quadratic Bezier
  76376. * @param nbPoints (integer) the wanted number of points in the curve
  76377. * @returns the created Curve3
  76378. */
  76379. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  76380. nbPoints = nbPoints > 2 ? nbPoints : 3;
  76381. var bez = new Array();
  76382. var equation = function (t, val0, val1, val2) {
  76383. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  76384. return res;
  76385. };
  76386. for (var i = 0; i <= nbPoints; i++) {
  76387. 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)));
  76388. }
  76389. return new Curve3(bez);
  76390. };
  76391. /**
  76392. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  76393. * @param v0 (Vector3) the origin point of the Cubic Bezier
  76394. * @param v1 (Vector3) the first control point
  76395. * @param v2 (Vector3) the second control point
  76396. * @param v3 (Vector3) the end point of the Cubic Bezier
  76397. * @param nbPoints (integer) the wanted number of points in the curve
  76398. * @returns the created Curve3
  76399. */
  76400. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  76401. nbPoints = nbPoints > 3 ? nbPoints : 4;
  76402. var bez = new Array();
  76403. var equation = function (t, val0, val1, val2, val3) {
  76404. 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;
  76405. return res;
  76406. };
  76407. for (var i = 0; i <= nbPoints; i++) {
  76408. 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)));
  76409. }
  76410. return new Curve3(bez);
  76411. };
  76412. /**
  76413. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  76414. * @param p1 (Vector3) the origin point of the Hermite Spline
  76415. * @param t1 (Vector3) the tangent vector at the origin point
  76416. * @param p2 (Vector3) the end point of the Hermite Spline
  76417. * @param t2 (Vector3) the tangent vector at the end point
  76418. * @param nbPoints (integer) the wanted number of points in the curve
  76419. * @returns the created Curve3
  76420. */
  76421. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  76422. var hermite = new Array();
  76423. var step = 1.0 / nbPoints;
  76424. for (var i = 0; i <= nbPoints; i++) {
  76425. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  76426. }
  76427. return new Curve3(hermite);
  76428. };
  76429. /**
  76430. * Returns a Curve3 object along a CatmullRom Spline curve :
  76431. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  76432. * @param nbPoints (integer) the wanted number of points between each curve control points
  76433. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  76434. * @returns the created Curve3
  76435. */
  76436. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  76437. var catmullRom = new Array();
  76438. var step = 1.0 / nbPoints;
  76439. var amount = 0.0;
  76440. if (closed) {
  76441. var pointsCount = points.length;
  76442. for (var i = 0; i < pointsCount; i++) {
  76443. amount = 0;
  76444. for (var c = 0; c < nbPoints; c++) {
  76445. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  76446. amount += step;
  76447. }
  76448. }
  76449. catmullRom.push(catmullRom[0]);
  76450. }
  76451. else {
  76452. var totalPoints = new Array();
  76453. totalPoints.push(points[0].clone());
  76454. Array.prototype.push.apply(totalPoints, points);
  76455. totalPoints.push(points[points.length - 1].clone());
  76456. for (var i = 0; i < totalPoints.length - 3; i++) {
  76457. amount = 0;
  76458. for (var c = 0; c < nbPoints; c++) {
  76459. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  76460. amount += step;
  76461. }
  76462. }
  76463. i--;
  76464. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  76465. }
  76466. return new Curve3(catmullRom);
  76467. };
  76468. /**
  76469. * @returns the Curve3 stored array of successive Vector3
  76470. */
  76471. Curve3.prototype.getPoints = function () {
  76472. return this._points;
  76473. };
  76474. /**
  76475. * @returns the computed length (float) of the curve.
  76476. */
  76477. Curve3.prototype.length = function () {
  76478. return this._length;
  76479. };
  76480. /**
  76481. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  76482. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  76483. * curveA and curveB keep unchanged.
  76484. * @param curve the curve to continue from this curve
  76485. * @returns the newly constructed curve
  76486. */
  76487. Curve3.prototype.continue = function (curve) {
  76488. var lastPoint = this._points[this._points.length - 1];
  76489. var continuedPoints = this._points.slice();
  76490. var curvePoints = curve.getPoints();
  76491. for (var i = 1; i < curvePoints.length; i++) {
  76492. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  76493. }
  76494. var continuedCurve = new Curve3(continuedPoints);
  76495. return continuedCurve;
  76496. };
  76497. Curve3.prototype._computeLength = function (path) {
  76498. var l = 0;
  76499. for (var i = 1; i < path.length; i++) {
  76500. l += (path[i].subtract(path[i - 1])).length();
  76501. }
  76502. return l;
  76503. };
  76504. return Curve3;
  76505. }());
  76506. // Vertex formats
  76507. /**
  76508. * Contains position and normal vectors for a vertex
  76509. */
  76510. var PositionNormalVertex = /** @class */ (function () {
  76511. /**
  76512. * Creates a PositionNormalVertex
  76513. * @param position the position of the vertex (defaut: 0,0,0)
  76514. * @param normal the normal of the vertex (defaut: 0,1,0)
  76515. */
  76516. function PositionNormalVertex(
  76517. /** the position of the vertex (defaut: 0,0,0) */
  76518. position,
  76519. /** the normal of the vertex (defaut: 0,1,0) */
  76520. normal) {
  76521. if (position === void 0) { position = Vector3.Zero(); }
  76522. if (normal === void 0) { normal = Vector3.Up(); }
  76523. this.position = position;
  76524. this.normal = normal;
  76525. }
  76526. /**
  76527. * Clones the PositionNormalVertex
  76528. * @returns the cloned PositionNormalVertex
  76529. */
  76530. PositionNormalVertex.prototype.clone = function () {
  76531. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  76532. };
  76533. return PositionNormalVertex;
  76534. }());
  76535. /**
  76536. * Contains position, normal and uv vectors for a vertex
  76537. */
  76538. var PositionNormalTextureVertex = /** @class */ (function () {
  76539. /**
  76540. * Creates a PositionNormalTextureVertex
  76541. * @param position the position of the vertex (defaut: 0,0,0)
  76542. * @param normal the normal of the vertex (defaut: 0,1,0)
  76543. * @param uv the uv of the vertex (default: 0,0)
  76544. */
  76545. function PositionNormalTextureVertex(
  76546. /** the position of the vertex (defaut: 0,0,0) */
  76547. position,
  76548. /** the normal of the vertex (defaut: 0,1,0) */
  76549. normal,
  76550. /** the uv of the vertex (default: 0,0) */
  76551. uv) {
  76552. if (position === void 0) { position = Vector3.Zero(); }
  76553. if (normal === void 0) { normal = Vector3.Up(); }
  76554. if (uv === void 0) { uv = Vector2.Zero(); }
  76555. this.position = position;
  76556. this.normal = normal;
  76557. this.uv = uv;
  76558. }
  76559. /**
  76560. * Clones the PositionNormalTextureVertex
  76561. * @returns the cloned PositionNormalTextureVertex
  76562. */
  76563. PositionNormalTextureVertex.prototype.clone = function () {
  76564. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  76565. };
  76566. return PositionNormalTextureVertex;
  76567. }());
  76568. // Temporary pre-allocated objects for engine internal use
  76569. // usage in any internal function :
  76570. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  76571. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  76572. /**
  76573. * @hidden
  76574. */
  76575. var Tmp = /** @class */ (function () {
  76576. function Tmp() {
  76577. }
  76578. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  76579. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  76580. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  76581. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  76582. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  76583. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  76584. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  76585. return Tmp;
  76586. }());
  76587. /**
  76588. * @hidden
  76589. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  76590. */
  76591. var MathTmp = /** @class */ (function () {
  76592. function MathTmp() {
  76593. }
  76594. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  76595. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  76596. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  76597. return MathTmp;
  76598. }());
  76599. /***/ }),
  76600. /***/ "./Maths/sphericalPolynomial.ts":
  76601. /*!**************************************!*\
  76602. !*** ./Maths/sphericalPolynomial.ts ***!
  76603. \**************************************/
  76604. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  76605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76606. "use strict";
  76607. __webpack_require__.r(__webpack_exports__);
  76608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  76609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  76610. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  76611. /**
  76612. * Class representing spherical polynomial coefficients to the 3rd degree
  76613. */
  76614. var SphericalPolynomial = /** @class */ (function () {
  76615. function SphericalPolynomial() {
  76616. /**
  76617. * The x coefficients of the spherical polynomial
  76618. */
  76619. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76620. /**
  76621. * The y coefficients of the spherical polynomial
  76622. */
  76623. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76624. /**
  76625. * The z coefficients of the spherical polynomial
  76626. */
  76627. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76628. /**
  76629. * The xx coefficients of the spherical polynomial
  76630. */
  76631. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76632. /**
  76633. * The yy coefficients of the spherical polynomial
  76634. */
  76635. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76636. /**
  76637. * The zz coefficients of the spherical polynomial
  76638. */
  76639. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76640. /**
  76641. * The xy coefficients of the spherical polynomial
  76642. */
  76643. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76644. /**
  76645. * The yz coefficients of the spherical polynomial
  76646. */
  76647. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76648. /**
  76649. * The zx coefficients of the spherical polynomial
  76650. */
  76651. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76652. }
  76653. /**
  76654. * Adds an ambient color to the spherical polynomial
  76655. * @param color the color to add
  76656. */
  76657. SphericalPolynomial.prototype.addAmbient = function (color) {
  76658. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  76659. this.xx = this.xx.add(colorVector);
  76660. this.yy = this.yy.add(colorVector);
  76661. this.zz = this.zz.add(colorVector);
  76662. };
  76663. /**
  76664. * Scales the spherical polynomial by the given amount
  76665. * @param scale the amount to scale
  76666. */
  76667. SphericalPolynomial.prototype.scale = function (scale) {
  76668. this.x = this.x.scale(scale);
  76669. this.y = this.y.scale(scale);
  76670. this.z = this.z.scale(scale);
  76671. this.xx = this.xx.scale(scale);
  76672. this.yy = this.yy.scale(scale);
  76673. this.zz = this.zz.scale(scale);
  76674. this.yz = this.yz.scale(scale);
  76675. this.zx = this.zx.scale(scale);
  76676. this.xy = this.xy.scale(scale);
  76677. };
  76678. /**
  76679. * Gets the spherical polynomial from harmonics
  76680. * @param harmonics the spherical harmonics
  76681. * @returns the spherical polynomial
  76682. */
  76683. SphericalPolynomial.FromHarmonics = function (harmonics) {
  76684. var result = new SphericalPolynomial();
  76685. result.x = harmonics.l11.scale(1.02333);
  76686. result.y = harmonics.l1_1.scale(1.02333);
  76687. result.z = harmonics.l10.scale(1.02333);
  76688. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  76689. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  76690. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  76691. result.yz = harmonics.l2_1.scale(0.858086);
  76692. result.zx = harmonics.l21.scale(0.858086);
  76693. result.xy = harmonics.l2_2.scale(0.858086);
  76694. result.scale(1.0 / Math.PI);
  76695. return result;
  76696. };
  76697. /**
  76698. * Constructs a spherical polynomial from an array.
  76699. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  76700. * @returns the spherical polynomial
  76701. */
  76702. SphericalPolynomial.FromArray = function (data) {
  76703. var sp = new SphericalPolynomial();
  76704. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  76705. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  76706. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  76707. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  76708. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  76709. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  76710. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  76711. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  76712. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  76713. return sp;
  76714. };
  76715. return SphericalPolynomial;
  76716. }());
  76717. /**
  76718. * Class representing spherical harmonics coefficients to the 3rd degree
  76719. */
  76720. var SphericalHarmonics = /** @class */ (function () {
  76721. function SphericalHarmonics() {
  76722. /**
  76723. * The l0,0 coefficients of the spherical harmonics
  76724. */
  76725. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76726. /**
  76727. * The l1,-1 coefficients of the spherical harmonics
  76728. */
  76729. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76730. /**
  76731. * The l1,0 coefficients of the spherical harmonics
  76732. */
  76733. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76734. /**
  76735. * The l1,1 coefficients of the spherical harmonics
  76736. */
  76737. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76738. /**
  76739. * The l2,-2 coefficients of the spherical harmonics
  76740. */
  76741. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76742. /**
  76743. * The l2,-1 coefficients of the spherical harmonics
  76744. */
  76745. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76746. /**
  76747. * The l2,0 coefficients of the spherical harmonics
  76748. */
  76749. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76750. /**
  76751. * The l2,1 coefficients of the spherical harmonics
  76752. */
  76753. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76754. /**
  76755. * The l2,2 coefficients of the spherical harmonics
  76756. */
  76757. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76758. }
  76759. /**
  76760. * Adds a light to the spherical harmonics
  76761. * @param direction the direction of the light
  76762. * @param color the color of the light
  76763. * @param deltaSolidAngle the delta solid angle of the light
  76764. */
  76765. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  76766. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  76767. var c = colorVector.scale(deltaSolidAngle);
  76768. this.l00 = this.l00.add(c.scale(0.282095));
  76769. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  76770. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  76771. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  76772. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  76773. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  76774. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  76775. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  76776. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  76777. };
  76778. /**
  76779. * Scales the spherical harmonics by the given amount
  76780. * @param scale the amount to scale
  76781. */
  76782. SphericalHarmonics.prototype.scale = function (scale) {
  76783. this.l00 = this.l00.scale(scale);
  76784. this.l1_1 = this.l1_1.scale(scale);
  76785. this.l10 = this.l10.scale(scale);
  76786. this.l11 = this.l11.scale(scale);
  76787. this.l2_2 = this.l2_2.scale(scale);
  76788. this.l2_1 = this.l2_1.scale(scale);
  76789. this.l20 = this.l20.scale(scale);
  76790. this.l21 = this.l21.scale(scale);
  76791. this.lL22 = this.lL22.scale(scale);
  76792. };
  76793. /**
  76794. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  76795. *
  76796. * ```
  76797. * E_lm = A_l * L_lm
  76798. * ```
  76799. *
  76800. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  76801. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  76802. * the scaling factors are given in equation 9.
  76803. */
  76804. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  76805. // Constant (Band 0)
  76806. this.l00 = this.l00.scale(3.141593);
  76807. // Linear (Band 1)
  76808. this.l1_1 = this.l1_1.scale(2.094395);
  76809. this.l10 = this.l10.scale(2.094395);
  76810. this.l11 = this.l11.scale(2.094395);
  76811. // Quadratic (Band 2)
  76812. this.l2_2 = this.l2_2.scale(0.785398);
  76813. this.l2_1 = this.l2_1.scale(0.785398);
  76814. this.l20 = this.l20.scale(0.785398);
  76815. this.l21 = this.l21.scale(0.785398);
  76816. this.lL22 = this.lL22.scale(0.785398);
  76817. };
  76818. /**
  76819. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  76820. *
  76821. * ```
  76822. * L = (1/pi) * E * rho
  76823. * ```
  76824. *
  76825. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  76826. */
  76827. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  76828. this.scale(1.0 / Math.PI);
  76829. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  76830. // (The pixel shader must apply albedo after texture fetches, etc).
  76831. };
  76832. /**
  76833. * Gets the spherical harmonics from polynomial
  76834. * @param polynomial the spherical polynomial
  76835. * @returns the spherical harmonics
  76836. */
  76837. SphericalHarmonics.FromPolynomial = function (polynomial) {
  76838. var result = new SphericalHarmonics();
  76839. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  76840. result.l1_1 = polynomial.y.scale(0.977204);
  76841. result.l10 = polynomial.z.scale(0.977204);
  76842. result.l11 = polynomial.x.scale(0.977204);
  76843. result.l2_2 = polynomial.xy.scale(1.16538);
  76844. result.l2_1 = polynomial.yz.scale(1.16538);
  76845. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  76846. result.l21 = polynomial.zx.scale(1.16538);
  76847. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  76848. result.scale(Math.PI);
  76849. return result;
  76850. };
  76851. /**
  76852. * Constructs a spherical harmonics from an array.
  76853. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  76854. * @returns the spherical harmonics
  76855. */
  76856. SphericalHarmonics.FromArray = function (data) {
  76857. var sh = new SphericalHarmonics();
  76858. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  76859. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  76860. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  76861. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  76862. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  76863. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  76864. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  76865. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  76866. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  76867. return sh;
  76868. };
  76869. return SphericalHarmonics;
  76870. }());
  76871. /***/ }),
  76872. /***/ "./Meshes/Builders/boxBuilder.ts":
  76873. /*!***************************************!*\
  76874. !*** ./Meshes/Builders/boxBuilder.ts ***!
  76875. \***************************************/
  76876. /*! exports provided: BoxBuilder */
  76877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76878. "use strict";
  76879. __webpack_require__.r(__webpack_exports__);
  76880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  76881. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76882. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76883. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76884. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  76885. var normalsSource = [
  76886. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  76887. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  76888. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  76889. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  76890. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  76891. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  76892. ];
  76893. var indices = [];
  76894. var positions = [];
  76895. var normals = [];
  76896. var uvs = [];
  76897. var width = options.width || options.size || 1;
  76898. var height = options.height || options.size || 1;
  76899. var depth = options.depth || options.size || 1;
  76900. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76901. var faceUV = options.faceUV || new Array(6);
  76902. var faceColors = options.faceColors;
  76903. var colors = [];
  76904. // default face colors and UV if undefined
  76905. for (var f = 0; f < 6; f++) {
  76906. if (faceUV[f] === undefined) {
  76907. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76908. }
  76909. if (faceColors && faceColors[f] === undefined) {
  76910. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76911. }
  76912. }
  76913. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  76914. // Create each face in turn.
  76915. for (var index = 0; index < normalsSource.length; index++) {
  76916. var normal = normalsSource[index];
  76917. // Get two vectors perpendicular to the face normal and to each other.
  76918. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  76919. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  76920. // Six indices (two triangles) per face.
  76921. var verticesLength = positions.length / 3;
  76922. indices.push(verticesLength);
  76923. indices.push(verticesLength + 1);
  76924. indices.push(verticesLength + 2);
  76925. indices.push(verticesLength);
  76926. indices.push(verticesLength + 2);
  76927. indices.push(verticesLength + 3);
  76928. // Four vertices per face.
  76929. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  76930. positions.push(vertex.x, vertex.y, vertex.z);
  76931. normals.push(normal.x, normal.y, normal.z);
  76932. uvs.push(faceUV[index].z, faceUV[index].w);
  76933. if (faceColors) {
  76934. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76935. }
  76936. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  76937. positions.push(vertex.x, vertex.y, vertex.z);
  76938. normals.push(normal.x, normal.y, normal.z);
  76939. uvs.push(faceUV[index].x, faceUV[index].w);
  76940. if (faceColors) {
  76941. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76942. }
  76943. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  76944. positions.push(vertex.x, vertex.y, vertex.z);
  76945. normals.push(normal.x, normal.y, normal.z);
  76946. uvs.push(faceUV[index].x, faceUV[index].y);
  76947. if (faceColors) {
  76948. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76949. }
  76950. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  76951. positions.push(vertex.x, vertex.y, vertex.z);
  76952. normals.push(normal.x, normal.y, normal.z);
  76953. uvs.push(faceUV[index].z, faceUV[index].y);
  76954. if (faceColors) {
  76955. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76956. }
  76957. }
  76958. // sides
  76959. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76960. // Result
  76961. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76962. vertexData.indices = indices;
  76963. vertexData.positions = positions;
  76964. vertexData.normals = normals;
  76965. vertexData.uvs = uvs;
  76966. if (faceColors) {
  76967. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  76968. vertexData.colors = totalColors;
  76969. }
  76970. return vertexData;
  76971. };
  76972. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  76973. if (scene === void 0) { scene = null; }
  76974. var options = {
  76975. size: size,
  76976. sideOrientation: sideOrientation,
  76977. updatable: updatable
  76978. };
  76979. return BoxBuilder.CreateBox(name, options, scene);
  76980. };
  76981. /**
  76982. * Class containing static functions to help procedurally build meshes
  76983. */
  76984. var BoxBuilder = /** @class */ (function () {
  76985. function BoxBuilder() {
  76986. }
  76987. /**
  76988. * Creates a box mesh
  76989. * * The parameter `size` sets the size (float) of each box side (default 1)
  76990. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  76991. * * 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)
  76992. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  76993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76994. * * 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
  76995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76996. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  76997. * @param name defines the name of the mesh
  76998. * @param options defines the options used to create the mesh
  76999. * @param scene defines the hosting scene
  77000. * @returns the box mesh
  77001. */
  77002. BoxBuilder.CreateBox = function (name, options, scene) {
  77003. if (scene === void 0) { scene = null; }
  77004. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77005. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77006. box._originalBuilderSideOrientation = options.sideOrientation;
  77007. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  77008. vertexData.applyToMesh(box, options.updatable);
  77009. return box;
  77010. };
  77011. return BoxBuilder;
  77012. }());
  77013. /***/ }),
  77014. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  77015. /*!********************************************!*\
  77016. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  77017. \********************************************/
  77018. /*! exports provided: CylinderBuilder */
  77019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77020. "use strict";
  77021. __webpack_require__.r(__webpack_exports__);
  77022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  77023. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77024. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77025. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77026. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  77027. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  77028. var height = options.height || 2;
  77029. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  77030. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  77031. var tessellation = options.tessellation || 24;
  77032. var subdivisions = options.subdivisions || 1;
  77033. var hasRings = options.hasRings ? true : false;
  77034. var enclose = options.enclose ? true : false;
  77035. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77036. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77037. var faceUV = options.faceUV || new Array(3);
  77038. var faceColors = options.faceColors;
  77039. // default face colors and UV if undefined
  77040. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  77041. var ringNb = (hasRings) ? subdivisions : 1;
  77042. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  77043. var f;
  77044. for (f = 0; f < surfaceNb; f++) {
  77045. if (faceColors && faceColors[f] === undefined) {
  77046. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  77047. }
  77048. }
  77049. for (f = 0; f < surfaceNb; f++) {
  77050. if (faceUV && faceUV[f] === undefined) {
  77051. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  77052. }
  77053. }
  77054. var indices = new Array();
  77055. var positions = new Array();
  77056. var normals = new Array();
  77057. var uvs = new Array();
  77058. var colors = new Array();
  77059. var angle_step = Math.PI * 2 * arc / tessellation;
  77060. var angle;
  77061. var h;
  77062. var radius;
  77063. var tan = (diameterBottom - diameterTop) / 2 / height;
  77064. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77065. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77066. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77067. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77068. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77069. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  77070. // positions, normals, uvs
  77071. var i;
  77072. var j;
  77073. var r;
  77074. var ringIdx = 1;
  77075. var s = 1; // surface index
  77076. var cs = 0;
  77077. var v = 0;
  77078. for (i = 0; i <= subdivisions; i++) {
  77079. h = i / subdivisions;
  77080. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  77081. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  77082. for (r = 0; r < ringIdx; r++) {
  77083. if (hasRings) {
  77084. s += r;
  77085. }
  77086. if (enclose) {
  77087. s += 2 * r;
  77088. }
  77089. for (j = 0; j <= tessellation; j++) {
  77090. angle = j * angle_step;
  77091. // position
  77092. ringVertex.x = Math.cos(-angle) * radius;
  77093. ringVertex.y = -height / 2 + h * height;
  77094. ringVertex.z = Math.sin(-angle) * radius;
  77095. // normal
  77096. if (diameterTop === 0 && i === subdivisions) {
  77097. // if no top cap, reuse former normals
  77098. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  77099. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  77100. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  77101. }
  77102. else {
  77103. ringNormal.x = ringVertex.x;
  77104. ringNormal.z = ringVertex.z;
  77105. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  77106. ringNormal.normalize();
  77107. }
  77108. // keep first ring vertex values for enclose
  77109. if (j === 0) {
  77110. ringFirstVertex.copyFrom(ringVertex);
  77111. ringFirstNormal.copyFrom(ringNormal);
  77112. }
  77113. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  77114. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  77115. if (hasRings) {
  77116. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  77117. }
  77118. else {
  77119. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  77120. }
  77121. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  77122. if (faceColors) {
  77123. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  77124. }
  77125. }
  77126. // if enclose, add four vertices and their dedicated normals
  77127. if (arc !== 1 && enclose) {
  77128. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  77129. positions.push(0, ringVertex.y, 0);
  77130. positions.push(0, ringVertex.y, 0);
  77131. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  77132. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  77133. quadNormal.normalize();
  77134. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  77135. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  77136. quadNormal.normalize();
  77137. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  77138. if (hasRings) {
  77139. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  77140. }
  77141. else {
  77142. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  77143. }
  77144. uvs.push(faceUV[s + 1].x, v);
  77145. uvs.push(faceUV[s + 1].z, v);
  77146. if (hasRings) {
  77147. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  77148. }
  77149. else {
  77150. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  77151. }
  77152. uvs.push(faceUV[s + 2].x, v);
  77153. uvs.push(faceUV[s + 2].z, v);
  77154. if (faceColors) {
  77155. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  77156. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  77157. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  77158. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  77159. }
  77160. }
  77161. if (cs !== s) {
  77162. cs = s;
  77163. }
  77164. }
  77165. }
  77166. // indices
  77167. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  77168. var s;
  77169. i = 0;
  77170. for (s = 0; s < subdivisions; s++) {
  77171. var i0 = 0;
  77172. var i1 = 0;
  77173. var i2 = 0;
  77174. var i3 = 0;
  77175. for (j = 0; j < tessellation; j++) {
  77176. i0 = i * (e + 1) + j;
  77177. i1 = (i + 1) * (e + 1) + j;
  77178. i2 = i * (e + 1) + (j + 1);
  77179. i3 = (i + 1) * (e + 1) + (j + 1);
  77180. indices.push(i0, i1, i2);
  77181. indices.push(i3, i2, i1);
  77182. }
  77183. if (arc !== 1 && enclose) { // if enclose, add two quads
  77184. indices.push(i0 + 2, i1 + 2, i2 + 2);
  77185. indices.push(i3 + 2, i2 + 2, i1 + 2);
  77186. indices.push(i0 + 4, i1 + 4, i2 + 4);
  77187. indices.push(i3 + 4, i2 + 4, i1 + 4);
  77188. }
  77189. i = (hasRings) ? (i + 2) : (i + 1);
  77190. }
  77191. // Caps
  77192. var createCylinderCap = function (isTop) {
  77193. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  77194. if (radius === 0) {
  77195. return;
  77196. }
  77197. // Cap positions, normals & uvs
  77198. var angle;
  77199. var circleVector;
  77200. var i;
  77201. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  77202. var c = null;
  77203. if (faceColors) {
  77204. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  77205. }
  77206. // cap center
  77207. var vbase = positions.length / 3;
  77208. var offset = isTop ? height / 2 : -height / 2;
  77209. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  77210. positions.push(center.x, center.y, center.z);
  77211. normals.push(0, isTop ? 1 : -1, 0);
  77212. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  77213. if (c) {
  77214. colors.push(c.r, c.g, c.b, c.a);
  77215. }
  77216. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  77217. for (i = 0; i <= tessellation; i++) {
  77218. angle = Math.PI * 2 * i * arc / tessellation;
  77219. var cos = Math.cos(-angle);
  77220. var sin = Math.sin(-angle);
  77221. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  77222. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  77223. positions.push(circleVector.x, circleVector.y, circleVector.z);
  77224. normals.push(0, isTop ? 1 : -1, 0);
  77225. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  77226. if (c) {
  77227. colors.push(c.r, c.g, c.b, c.a);
  77228. }
  77229. }
  77230. // Cap indices
  77231. for (i = 0; i < tessellation; i++) {
  77232. if (!isTop) {
  77233. indices.push(vbase);
  77234. indices.push(vbase + (i + 1));
  77235. indices.push(vbase + (i + 2));
  77236. }
  77237. else {
  77238. indices.push(vbase);
  77239. indices.push(vbase + (i + 2));
  77240. indices.push(vbase + (i + 1));
  77241. }
  77242. }
  77243. };
  77244. // add caps to geometry
  77245. createCylinderCap(false);
  77246. createCylinderCap(true);
  77247. // Sides
  77248. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77249. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77250. vertexData.indices = indices;
  77251. vertexData.positions = positions;
  77252. vertexData.normals = normals;
  77253. vertexData.uvs = uvs;
  77254. if (faceColors) {
  77255. vertexData.colors = colors;
  77256. }
  77257. return vertexData;
  77258. };
  77259. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  77260. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  77261. if (scene !== undefined) {
  77262. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  77263. updatable = scene;
  77264. }
  77265. scene = subdivisions;
  77266. subdivisions = 1;
  77267. }
  77268. var options = {
  77269. height: height,
  77270. diameterTop: diameterTop,
  77271. diameterBottom: diameterBottom,
  77272. tessellation: tessellation,
  77273. subdivisions: subdivisions,
  77274. sideOrientation: sideOrientation,
  77275. updatable: updatable
  77276. };
  77277. return CylinderBuilder.CreateCylinder(name, options, scene);
  77278. };
  77279. /**
  77280. * Class containing static functions to help procedurally build meshes
  77281. */
  77282. var CylinderBuilder = /** @class */ (function () {
  77283. function CylinderBuilder() {
  77284. }
  77285. /**
  77286. * Creates a cylinder or a cone mesh
  77287. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  77288. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  77289. * * 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.
  77290. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  77291. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  77292. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  77293. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  77294. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  77295. * * 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).
  77296. * * 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
  77297. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  77298. * * 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
  77299. * * 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.
  77300. * * If `enclose` is false, a ring surface is one element.
  77301. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  77302. * * 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
  77303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77304. * * 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
  77305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77306. * @param name defines the name of the mesh
  77307. * @param options defines the options used to create the mesh
  77308. * @param scene defines the hosting scene
  77309. * @returns the cylinder mesh
  77310. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  77311. */
  77312. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  77313. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77314. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77315. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  77316. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  77317. vertexData.applyToMesh(cylinder, options.updatable);
  77318. return cylinder;
  77319. };
  77320. return CylinderBuilder;
  77321. }());
  77322. /***/ }),
  77323. /***/ "./Meshes/Builders/decalBuilder.ts":
  77324. /*!*****************************************!*\
  77325. !*** ./Meshes/Builders/decalBuilder.ts ***!
  77326. \*****************************************/
  77327. /*! exports provided: DecalBuilder */
  77328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77329. "use strict";
  77330. __webpack_require__.r(__webpack_exports__);
  77331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  77332. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77333. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77334. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  77335. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77336. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  77337. var options = {
  77338. position: position,
  77339. normal: normal,
  77340. size: size,
  77341. angle: angle
  77342. };
  77343. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  77344. };
  77345. /**
  77346. * Class containing static functions to help procedurally build meshes
  77347. */
  77348. var DecalBuilder = /** @class */ (function () {
  77349. function DecalBuilder() {
  77350. }
  77351. /**
  77352. * Creates a decal mesh.
  77353. * 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
  77354. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  77355. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  77356. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  77357. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  77358. * @param name defines the name of the mesh
  77359. * @param sourceMesh defines the mesh where the decal must be applied
  77360. * @param options defines the options used to create the mesh
  77361. * @param scene defines the hosting scene
  77362. * @returns the decal mesh
  77363. * @see https://doc.babylonjs.com/how_to/decals
  77364. */
  77365. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  77366. var indices = sourceMesh.getIndices();
  77367. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77368. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77369. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77370. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  77371. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  77372. var angle = options.angle || 0;
  77373. // Getting correct rotation
  77374. if (!normal) {
  77375. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  77376. var camera = sourceMesh.getScene().activeCamera;
  77377. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  77378. normal = camera.globalPosition.subtract(cameraWorldTarget);
  77379. }
  77380. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  77381. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  77382. var pitch = Math.atan2(normal.y, len);
  77383. // Matrix
  77384. 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));
  77385. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  77386. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  77387. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  77388. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  77389. vertexData.indices = [];
  77390. vertexData.positions = [];
  77391. vertexData.normals = [];
  77392. vertexData.uvs = [];
  77393. var currentVertexDataIndex = 0;
  77394. var extractDecalVector3 = function (indexId) {
  77395. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  77396. if (!indices || !positions || !normals) {
  77397. return result;
  77398. }
  77399. var vertexId = indices[indexId];
  77400. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  77401. // Send vector to decal local world
  77402. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  77403. // Get normal
  77404. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  77405. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  77406. return result;
  77407. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  77408. var clip = function (vertices, axis) {
  77409. if (vertices.length === 0) {
  77410. return vertices;
  77411. }
  77412. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  77413. var clipVertices = function (v0, v1) {
  77414. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  77415. 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));
  77416. };
  77417. var result = new Array();
  77418. for (var index = 0; index < vertices.length; index += 3) {
  77419. var v1Out;
  77420. var v2Out;
  77421. var v3Out;
  77422. var total = 0;
  77423. var nV1 = null;
  77424. var nV2 = null;
  77425. var nV3 = null;
  77426. var nV4 = null;
  77427. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  77428. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  77429. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  77430. v1Out = d1 > 0;
  77431. v2Out = d2 > 0;
  77432. v3Out = d3 > 0;
  77433. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  77434. switch (total) {
  77435. case 0:
  77436. result.push(vertices[index]);
  77437. result.push(vertices[index + 1]);
  77438. result.push(vertices[index + 2]);
  77439. break;
  77440. case 1:
  77441. if (v1Out) {
  77442. nV1 = vertices[index + 1];
  77443. nV2 = vertices[index + 2];
  77444. nV3 = clipVertices(vertices[index], nV1);
  77445. nV4 = clipVertices(vertices[index], nV2);
  77446. }
  77447. if (v2Out) {
  77448. nV1 = vertices[index];
  77449. nV2 = vertices[index + 2];
  77450. nV3 = clipVertices(vertices[index + 1], nV1);
  77451. nV4 = clipVertices(vertices[index + 1], nV2);
  77452. result.push(nV3);
  77453. result.push(nV2.clone());
  77454. result.push(nV1.clone());
  77455. result.push(nV2.clone());
  77456. result.push(nV3.clone());
  77457. result.push(nV4);
  77458. break;
  77459. }
  77460. if (v3Out) {
  77461. nV1 = vertices[index];
  77462. nV2 = vertices[index + 1];
  77463. nV3 = clipVertices(vertices[index + 2], nV1);
  77464. nV4 = clipVertices(vertices[index + 2], nV2);
  77465. }
  77466. if (nV1 && nV2 && nV3 && nV4) {
  77467. result.push(nV1.clone());
  77468. result.push(nV2.clone());
  77469. result.push(nV3);
  77470. result.push(nV4);
  77471. result.push(nV3.clone());
  77472. result.push(nV2.clone());
  77473. }
  77474. break;
  77475. case 2:
  77476. if (!v1Out) {
  77477. nV1 = vertices[index].clone();
  77478. nV2 = clipVertices(nV1, vertices[index + 1]);
  77479. nV3 = clipVertices(nV1, vertices[index + 2]);
  77480. result.push(nV1);
  77481. result.push(nV2);
  77482. result.push(nV3);
  77483. }
  77484. if (!v2Out) {
  77485. nV1 = vertices[index + 1].clone();
  77486. nV2 = clipVertices(nV1, vertices[index + 2]);
  77487. nV3 = clipVertices(nV1, vertices[index]);
  77488. result.push(nV1);
  77489. result.push(nV2);
  77490. result.push(nV3);
  77491. }
  77492. if (!v3Out) {
  77493. nV1 = vertices[index + 2].clone();
  77494. nV2 = clipVertices(nV1, vertices[index]);
  77495. nV3 = clipVertices(nV1, vertices[index + 1]);
  77496. result.push(nV1);
  77497. result.push(nV2);
  77498. result.push(nV3);
  77499. }
  77500. break;
  77501. case 3:
  77502. break;
  77503. }
  77504. }
  77505. return result;
  77506. };
  77507. for (var index = 0; index < indices.length; index += 3) {
  77508. var faceVertices = new Array();
  77509. faceVertices.push(extractDecalVector3(index));
  77510. faceVertices.push(extractDecalVector3(index + 1));
  77511. faceVertices.push(extractDecalVector3(index + 2));
  77512. // Clip
  77513. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  77514. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  77515. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  77516. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  77517. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  77518. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  77519. if (faceVertices.length === 0) {
  77520. continue;
  77521. }
  77522. // Add UVs and get back to world
  77523. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  77524. var vertex = faceVertices[vIndex];
  77525. //TODO check for Int32Array | Uint32Array | Uint16Array
  77526. vertexData.indices.push(currentVertexDataIndex);
  77527. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  77528. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  77529. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  77530. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  77531. currentVertexDataIndex++;
  77532. }
  77533. }
  77534. // Return mesh
  77535. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  77536. vertexData.applyToMesh(decal);
  77537. decal.position = position.clone();
  77538. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  77539. return decal;
  77540. };
  77541. return DecalBuilder;
  77542. }());
  77543. /***/ }),
  77544. /***/ "./Meshes/Builders/discBuilder.ts":
  77545. /*!****************************************!*\
  77546. !*** ./Meshes/Builders/discBuilder.ts ***!
  77547. \****************************************/
  77548. /*! exports provided: DiscBuilder */
  77549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77550. "use strict";
  77551. __webpack_require__.r(__webpack_exports__);
  77552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  77553. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77554. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77555. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  77556. var positions = new Array();
  77557. var indices = new Array();
  77558. var normals = new Array();
  77559. var uvs = new Array();
  77560. var radius = options.radius || 0.5;
  77561. var tessellation = options.tessellation || 64;
  77562. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77563. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  77564. // positions and uvs
  77565. positions.push(0, 0, 0); // disc center first
  77566. uvs.push(0.5, 0.5);
  77567. var theta = Math.PI * 2 * arc;
  77568. var step = theta / tessellation;
  77569. for (var a = 0; a < theta; a += step) {
  77570. var x = Math.cos(a);
  77571. var y = Math.sin(a);
  77572. var u = (x + 1) / 2;
  77573. var v = (1 - y) / 2;
  77574. positions.push(radius * x, radius * y, 0);
  77575. uvs.push(u, v);
  77576. }
  77577. if (arc === 1) {
  77578. positions.push(positions[3], positions[4], positions[5]); // close the circle
  77579. uvs.push(uvs[2], uvs[3]);
  77580. }
  77581. //indices
  77582. var vertexNb = positions.length / 3;
  77583. for (var i = 1; i < vertexNb - 1; i++) {
  77584. indices.push(i + 1, 0, i);
  77585. }
  77586. // result
  77587. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  77588. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77589. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  77590. vertexData.indices = indices;
  77591. vertexData.positions = positions;
  77592. vertexData.normals = normals;
  77593. vertexData.uvs = uvs;
  77594. return vertexData;
  77595. };
  77596. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  77597. if (scene === void 0) { scene = null; }
  77598. var options = {
  77599. radius: radius,
  77600. tessellation: tessellation,
  77601. sideOrientation: sideOrientation,
  77602. updatable: updatable
  77603. };
  77604. return DiscBuilder.CreateDisc(name, options, scene);
  77605. };
  77606. /**
  77607. * Class containing static functions to help procedurally build meshes
  77608. */
  77609. var DiscBuilder = /** @class */ (function () {
  77610. function DiscBuilder() {
  77611. }
  77612. /**
  77613. * Creates a plane polygonal mesh. By default, this is a disc
  77614. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  77615. * * 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
  77616. * * 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
  77617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77618. * * 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
  77619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77620. * @param name defines the name of the mesh
  77621. * @param options defines the options used to create the mesh
  77622. * @param scene defines the hosting scene
  77623. * @returns the plane polygonal mesh
  77624. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  77625. */
  77626. DiscBuilder.CreateDisc = function (name, options, scene) {
  77627. if (scene === void 0) { scene = null; }
  77628. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  77629. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77630. disc._originalBuilderSideOrientation = options.sideOrientation;
  77631. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  77632. vertexData.applyToMesh(disc, options.updatable);
  77633. return disc;
  77634. };
  77635. return DiscBuilder;
  77636. }());
  77637. /***/ }),
  77638. /***/ "./Meshes/Builders/groundBuilder.ts":
  77639. /*!******************************************!*\
  77640. !*** ./Meshes/Builders/groundBuilder.ts ***!
  77641. \******************************************/
  77642. /*! exports provided: GroundBuilder */
  77643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77644. "use strict";
  77645. __webpack_require__.r(__webpack_exports__);
  77646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  77647. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77648. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77649. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77650. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  77651. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  77652. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  77653. var indices = [];
  77654. var positions = [];
  77655. var normals = [];
  77656. var uvs = [];
  77657. var row, col;
  77658. var width = options.width || 1;
  77659. var height = options.height || 1;
  77660. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  77661. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  77662. for (row = 0; row <= subdivisionsY; row++) {
  77663. for (col = 0; col <= subdivisionsX; col++) {
  77664. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  77665. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  77666. positions.push(position.x, position.y, position.z);
  77667. normals.push(normal.x, normal.y, normal.z);
  77668. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  77669. }
  77670. }
  77671. for (row = 0; row < subdivisionsY; row++) {
  77672. for (col = 0; col < subdivisionsX; col++) {
  77673. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  77674. indices.push(col + 1 + row * (subdivisionsX + 1));
  77675. indices.push(col + row * (subdivisionsX + 1));
  77676. indices.push(col + (row + 1) * (subdivisionsX + 1));
  77677. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  77678. indices.push(col + row * (subdivisionsX + 1));
  77679. }
  77680. }
  77681. // Result
  77682. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77683. vertexData.indices = indices;
  77684. vertexData.positions = positions;
  77685. vertexData.normals = normals;
  77686. vertexData.uvs = uvs;
  77687. return vertexData;
  77688. };
  77689. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  77690. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  77691. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  77692. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  77693. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  77694. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  77695. var precision = options.precision || { w: 1, h: 1 };
  77696. var indices = new Array();
  77697. var positions = new Array();
  77698. var normals = new Array();
  77699. var uvs = new Array();
  77700. var row, col, tileRow, tileCol;
  77701. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  77702. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  77703. precision.w = (precision.w < 1) ? 1 : precision.w;
  77704. precision.h = (precision.h < 1) ? 1 : precision.h;
  77705. var tileSize = {
  77706. 'w': (xmax - xmin) / subdivisions.w,
  77707. 'h': (zmax - zmin) / subdivisions.h
  77708. };
  77709. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  77710. // Indices
  77711. var base = positions.length / 3;
  77712. var rowLength = precision.w + 1;
  77713. for (row = 0; row < precision.h; row++) {
  77714. for (col = 0; col < precision.w; col++) {
  77715. var square = [
  77716. base + col + row * rowLength,
  77717. base + (col + 1) + row * rowLength,
  77718. base + (col + 1) + (row + 1) * rowLength,
  77719. base + col + (row + 1) * rowLength
  77720. ];
  77721. indices.push(square[1]);
  77722. indices.push(square[2]);
  77723. indices.push(square[3]);
  77724. indices.push(square[0]);
  77725. indices.push(square[1]);
  77726. indices.push(square[3]);
  77727. }
  77728. }
  77729. // Position, normals and uvs
  77730. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77731. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  77732. for (row = 0; row <= precision.h; row++) {
  77733. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  77734. for (col = 0; col <= precision.w; col++) {
  77735. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  77736. position.y = 0;
  77737. positions.push(position.x, position.y, position.z);
  77738. normals.push(normal.x, normal.y, normal.z);
  77739. uvs.push(col / precision.w, row / precision.h);
  77740. }
  77741. }
  77742. }
  77743. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  77744. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  77745. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  77746. }
  77747. }
  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_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  77757. var indices = [];
  77758. var positions = [];
  77759. var normals = [];
  77760. var uvs = [];
  77761. var row, col;
  77762. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  77763. var alphaFilter = options.alphaFilter || 0.0;
  77764. // Vertices
  77765. for (row = 0; row <= options.subdivisions; row++) {
  77766. for (col = 0; col <= options.subdivisions; col++) {
  77767. 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));
  77768. // Compute height
  77769. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  77770. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  77771. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  77772. var r = options.buffer[pos] / 255.0;
  77773. var g = options.buffer[pos + 1] / 255.0;
  77774. var b = options.buffer[pos + 2] / 255.0;
  77775. var a = options.buffer[pos + 3] / 255.0;
  77776. var gradient = r * filter.r + g * filter.g + b * filter.b;
  77777. // If our alpha channel is not within our filter then we will assign a 'special' height
  77778. // Then when building the indices, we will ignore any vertex that is using the special height
  77779. if (a >= alphaFilter) {
  77780. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  77781. }
  77782. else {
  77783. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  77784. }
  77785. // Add vertex
  77786. positions.push(position.x, position.y, position.z);
  77787. normals.push(0, 0, 0);
  77788. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  77789. }
  77790. }
  77791. // Indices
  77792. for (row = 0; row < options.subdivisions; row++) {
  77793. for (col = 0; col < options.subdivisions; col++) {
  77794. // Calculate Indices
  77795. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  77796. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  77797. var idx3 = (col + row * (options.subdivisions + 1));
  77798. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  77799. // Check that all indices are visible (based on our special height)
  77800. // Only display the vertex if all Indices are visible
  77801. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  77802. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  77803. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  77804. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  77805. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  77806. indices.push(idx1);
  77807. indices.push(idx2);
  77808. indices.push(idx3);
  77809. }
  77810. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  77811. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  77812. indices.push(idx4);
  77813. indices.push(idx1);
  77814. indices.push(idx3);
  77815. }
  77816. }
  77817. }
  77818. // Normals
  77819. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77820. // Result
  77821. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77822. vertexData.indices = indices;
  77823. vertexData.positions = positions;
  77824. vertexData.normals = normals;
  77825. vertexData.uvs = uvs;
  77826. return vertexData;
  77827. };
  77828. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  77829. var options = {
  77830. width: width,
  77831. height: height,
  77832. subdivisions: subdivisions,
  77833. updatable: updatable
  77834. };
  77835. return GroundBuilder.CreateGround(name, options, scene);
  77836. };
  77837. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  77838. var options = {
  77839. xmin: xmin,
  77840. zmin: zmin,
  77841. xmax: xmax,
  77842. zmax: zmax,
  77843. subdivisions: subdivisions,
  77844. precision: precision,
  77845. updatable: updatable
  77846. };
  77847. return GroundBuilder.CreateTiledGround(name, options, scene);
  77848. };
  77849. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  77850. var options = {
  77851. width: width,
  77852. height: height,
  77853. subdivisions: subdivisions,
  77854. minHeight: minHeight,
  77855. maxHeight: maxHeight,
  77856. updatable: updatable,
  77857. onReady: onReady,
  77858. alphaFilter: alphaFilter
  77859. };
  77860. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  77861. };
  77862. /**
  77863. * Class containing static functions to help procedurally build meshes
  77864. */
  77865. var GroundBuilder = /** @class */ (function () {
  77866. function GroundBuilder() {
  77867. }
  77868. /**
  77869. * Creates a ground mesh
  77870. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  77871. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  77872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77873. * @param name defines the name of the mesh
  77874. * @param options defines the options used to create the mesh
  77875. * @param scene defines the hosting scene
  77876. * @returns the ground mesh
  77877. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  77878. */
  77879. GroundBuilder.CreateGround = function (name, options, scene) {
  77880. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  77881. ground._setReady(false);
  77882. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  77883. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  77884. ground._width = options.width || 1;
  77885. ground._height = options.height || 1;
  77886. ground._maxX = ground._width / 2;
  77887. ground._maxZ = ground._height / 2;
  77888. ground._minX = -ground._maxX;
  77889. ground._minZ = -ground._maxZ;
  77890. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  77891. vertexData.applyToMesh(ground, options.updatable);
  77892. ground._setReady(true);
  77893. return ground;
  77894. };
  77895. /**
  77896. * Creates a tiled ground mesh
  77897. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  77898. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  77899. * * 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
  77900. * * 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
  77901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77902. * @param name defines the name of the mesh
  77903. * @param options defines the options used to create the mesh
  77904. * @param scene defines the hosting scene
  77905. * @returns the tiled ground mesh
  77906. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  77907. */
  77908. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  77909. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77910. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  77911. vertexData.applyToMesh(tiledGround, options.updatable);
  77912. return tiledGround;
  77913. };
  77914. /**
  77915. * Creates a ground mesh from a height map
  77916. * * The parameter `url` sets the URL of the height map image resource.
  77917. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  77918. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  77919. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  77920. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  77921. * * 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.
  77922. * * 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).
  77923. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77925. * @param name defines the name of the mesh
  77926. * @param url defines the url to the height map
  77927. * @param options defines the options used to create the mesh
  77928. * @param scene defines the hosting scene
  77929. * @returns the ground mesh
  77930. * @see https://doc.babylonjs.com/babylon101/height_map
  77931. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  77932. */
  77933. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  77934. var width = options.width || 10.0;
  77935. var height = options.height || 10.0;
  77936. var subdivisions = options.subdivisions || 1 | 0;
  77937. var minHeight = options.minHeight || 0.0;
  77938. var maxHeight = options.maxHeight || 1.0;
  77939. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  77940. var alphaFilter = options.alphaFilter || 0.0;
  77941. var updatable = options.updatable;
  77942. var onReady = options.onReady;
  77943. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  77944. ground._subdivisionsX = subdivisions;
  77945. ground._subdivisionsY = subdivisions;
  77946. ground._width = width;
  77947. ground._height = height;
  77948. ground._maxX = ground._width / 2.0;
  77949. ground._maxZ = ground._height / 2.0;
  77950. ground._minX = -ground._maxX;
  77951. ground._minZ = -ground._maxZ;
  77952. ground._setReady(false);
  77953. var onload = function (img) {
  77954. // Getting height map data
  77955. var canvas = document.createElement("canvas");
  77956. var context = canvas.getContext("2d");
  77957. if (!context) {
  77958. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  77959. }
  77960. if (scene.isDisposed) {
  77961. return;
  77962. }
  77963. var bufferWidth = img.width;
  77964. var bufferHeight = img.height;
  77965. canvas.width = bufferWidth;
  77966. canvas.height = bufferHeight;
  77967. context.drawImage(img, 0, 0);
  77968. // Create VertexData from map data
  77969. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  77970. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  77971. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  77972. width: width, height: height,
  77973. subdivisions: subdivisions,
  77974. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  77975. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  77976. alphaFilter: alphaFilter
  77977. });
  77978. vertexData.applyToMesh(ground, updatable);
  77979. //execute ready callback, if set
  77980. if (onReady) {
  77981. onReady(ground);
  77982. }
  77983. ground._setReady(true);
  77984. };
  77985. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  77986. return ground;
  77987. };
  77988. return GroundBuilder;
  77989. }());
  77990. /***/ }),
  77991. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  77992. /*!*********************************************!*\
  77993. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  77994. \*********************************************/
  77995. /*! exports provided: IcoSphereBuilder */
  77996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77997. "use strict";
  77998. __webpack_require__.r(__webpack_exports__);
  77999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  78000. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78001. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78002. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78003. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  78004. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78005. var radius = options.radius || 1;
  78006. var flat = (options.flat === undefined) ? true : options.flat;
  78007. var subdivisions = options.subdivisions || 4;
  78008. var radiusX = options.radiusX || radius;
  78009. var radiusY = options.radiusY || radius;
  78010. var radiusZ = options.radiusZ || radius;
  78011. var t = (1 + Math.sqrt(5)) / 2;
  78012. // 12 vertex x,y,z
  78013. var ico_vertices = [
  78014. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  78015. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  78016. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  78017. ];
  78018. // index of 3 vertex makes a face of icopshere
  78019. var ico_indices = [
  78020. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  78021. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  78022. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  78023. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  78024. ];
  78025. // vertex for uv have aliased position, not for UV
  78026. var vertices_unalias_id = [
  78027. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  78028. // vertex alias
  78029. 0,
  78030. 2,
  78031. 3,
  78032. 3,
  78033. 3,
  78034. 4,
  78035. 7,
  78036. 8,
  78037. 9,
  78038. 9,
  78039. 10,
  78040. 11 // 23: B + 12
  78041. ];
  78042. // uv as integer step (not pixels !)
  78043. var ico_vertexuv = [
  78044. 5, 1, 3, 1, 6, 4, 0, 0,
  78045. 5, 3, 4, 2, 2, 2, 4, 0,
  78046. 2, 0, 1, 1, 6, 0, 6, 2,
  78047. // vertex alias (for same vertex on different faces)
  78048. 0, 4,
  78049. 3, 3,
  78050. 4, 4,
  78051. 3, 1,
  78052. 4, 2,
  78053. 4, 4,
  78054. 0, 2,
  78055. 1, 1,
  78056. 2, 2,
  78057. 3, 3,
  78058. 1, 3,
  78059. 2, 4 // 23: B + 12
  78060. ];
  78061. // Vertices[0, 1, ...9, A, B] : position on UV plane
  78062. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  78063. // First island of uv mapping
  78064. // v = 4h 3+ 2
  78065. // v = 3h 9+ 4
  78066. // v = 2h 9+ 5 B
  78067. // v = 1h 9 1 0
  78068. // v = 0h 3 8 7 A
  78069. // u = 0 1 2 3 4 5 6 *a
  78070. // Second island of uv mapping
  78071. // v = 4h 0+ B+ 4+
  78072. // v = 3h A+ 2+
  78073. // v = 2h 7+ 6 3+
  78074. // v = 1h 8+ 3+
  78075. // v = 0h
  78076. // u = 0 1 2 3 4 5 6 *a
  78077. // Face layout on texture UV mapping
  78078. // ============
  78079. // \ 4 /\ 16 / ======
  78080. // \ / \ / /\ 11 /
  78081. // \/ 7 \/ / \ /
  78082. // ======= / 10 \/
  78083. // /\ 17 /\ =======
  78084. // / \ / \ \ 15 /\
  78085. // / 8 \/ 12 \ \ / \
  78086. // ============ \/ 6 \
  78087. // \ 18 /\ ============
  78088. // \ / \ \ 5 /\ 0 /
  78089. // \/ 13 \ \ / \ /
  78090. // ======= \/ 1 \/
  78091. // =============
  78092. // /\ 19 /\ 2 /\
  78093. // / \ / \ / \
  78094. // / 14 \/ 9 \/ 3 \
  78095. // ===================
  78096. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  78097. var ustep = 138 / 1024;
  78098. var vstep = 239 / 1024;
  78099. var uoffset = 60 / 1024;
  78100. var voffset = 26 / 1024;
  78101. // Second island should have margin, not to touch the first island
  78102. // avoid any borderline artefact in pixel rounding
  78103. var island_u_offset = -40 / 1024;
  78104. var island_v_offset = +20 / 1024;
  78105. // face is either island 0 or 1 :
  78106. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  78107. var island = [
  78108. 0, 0, 0, 0, 1,
  78109. 0, 0, 1, 1, 0,
  78110. 0, 0, 1, 1, 0,
  78111. 0, 1, 1, 1, 0 // 15 - 19
  78112. ];
  78113. var indices = new Array();
  78114. var positions = new Array();
  78115. var normals = new Array();
  78116. var uvs = new Array();
  78117. var current_indice = 0;
  78118. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  78119. var face_vertex_pos = new Array(3);
  78120. var face_vertex_uv = new Array(3);
  78121. var v012;
  78122. for (v012 = 0; v012 < 3; v012++) {
  78123. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78124. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  78125. }
  78126. // create all with normals
  78127. for (var face = 0; face < 20; face++) {
  78128. // 3 vertex per face
  78129. for (v012 = 0; v012 < 3; v012++) {
  78130. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  78131. var v_id = ico_indices[3 * face + v012];
  78132. // vertex have 3D position (x,y,z)
  78133. 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]);
  78134. // Normalize to get normal, then scale to radius
  78135. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  78136. // uv Coordinates from vertex ID
  78137. 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);
  78138. }
  78139. // Subdivide the face (interpolate pos, norm, uv)
  78140. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  78141. // - norm is linear interpolation of vertex corner normal
  78142. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  78143. // - uv is linear interpolation
  78144. //
  78145. // Topology is as below for sub-divide by 2
  78146. // vertex shown as v0,v1,v2
  78147. // interp index is i1 to progress in range [v0,v1[
  78148. // interp index is i2 to progress in range [v0,v2[
  78149. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  78150. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  78151. //
  78152. //
  78153. // i2 v2
  78154. // ^ ^
  78155. // / / \
  78156. // / / \
  78157. // / / \
  78158. // / / (0,1) \
  78159. // / #---------\
  78160. // / / \ (0,0)'/ \
  78161. // / / \ / \
  78162. // / / \ / \
  78163. // / / (0,0) \ / (1,0) \
  78164. // / #---------#---------\
  78165. // v0 v1
  78166. //
  78167. // --------------------> i1
  78168. //
  78169. // interp of (i1,i2):
  78170. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  78171. // along i1 : lerp(x0,x1, i1/(S-i2))
  78172. //
  78173. // centroid of triangle is needed to get help normal computation
  78174. // (c1,c2) are used for centroid location
  78175. var interp_vertex = function (i1, i2, c1, c2) {
  78176. // vertex is interpolated from
  78177. // - face_vertex_pos[0..2]
  78178. // - face_vertex_uv[0..2]
  78179. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  78180. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  78181. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  78182. pos_interp.normalize();
  78183. var vertex_normal;
  78184. if (flat) {
  78185. // in flat mode, recalculate normal as face centroid normal
  78186. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  78187. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  78188. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  78189. }
  78190. else {
  78191. // in smooth mode, recalculate normal from each single vertex position
  78192. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  78193. }
  78194. // Vertex normal need correction due to X,Y,Z radius scaling
  78195. vertex_normal.x /= radiusX;
  78196. vertex_normal.y /= radiusY;
  78197. vertex_normal.z /= radiusZ;
  78198. vertex_normal.normalize();
  78199. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  78200. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  78201. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  78202. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  78203. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  78204. uvs.push(uv_interp.x, uv_interp.y);
  78205. // push each vertex has member of a face
  78206. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  78207. indices.push(current_indice);
  78208. current_indice++;
  78209. };
  78210. for (var i2 = 0; i2 < subdivisions; i2++) {
  78211. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  78212. // face : (i1,i2) for /\ :
  78213. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  78214. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78215. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78216. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78217. if (i1 + i2 + 1 < subdivisions) {
  78218. // face : (i1,i2)' for \/ :
  78219. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  78220. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78221. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78222. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78223. }
  78224. }
  78225. }
  78226. }
  78227. // Sides
  78228. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78229. // Result
  78230. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78231. vertexData.indices = indices;
  78232. vertexData.positions = positions;
  78233. vertexData.normals = normals;
  78234. vertexData.uvs = uvs;
  78235. return vertexData;
  78236. };
  78237. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  78238. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  78239. };
  78240. /**
  78241. * Class containing static functions to help procedurally build meshes
  78242. */
  78243. var IcoSphereBuilder = /** @class */ (function () {
  78244. function IcoSphereBuilder() {
  78245. }
  78246. /**
  78247. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78248. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78249. * * 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`)
  78250. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78251. * * 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
  78252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78253. * * 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
  78254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78255. * @param name defines the name of the mesh
  78256. * @param options defines the options used to create the mesh
  78257. * @param scene defines the hosting scene
  78258. * @returns the icosahedron mesh
  78259. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78260. */
  78261. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  78262. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78263. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78264. sphere._originalBuilderSideOrientation = options.sideOrientation;
  78265. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  78266. vertexData.applyToMesh(sphere, options.updatable);
  78267. return sphere;
  78268. };
  78269. return IcoSphereBuilder;
  78270. }());
  78271. /***/ }),
  78272. /***/ "./Meshes/Builders/index.ts":
  78273. /*!**********************************!*\
  78274. !*** ./Meshes/Builders/index.ts ***!
  78275. \**********************************/
  78276. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, DiscBuilder, RibbonBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  78277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78278. "use strict";
  78279. __webpack_require__.r(__webpack_exports__);
  78280. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  78281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  78282. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  78283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  78284. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  78285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  78286. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  78287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  78288. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  78289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  78290. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  78291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  78292. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  78293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  78294. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  78295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  78296. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  78297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  78298. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  78299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  78300. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  78301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  78302. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  78303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  78304. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  78305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  78306. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  78307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  78308. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  78309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  78310. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  78311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  78312. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  78313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  78314. /***/ }),
  78315. /***/ "./Meshes/Builders/latheBuilder.ts":
  78316. /*!*****************************************!*\
  78317. !*** ./Meshes/Builders/latheBuilder.ts ***!
  78318. \*****************************************/
  78319. /*! exports provided: LatheBuilder */
  78320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78321. "use strict";
  78322. __webpack_require__.r(__webpack_exports__);
  78323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  78324. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78325. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78326. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  78327. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  78328. var options = {
  78329. shape: shape,
  78330. radius: radius,
  78331. tessellation: tessellation,
  78332. sideOrientation: sideOrientation,
  78333. updatable: updatable
  78334. };
  78335. return LatheBuilder.CreateLathe(name, options, scene);
  78336. };
  78337. /**
  78338. * Class containing static functions to help procedurally build meshes
  78339. */
  78340. var LatheBuilder = /** @class */ (function () {
  78341. function LatheBuilder() {
  78342. }
  78343. /**
  78344. * Creates lathe mesh.
  78345. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  78346. * * 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
  78347. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  78348. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  78349. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  78350. * * 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
  78351. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  78352. * * 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
  78353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78354. * * 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
  78355. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  78356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78357. * @param name defines the name of the mesh
  78358. * @param options defines the options used to create the mesh
  78359. * @param scene defines the hosting scene
  78360. * @returns the lathe mesh
  78361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  78362. */
  78363. LatheBuilder.CreateLathe = function (name, options, scene) {
  78364. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  78365. var closed = (options.closed === undefined) ? true : options.closed;
  78366. var shape = options.shape;
  78367. var radius = options.radius || 1;
  78368. var tessellation = options.tessellation || 64;
  78369. var clip = options.clip || 0;
  78370. var updatable = options.updatable;
  78371. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78372. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  78373. var pi2 = Math.PI * 2;
  78374. var paths = new Array();
  78375. var invertUV = options.invertUV || false;
  78376. var i = 0;
  78377. var p = 0;
  78378. var step = pi2 / tessellation * arc;
  78379. var rotated;
  78380. var path = new Array();
  78381. for (i = 0; i <= tessellation - clip; i++) {
  78382. var path = [];
  78383. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  78384. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  78385. 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));
  78386. }
  78387. for (p = 0; p < shape.length; p++) {
  78388. 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);
  78389. path.push(rotated);
  78390. }
  78391. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  78392. 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));
  78393. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  78394. }
  78395. paths.push(path);
  78396. }
  78397. // lathe ribbon
  78398. 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);
  78399. return lathe;
  78400. };
  78401. return LatheBuilder;
  78402. }());
  78403. /***/ }),
  78404. /***/ "./Meshes/Builders/linesBuilder.ts":
  78405. /*!*****************************************!*\
  78406. !*** ./Meshes/Builders/linesBuilder.ts ***!
  78407. \*****************************************/
  78408. /*! exports provided: LinesBuilder */
  78409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78410. "use strict";
  78411. __webpack_require__.r(__webpack_exports__);
  78412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  78413. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78414. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78415. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78416. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  78417. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  78418. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  78419. var indices = [];
  78420. var positions = [];
  78421. var lines = options.lines;
  78422. var colors = options.colors;
  78423. var vertexColors = [];
  78424. var idx = 0;
  78425. for (var l = 0; l < lines.length; l++) {
  78426. var points = lines[l];
  78427. for (var index = 0; index < points.length; index++) {
  78428. positions.push(points[index].x, points[index].y, points[index].z);
  78429. if (colors) {
  78430. var color = colors[l];
  78431. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  78432. }
  78433. if (index > 0) {
  78434. indices.push(idx - 1);
  78435. indices.push(idx);
  78436. }
  78437. idx++;
  78438. }
  78439. }
  78440. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78441. vertexData.indices = indices;
  78442. vertexData.positions = positions;
  78443. if (colors) {
  78444. vertexData.colors = vertexColors;
  78445. }
  78446. return vertexData;
  78447. };
  78448. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  78449. var dashSize = options.dashSize || 3;
  78450. var gapSize = options.gapSize || 1;
  78451. var dashNb = options.dashNb || 200;
  78452. var points = options.points;
  78453. var positions = new Array();
  78454. var indices = new Array();
  78455. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78456. var lg = 0;
  78457. var nb = 0;
  78458. var shft = 0;
  78459. var dashshft = 0;
  78460. var curshft = 0;
  78461. var idx = 0;
  78462. var i = 0;
  78463. for (i = 0; i < points.length - 1; i++) {
  78464. points[i + 1].subtractToRef(points[i], curvect);
  78465. lg += curvect.length();
  78466. }
  78467. shft = lg / dashNb;
  78468. dashshft = dashSize * shft / (dashSize + gapSize);
  78469. for (i = 0; i < points.length - 1; i++) {
  78470. points[i + 1].subtractToRef(points[i], curvect);
  78471. nb = Math.floor(curvect.length() / shft);
  78472. curvect.normalize();
  78473. for (var j = 0; j < nb; j++) {
  78474. curshft = shft * j;
  78475. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  78476. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  78477. indices.push(idx, idx + 1);
  78478. idx += 2;
  78479. }
  78480. }
  78481. // Result
  78482. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78483. vertexData.positions = positions;
  78484. vertexData.indices = indices;
  78485. return vertexData;
  78486. };
  78487. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  78488. if (scene === void 0) { scene = null; }
  78489. if (updatable === void 0) { updatable = false; }
  78490. if (instance === void 0) { instance = null; }
  78491. var options = {
  78492. points: points,
  78493. updatable: updatable,
  78494. instance: instance
  78495. };
  78496. return LinesBuilder.CreateLines(name, options, scene);
  78497. };
  78498. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  78499. if (scene === void 0) { scene = null; }
  78500. var options = {
  78501. points: points,
  78502. dashSize: dashSize,
  78503. gapSize: gapSize,
  78504. dashNb: dashNb,
  78505. updatable: updatable,
  78506. instance: instance
  78507. };
  78508. return LinesBuilder.CreateDashedLines(name, options, scene);
  78509. };
  78510. /**
  78511. * Class containing static functions to help procedurally build meshes
  78512. */
  78513. var LinesBuilder = /** @class */ (function () {
  78514. function LinesBuilder() {
  78515. }
  78516. /**
  78517. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  78518. * * 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
  78519. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  78520. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  78521. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  78522. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  78523. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  78524. * * 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
  78525. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  78526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  78528. * @param name defines the name of the new line system
  78529. * @param options defines the options used to create the line system
  78530. * @param scene defines the hosting scene
  78531. * @returns a new line system mesh
  78532. */
  78533. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  78534. var instance = options.instance;
  78535. var lines = options.lines;
  78536. var colors = options.colors;
  78537. if (instance) { // lines update
  78538. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  78539. var vertexColor;
  78540. var lineColors;
  78541. if (colors) {
  78542. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  78543. }
  78544. var i = 0;
  78545. var c = 0;
  78546. for (var l = 0; l < lines.length; l++) {
  78547. var points = lines[l];
  78548. for (var p = 0; p < points.length; p++) {
  78549. positions[i] = points[p].x;
  78550. positions[i + 1] = points[p].y;
  78551. positions[i + 2] = points[p].z;
  78552. if (colors && vertexColor) {
  78553. lineColors = colors[l];
  78554. vertexColor[c] = lineColors[p].r;
  78555. vertexColor[c + 1] = lineColors[p].g;
  78556. vertexColor[c + 2] = lineColors[p].b;
  78557. vertexColor[c + 3] = lineColors[p].a;
  78558. c += 4;
  78559. }
  78560. i += 3;
  78561. }
  78562. }
  78563. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  78564. if (colors && vertexColor) {
  78565. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  78566. }
  78567. return instance;
  78568. }
  78569. // line system creation
  78570. var useVertexColor = (colors) ? true : false;
  78571. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  78572. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  78573. vertexData.applyToMesh(lineSystem, options.updatable);
  78574. return lineSystem;
  78575. };
  78576. /**
  78577. * Creates a line mesh
  78578. * 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
  78579. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  78580. * * The parameter `points` is an array successive Vector3
  78581. * * 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
  78582. * * The optional parameter `colors` is an array of successive Color4, one per line point
  78583. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  78584. * * When updating an instance, remember that only point positions can change, not the number of points
  78585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  78587. * @param name defines the name of the new line system
  78588. * @param options defines the options used to create the line system
  78589. * @param scene defines the hosting scene
  78590. * @returns a new line mesh
  78591. */
  78592. LinesBuilder.CreateLines = function (name, options, scene) {
  78593. if (scene === void 0) { scene = null; }
  78594. var colors = (options.colors) ? [options.colors] : null;
  78595. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  78596. return lines;
  78597. };
  78598. /**
  78599. * Creates a dashed line mesh
  78600. * * 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
  78601. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  78602. * * The parameter `points` is an array successive Vector3
  78603. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  78604. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  78605. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78606. * * 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
  78607. * * When updating an instance, remember that only point positions can change, not the number of points
  78608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78609. * @param name defines the name of the mesh
  78610. * @param options defines the options used to create the mesh
  78611. * @param scene defines the hosting scene
  78612. * @returns the dashed line mesh
  78613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  78614. */
  78615. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  78616. if (scene === void 0) { scene = null; }
  78617. var points = options.points;
  78618. var instance = options.instance;
  78619. var gapSize = options.gapSize || 1;
  78620. var dashSize = options.dashSize || 3;
  78621. if (instance) { // dashed lines update
  78622. var positionFunction = function (positions) {
  78623. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78624. var nbSeg = positions.length / 6;
  78625. var lg = 0;
  78626. var nb = 0;
  78627. var shft = 0;
  78628. var dashshft = 0;
  78629. var curshft = 0;
  78630. var p = 0;
  78631. var i = 0;
  78632. var j = 0;
  78633. for (i = 0; i < points.length - 1; i++) {
  78634. points[i + 1].subtractToRef(points[i], curvect);
  78635. lg += curvect.length();
  78636. }
  78637. shft = lg / nbSeg;
  78638. var dashSize = instance._creationDataStorage.dashSize;
  78639. var gapSize = instance._creationDataStorage.gapSize;
  78640. dashshft = dashSize * shft / (dashSize + gapSize);
  78641. for (i = 0; i < points.length - 1; i++) {
  78642. points[i + 1].subtractToRef(points[i], curvect);
  78643. nb = Math.floor(curvect.length() / shft);
  78644. curvect.normalize();
  78645. j = 0;
  78646. while (j < nb && p < positions.length) {
  78647. curshft = shft * j;
  78648. positions[p] = points[i].x + curshft * curvect.x;
  78649. positions[p + 1] = points[i].y + curshft * curvect.y;
  78650. positions[p + 2] = points[i].z + curshft * curvect.z;
  78651. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  78652. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  78653. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  78654. p += 6;
  78655. j++;
  78656. }
  78657. }
  78658. while (p < positions.length) {
  78659. positions[p] = points[i].x;
  78660. positions[p + 1] = points[i].y;
  78661. positions[p + 2] = points[i].z;
  78662. p += 3;
  78663. }
  78664. };
  78665. instance.updateMeshPositions(positionFunction, false);
  78666. return instance;
  78667. }
  78668. // dashed lines creation
  78669. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  78670. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  78671. vertexData.applyToMesh(dashedLines, options.updatable);
  78672. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  78673. dashedLines._creationDataStorage.dashSize = dashSize;
  78674. dashedLines._creationDataStorage.gapSize = gapSize;
  78675. return dashedLines;
  78676. };
  78677. return LinesBuilder;
  78678. }());
  78679. /***/ }),
  78680. /***/ "./Meshes/Builders/planeBuilder.ts":
  78681. /*!*****************************************!*\
  78682. !*** ./Meshes/Builders/planeBuilder.ts ***!
  78683. \*****************************************/
  78684. /*! exports provided: PlaneBuilder */
  78685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78686. "use strict";
  78687. __webpack_require__.r(__webpack_exports__);
  78688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  78689. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78690. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78691. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  78692. var indices = [];
  78693. var positions = [];
  78694. var normals = [];
  78695. var uvs = [];
  78696. var width = options.width || options.size || 1;
  78697. var height = options.height || options.size || 1;
  78698. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  78699. // Vertices
  78700. var halfWidth = width / 2.0;
  78701. var halfHeight = height / 2.0;
  78702. positions.push(-halfWidth, -halfHeight, 0);
  78703. normals.push(0, 0, -1.0);
  78704. uvs.push(0.0, 0.0);
  78705. positions.push(halfWidth, -halfHeight, 0);
  78706. normals.push(0, 0, -1.0);
  78707. uvs.push(1.0, 0.0);
  78708. positions.push(halfWidth, halfHeight, 0);
  78709. normals.push(0, 0, -1.0);
  78710. uvs.push(1.0, 1.0);
  78711. positions.push(-halfWidth, halfHeight, 0);
  78712. normals.push(0, 0, -1.0);
  78713. uvs.push(0.0, 1.0);
  78714. // Indices
  78715. indices.push(0);
  78716. indices.push(1);
  78717. indices.push(2);
  78718. indices.push(0);
  78719. indices.push(2);
  78720. indices.push(3);
  78721. // Sides
  78722. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78723. // Result
  78724. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78725. vertexData.indices = indices;
  78726. vertexData.positions = positions;
  78727. vertexData.normals = normals;
  78728. vertexData.uvs = uvs;
  78729. return vertexData;
  78730. };
  78731. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  78732. var options = {
  78733. size: size,
  78734. width: size,
  78735. height: size,
  78736. sideOrientation: sideOrientation,
  78737. updatable: updatable
  78738. };
  78739. return PlaneBuilder.CreatePlane(name, options, scene);
  78740. };
  78741. /**
  78742. * Class containing static functions to help procedurally build meshes
  78743. */
  78744. var PlaneBuilder = /** @class */ (function () {
  78745. function PlaneBuilder() {
  78746. }
  78747. /**
  78748. * Creates a plane mesh
  78749. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  78750. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  78751. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  78752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78753. * * 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
  78754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78755. * @param name defines the name of the mesh
  78756. * @param options defines the options used to create the mesh
  78757. * @param scene defines the hosting scene
  78758. * @returns the plane mesh
  78759. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  78760. */
  78761. PlaneBuilder.CreatePlane = function (name, options, scene) {
  78762. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  78763. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78764. plane._originalBuilderSideOrientation = options.sideOrientation;
  78765. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  78766. vertexData.applyToMesh(plane, options.updatable);
  78767. if (options.sourcePlane) {
  78768. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  78769. plane.setDirection(options.sourcePlane.normal.scale(-1));
  78770. }
  78771. return plane;
  78772. };
  78773. return PlaneBuilder;
  78774. }());
  78775. /***/ }),
  78776. /***/ "./Meshes/Builders/polygonBuilder.ts":
  78777. /*!*******************************************!*\
  78778. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  78779. \*******************************************/
  78780. /*! exports provided: PolygonBuilder */
  78781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78782. "use strict";
  78783. __webpack_require__.r(__webpack_exports__);
  78784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  78785. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78786. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78787. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78788. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  78789. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  78790. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  78791. var faceUV = fUV || new Array(3);
  78792. var faceColors = fColors;
  78793. var colors = [];
  78794. // default face colors and UV if undefined
  78795. for (var f = 0; f < 3; f++) {
  78796. if (faceUV[f] === undefined) {
  78797. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78798. }
  78799. if (faceColors && faceColors[f] === undefined) {
  78800. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78801. }
  78802. }
  78803. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  78804. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  78805. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  78806. var indices = polygon.getIndices();
  78807. // set face colours and textures
  78808. var idx = 0;
  78809. var face = 0;
  78810. for (var index = 0; index < normals.length; index += 3) {
  78811. //Edge Face no. 1
  78812. if (Math.abs(normals[index + 1]) < 0.001) {
  78813. face = 1;
  78814. }
  78815. //Top Face no. 0
  78816. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  78817. face = 0;
  78818. }
  78819. //Bottom Face no. 2
  78820. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  78821. face = 2;
  78822. }
  78823. idx = index / 3;
  78824. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  78825. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  78826. if (faceColors) {
  78827. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  78828. }
  78829. }
  78830. // sides
  78831. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  78832. // Result
  78833. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78834. vertexData.indices = indices;
  78835. vertexData.positions = positions;
  78836. vertexData.normals = normals;
  78837. vertexData.uvs = uvs;
  78838. if (faceColors) {
  78839. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  78840. vertexData.colors = totalColors;
  78841. }
  78842. return vertexData;
  78843. };
  78844. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  78845. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78846. var options = {
  78847. shape: shape,
  78848. holes: holes,
  78849. updatable: updatable,
  78850. sideOrientation: sideOrientation
  78851. };
  78852. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  78853. };
  78854. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  78855. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78856. var options = {
  78857. shape: shape,
  78858. holes: holes,
  78859. depth: depth,
  78860. updatable: updatable,
  78861. sideOrientation: sideOrientation
  78862. };
  78863. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  78864. };
  78865. /**
  78866. * Class containing static functions to help procedurally build meshes
  78867. */
  78868. var PolygonBuilder = /** @class */ (function () {
  78869. function PolygonBuilder() {
  78870. }
  78871. /**
  78872. * Creates a polygon mesh
  78873. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  78874. * * 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
  78875. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78877. * * 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)
  78878. * * Remember you can only change the shape positions, not their number when updating a polygon
  78879. * @param name defines the name of the mesh
  78880. * @param options defines the options used to create the mesh
  78881. * @param scene defines the hosting scene
  78882. * @param earcutInjection can be used to inject your own earcut reference
  78883. * @returns the polygon mesh
  78884. */
  78885. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  78886. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78887. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78888. var shape = options.shape;
  78889. var holes = options.holes || [];
  78890. var depth = options.depth || 0;
  78891. var contours = [];
  78892. var hole = [];
  78893. for (var i = 0; i < shape.length; i++) {
  78894. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  78895. }
  78896. var epsilon = 0.00000001;
  78897. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  78898. contours.pop();
  78899. }
  78900. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  78901. for (var hNb = 0; hNb < holes.length; hNb++) {
  78902. hole = [];
  78903. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  78904. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  78905. }
  78906. polygonTriangulation.addHole(hole);
  78907. }
  78908. var polygon = polygonTriangulation.build(options.updatable, depth);
  78909. polygon._originalBuilderSideOrientation = options.sideOrientation;
  78910. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  78911. vertexData.applyToMesh(polygon, options.updatable);
  78912. return polygon;
  78913. };
  78914. /**
  78915. * Creates an extruded polygon mesh, with depth in the Y direction.
  78916. * * 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)
  78917. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  78918. * @param name defines the name of the mesh
  78919. * @param options defines the options used to create the mesh
  78920. * @param scene defines the hosting scene
  78921. * @param earcutInjection can be used to inject your own earcut reference
  78922. * @returns the polygon mesh
  78923. */
  78924. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  78925. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78926. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  78927. };
  78928. return PolygonBuilder;
  78929. }());
  78930. /***/ }),
  78931. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  78932. /*!**********************************************!*\
  78933. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  78934. \**********************************************/
  78935. /*! exports provided: PolyhedronBuilder */
  78936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78937. "use strict";
  78938. __webpack_require__.r(__webpack_exports__);
  78939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  78940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78941. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78942. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78943. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  78944. // provided polyhedron types :
  78945. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78946. // 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)
  78947. var polyhedra = [];
  78948. 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]] };
  78949. 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]] };
  78950. polyhedra[2] = {
  78951. 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]],
  78952. 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]]
  78953. };
  78954. polyhedra[3] = {
  78955. 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]],
  78956. 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]]
  78957. };
  78958. polyhedra[4] = {
  78959. 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]],
  78960. 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]]
  78961. };
  78962. 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]] };
  78963. 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]] };
  78964. 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]] };
  78965. 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]] };
  78966. 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]] };
  78967. 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]] };
  78968. 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]] };
  78969. 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]] };
  78970. 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]] };
  78971. polyhedra[14] = {
  78972. 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]],
  78973. 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]]
  78974. };
  78975. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  78976. var size = options.size;
  78977. var sizeX = options.sizeX || size || 1;
  78978. var sizeY = options.sizeY || size || 1;
  78979. var sizeZ = options.sizeZ || size || 1;
  78980. var data = options.custom || polyhedra[type];
  78981. var nbfaces = data.face.length;
  78982. var faceUV = options.faceUV || new Array(nbfaces);
  78983. var faceColors = options.faceColors;
  78984. var flat = (options.flat === undefined) ? true : options.flat;
  78985. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78986. var positions = new Array();
  78987. var indices = new Array();
  78988. var normals = new Array();
  78989. var uvs = new Array();
  78990. var colors = new Array();
  78991. var index = 0;
  78992. var faceIdx = 0; // face cursor in the array "indexes"
  78993. var indexes = new Array();
  78994. var i = 0;
  78995. var f = 0;
  78996. var u, v, ang, x, y, tmp;
  78997. // default face colors and UV if undefined
  78998. if (flat) {
  78999. for (f = 0; f < nbfaces; f++) {
  79000. if (faceColors && faceColors[f] === undefined) {
  79001. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  79002. }
  79003. if (faceUV && faceUV[f] === undefined) {
  79004. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  79005. }
  79006. }
  79007. }
  79008. if (!flat) {
  79009. for (i = 0; i < data.vertex.length; i++) {
  79010. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  79011. uvs.push(0, 0);
  79012. }
  79013. for (f = 0; f < nbfaces; f++) {
  79014. for (i = 0; i < data.face[f].length - 2; i++) {
  79015. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  79016. }
  79017. }
  79018. }
  79019. else {
  79020. for (f = 0; f < nbfaces; f++) {
  79021. var fl = data.face[f].length; // number of vertices of the current face
  79022. ang = 2 * Math.PI / fl;
  79023. x = 0.5 * Math.tan(ang / 2);
  79024. y = 0.5;
  79025. // positions, uvs, colors
  79026. for (i = 0; i < fl; i++) {
  79027. // positions
  79028. 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);
  79029. indexes.push(index);
  79030. index++;
  79031. // uvs
  79032. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  79033. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  79034. uvs.push(u, v);
  79035. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  79036. y = x * Math.sin(ang) + y * Math.cos(ang);
  79037. x = tmp;
  79038. // colors
  79039. if (faceColors) {
  79040. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  79041. }
  79042. }
  79043. // indices from indexes
  79044. for (i = 0; i < fl - 2; i++) {
  79045. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  79046. }
  79047. faceIdx += fl;
  79048. }
  79049. }
  79050. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79051. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79052. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79053. vertexData.positions = positions;
  79054. vertexData.indices = indices;
  79055. vertexData.normals = normals;
  79056. vertexData.uvs = uvs;
  79057. if (faceColors && flat) {
  79058. vertexData.colors = colors;
  79059. }
  79060. return vertexData;
  79061. };
  79062. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  79063. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  79064. };
  79065. /**
  79066. * Class containing static functions to help procedurally build meshes
  79067. */
  79068. var PolyhedronBuilder = /** @class */ (function () {
  79069. function PolyhedronBuilder() {
  79070. }
  79071. /**
  79072. * Creates a polyhedron mesh
  79073. * * 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
  79074. * * The parameter `size` (positive float, default 1) sets the polygon size
  79075. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79076. * * 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`
  79077. * * 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
  79078. * * 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)`)
  79079. * * 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
  79080. * * 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
  79081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79082. * * 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
  79083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79084. * @param name defines the name of the mesh
  79085. * @param options defines the options used to create the mesh
  79086. * @param scene defines the hosting scene
  79087. * @returns the polyhedron mesh
  79088. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  79089. */
  79090. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  79091. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79092. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79093. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  79094. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  79095. vertexData.applyToMesh(polyhedron, options.updatable);
  79096. return polyhedron;
  79097. };
  79098. return PolyhedronBuilder;
  79099. }());
  79100. /***/ }),
  79101. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  79102. /*!******************************************!*\
  79103. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  79104. \******************************************/
  79105. /*! exports provided: RibbonBuilder */
  79106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79107. "use strict";
  79108. __webpack_require__.r(__webpack_exports__);
  79109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  79110. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79111. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79112. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  79113. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79114. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  79115. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  79116. var pathArray = options.pathArray;
  79117. var closeArray = options.closeArray || false;
  79118. var closePath = options.closePath || false;
  79119. var invertUV = options.invertUV || false;
  79120. var defaultOffset = Math.floor(pathArray[0].length / 2);
  79121. var offset = options.offset || defaultOffset;
  79122. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  79123. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  79124. var customUV = options.uvs;
  79125. var customColors = options.colors;
  79126. var positions = [];
  79127. var indices = [];
  79128. var normals = [];
  79129. var uvs = [];
  79130. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  79131. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  79132. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  79133. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  79134. var minlg; // minimal length among all paths from pathArray
  79135. var lg = []; // array of path lengths : nb of vertex per path
  79136. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  79137. var p; // path iterator
  79138. var i; // point iterator
  79139. var j; // point iterator
  79140. // if single path in pathArray
  79141. if (pathArray.length < 2) {
  79142. var ar1 = [];
  79143. var ar2 = [];
  79144. for (i = 0; i < pathArray[0].length - offset; i++) {
  79145. ar1.push(pathArray[0][i]);
  79146. ar2.push(pathArray[0][i + offset]);
  79147. }
  79148. pathArray = [ar1, ar2];
  79149. }
  79150. // positions and horizontal distances (u)
  79151. var idc = 0;
  79152. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  79153. var path;
  79154. var l;
  79155. minlg = pathArray[0].length;
  79156. var vectlg;
  79157. var dist;
  79158. for (p = 0; p < pathArray.length; p++) {
  79159. uTotalDistance[p] = 0;
  79160. us[p] = [0];
  79161. path = pathArray[p];
  79162. l = path.length;
  79163. minlg = (minlg < l) ? minlg : l;
  79164. j = 0;
  79165. while (j < l) {
  79166. positions.push(path[j].x, path[j].y, path[j].z);
  79167. if (j > 0) {
  79168. vectlg = path[j].subtract(path[j - 1]).length();
  79169. dist = vectlg + uTotalDistance[p];
  79170. us[p].push(dist);
  79171. uTotalDistance[p] = dist;
  79172. }
  79173. j++;
  79174. }
  79175. if (closePath) { // an extra hidden vertex is added in the "positions" array
  79176. j--;
  79177. positions.push(path[0].x, path[0].y, path[0].z);
  79178. vectlg = path[j].subtract(path[0]).length();
  79179. dist = vectlg + uTotalDistance[p];
  79180. us[p].push(dist);
  79181. uTotalDistance[p] = dist;
  79182. }
  79183. lg[p] = l + closePathCorr;
  79184. idx[p] = idc;
  79185. idc += (l + closePathCorr);
  79186. }
  79187. // vertical distances (v)
  79188. var path1;
  79189. var path2;
  79190. var vertex1 = null;
  79191. var vertex2 = null;
  79192. for (i = 0; i < minlg + closePathCorr; i++) {
  79193. vTotalDistance[i] = 0;
  79194. vs[i] = [0];
  79195. for (p = 0; p < pathArray.length - 1; p++) {
  79196. path1 = pathArray[p];
  79197. path2 = pathArray[p + 1];
  79198. if (i === minlg) { // closePath
  79199. vertex1 = path1[0];
  79200. vertex2 = path2[0];
  79201. }
  79202. else {
  79203. vertex1 = path1[i];
  79204. vertex2 = path2[i];
  79205. }
  79206. vectlg = vertex2.subtract(vertex1).length();
  79207. dist = vectlg + vTotalDistance[i];
  79208. vs[i].push(dist);
  79209. vTotalDistance[i] = dist;
  79210. }
  79211. if (closeArray && vertex2 && vertex1) {
  79212. path1 = pathArray[p];
  79213. path2 = pathArray[0];
  79214. if (i === minlg) { // closePath
  79215. vertex2 = path2[0];
  79216. }
  79217. vectlg = vertex2.subtract(vertex1).length();
  79218. dist = vectlg + vTotalDistance[i];
  79219. vTotalDistance[i] = dist;
  79220. }
  79221. }
  79222. // uvs
  79223. var u;
  79224. var v;
  79225. if (customUV) {
  79226. for (p = 0; p < customUV.length; p++) {
  79227. uvs.push(customUV[p].x, customUV[p].y);
  79228. }
  79229. }
  79230. else {
  79231. for (p = 0; p < pathArray.length; p++) {
  79232. for (i = 0; i < minlg + closePathCorr; i++) {
  79233. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  79234. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  79235. if (invertUV) {
  79236. uvs.push(v, u);
  79237. }
  79238. else {
  79239. uvs.push(u, v);
  79240. }
  79241. }
  79242. }
  79243. }
  79244. // indices
  79245. p = 0; // path index
  79246. var pi = 0; // positions array index
  79247. var l1 = lg[p] - 1; // path1 length
  79248. var l2 = lg[p + 1] - 1; // path2 length
  79249. var min = (l1 < l2) ? l1 : l2; // current path stop index
  79250. var shft = idx[1] - idx[0]; // shift
  79251. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  79252. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  79253. // 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
  79254. indices.push(pi, pi + shft, pi + 1);
  79255. indices.push(pi + shft + 1, pi + 1, pi + shft);
  79256. pi += 1;
  79257. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  79258. p++;
  79259. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  79260. shft = idx[0] - idx[p];
  79261. l1 = lg[p] - 1;
  79262. l2 = lg[0] - 1;
  79263. }
  79264. else {
  79265. shft = idx[p + 1] - idx[p];
  79266. l1 = lg[p] - 1;
  79267. l2 = lg[p + 1] - 1;
  79268. }
  79269. pi = idx[p];
  79270. min = (l1 < l2) ? l1 + pi : l2 + pi;
  79271. }
  79272. }
  79273. // normals
  79274. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  79275. if (closePath) { // update both the first and last vertex normals to their average value
  79276. var indexFirst = 0;
  79277. var indexLast = 0;
  79278. for (p = 0; p < pathArray.length; p++) {
  79279. indexFirst = idx[p] * 3;
  79280. if (p + 1 < pathArray.length) {
  79281. indexLast = (idx[p + 1] - 1) * 3;
  79282. }
  79283. else {
  79284. indexLast = normals.length - 3;
  79285. }
  79286. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  79287. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  79288. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  79289. normals[indexLast] = normals[indexFirst];
  79290. normals[indexLast + 1] = normals[indexFirst + 1];
  79291. normals[indexLast + 2] = normals[indexFirst + 2];
  79292. }
  79293. }
  79294. // sides
  79295. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79296. // Colors
  79297. var colors = null;
  79298. if (customColors) {
  79299. colors = new Float32Array(customColors.length * 4);
  79300. for (var c = 0; c < customColors.length; c++) {
  79301. colors[c * 4] = customColors[c].r;
  79302. colors[c * 4 + 1] = customColors[c].g;
  79303. colors[c * 4 + 2] = customColors[c].b;
  79304. colors[c * 4 + 3] = customColors[c].a;
  79305. }
  79306. }
  79307. // Result
  79308. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  79309. var positions32 = new Float32Array(positions);
  79310. var normals32 = new Float32Array(normals);
  79311. var uvs32 = new Float32Array(uvs);
  79312. vertexData.indices = indices;
  79313. vertexData.positions = positions32;
  79314. vertexData.normals = normals32;
  79315. vertexData.uvs = uvs32;
  79316. if (colors) {
  79317. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  79318. }
  79319. if (closePath) {
  79320. vertexData._idx = idx;
  79321. }
  79322. return vertexData;
  79323. };
  79324. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  79325. if (closeArray === void 0) { closeArray = false; }
  79326. if (updatable === void 0) { updatable = false; }
  79327. return RibbonBuilder.CreateRibbon(name, {
  79328. pathArray: pathArray,
  79329. closeArray: closeArray,
  79330. closePath: closePath,
  79331. offset: offset,
  79332. updatable: updatable,
  79333. sideOrientation: sideOrientation,
  79334. instance: instance
  79335. }, scene);
  79336. };
  79337. /**
  79338. * Class containing static functions to help procedurally build meshes
  79339. */
  79340. var RibbonBuilder = /** @class */ (function () {
  79341. function RibbonBuilder() {
  79342. }
  79343. /**
  79344. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  79345. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  79346. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  79347. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  79348. * * 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
  79349. * * 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
  79350. * * 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
  79351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79352. * * 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
  79353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79354. * * 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
  79355. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  79356. * * 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
  79357. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  79358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79359. * @param name defines the name of the mesh
  79360. * @param options defines the options used to create the mesh
  79361. * @param scene defines the hosting scene
  79362. * @returns the ribbon mesh
  79363. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  79364. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79365. */
  79366. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  79367. if (scene === void 0) { scene = null; }
  79368. var pathArray = options.pathArray;
  79369. var closeArray = options.closeArray;
  79370. var closePath = options.closePath;
  79371. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79372. var instance = options.instance;
  79373. var updatable = options.updatable;
  79374. if (instance) { // existing ribbon instance update
  79375. // positionFunction : ribbon case
  79376. // only pathArray and sideOrientation parameters are taken into account for positions update
  79377. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  79378. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  79379. var positionFunction = function (positions) {
  79380. var minlg = pathArray[0].length;
  79381. var mesh = instance;
  79382. var i = 0;
  79383. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  79384. for (var si = 1; si <= ns; ++si) {
  79385. for (var p = 0; p < pathArray.length; ++p) {
  79386. var path = pathArray[p];
  79387. var l = path.length;
  79388. minlg = (minlg < l) ? minlg : l;
  79389. for (var j = 0; j < minlg; ++j) {
  79390. var pathPoint = path[j];
  79391. positions[i] = pathPoint.x;
  79392. positions[i + 1] = pathPoint.y;
  79393. positions[i + 2] = pathPoint.z;
  79394. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  79395. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  79396. i += 3;
  79397. }
  79398. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  79399. var pathPoint = path[0];
  79400. positions[i] = pathPoint.x;
  79401. positions[i + 1] = pathPoint.y;
  79402. positions[i + 2] = pathPoint.z;
  79403. i += 3;
  79404. }
  79405. }
  79406. }
  79407. };
  79408. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  79409. positionFunction(positions);
  79410. if (instance._boundingInfo) {
  79411. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  79412. }
  79413. else {
  79414. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  79415. }
  79416. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  79417. if (options.colors) {
  79418. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  79419. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  79420. var color = options.colors[c];
  79421. colors[colorIndex] = color.r;
  79422. colors[colorIndex + 1] = color.g;
  79423. colors[colorIndex + 2] = color.b;
  79424. colors[colorIndex + 3] = color.a;
  79425. }
  79426. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  79427. }
  79428. if (options.uvs) {
  79429. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  79430. for (var i = 0; i < options.uvs.length; i++) {
  79431. uvs[i * 2] = options.uvs[i].x;
  79432. uvs[i * 2 + 1] = options.uvs[i].y;
  79433. }
  79434. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  79435. }
  79436. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  79437. var indices = instance.getIndices();
  79438. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  79439. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  79440. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  79441. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  79442. var indexFirst = 0;
  79443. var indexLast = 0;
  79444. for (var p = 0; p < pathArray.length; p++) {
  79445. indexFirst = instance._creationDataStorage.idx[p] * 3;
  79446. if (p + 1 < pathArray.length) {
  79447. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  79448. }
  79449. else {
  79450. indexLast = normals.length - 3;
  79451. }
  79452. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  79453. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  79454. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  79455. normals[indexLast] = normals[indexFirst];
  79456. normals[indexLast + 1] = normals[indexFirst + 1];
  79457. normals[indexLast + 2] = normals[indexFirst + 2];
  79458. }
  79459. }
  79460. if (!(instance.areNormalsFrozen)) {
  79461. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  79462. }
  79463. }
  79464. return instance;
  79465. }
  79466. else { // new ribbon creation
  79467. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79468. ribbon._originalBuilderSideOrientation = sideOrientation;
  79469. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  79470. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  79471. if (closePath) {
  79472. ribbon._creationDataStorage.idx = vertexData._idx;
  79473. }
  79474. ribbon._creationDataStorage.closePath = closePath;
  79475. ribbon._creationDataStorage.closeArray = closeArray;
  79476. vertexData.applyToMesh(ribbon, updatable);
  79477. return ribbon;
  79478. }
  79479. };
  79480. return RibbonBuilder;
  79481. }());
  79482. /***/ }),
  79483. /***/ "./Meshes/Builders/shapeBuilder.ts":
  79484. /*!*****************************************!*\
  79485. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  79486. \*****************************************/
  79487. /*! exports provided: ShapeBuilder */
  79488. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79489. "use strict";
  79490. __webpack_require__.r(__webpack_exports__);
  79491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  79492. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79493. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79494. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79495. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  79496. if (scene === void 0) { scene = null; }
  79497. var options = {
  79498. shape: shape,
  79499. path: path,
  79500. scale: scale,
  79501. rotation: rotation,
  79502. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  79503. sideOrientation: sideOrientation,
  79504. instance: instance,
  79505. updatable: updatable
  79506. };
  79507. return ShapeBuilder.ExtrudeShape(name, options, scene);
  79508. };
  79509. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  79510. var options = {
  79511. shape: shape,
  79512. path: path,
  79513. scaleFunction: scaleFunction,
  79514. rotationFunction: rotationFunction,
  79515. ribbonCloseArray: ribbonCloseArray,
  79516. ribbonClosePath: ribbonClosePath,
  79517. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  79518. sideOrientation: sideOrientation,
  79519. instance: instance,
  79520. updatable: updatable
  79521. };
  79522. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  79523. };
  79524. /**
  79525. * Class containing static functions to help procedurally build meshes
  79526. */
  79527. var ShapeBuilder = /** @class */ (function () {
  79528. function ShapeBuilder() {
  79529. }
  79530. /**
  79531. * 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.
  79532. * * 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.
  79533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  79534. * * 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.
  79535. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  79536. * * 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
  79537. * * 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
  79538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  79539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79540. * * 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
  79541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  79542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79543. * @param name defines the name of the mesh
  79544. * @param options defines the options used to create the mesh
  79545. * @param scene defines the hosting scene
  79546. * @returns the extruded shape mesh
  79547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79549. */
  79550. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  79551. if (scene === void 0) { scene = null; }
  79552. var path = options.path;
  79553. var shape = options.shape;
  79554. var scale = options.scale || 1;
  79555. var rotation = options.rotation || 0;
  79556. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79557. var updatable = options.updatable;
  79558. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79559. var instance = options.instance || null;
  79560. var invertUV = options.invertUV || false;
  79561. 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);
  79562. };
  79563. /**
  79564. * Creates an custom extruded shape mesh.
  79565. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  79566. * * 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.
  79567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  79568. * * 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
  79569. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  79570. * * 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
  79571. * * It must returns a float value that will be the scale value applied to the shape on each path point
  79572. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79573. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  79574. * * 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
  79575. * * 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
  79576. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  79577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79578. * * 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
  79579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79581. * @param name defines the name of the mesh
  79582. * @param options defines the options used to create the mesh
  79583. * @param scene defines the hosting scene
  79584. * @returns the custom extruded shape mesh
  79585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  79586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79588. */
  79589. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  79590. var path = options.path;
  79591. var shape = options.shape;
  79592. var scaleFunction = options.scaleFunction || (function () { return 1; });
  79593. var rotationFunction = options.rotationFunction || (function () { return 0; });
  79594. var ribbonCloseArray = options.ribbonCloseArray || false;
  79595. var ribbonClosePath = options.ribbonClosePath || false;
  79596. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79597. var updatable = options.updatable;
  79598. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79599. var instance = options.instance;
  79600. var invertUV = options.invertUV || false;
  79601. 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);
  79602. };
  79603. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  79604. // extrusion geometry
  79605. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  79606. var tangents = path3D.getTangents();
  79607. var normals = path3D.getNormals();
  79608. var binormals = path3D.getBinormals();
  79609. var distances = path3D.getDistances();
  79610. var angle = 0;
  79611. var returnScale = function () { return scale !== null ? scale : 1; };
  79612. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  79613. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  79614. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  79615. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  79616. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  79617. for (var i = 0; i < curve.length; i++) {
  79618. var shapePath = new Array();
  79619. var angleStep = rotate(i, distances[i]);
  79620. var scaleRatio = scl(i, distances[i]);
  79621. for (var p = 0; p < shape.length; p++) {
  79622. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  79623. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  79624. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79625. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  79626. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  79627. shapePath[p] = rotated;
  79628. }
  79629. shapePaths[index] = shapePath;
  79630. angle += angleStep;
  79631. index++;
  79632. }
  79633. // cap
  79634. var capPath = function (shapePath) {
  79635. var pointCap = Array();
  79636. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79637. var i;
  79638. for (i = 0; i < shapePath.length; i++) {
  79639. barycenter.addInPlace(shapePath[i]);
  79640. }
  79641. barycenter.scaleInPlace(1.0 / shapePath.length);
  79642. for (i = 0; i < shapePath.length; i++) {
  79643. pointCap.push(barycenter);
  79644. }
  79645. return pointCap;
  79646. };
  79647. switch (cap) {
  79648. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  79649. break;
  79650. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  79651. shapePaths[0] = capPath(shapePaths[2]);
  79652. shapePaths[1] = shapePaths[2];
  79653. break;
  79654. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  79655. shapePaths[index] = shapePaths[index - 1];
  79656. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  79657. break;
  79658. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  79659. shapePaths[0] = capPath(shapePaths[2]);
  79660. shapePaths[1] = shapePaths[2];
  79661. shapePaths[index] = shapePaths[index - 1];
  79662. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  79663. break;
  79664. default:
  79665. break;
  79666. }
  79667. return shapePaths;
  79668. };
  79669. var path3D;
  79670. var pathArray;
  79671. if (instance) { // instance update
  79672. var storage = instance._creationDataStorage;
  79673. path3D = storage.path3D.update(curve);
  79674. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  79675. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  79676. return instance;
  79677. }
  79678. // extruded shape creation
  79679. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  79680. var newShapePaths = new Array();
  79681. cap = (cap < 0 || cap > 3) ? 0 : cap;
  79682. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  79683. 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);
  79684. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  79685. extrudedGeneric._creationDataStorage.path3D = path3D;
  79686. extrudedGeneric._creationDataStorage.cap = cap;
  79687. return extrudedGeneric;
  79688. };
  79689. return ShapeBuilder;
  79690. }());
  79691. /***/ }),
  79692. /***/ "./Meshes/Builders/sphereBuilder.ts":
  79693. /*!******************************************!*\
  79694. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  79695. \******************************************/
  79696. /*! exports provided: SphereBuilder */
  79697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79698. "use strict";
  79699. __webpack_require__.r(__webpack_exports__);
  79700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  79701. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79702. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79703. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79704. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  79705. var segments = options.segments || 32;
  79706. var diameterX = options.diameterX || options.diameter || 1;
  79707. var diameterY = options.diameterY || options.diameter || 1;
  79708. var diameterZ = options.diameterZ || options.diameter || 1;
  79709. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  79710. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  79711. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79712. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  79713. var totalZRotationSteps = 2 + segments;
  79714. var totalYRotationSteps = 2 * totalZRotationSteps;
  79715. var indices = [];
  79716. var positions = [];
  79717. var normals = [];
  79718. var uvs = [];
  79719. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  79720. var normalizedZ = zRotationStep / totalZRotationSteps;
  79721. var angleZ = normalizedZ * Math.PI * slice;
  79722. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  79723. var normalizedY = yRotationStep / totalYRotationSteps;
  79724. var angleY = normalizedY * Math.PI * 2 * arc;
  79725. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  79726. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  79727. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  79728. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  79729. var vertex = complete.multiply(radius);
  79730. var normal = complete.divide(radius).normalize();
  79731. positions.push(vertex.x, vertex.y, vertex.z);
  79732. normals.push(normal.x, normal.y, normal.z);
  79733. uvs.push(normalizedY, normalizedZ);
  79734. }
  79735. if (zRotationStep > 0) {
  79736. var verticesCount = positions.length / 3;
  79737. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  79738. indices.push((firstIndex));
  79739. indices.push((firstIndex + 1));
  79740. indices.push(firstIndex + totalYRotationSteps + 1);
  79741. indices.push((firstIndex + totalYRotationSteps + 1));
  79742. indices.push((firstIndex + 1));
  79743. indices.push((firstIndex + totalYRotationSteps + 2));
  79744. }
  79745. }
  79746. }
  79747. // Sides
  79748. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79749. // Result
  79750. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79751. vertexData.indices = indices;
  79752. vertexData.positions = positions;
  79753. vertexData.normals = normals;
  79754. vertexData.uvs = uvs;
  79755. return vertexData;
  79756. };
  79757. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  79758. var options = {
  79759. segments: segments,
  79760. diameterX: diameter,
  79761. diameterY: diameter,
  79762. diameterZ: diameter,
  79763. sideOrientation: sideOrientation,
  79764. updatable: updatable
  79765. };
  79766. return SphereBuilder.CreateSphere(name, options, scene);
  79767. };
  79768. /**
  79769. * Class containing static functions to help procedurally build meshes
  79770. */
  79771. var SphereBuilder = /** @class */ (function () {
  79772. function SphereBuilder() {
  79773. }
  79774. /**
  79775. * Creates a sphere mesh
  79776. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  79777. * * 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`)
  79778. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  79779. * * 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
  79780. * * 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)
  79781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79782. * * 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
  79783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79784. * @param name defines the name of the mesh
  79785. * @param options defines the options used to create the mesh
  79786. * @param scene defines the hosting scene
  79787. * @returns the sphere mesh
  79788. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  79789. */
  79790. SphereBuilder.CreateSphere = function (name, options, scene) {
  79791. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79792. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79793. sphere._originalBuilderSideOrientation = options.sideOrientation;
  79794. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  79795. vertexData.applyToMesh(sphere, options.updatable);
  79796. return sphere;
  79797. };
  79798. return SphereBuilder;
  79799. }());
  79800. /***/ }),
  79801. /***/ "./Meshes/Builders/torusBuilder.ts":
  79802. /*!*****************************************!*\
  79803. !*** ./Meshes/Builders/torusBuilder.ts ***!
  79804. \*****************************************/
  79805. /*! exports provided: TorusBuilder */
  79806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79807. "use strict";
  79808. __webpack_require__.r(__webpack_exports__);
  79809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  79810. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79811. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79812. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79813. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  79814. var indices = [];
  79815. var positions = [];
  79816. var normals = [];
  79817. var uvs = [];
  79818. var diameter = options.diameter || 1;
  79819. var thickness = options.thickness || 0.5;
  79820. var tessellation = options.tessellation || 16;
  79821. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79822. var stride = tessellation + 1;
  79823. for (var i = 0; i <= tessellation; i++) {
  79824. var u = i / tessellation;
  79825. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  79826. 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));
  79827. for (var j = 0; j <= tessellation; j++) {
  79828. var v = 1 - j / tessellation;
  79829. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  79830. var dx = Math.cos(innerAngle);
  79831. var dy = Math.sin(innerAngle);
  79832. // Create a vertex.
  79833. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  79834. var position = normal.scale(thickness / 2);
  79835. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  79836. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  79837. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  79838. positions.push(position.x, position.y, position.z);
  79839. normals.push(normal.x, normal.y, normal.z);
  79840. uvs.push(textureCoordinate.x, textureCoordinate.y);
  79841. // And create indices for two triangles.
  79842. var nextI = (i + 1) % stride;
  79843. var nextJ = (j + 1) % stride;
  79844. indices.push(i * stride + j);
  79845. indices.push(i * stride + nextJ);
  79846. indices.push(nextI * stride + j);
  79847. indices.push(i * stride + nextJ);
  79848. indices.push(nextI * stride + nextJ);
  79849. indices.push(nextI * stride + j);
  79850. }
  79851. }
  79852. // Sides
  79853. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79854. // Result
  79855. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79856. vertexData.indices = indices;
  79857. vertexData.positions = positions;
  79858. vertexData.normals = normals;
  79859. vertexData.uvs = uvs;
  79860. return vertexData;
  79861. };
  79862. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  79863. var options = {
  79864. diameter: diameter,
  79865. thickness: thickness,
  79866. tessellation: tessellation,
  79867. sideOrientation: sideOrientation,
  79868. updatable: updatable
  79869. };
  79870. return TorusBuilder.CreateTorus(name, options, scene);
  79871. };
  79872. /**
  79873. * Class containing static functions to help procedurally build meshes
  79874. */
  79875. var TorusBuilder = /** @class */ (function () {
  79876. function TorusBuilder() {
  79877. }
  79878. /**
  79879. * Creates a torus mesh
  79880. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  79881. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  79882. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  79883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79884. * * 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
  79885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79886. * @param name defines the name of the mesh
  79887. * @param options defines the options used to create the mesh
  79888. * @param scene defines the hosting scene
  79889. * @returns the torus mesh
  79890. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  79891. */
  79892. TorusBuilder.CreateTorus = function (name, options, scene) {
  79893. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79894. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79895. torus._originalBuilderSideOrientation = options.sideOrientation;
  79896. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  79897. vertexData.applyToMesh(torus, options.updatable);
  79898. return torus;
  79899. };
  79900. return TorusBuilder;
  79901. }());
  79902. /***/ }),
  79903. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  79904. /*!*********************************************!*\
  79905. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  79906. \*********************************************/
  79907. /*! exports provided: TorusKnotBuilder */
  79908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79909. "use strict";
  79910. __webpack_require__.r(__webpack_exports__);
  79911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  79912. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79913. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79914. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79915. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  79916. var indices = new Array();
  79917. var positions = new Array();
  79918. var normals = new Array();
  79919. var uvs = new Array();
  79920. var radius = options.radius || 2;
  79921. var tube = options.tube || 0.5;
  79922. var radialSegments = options.radialSegments || 32;
  79923. var tubularSegments = options.tubularSegments || 32;
  79924. var p = options.p || 2;
  79925. var q = options.q || 3;
  79926. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79927. // Helper
  79928. var getPos = function (angle) {
  79929. var cu = Math.cos(angle);
  79930. var su = Math.sin(angle);
  79931. var quOverP = q / p * angle;
  79932. var cs = Math.cos(quOverP);
  79933. var tx = radius * (2 + cs) * 0.5 * cu;
  79934. var ty = radius * (2 + cs) * su * 0.5;
  79935. var tz = radius * Math.sin(quOverP) * 0.5;
  79936. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  79937. };
  79938. // Vertices
  79939. var i;
  79940. var j;
  79941. for (i = 0; i <= radialSegments; i++) {
  79942. var modI = i % radialSegments;
  79943. var u = modI / radialSegments * 2 * p * Math.PI;
  79944. var p1 = getPos(u);
  79945. var p2 = getPos(u + 0.01);
  79946. var tang = p2.subtract(p1);
  79947. var n = p2.add(p1);
  79948. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  79949. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  79950. bitan.normalize();
  79951. n.normalize();
  79952. for (j = 0; j < tubularSegments; j++) {
  79953. var modJ = j % tubularSegments;
  79954. var v = modJ / tubularSegments * 2 * Math.PI;
  79955. var cx = -tube * Math.cos(v);
  79956. var cy = tube * Math.sin(v);
  79957. positions.push(p1.x + cx * n.x + cy * bitan.x);
  79958. positions.push(p1.y + cx * n.y + cy * bitan.y);
  79959. positions.push(p1.z + cx * n.z + cy * bitan.z);
  79960. uvs.push(i / radialSegments);
  79961. uvs.push(j / tubularSegments);
  79962. }
  79963. }
  79964. for (i = 0; i < radialSegments; i++) {
  79965. for (j = 0; j < tubularSegments; j++) {
  79966. var jNext = (j + 1) % tubularSegments;
  79967. var a = i * tubularSegments + j;
  79968. var b = (i + 1) * tubularSegments + j;
  79969. var c = (i + 1) * tubularSegments + jNext;
  79970. var d = i * tubularSegments + jNext;
  79971. indices.push(d);
  79972. indices.push(b);
  79973. indices.push(a);
  79974. indices.push(d);
  79975. indices.push(c);
  79976. indices.push(b);
  79977. }
  79978. }
  79979. // Normals
  79980. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79981. // Sides
  79982. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79983. // Result
  79984. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79985. vertexData.indices = indices;
  79986. vertexData.positions = positions;
  79987. vertexData.normals = normals;
  79988. vertexData.uvs = uvs;
  79989. return vertexData;
  79990. };
  79991. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  79992. var options = {
  79993. radius: radius,
  79994. tube: tube,
  79995. radialSegments: radialSegments,
  79996. tubularSegments: tubularSegments,
  79997. p: p,
  79998. q: q,
  79999. sideOrientation: sideOrientation,
  80000. updatable: updatable
  80001. };
  80002. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  80003. };
  80004. /**
  80005. * Class containing static functions to help procedurally build meshes
  80006. */
  80007. var TorusKnotBuilder = /** @class */ (function () {
  80008. function TorusKnotBuilder() {
  80009. }
  80010. /**
  80011. * Creates a torus knot mesh
  80012. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  80013. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  80014. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  80015. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  80016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80017. * * 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
  80018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80019. * @param name defines the name of the mesh
  80020. * @param options defines the options used to create the mesh
  80021. * @param scene defines the hosting scene
  80022. * @returns the torus knot mesh
  80023. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  80024. */
  80025. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  80026. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80027. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80028. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  80029. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  80030. vertexData.applyToMesh(torusKnot, options.updatable);
  80031. return torusKnot;
  80032. };
  80033. return TorusKnotBuilder;
  80034. }());
  80035. /***/ }),
  80036. /***/ "./Meshes/Builders/tubeBuilder.ts":
  80037. /*!****************************************!*\
  80038. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  80039. \****************************************/
  80040. /*! exports provided: TubeBuilder */
  80041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80042. "use strict";
  80043. __webpack_require__.r(__webpack_exports__);
  80044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  80045. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80046. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80047. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  80048. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  80049. var options = {
  80050. path: path,
  80051. radius: radius,
  80052. tessellation: tessellation,
  80053. radiusFunction: radiusFunction,
  80054. arc: 1,
  80055. cap: cap,
  80056. updatable: updatable,
  80057. sideOrientation: sideOrientation,
  80058. instance: instance
  80059. };
  80060. return TubeBuilder.CreateTube(name, options, scene);
  80061. };
  80062. /**
  80063. * Class containing static functions to help procedurally build meshes
  80064. */
  80065. var TubeBuilder = /** @class */ (function () {
  80066. function TubeBuilder() {
  80067. }
  80068. /**
  80069. * Creates a tube mesh.
  80070. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  80071. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  80072. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  80073. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  80074. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  80075. * * 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)
  80076. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  80077. * * 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
  80078. * * 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
  80079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80080. * * 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
  80081. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80083. * @param name defines the name of the mesh
  80084. * @param options defines the options used to create the mesh
  80085. * @param scene defines the hosting scene
  80086. * @returns the tube mesh
  80087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80088. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  80089. */
  80090. TubeBuilder.CreateTube = function (name, options, scene) {
  80091. var path = options.path;
  80092. var instance = options.instance;
  80093. var radius = 1.0;
  80094. if (options.radius !== undefined) {
  80095. radius = options.radius;
  80096. }
  80097. else if (instance) {
  80098. radius = instance._creationDataStorage.radius;
  80099. }
  80100. var tessellation = options.tessellation || 64 | 0;
  80101. var radiusFunction = options.radiusFunction || null;
  80102. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80103. var invertUV = options.invertUV || false;
  80104. var updatable = options.updatable;
  80105. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80106. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  80107. // tube geometry
  80108. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  80109. var tangents = path3D.getTangents();
  80110. var normals = path3D.getNormals();
  80111. var distances = path3D.getDistances();
  80112. var pi2 = Math.PI * 2;
  80113. var step = pi2 / tessellation * arc;
  80114. var returnRadius = function () { return radius; };
  80115. var radiusFunctionFinal = radiusFunction || returnRadius;
  80116. var circlePath;
  80117. var rad;
  80118. var normal;
  80119. var rotated;
  80120. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  80121. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  80122. for (var i = 0; i < path.length; i++) {
  80123. rad = radiusFunctionFinal(i, distances[i]); // current radius
  80124. circlePath = Array(); // current circle array
  80125. normal = normals[i]; // current normal
  80126. for (var t = 0; t < tessellation; t++) {
  80127. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  80128. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80129. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  80130. rotated.scaleInPlace(rad).addInPlace(path[i]);
  80131. circlePath[t] = rotated;
  80132. }
  80133. circlePaths[index] = circlePath;
  80134. index++;
  80135. }
  80136. // cap
  80137. var capPath = function (nbPoints, pathIndex) {
  80138. var pointCap = Array();
  80139. for (var i = 0; i < nbPoints; i++) {
  80140. pointCap.push(path[pathIndex]);
  80141. }
  80142. return pointCap;
  80143. };
  80144. switch (cap) {
  80145. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  80146. break;
  80147. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  80148. circlePaths[0] = capPath(tessellation, 0);
  80149. circlePaths[1] = circlePaths[2].slice(0);
  80150. break;
  80151. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  80152. circlePaths[index] = circlePaths[index - 1].slice(0);
  80153. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  80154. break;
  80155. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  80156. circlePaths[0] = capPath(tessellation, 0);
  80157. circlePaths[1] = circlePaths[2].slice(0);
  80158. circlePaths[index] = circlePaths[index - 1].slice(0);
  80159. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  80160. break;
  80161. default:
  80162. break;
  80163. }
  80164. return circlePaths;
  80165. };
  80166. var path3D;
  80167. var pathArray;
  80168. if (instance) { // tube update
  80169. var storage = instance._creationDataStorage;
  80170. var arc = options.arc || storage.arc;
  80171. path3D = storage.path3D.update(path);
  80172. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  80173. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  80174. // Update mode, no need to recreate the storage.
  80175. storage.path3D = path3D;
  80176. storage.pathArray = pathArray;
  80177. storage.arc = arc;
  80178. storage.radius = radius;
  80179. return instance;
  80180. }
  80181. // tube creation
  80182. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  80183. var newPathArray = new Array();
  80184. cap = (cap < 0 || cap > 3) ? 0 : cap;
  80185. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  80186. 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);
  80187. tube._creationDataStorage.pathArray = pathArray;
  80188. tube._creationDataStorage.path3D = path3D;
  80189. tube._creationDataStorage.tessellation = tessellation;
  80190. tube._creationDataStorage.cap = cap;
  80191. tube._creationDataStorage.arc = options.arc;
  80192. tube._creationDataStorage.radius = radius;
  80193. return tube;
  80194. };
  80195. return TubeBuilder;
  80196. }());
  80197. /***/ }),
  80198. /***/ "./Meshes/Compression/dracoCompression.ts":
  80199. /*!************************************************!*\
  80200. !*** ./Meshes/Compression/dracoCompression.ts ***!
  80201. \************************************************/
  80202. /*! exports provided: DracoCompression */
  80203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80204. "use strict";
  80205. __webpack_require__.r(__webpack_exports__);
  80206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  80207. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  80208. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80209. /**
  80210. * Draco compression (https://google.github.io/draco/)
  80211. *
  80212. * This class wraps the Draco module.
  80213. *
  80214. * **Encoder**
  80215. *
  80216. * The encoder is not currently implemented.
  80217. *
  80218. * **Decoder**
  80219. *
  80220. * 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.
  80221. *
  80222. * To update the configuration, use the following code:
  80223. * ```javascript
  80224. * DracoCompression.Configuration = {
  80225. * decoder: {
  80226. * wasmUrl: "<url to the WebAssembly library>",
  80227. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  80228. * fallbackUrl: "<url to the fallback JavaScript library>",
  80229. * }
  80230. * };
  80231. * ```
  80232. *
  80233. * 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.
  80234. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  80235. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  80236. *
  80237. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  80238. * ```javascript
  80239. * var dracoCompression = new DracoCompression();
  80240. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  80241. * [VertexBuffer.PositionKind]: 0
  80242. * });
  80243. * ```
  80244. *
  80245. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  80246. */
  80247. var DracoCompression = /** @class */ (function () {
  80248. /**
  80249. * Constructor
  80250. */
  80251. function DracoCompression() {
  80252. }
  80253. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  80254. /**
  80255. * Returns true if the decoder is available.
  80256. */
  80257. get: function () {
  80258. if (typeof DracoDecoderModule !== "undefined") {
  80259. return true;
  80260. }
  80261. var decoder = DracoCompression.Configuration.decoder;
  80262. if (decoder) {
  80263. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  80264. return true;
  80265. }
  80266. if (decoder.fallbackUrl) {
  80267. return true;
  80268. }
  80269. }
  80270. return false;
  80271. },
  80272. enumerable: true,
  80273. configurable: true
  80274. });
  80275. /**
  80276. * Stop all async operations and release resources.
  80277. */
  80278. DracoCompression.prototype.dispose = function () {
  80279. };
  80280. /**
  80281. * Decode Draco compressed mesh data to vertex data.
  80282. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  80283. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  80284. * @returns A promise that resolves with the decoded vertex data
  80285. */
  80286. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  80287. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  80288. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  80289. var module = wrappedModule.module;
  80290. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  80291. var buffer = new module.DecoderBuffer();
  80292. buffer.Init(dataView, dataView.byteLength);
  80293. var decoder = new module.Decoder();
  80294. var geometry;
  80295. var status;
  80296. try {
  80297. var type = decoder.GetEncodedGeometryType(buffer);
  80298. switch (type) {
  80299. case module.TRIANGULAR_MESH:
  80300. geometry = new module.Mesh();
  80301. status = decoder.DecodeBufferToMesh(buffer, geometry);
  80302. break;
  80303. case module.POINT_CLOUD:
  80304. geometry = new module.PointCloud();
  80305. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  80306. break;
  80307. default:
  80308. throw new Error("Invalid geometry type " + type);
  80309. }
  80310. if (!status.ok() || !geometry.ptr) {
  80311. throw new Error(status.error_msg());
  80312. }
  80313. var numPoints = geometry.num_points();
  80314. if (type === module.TRIANGULAR_MESH) {
  80315. var numFaces = geometry.num_faces();
  80316. var faceIndices = new module.DracoInt32Array();
  80317. try {
  80318. var indices = new Uint32Array(numFaces * 3);
  80319. for (var i = 0; i < numFaces; i++) {
  80320. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  80321. var offset = i * 3;
  80322. indices[offset + 0] = faceIndices.GetValue(0);
  80323. indices[offset + 1] = faceIndices.GetValue(1);
  80324. indices[offset + 2] = faceIndices.GetValue(2);
  80325. }
  80326. vertexData.indices = indices;
  80327. }
  80328. finally {
  80329. module.destroy(faceIndices);
  80330. }
  80331. }
  80332. for (var kind in attributes) {
  80333. var uniqueId = attributes[kind];
  80334. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  80335. var dracoData = new module.DracoFloat32Array();
  80336. try {
  80337. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  80338. var babylonData = new Float32Array(numPoints * attribute.num_components());
  80339. for (var i = 0; i < babylonData.length; i++) {
  80340. babylonData[i] = dracoData.GetValue(i);
  80341. }
  80342. vertexData.set(babylonData, kind);
  80343. }
  80344. finally {
  80345. module.destroy(dracoData);
  80346. }
  80347. }
  80348. }
  80349. finally {
  80350. if (geometry) {
  80351. module.destroy(geometry);
  80352. }
  80353. module.destroy(decoder);
  80354. module.destroy(buffer);
  80355. }
  80356. return vertexData;
  80357. });
  80358. };
  80359. DracoCompression._GetDecoderModule = function () {
  80360. if (!DracoCompression._DecoderModulePromise) {
  80361. var promise = null;
  80362. var config_1 = {};
  80363. if (typeof DracoDecoderModule !== "undefined") {
  80364. promise = Promise.resolve();
  80365. }
  80366. else {
  80367. var decoder = DracoCompression.Configuration.decoder;
  80368. if (decoder) {
  80369. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  80370. promise = Promise.all([
  80371. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  80372. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  80373. config_1.wasmBinary = data;
  80374. })
  80375. ]);
  80376. }
  80377. else if (decoder.fallbackUrl) {
  80378. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  80379. }
  80380. }
  80381. }
  80382. if (!promise) {
  80383. throw new Error("Draco decoder module is not available");
  80384. }
  80385. DracoCompression._DecoderModulePromise = promise.then(function () {
  80386. return new Promise(function (resolve) {
  80387. config_1.onModuleLoaded = function (decoderModule) {
  80388. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  80389. resolve({ module: decoderModule });
  80390. };
  80391. DracoDecoderModule(config_1);
  80392. });
  80393. });
  80394. }
  80395. return DracoCompression._DecoderModulePromise;
  80396. };
  80397. DracoCompression._LoadScriptAsync = function (url) {
  80398. return new Promise(function (resolve, reject) {
  80399. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  80400. resolve();
  80401. }, function (message) {
  80402. reject(new Error(message));
  80403. });
  80404. });
  80405. };
  80406. DracoCompression._LoadFileAsync = function (url) {
  80407. return new Promise(function (resolve, reject) {
  80408. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  80409. resolve(data);
  80410. }, undefined, undefined, true, function (request, exception) {
  80411. reject(exception);
  80412. });
  80413. });
  80414. };
  80415. /**
  80416. * The configuration. Defaults to the following urls:
  80417. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  80418. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  80419. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  80420. */
  80421. DracoCompression.Configuration = {
  80422. decoder: {
  80423. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  80424. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  80425. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  80426. }
  80427. };
  80428. return DracoCompression;
  80429. }());
  80430. /***/ }),
  80431. /***/ "./Meshes/Compression/index.ts":
  80432. /*!*************************************!*\
  80433. !*** ./Meshes/Compression/index.ts ***!
  80434. \*************************************/
  80435. /*! exports provided: DracoCompression */
  80436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80437. "use strict";
  80438. __webpack_require__.r(__webpack_exports__);
  80439. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  80440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  80441. /***/ }),
  80442. /***/ "./Meshes/abstractMesh.ts":
  80443. /*!********************************!*\
  80444. !*** ./Meshes/abstractMesh.ts ***!
  80445. \********************************/
  80446. /*! exports provided: AbstractMesh */
  80447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80448. "use strict";
  80449. __webpack_require__.r(__webpack_exports__);
  80450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  80451. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  80452. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  80453. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  80454. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80455. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  80456. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80457. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80458. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  80459. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  80460. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80461. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  80462. /** @hidden */
  80463. var _FacetDataStorage = /** @class */ (function () {
  80464. function _FacetDataStorage() {
  80465. this.facetNb = 0; // facet number
  80466. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  80467. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  80468. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  80469. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  80470. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  80471. this.subDiv = {
  80472. max: 1,
  80473. X: 1,
  80474. Y: 1,
  80475. Z: 1
  80476. };
  80477. this.facetDepthSort = false; // is the facet depth sort to be computed
  80478. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  80479. }
  80480. return _FacetDataStorage;
  80481. }());
  80482. /**
  80483. * Class used to store all common mesh properties
  80484. */
  80485. var AbstractMesh = /** @class */ (function (_super) {
  80486. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  80487. // Constructor
  80488. /**
  80489. * Creates a new AbstractMesh
  80490. * @param name defines the name of the mesh
  80491. * @param scene defines the hosting scene
  80492. */
  80493. function AbstractMesh(name, scene) {
  80494. if (scene === void 0) { scene = null; }
  80495. var _this = _super.call(this, name, scene, false) || this;
  80496. _this._facetData = new _FacetDataStorage();
  80497. /**
  80498. * The culling strategy to use to check whether the mesh must be rendered or not.
  80499. * This value can be changed at any time and will be used on the next render mesh selection.
  80500. * The possible values are :
  80501. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80502. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80503. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80504. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80505. * Please read each static variable documentation to get details about the culling process.
  80506. * */
  80507. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  80508. // Events
  80509. /**
  80510. * An event triggered when this mesh collides with another one
  80511. */
  80512. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80513. /**
  80514. * An event triggered when the collision's position changes
  80515. */
  80516. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80517. /**
  80518. * An event triggered when material is changed
  80519. */
  80520. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80521. // Properties
  80522. /**
  80523. * Gets or sets the orientation for POV movement & rotation
  80524. */
  80525. _this.definedFacingForward = true;
  80526. _this._visibility = 1.0;
  80527. /** Gets or sets the alpha index used to sort transparent meshes
  80528. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80529. */
  80530. _this.alphaIndex = Number.MAX_VALUE;
  80531. /**
  80532. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80533. */
  80534. _this.isVisible = true;
  80535. /**
  80536. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80537. */
  80538. _this.isPickable = true;
  80539. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80540. _this.showSubMeshesBoundingBox = false;
  80541. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80542. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80543. */
  80544. _this.isBlocker = false;
  80545. /**
  80546. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80547. */
  80548. _this.enablePointerMoveEvents = false;
  80549. /**
  80550. * Specifies the rendering group id for this mesh (0 by default)
  80551. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80552. */
  80553. _this.renderingGroupId = 0;
  80554. _this._receiveShadows = false;
  80555. /** Defines color to use when rendering outline */
  80556. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  80557. /** Define width to use when rendering outline */
  80558. _this.outlineWidth = 0.02;
  80559. /** Defines color to use when rendering overlay */
  80560. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  80561. /** Defines alpha to use when rendering overlay */
  80562. _this.overlayAlpha = 0.5;
  80563. _this._hasVertexAlpha = false;
  80564. _this._useVertexColors = true;
  80565. _this._computeBonesUsingShaders = true;
  80566. _this._numBoneInfluencers = 4;
  80567. _this._applyFog = true;
  80568. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80569. _this.useOctreeForRenderingSelection = true;
  80570. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80571. _this.useOctreeForPicking = true;
  80572. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80573. _this.useOctreeForCollisions = true;
  80574. _this._layerMask = 0x0FFFFFFF;
  80575. /**
  80576. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80577. */
  80578. _this.alwaysSelectAsActiveMesh = false;
  80579. /**
  80580. * Gets or sets the current action manager
  80581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80582. */
  80583. _this.actionManager = null;
  80584. // Collisions
  80585. _this._checkCollisions = false;
  80586. _this._collisionMask = -1;
  80587. _this._collisionGroup = -1;
  80588. /**
  80589. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80590. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80591. */
  80592. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  80593. /**
  80594. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80595. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80596. */
  80597. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80598. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80599. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80600. // Edges
  80601. /**
  80602. * Defines edge width used when edgesRenderer is enabled
  80603. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80604. */
  80605. _this.edgesWidth = 1;
  80606. /**
  80607. * Defines edge color used when edgesRenderer is enabled
  80608. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80609. */
  80610. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  80611. /** @hidden */
  80612. _this._renderId = 0;
  80613. /** @hidden */
  80614. _this._intersectionsInProgress = new Array();
  80615. /** @hidden */
  80616. _this._unIndexed = false;
  80617. /** @hidden */
  80618. _this._lightSources = new Array();
  80619. /**
  80620. * An event triggered when the mesh is rebuilt.
  80621. */
  80622. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80623. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  80624. if (collidedMesh === void 0) { collidedMesh = null; }
  80625. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  80626. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  80627. _this.position.addInPlace(_this._diffPositionForCollisions);
  80628. }
  80629. if (collidedMesh) {
  80630. _this.onCollideObservable.notifyObservers(collidedMesh);
  80631. }
  80632. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  80633. };
  80634. _this.getScene().addMesh(_this);
  80635. _this._resyncLightSources();
  80636. return _this;
  80637. }
  80638. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  80639. /**
  80640. * No billboard
  80641. */
  80642. get: function () {
  80643. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  80644. },
  80645. enumerable: true,
  80646. configurable: true
  80647. });
  80648. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  80649. /** Billboard on X axis */
  80650. get: function () {
  80651. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  80652. },
  80653. enumerable: true,
  80654. configurable: true
  80655. });
  80656. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  80657. /** Billboard on Y axis */
  80658. get: function () {
  80659. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  80660. },
  80661. enumerable: true,
  80662. configurable: true
  80663. });
  80664. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  80665. /** Billboard on Z axis */
  80666. get: function () {
  80667. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  80668. },
  80669. enumerable: true,
  80670. configurable: true
  80671. });
  80672. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  80673. /** Billboard on all axes */
  80674. get: function () {
  80675. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  80676. },
  80677. enumerable: true,
  80678. configurable: true
  80679. });
  80680. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  80681. /**
  80682. * Gets the number of facets in the mesh
  80683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80684. */
  80685. get: function () {
  80686. return this._facetData.facetNb;
  80687. },
  80688. enumerable: true,
  80689. configurable: true
  80690. });
  80691. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  80692. /**
  80693. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80695. */
  80696. get: function () {
  80697. return this._facetData.partitioningSubdivisions;
  80698. },
  80699. set: function (nb) {
  80700. this._facetData.partitioningSubdivisions = nb;
  80701. },
  80702. enumerable: true,
  80703. configurable: true
  80704. });
  80705. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  80706. /**
  80707. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80708. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80710. */
  80711. get: function () {
  80712. return this._facetData.partitioningBBoxRatio;
  80713. },
  80714. set: function (ratio) {
  80715. this._facetData.partitioningBBoxRatio = ratio;
  80716. },
  80717. enumerable: true,
  80718. configurable: true
  80719. });
  80720. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  80721. /**
  80722. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80723. * Works only for updatable meshes.
  80724. * Doesn't work with multi-materials
  80725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80726. */
  80727. get: function () {
  80728. return this._facetData.facetDepthSort;
  80729. },
  80730. set: function (sort) {
  80731. this._facetData.facetDepthSort = sort;
  80732. },
  80733. enumerable: true,
  80734. configurable: true
  80735. });
  80736. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  80737. /**
  80738. * The location (Vector3) where the facet depth sort must be computed from.
  80739. * By default, the active camera position.
  80740. * Used only when facet depth sort is enabled
  80741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80742. */
  80743. get: function () {
  80744. return this._facetData.facetDepthSortFrom;
  80745. },
  80746. set: function (location) {
  80747. this._facetData.facetDepthSortFrom = location;
  80748. },
  80749. enumerable: true,
  80750. configurable: true
  80751. });
  80752. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  80753. /**
  80754. * gets a boolean indicating if facetData is enabled
  80755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80756. */
  80757. get: function () {
  80758. return this._facetData.facetDataEnabled;
  80759. },
  80760. enumerable: true,
  80761. configurable: true
  80762. });
  80763. /** @hidden */
  80764. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  80765. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  80766. return false;
  80767. }
  80768. this._markSubMeshesAsMiscDirty();
  80769. return true;
  80770. };
  80771. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  80772. /** Set a function to call when this mesh collides with another one */
  80773. set: function (callback) {
  80774. if (this._onCollideObserver) {
  80775. this.onCollideObservable.remove(this._onCollideObserver);
  80776. }
  80777. this._onCollideObserver = this.onCollideObservable.add(callback);
  80778. },
  80779. enumerable: true,
  80780. configurable: true
  80781. });
  80782. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  80783. /** Set a function to call when the collision's position changes */
  80784. set: function (callback) {
  80785. if (this._onCollisionPositionChangeObserver) {
  80786. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  80787. }
  80788. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  80789. },
  80790. enumerable: true,
  80791. configurable: true
  80792. });
  80793. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  80794. /**
  80795. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80796. */
  80797. get: function () {
  80798. return this._visibility;
  80799. },
  80800. /**
  80801. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80802. */
  80803. set: function (value) {
  80804. if (this._visibility === value) {
  80805. return;
  80806. }
  80807. this._visibility = value;
  80808. this._markSubMeshesAsMiscDirty();
  80809. },
  80810. enumerable: true,
  80811. configurable: true
  80812. });
  80813. Object.defineProperty(AbstractMesh.prototype, "material", {
  80814. /** Gets or sets current material */
  80815. get: function () {
  80816. return this._material;
  80817. },
  80818. set: function (value) {
  80819. if (this._material === value) {
  80820. return;
  80821. }
  80822. // remove from material mesh map id needed
  80823. if (this._material && this._material.meshMap) {
  80824. this._material.meshMap[this.uniqueId] = undefined;
  80825. }
  80826. this._material = value;
  80827. if (value && value.meshMap) {
  80828. value.meshMap[this.uniqueId] = this;
  80829. }
  80830. if (this.onMaterialChangedObservable.hasObservers) {
  80831. this.onMaterialChangedObservable.notifyObservers(this);
  80832. }
  80833. if (!this.subMeshes) {
  80834. return;
  80835. }
  80836. this._unBindEffect();
  80837. },
  80838. enumerable: true,
  80839. configurable: true
  80840. });
  80841. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  80842. /**
  80843. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80844. * @see http://doc.babylonjs.com/babylon101/shadows
  80845. */
  80846. get: function () {
  80847. return this._receiveShadows;
  80848. },
  80849. set: function (value) {
  80850. if (this._receiveShadows === value) {
  80851. return;
  80852. }
  80853. this._receiveShadows = value;
  80854. this._markSubMeshesAsLightDirty();
  80855. },
  80856. enumerable: true,
  80857. configurable: true
  80858. });
  80859. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  80860. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80861. get: function () {
  80862. return this._hasVertexAlpha;
  80863. },
  80864. set: function (value) {
  80865. if (this._hasVertexAlpha === value) {
  80866. return;
  80867. }
  80868. this._hasVertexAlpha = value;
  80869. this._markSubMeshesAsAttributesDirty();
  80870. this._markSubMeshesAsMiscDirty();
  80871. },
  80872. enumerable: true,
  80873. configurable: true
  80874. });
  80875. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  80876. /** 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) */
  80877. get: function () {
  80878. return this._useVertexColors;
  80879. },
  80880. set: function (value) {
  80881. if (this._useVertexColors === value) {
  80882. return;
  80883. }
  80884. this._useVertexColors = value;
  80885. this._markSubMeshesAsAttributesDirty();
  80886. },
  80887. enumerable: true,
  80888. configurable: true
  80889. });
  80890. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  80891. /**
  80892. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80893. */
  80894. get: function () {
  80895. return this._computeBonesUsingShaders;
  80896. },
  80897. set: function (value) {
  80898. if (this._computeBonesUsingShaders === value) {
  80899. return;
  80900. }
  80901. this._computeBonesUsingShaders = value;
  80902. this._markSubMeshesAsAttributesDirty();
  80903. },
  80904. enumerable: true,
  80905. configurable: true
  80906. });
  80907. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  80908. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80909. get: function () {
  80910. return this._numBoneInfluencers;
  80911. },
  80912. set: function (value) {
  80913. if (this._numBoneInfluencers === value) {
  80914. return;
  80915. }
  80916. this._numBoneInfluencers = value;
  80917. this._markSubMeshesAsAttributesDirty();
  80918. },
  80919. enumerable: true,
  80920. configurable: true
  80921. });
  80922. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  80923. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80924. get: function () {
  80925. return this._applyFog;
  80926. },
  80927. set: function (value) {
  80928. if (this._applyFog === value) {
  80929. return;
  80930. }
  80931. this._applyFog = value;
  80932. this._markSubMeshesAsMiscDirty();
  80933. },
  80934. enumerable: true,
  80935. configurable: true
  80936. });
  80937. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  80938. /**
  80939. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80940. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80941. */
  80942. get: function () {
  80943. return this._layerMask;
  80944. },
  80945. set: function (value) {
  80946. if (value === this._layerMask) {
  80947. return;
  80948. }
  80949. this._layerMask = value;
  80950. this._resyncLightSources();
  80951. },
  80952. enumerable: true,
  80953. configurable: true
  80954. });
  80955. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  80956. /**
  80957. * Gets or sets a collision mask used to mask collisions (default is -1).
  80958. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80959. */
  80960. get: function () {
  80961. return this._collisionMask;
  80962. },
  80963. set: function (mask) {
  80964. this._collisionMask = !isNaN(mask) ? mask : -1;
  80965. },
  80966. enumerable: true,
  80967. configurable: true
  80968. });
  80969. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  80970. /**
  80971. * Gets or sets the current collision group mask (-1 by default).
  80972. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80973. */
  80974. get: function () {
  80975. return this._collisionGroup;
  80976. },
  80977. set: function (mask) {
  80978. this._collisionGroup = !isNaN(mask) ? mask : -1;
  80979. },
  80980. enumerable: true,
  80981. configurable: true
  80982. });
  80983. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  80984. /** @hidden */
  80985. get: function () {
  80986. return null;
  80987. },
  80988. enumerable: true,
  80989. configurable: true
  80990. });
  80991. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  80992. get: function () {
  80993. return this._skeleton;
  80994. },
  80995. /**
  80996. * Gets or sets a skeleton to apply skining transformations
  80997. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80998. */
  80999. set: function (value) {
  81000. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  81001. this._skeleton._unregisterMeshWithPoseMatrix(this);
  81002. }
  81003. if (value && value.needInitialSkinMatrix) {
  81004. value._registerMeshWithPoseMatrix(this);
  81005. }
  81006. this._skeleton = value;
  81007. if (!this._skeleton) {
  81008. this._bonesTransformMatrices = null;
  81009. }
  81010. this._markSubMeshesAsAttributesDirty();
  81011. },
  81012. enumerable: true,
  81013. configurable: true
  81014. });
  81015. /**
  81016. * Returns the string "AbstractMesh"
  81017. * @returns "AbstractMesh"
  81018. */
  81019. AbstractMesh.prototype.getClassName = function () {
  81020. return "AbstractMesh";
  81021. };
  81022. /**
  81023. * Gets a string representation of the current mesh
  81024. * @param fullDetails defines a boolean indicating if full details must be included
  81025. * @returns a string representation of the current mesh
  81026. */
  81027. AbstractMesh.prototype.toString = function (fullDetails) {
  81028. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  81029. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  81030. if (this._skeleton) {
  81031. ret += ", skeleton: " + this._skeleton.name;
  81032. }
  81033. if (fullDetails) {
  81034. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  81035. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  81036. }
  81037. return ret;
  81038. };
  81039. /** @hidden */
  81040. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  81041. if (initialCall === void 0) { initialCall = true; }
  81042. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  81043. if (trigger) {
  81044. if (this.actionManager.hasSpecificTrigger(trigger)) {
  81045. return this.actionManager;
  81046. }
  81047. }
  81048. else {
  81049. return this.actionManager;
  81050. }
  81051. }
  81052. if (!this.parent) {
  81053. return null;
  81054. }
  81055. return this.parent._getActionManagerForTrigger(trigger, false);
  81056. };
  81057. /** @hidden */
  81058. AbstractMesh.prototype._rebuild = function () {
  81059. this.onRebuildObservable.notifyObservers(this);
  81060. if (this._occlusionQuery) {
  81061. this._occlusionQuery = null;
  81062. }
  81063. if (!this.subMeshes) {
  81064. return;
  81065. }
  81066. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81067. var subMesh = _a[_i];
  81068. subMesh._rebuild();
  81069. }
  81070. };
  81071. /** @hidden */
  81072. AbstractMesh.prototype._resyncLightSources = function () {
  81073. this._lightSources.length = 0;
  81074. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  81075. var light = _a[_i];
  81076. if (!light.isEnabled()) {
  81077. continue;
  81078. }
  81079. if (light.canAffectMesh(this)) {
  81080. this._lightSources.push(light);
  81081. }
  81082. }
  81083. this._markSubMeshesAsLightDirty();
  81084. };
  81085. /** @hidden */
  81086. AbstractMesh.prototype._resyncLighSource = function (light) {
  81087. var isIn = light.isEnabled() && light.canAffectMesh(this);
  81088. var index = this._lightSources.indexOf(light);
  81089. if (index === -1) {
  81090. if (!isIn) {
  81091. return;
  81092. }
  81093. this._lightSources.push(light);
  81094. }
  81095. else {
  81096. if (isIn) {
  81097. return;
  81098. }
  81099. this._lightSources.splice(index, 1);
  81100. }
  81101. this._markSubMeshesAsLightDirty();
  81102. };
  81103. /** @hidden */
  81104. AbstractMesh.prototype._unBindEffect = function () {
  81105. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81106. var subMesh = _a[_i];
  81107. subMesh.setEffect(null);
  81108. }
  81109. };
  81110. /** @hidden */
  81111. AbstractMesh.prototype._removeLightSource = function (light) {
  81112. var index = this._lightSources.indexOf(light);
  81113. if (index === -1) {
  81114. return;
  81115. }
  81116. this._lightSources.splice(index, 1);
  81117. this._markSubMeshesAsLightDirty();
  81118. };
  81119. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  81120. if (!this.subMeshes) {
  81121. return;
  81122. }
  81123. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81124. var subMesh = _a[_i];
  81125. if (subMesh._materialDefines) {
  81126. func(subMesh._materialDefines);
  81127. }
  81128. }
  81129. };
  81130. /** @hidden */
  81131. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  81132. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  81133. };
  81134. /** @hidden */
  81135. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  81136. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  81137. };
  81138. /** @hidden */
  81139. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  81140. if (!this.subMeshes) {
  81141. return;
  81142. }
  81143. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81144. var subMesh = _a[_i];
  81145. var material = subMesh.getMaterial();
  81146. if (material) {
  81147. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  81148. }
  81149. }
  81150. };
  81151. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  81152. /**
  81153. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81154. */
  81155. get: function () {
  81156. return this._scaling;
  81157. },
  81158. set: function (newScaling) {
  81159. this._scaling = newScaling;
  81160. if (this.physicsImpostor) {
  81161. this.physicsImpostor.forceUpdate();
  81162. }
  81163. },
  81164. enumerable: true,
  81165. configurable: true
  81166. });
  81167. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  81168. // Methods
  81169. /**
  81170. * Returns true if the mesh is blocked. Implemented by child classes
  81171. */
  81172. get: function () {
  81173. return false;
  81174. },
  81175. enumerable: true,
  81176. configurable: true
  81177. });
  81178. /**
  81179. * Returns the mesh itself by default. Implemented by child classes
  81180. * @param camera defines the camera to use to pick the right LOD level
  81181. * @returns the currentAbstractMesh
  81182. */
  81183. AbstractMesh.prototype.getLOD = function (camera) {
  81184. return this;
  81185. };
  81186. /**
  81187. * Returns 0 by default. Implemented by child classes
  81188. * @returns an integer
  81189. */
  81190. AbstractMesh.prototype.getTotalVertices = function () {
  81191. return 0;
  81192. };
  81193. /**
  81194. * Returns a positive integer : the total number of indices in this mesh geometry.
  81195. * @returns the numner of indices or zero if the mesh has no geometry.
  81196. */
  81197. AbstractMesh.prototype.getTotalIndices = function () {
  81198. return 0;
  81199. };
  81200. /**
  81201. * Returns null by default. Implemented by child classes
  81202. * @returns null
  81203. */
  81204. AbstractMesh.prototype.getIndices = function () {
  81205. return null;
  81206. };
  81207. /**
  81208. * Returns the array of the requested vertex data kind. Implemented by child classes
  81209. * @param kind defines the vertex data kind to use
  81210. * @returns null
  81211. */
  81212. AbstractMesh.prototype.getVerticesData = function (kind) {
  81213. return null;
  81214. };
  81215. /**
  81216. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81217. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81218. * Note that a new underlying VertexBuffer object is created each call.
  81219. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81220. * @param kind defines vertex data kind:
  81221. * * VertexBuffer.PositionKind
  81222. * * VertexBuffer.UVKind
  81223. * * VertexBuffer.UV2Kind
  81224. * * VertexBuffer.UV3Kind
  81225. * * VertexBuffer.UV4Kind
  81226. * * VertexBuffer.UV5Kind
  81227. * * VertexBuffer.UV6Kind
  81228. * * VertexBuffer.ColorKind
  81229. * * VertexBuffer.MatricesIndicesKind
  81230. * * VertexBuffer.MatricesIndicesExtraKind
  81231. * * VertexBuffer.MatricesWeightsKind
  81232. * * VertexBuffer.MatricesWeightsExtraKind
  81233. * @param data defines the data source
  81234. * @param updatable defines if the data must be flagged as updatable (or static)
  81235. * @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
  81236. * @returns the current mesh
  81237. */
  81238. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81239. return this;
  81240. };
  81241. /**
  81242. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81243. * If the mesh has no geometry, it is simply returned as it is.
  81244. * @param kind defines vertex data kind:
  81245. * * VertexBuffer.PositionKind
  81246. * * VertexBuffer.UVKind
  81247. * * VertexBuffer.UV2Kind
  81248. * * VertexBuffer.UV3Kind
  81249. * * VertexBuffer.UV4Kind
  81250. * * VertexBuffer.UV5Kind
  81251. * * VertexBuffer.UV6Kind
  81252. * * VertexBuffer.ColorKind
  81253. * * VertexBuffer.MatricesIndicesKind
  81254. * * VertexBuffer.MatricesIndicesExtraKind
  81255. * * VertexBuffer.MatricesWeightsKind
  81256. * * VertexBuffer.MatricesWeightsExtraKind
  81257. * @param data defines the data source
  81258. * @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
  81259. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81260. * @returns the current mesh
  81261. */
  81262. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  81263. return this;
  81264. };
  81265. /**
  81266. * Sets the mesh indices,
  81267. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81268. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81269. * @param totalVertices Defines the total number of vertices
  81270. * @returns the current mesh
  81271. */
  81272. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  81273. return this;
  81274. };
  81275. /**
  81276. * Gets a boolean indicating if specific vertex data is present
  81277. * @param kind defines the vertex data kind to use
  81278. * @returns true is data kind is present
  81279. */
  81280. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  81281. return false;
  81282. };
  81283. /**
  81284. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81285. * @returns a BoundingInfo
  81286. */
  81287. AbstractMesh.prototype.getBoundingInfo = function () {
  81288. if (this._masterMesh) {
  81289. return this._masterMesh.getBoundingInfo();
  81290. }
  81291. if (!this._boundingInfo) {
  81292. // this._boundingInfo is being created here
  81293. this._updateBoundingInfo();
  81294. }
  81295. // cannot be null.
  81296. return this._boundingInfo;
  81297. };
  81298. /**
  81299. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81300. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81301. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81302. * @returns the current mesh
  81303. */
  81304. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation) {
  81305. if (includeDescendants === void 0) { includeDescendants = true; }
  81306. if (ignoreRotation === void 0) { ignoreRotation = false; }
  81307. var storedRotation = null;
  81308. var storedRotationQuaternion = null;
  81309. if (ignoreRotation) {
  81310. if (this.rotationQuaternion) {
  81311. storedRotationQuaternion = this.rotationQuaternion.clone();
  81312. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
  81313. }
  81314. else if (this.rotation) {
  81315. storedRotation = this.rotation.clone();
  81316. this.rotation.copyFromFloats(0, 0, 0);
  81317. }
  81318. }
  81319. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  81320. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  81321. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  81322. if (maxDimension === 0) {
  81323. return this;
  81324. }
  81325. var scale = 1 / maxDimension;
  81326. this.scaling.scaleInPlace(scale);
  81327. if (ignoreRotation) {
  81328. if (this.rotationQuaternion && storedRotationQuaternion) {
  81329. this.rotationQuaternion.copyFrom(storedRotationQuaternion);
  81330. }
  81331. else if (this.rotation && storedRotation) {
  81332. this.rotation.copyFrom(storedRotation);
  81333. }
  81334. }
  81335. return this;
  81336. };
  81337. /**
  81338. * Overwrite the current bounding info
  81339. * @param boundingInfo defines the new bounding info
  81340. * @returns the current mesh
  81341. */
  81342. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  81343. this._boundingInfo = boundingInfo;
  81344. return this;
  81345. };
  81346. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  81347. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81348. get: function () {
  81349. 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));
  81350. },
  81351. enumerable: true,
  81352. configurable: true
  81353. });
  81354. /** @hidden */
  81355. AbstractMesh.prototype._preActivate = function () {
  81356. };
  81357. /** @hidden */
  81358. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  81359. };
  81360. /** @hidden */
  81361. AbstractMesh.prototype._activate = function (renderId) {
  81362. this._renderId = renderId;
  81363. };
  81364. /**
  81365. * Gets the current world matrix
  81366. * @returns a Matrix
  81367. */
  81368. AbstractMesh.prototype.getWorldMatrix = function () {
  81369. if (this._masterMesh) {
  81370. return this._masterMesh.getWorldMatrix();
  81371. }
  81372. return _super.prototype.getWorldMatrix.call(this);
  81373. };
  81374. /** @hidden */
  81375. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  81376. if (this._masterMesh) {
  81377. return this._masterMesh._getWorldMatrixDeterminant();
  81378. }
  81379. return _super.prototype._getWorldMatrixDeterminant.call(this);
  81380. };
  81381. // ================================== Point of View Movement =================================
  81382. /**
  81383. * Perform relative position change from the point of view of behind the front of the mesh.
  81384. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81385. * Supports definition of mesh facing forward or backward
  81386. * @param amountRight defines the distance on the right axis
  81387. * @param amountUp defines the distance on the up axis
  81388. * @param amountForward defines the distance on the forward axis
  81389. * @returns the current mesh
  81390. */
  81391. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  81392. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  81393. return this;
  81394. };
  81395. /**
  81396. * Calculate relative position change from the point of view of behind the front of the mesh.
  81397. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81398. * Supports definition of mesh facing forward or backward
  81399. * @param amountRight defines the distance on the right axis
  81400. * @param amountUp defines the distance on the up axis
  81401. * @param amountForward defines the distance on the forward axis
  81402. * @returns the new displacement vector
  81403. */
  81404. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  81405. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  81406. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  81407. rotQuaternion.toRotationMatrix(rotMatrix);
  81408. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81409. var defForwardMult = this.definedFacingForward ? -1 : 1;
  81410. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  81411. return translationDelta;
  81412. };
  81413. // ================================== Point of View Rotation =================================
  81414. /**
  81415. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81416. * Supports definition of mesh facing forward or backward
  81417. * @param flipBack defines the flip
  81418. * @param twirlClockwise defines the twirl
  81419. * @param tiltRight defines the tilt
  81420. * @returns the current mesh
  81421. */
  81422. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  81423. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  81424. return this;
  81425. };
  81426. /**
  81427. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81428. * Supports definition of mesh facing forward or backward.
  81429. * @param flipBack defines the flip
  81430. * @param twirlClockwise defines the twirl
  81431. * @param tiltRight defines the tilt
  81432. * @returns the new rotation vector
  81433. */
  81434. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  81435. var defForwardMult = this.definedFacingForward ? 1 : -1;
  81436. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  81437. };
  81438. /**
  81439. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81440. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81441. * @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
  81442. * @returns the new bounding vectors
  81443. */
  81444. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  81445. if (includeDescendants === void 0) { includeDescendants = true; }
  81446. if (predicate === void 0) { predicate = null; }
  81447. // Ensures that all world matrix will be recomputed.
  81448. this.getScene().incrementRenderId();
  81449. this.computeWorldMatrix(true);
  81450. var min;
  81451. var max;
  81452. var boundingInfo = this.getBoundingInfo();
  81453. if (!this.subMeshes) {
  81454. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  81455. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  81456. }
  81457. else {
  81458. min = boundingInfo.boundingBox.minimumWorld;
  81459. max = boundingInfo.boundingBox.maximumWorld;
  81460. }
  81461. if (includeDescendants) {
  81462. var descendants = this.getDescendants(false);
  81463. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  81464. var descendant = descendants_1[_i];
  81465. var childMesh = descendant;
  81466. childMesh.computeWorldMatrix(true);
  81467. // Filters meshes based on custom predicate function.
  81468. if (predicate && !predicate(childMesh)) {
  81469. continue;
  81470. }
  81471. //make sure we have the needed params to get mix and max
  81472. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  81473. continue;
  81474. }
  81475. var childBoundingInfo = childMesh.getBoundingInfo();
  81476. var boundingBox = childBoundingInfo.boundingBox;
  81477. var minBox = boundingBox.minimumWorld;
  81478. var maxBox = boundingBox.maximumWorld;
  81479. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  81480. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  81481. }
  81482. }
  81483. return {
  81484. min: min,
  81485. max: max
  81486. };
  81487. };
  81488. /**
  81489. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81490. * This means the mesh underlying bounding box and sphere are recomputed.
  81491. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81492. * @returns the current mesh
  81493. */
  81494. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  81495. if (applySkeleton === void 0) { applySkeleton = false; }
  81496. if (this._boundingInfo && this._boundingInfo.isLocked) {
  81497. return this;
  81498. }
  81499. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  81500. return this;
  81501. };
  81502. /** @hidden */
  81503. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  81504. if (data) {
  81505. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  81506. if (this._boundingInfo) {
  81507. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  81508. }
  81509. else {
  81510. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  81511. }
  81512. }
  81513. if (this.subMeshes) {
  81514. for (var index = 0; index < this.subMeshes.length; index++) {
  81515. this.subMeshes[index].refreshBoundingInfo();
  81516. }
  81517. }
  81518. this._updateBoundingInfo();
  81519. };
  81520. /** @hidden */
  81521. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  81522. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  81523. if (data && applySkeleton && this.skeleton) {
  81524. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  81525. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  81526. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  81527. if (matricesWeightsData && matricesIndicesData) {
  81528. var needExtras = this.numBoneInfluencers > 4;
  81529. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  81530. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  81531. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  81532. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  81533. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  81534. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  81535. var matWeightIdx = 0;
  81536. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  81537. finalMatrix.reset();
  81538. var inf;
  81539. var weight;
  81540. for (inf = 0; inf < 4; inf++) {
  81541. weight = matricesWeightsData[matWeightIdx + inf];
  81542. if (weight > 0) {
  81543. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  81544. finalMatrix.addToSelf(tempMatrix);
  81545. }
  81546. }
  81547. if (needExtras) {
  81548. for (inf = 0; inf < 4; inf++) {
  81549. weight = matricesWeightsExtraData[matWeightIdx + inf];
  81550. if (weight > 0) {
  81551. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  81552. finalMatrix.addToSelf(tempMatrix);
  81553. }
  81554. }
  81555. }
  81556. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  81557. tempVector.toArray(data, index);
  81558. }
  81559. }
  81560. }
  81561. return data;
  81562. };
  81563. /** @hidden */
  81564. AbstractMesh.prototype._updateBoundingInfo = function () {
  81565. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  81566. if (this._boundingInfo) {
  81567. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  81568. }
  81569. else {
  81570. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  81571. }
  81572. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  81573. return this;
  81574. };
  81575. /** @hidden */
  81576. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  81577. if (!this.subMeshes) {
  81578. return this;
  81579. }
  81580. var count = this.subMeshes.length;
  81581. for (var subIndex = 0; subIndex < count; subIndex++) {
  81582. var subMesh = this.subMeshes[subIndex];
  81583. if (count > 1 || !subMesh.IsGlobal) {
  81584. subMesh.updateBoundingInfo(matrix);
  81585. }
  81586. }
  81587. return this;
  81588. };
  81589. /** @hidden */
  81590. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  81591. // Bounding info
  81592. this._updateBoundingInfo();
  81593. };
  81594. /**
  81595. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81596. * A mesh is in the frustum if its bounding box intersects the frustum
  81597. * @param frustumPlanes defines the frustum to test
  81598. * @returns true if the mesh is in the frustum planes
  81599. */
  81600. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  81601. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  81602. };
  81603. /**
  81604. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81605. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81606. * @param frustumPlanes defines the frustum to test
  81607. * @returns true if the mesh is completely in the frustum planes
  81608. */
  81609. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  81610. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  81611. };
  81612. /**
  81613. * True if the mesh intersects another mesh or a SolidParticle object
  81614. * @param mesh defines a target mesh or SolidParticle to test
  81615. * @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)
  81616. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81617. * @returns true if there is an intersection
  81618. */
  81619. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  81620. if (precise === void 0) { precise = false; }
  81621. if (!this._boundingInfo || !mesh._boundingInfo) {
  81622. return false;
  81623. }
  81624. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  81625. return true;
  81626. }
  81627. if (includeDescendants) {
  81628. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  81629. var child = _a[_i];
  81630. if (child.intersectsMesh(mesh, precise, true)) {
  81631. return true;
  81632. }
  81633. }
  81634. }
  81635. return false;
  81636. };
  81637. /**
  81638. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81639. * @param point defines the point to test
  81640. * @returns true if there is an intersection
  81641. */
  81642. AbstractMesh.prototype.intersectsPoint = function (point) {
  81643. if (!this._boundingInfo) {
  81644. return false;
  81645. }
  81646. return this._boundingInfo.intersectsPoint(point);
  81647. };
  81648. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  81649. // Collisions
  81650. /**
  81651. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81653. */
  81654. get: function () {
  81655. return this._checkCollisions;
  81656. },
  81657. set: function (collisionEnabled) {
  81658. this._checkCollisions = collisionEnabled;
  81659. },
  81660. enumerable: true,
  81661. configurable: true
  81662. });
  81663. Object.defineProperty(AbstractMesh.prototype, "collider", {
  81664. /**
  81665. * Gets Collider object used to compute collisions (not physics)
  81666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81667. */
  81668. get: function () {
  81669. return this._collider;
  81670. },
  81671. enumerable: true,
  81672. configurable: true
  81673. });
  81674. /**
  81675. * Move the mesh using collision engine
  81676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81677. * @param displacement defines the requested displacement vector
  81678. * @returns the current mesh
  81679. */
  81680. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  81681. var globalPosition = this.getAbsolutePosition();
  81682. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  81683. var coordinator = this.getScene().collisionCoordinator;
  81684. if (!this._collider) {
  81685. this._collider = coordinator.createCollider();
  81686. }
  81687. this._collider._radius = this.ellipsoid;
  81688. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  81689. return this;
  81690. };
  81691. // Collisions
  81692. /** @hidden */
  81693. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  81694. this._generatePointsArray();
  81695. if (!this._positions) {
  81696. return this;
  81697. }
  81698. // Transformation
  81699. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  81700. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  81701. subMesh._lastColliderWorldVertices = [];
  81702. subMesh._trianglePlanes = [];
  81703. var start = subMesh.verticesStart;
  81704. var end = (subMesh.verticesStart + subMesh.verticesCount);
  81705. for (var i = start; i < end; i++) {
  81706. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  81707. }
  81708. }
  81709. // Collide
  81710. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  81711. if (collider.collisionFound) {
  81712. collider.collidedMesh = this;
  81713. }
  81714. return this;
  81715. };
  81716. /** @hidden */
  81717. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  81718. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  81719. var len = subMeshes.length;
  81720. for (var index = 0; index < len; index++) {
  81721. var subMesh = subMeshes.data[index];
  81722. // Bounding test
  81723. if (len > 1 && !subMesh._checkCollision(collider)) {
  81724. continue;
  81725. }
  81726. this._collideForSubMesh(subMesh, transformMatrix, collider);
  81727. }
  81728. return this;
  81729. };
  81730. /** @hidden */
  81731. AbstractMesh.prototype._checkCollision = function (collider) {
  81732. // Bounding box test
  81733. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  81734. return this;
  81735. }
  81736. // Transformation matrix
  81737. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  81738. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  81739. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  81740. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  81741. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  81742. return this;
  81743. };
  81744. // Picking
  81745. /** @hidden */
  81746. AbstractMesh.prototype._generatePointsArray = function () {
  81747. return false;
  81748. };
  81749. /**
  81750. * Checks if the passed Ray intersects with the mesh
  81751. * @param ray defines the ray to use
  81752. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81753. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81754. * @returns the picking info
  81755. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81756. */
  81757. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  81758. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  81759. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  81760. var boundingInfo = this._boundingInfo;
  81761. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  81762. return pickingInfo;
  81763. }
  81764. if (!this._generatePointsArray()) {
  81765. return pickingInfo;
  81766. }
  81767. var intersectInfo = null;
  81768. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  81769. var len = subMeshes.length;
  81770. for (var index = 0; index < len; index++) {
  81771. var subMesh = subMeshes.data[index];
  81772. // Bounding test
  81773. if (len > 1 && !subMesh.canIntersects(ray)) {
  81774. continue;
  81775. }
  81776. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  81777. if (currentIntersectInfo) {
  81778. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  81779. intersectInfo = currentIntersectInfo;
  81780. intersectInfo.subMeshId = index;
  81781. if (fastCheck) {
  81782. break;
  81783. }
  81784. }
  81785. }
  81786. }
  81787. if (intersectInfo) {
  81788. // Get picked point
  81789. var world = this.getWorldMatrix();
  81790. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  81791. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  81792. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  81793. ray.direction.scaleToRef(intersectInfo.distance, direction);
  81794. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  81795. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  81796. // Return result
  81797. pickingInfo.hit = true;
  81798. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  81799. pickingInfo.pickedPoint = pickedPoint;
  81800. pickingInfo.pickedMesh = this;
  81801. pickingInfo.bu = intersectInfo.bu || 0;
  81802. pickingInfo.bv = intersectInfo.bv || 0;
  81803. pickingInfo.faceId = intersectInfo.faceId;
  81804. pickingInfo.subMeshId = intersectInfo.subMeshId;
  81805. return pickingInfo;
  81806. }
  81807. return pickingInfo;
  81808. };
  81809. /**
  81810. * Clones the current mesh
  81811. * @param name defines the mesh name
  81812. * @param newParent defines the new mesh parent
  81813. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81814. * @returns the new mesh
  81815. */
  81816. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  81817. return null;
  81818. };
  81819. /**
  81820. * Disposes all the submeshes of the current meshnp
  81821. * @returns the current mesh
  81822. */
  81823. AbstractMesh.prototype.releaseSubMeshes = function () {
  81824. if (this.subMeshes) {
  81825. while (this.subMeshes.length) {
  81826. this.subMeshes[0].dispose();
  81827. }
  81828. }
  81829. else {
  81830. this.subMeshes = new Array();
  81831. }
  81832. return this;
  81833. };
  81834. /**
  81835. * Releases resources associated with this abstract mesh.
  81836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81838. */
  81839. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  81840. var _this = this;
  81841. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  81842. var index;
  81843. // Smart Array Retainers.
  81844. this.getScene().freeActiveMeshes();
  81845. this.getScene().freeRenderingGroups();
  81846. // Action manager
  81847. if (this.actionManager !== undefined && this.actionManager !== null) {
  81848. this.actionManager.dispose();
  81849. this.actionManager = null;
  81850. }
  81851. // Skeleton
  81852. this._skeleton = null;
  81853. // Intersections in progress
  81854. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  81855. var other = this._intersectionsInProgress[index];
  81856. var pos = other._intersectionsInProgress.indexOf(this);
  81857. other._intersectionsInProgress.splice(pos, 1);
  81858. }
  81859. this._intersectionsInProgress = [];
  81860. // Lights
  81861. var lights = this.getScene().lights;
  81862. lights.forEach(function (light) {
  81863. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  81864. if (meshIndex !== -1) {
  81865. light.includedOnlyMeshes.splice(meshIndex, 1);
  81866. }
  81867. meshIndex = light.excludedMeshes.indexOf(_this);
  81868. if (meshIndex !== -1) {
  81869. light.excludedMeshes.splice(meshIndex, 1);
  81870. }
  81871. // Shadow generators
  81872. var generator = light.getShadowGenerator();
  81873. if (generator) {
  81874. var shadowMap = generator.getShadowMap();
  81875. if (shadowMap && shadowMap.renderList) {
  81876. meshIndex = shadowMap.renderList.indexOf(_this);
  81877. if (meshIndex !== -1) {
  81878. shadowMap.renderList.splice(meshIndex, 1);
  81879. }
  81880. }
  81881. }
  81882. });
  81883. // SubMeshes
  81884. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  81885. this.releaseSubMeshes();
  81886. }
  81887. // Query
  81888. var engine = this.getScene().getEngine();
  81889. if (this._occlusionQuery) {
  81890. this.isOcclusionQueryInProgress = false;
  81891. engine.deleteQuery(this._occlusionQuery);
  81892. this._occlusionQuery = null;
  81893. }
  81894. // Engine
  81895. engine.wipeCaches();
  81896. // Remove from scene
  81897. this.getScene().removeMesh(this);
  81898. if (disposeMaterialAndTextures) {
  81899. if (this.material) {
  81900. if (this.material.getClassName() === "MultiMaterial") {
  81901. this.material.dispose(false, true, true);
  81902. }
  81903. else {
  81904. this.material.dispose(false, true);
  81905. }
  81906. }
  81907. }
  81908. if (!doNotRecurse) {
  81909. // Particles
  81910. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  81911. if (this.getScene().particleSystems[index].emitter === this) {
  81912. this.getScene().particleSystems[index].dispose();
  81913. index--;
  81914. }
  81915. }
  81916. }
  81917. // facet data
  81918. if (this._facetData.facetDataEnabled) {
  81919. this.disableFacetData();
  81920. }
  81921. this.onAfterWorldMatrixUpdateObservable.clear();
  81922. this.onCollideObservable.clear();
  81923. this.onCollisionPositionChangeObservable.clear();
  81924. this.onRebuildObservable.clear();
  81925. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  81926. };
  81927. /**
  81928. * Adds the passed mesh as a child to the current mesh
  81929. * @param mesh defines the child mesh
  81930. * @returns the current mesh
  81931. */
  81932. AbstractMesh.prototype.addChild = function (mesh) {
  81933. mesh.setParent(this);
  81934. return this;
  81935. };
  81936. /**
  81937. * Removes the passed mesh from the current mesh children list
  81938. * @param mesh defines the child mesh
  81939. * @returns the current mesh
  81940. */
  81941. AbstractMesh.prototype.removeChild = function (mesh) {
  81942. mesh.setParent(null);
  81943. return this;
  81944. };
  81945. // Facet data
  81946. /** @hidden */
  81947. AbstractMesh.prototype._initFacetData = function () {
  81948. var data = this._facetData;
  81949. if (!data.facetNormals) {
  81950. data.facetNormals = new Array();
  81951. }
  81952. if (!data.facetPositions) {
  81953. data.facetPositions = new Array();
  81954. }
  81955. if (!data.facetPartitioning) {
  81956. data.facetPartitioning = new Array();
  81957. }
  81958. data.facetNb = (this.getIndices().length / 3) | 0;
  81959. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  81960. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  81961. for (var f = 0; f < data.facetNb; f++) {
  81962. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81963. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81964. }
  81965. data.facetDataEnabled = true;
  81966. return this;
  81967. };
  81968. /**
  81969. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81970. * This method can be called within the render loop.
  81971. * 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
  81972. * @returns the current mesh
  81973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81974. */
  81975. AbstractMesh.prototype.updateFacetData = function () {
  81976. var data = this._facetData;
  81977. if (!data.facetDataEnabled) {
  81978. this._initFacetData();
  81979. }
  81980. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  81981. var indices = this.getIndices();
  81982. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  81983. var bInfo = this.getBoundingInfo();
  81984. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  81985. // init arrays, matrix and sort function on first call
  81986. data.facetDepthSortEnabled = true;
  81987. if (indices instanceof Uint16Array) {
  81988. data.depthSortedIndices = new Uint16Array(indices);
  81989. }
  81990. else if (indices instanceof Uint32Array) {
  81991. data.depthSortedIndices = new Uint32Array(indices);
  81992. }
  81993. else {
  81994. var needs32bits = false;
  81995. for (var i = 0; i < indices.length; i++) {
  81996. if (indices[i] > 65535) {
  81997. needs32bits = true;
  81998. break;
  81999. }
  82000. }
  82001. if (needs32bits) {
  82002. data.depthSortedIndices = new Uint32Array(indices);
  82003. }
  82004. else {
  82005. data.depthSortedIndices = new Uint16Array(indices);
  82006. }
  82007. }
  82008. data.facetDepthSortFunction = function (f1, f2) {
  82009. return (f2.sqDistance - f1.sqDistance);
  82010. };
  82011. if (!data.facetDepthSortFrom) {
  82012. var camera = this.getScene().activeCamera;
  82013. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82014. }
  82015. data.depthSortedFacets = [];
  82016. for (var f = 0; f < data.facetNb; f++) {
  82017. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  82018. data.depthSortedFacets.push(depthSortedFacet);
  82019. }
  82020. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  82021. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82022. }
  82023. 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"];
  82024. 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"];
  82025. 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"];
  82026. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  82027. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  82028. data.subDiv.max = data.partitioningSubdivisions;
  82029. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  82030. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  82031. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  82032. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  82033. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  82034. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  82035. // set the parameters for ComputeNormals()
  82036. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  82037. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  82038. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  82039. data.facetParameters.bInfo = bInfo;
  82040. data.facetParameters.bbSize = data.bbSize;
  82041. data.facetParameters.subDiv = data.subDiv;
  82042. data.facetParameters.ratio = this.partitioningBBoxRatio;
  82043. data.facetParameters.depthSort = data.facetDepthSort;
  82044. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  82045. this.computeWorldMatrix(true);
  82046. this._worldMatrix.invertToRef(data.invertedMatrix);
  82047. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  82048. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  82049. }
  82050. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  82051. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  82052. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  82053. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  82054. var l = (data.depthSortedIndices.length / 3) | 0;
  82055. for (var f = 0; f < l; f++) {
  82056. var sind = data.depthSortedFacets[f].ind;
  82057. data.depthSortedIndices[f * 3] = indices[sind];
  82058. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  82059. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  82060. }
  82061. this.updateIndices(data.depthSortedIndices, undefined, true);
  82062. }
  82063. return this;
  82064. };
  82065. /**
  82066. * Returns the facetLocalNormals array.
  82067. * The normals are expressed in the mesh local spac
  82068. * @returns an array of Vector3
  82069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82070. */
  82071. AbstractMesh.prototype.getFacetLocalNormals = function () {
  82072. if (!this._facetData.facetNormals) {
  82073. this.updateFacetData();
  82074. }
  82075. return this._facetData.facetNormals;
  82076. };
  82077. /**
  82078. * Returns the facetLocalPositions array.
  82079. * The facet positions are expressed in the mesh local space
  82080. * @returns an array of Vector3
  82081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82082. */
  82083. AbstractMesh.prototype.getFacetLocalPositions = function () {
  82084. if (!this._facetData.facetPositions) {
  82085. this.updateFacetData();
  82086. }
  82087. return this._facetData.facetPositions;
  82088. };
  82089. /**
  82090. * Returns the facetLocalPartioning array
  82091. * @returns an array of array of numbers
  82092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82093. */
  82094. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  82095. if (!this._facetData.facetPartitioning) {
  82096. this.updateFacetData();
  82097. }
  82098. return this._facetData.facetPartitioning;
  82099. };
  82100. /**
  82101. * Returns the i-th facet position in the world system.
  82102. * This method allocates a new Vector3 per call
  82103. * @param i defines the facet index
  82104. * @returns a new Vector3
  82105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82106. */
  82107. AbstractMesh.prototype.getFacetPosition = function (i) {
  82108. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82109. this.getFacetPositionToRef(i, pos);
  82110. return pos;
  82111. };
  82112. /**
  82113. * Sets the reference Vector3 with the i-th facet position in the world system
  82114. * @param i defines the facet index
  82115. * @param ref defines the target vector
  82116. * @returns the current mesh
  82117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82118. */
  82119. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  82120. var localPos = (this.getFacetLocalPositions())[i];
  82121. var world = this.getWorldMatrix();
  82122. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  82123. return this;
  82124. };
  82125. /**
  82126. * Returns the i-th facet normal in the world system.
  82127. * This method allocates a new Vector3 per call
  82128. * @param i defines the facet index
  82129. * @returns a new Vector3
  82130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82131. */
  82132. AbstractMesh.prototype.getFacetNormal = function (i) {
  82133. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82134. this.getFacetNormalToRef(i, norm);
  82135. return norm;
  82136. };
  82137. /**
  82138. * Sets the reference Vector3 with the i-th facet normal in the world system
  82139. * @param i defines the facet index
  82140. * @param ref defines the target vector
  82141. * @returns the current mesh
  82142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82143. */
  82144. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  82145. var localNorm = (this.getFacetLocalNormals())[i];
  82146. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  82147. return this;
  82148. };
  82149. /**
  82150. * 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)
  82151. * @param x defines x coordinate
  82152. * @param y defines y coordinate
  82153. * @param z defines z coordinate
  82154. * @returns the array of facet indexes
  82155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82156. */
  82157. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  82158. var bInfo = this.getBoundingInfo();
  82159. var data = this._facetData;
  82160. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  82161. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  82162. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  82163. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  82164. return null;
  82165. }
  82166. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  82167. };
  82168. /**
  82169. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82170. * @param projected sets as the (x,y,z) world projection on the facet
  82171. * @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
  82172. * @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
  82173. * @param x defines x coordinate
  82174. * @param y defines y coordinate
  82175. * @param z defines z coordinate
  82176. * @returns the face index if found (or null instead)
  82177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82178. */
  82179. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  82180. if (checkFace === void 0) { checkFace = false; }
  82181. if (facing === void 0) { facing = true; }
  82182. var world = this.getWorldMatrix();
  82183. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  82184. world.invertToRef(invMat);
  82185. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  82186. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  82187. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  82188. if (projected) {
  82189. // tranform the local computed projected vector to world coordinates
  82190. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  82191. }
  82192. return closest;
  82193. };
  82194. /**
  82195. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82196. * @param projected sets as the (x,y,z) local projection on the facet
  82197. * @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
  82198. * @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
  82199. * @param x defines x coordinate
  82200. * @param y defines y coordinate
  82201. * @param z defines z coordinate
  82202. * @returns the face index if found (or null instead)
  82203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82204. */
  82205. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  82206. if (checkFace === void 0) { checkFace = false; }
  82207. if (facing === void 0) { facing = true; }
  82208. var closest = null;
  82209. var tmpx = 0.0;
  82210. var tmpy = 0.0;
  82211. var tmpz = 0.0;
  82212. var d = 0.0; // tmp dot facet normal * facet position
  82213. var t0 = 0.0;
  82214. var projx = 0.0;
  82215. var projy = 0.0;
  82216. var projz = 0.0;
  82217. // Get all the facets in the same partitioning block than (x, y, z)
  82218. var facetPositions = this.getFacetLocalPositions();
  82219. var facetNormals = this.getFacetLocalNormals();
  82220. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  82221. if (!facetsInBlock) {
  82222. return null;
  82223. }
  82224. // Get the closest facet to (x, y, z)
  82225. var shortest = Number.MAX_VALUE; // init distance vars
  82226. var tmpDistance = shortest;
  82227. var fib; // current facet in the block
  82228. var norm; // current facet normal
  82229. var p0; // current facet barycenter position
  82230. // loop on all the facets in the current partitioning block
  82231. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  82232. fib = facetsInBlock[idx];
  82233. norm = facetNormals[fib];
  82234. p0 = facetPositions[fib];
  82235. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  82236. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  82237. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  82238. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  82239. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  82240. projx = x + norm.x * t0;
  82241. projy = y + norm.y * t0;
  82242. projz = z + norm.z * t0;
  82243. tmpx = projx - x;
  82244. tmpy = projy - y;
  82245. tmpz = projz - z;
  82246. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  82247. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  82248. shortest = tmpDistance;
  82249. closest = fib;
  82250. if (projected) {
  82251. projected.x = projx;
  82252. projected.y = projy;
  82253. projected.z = projz;
  82254. }
  82255. }
  82256. }
  82257. }
  82258. return closest;
  82259. };
  82260. /**
  82261. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82262. * @returns the parameters
  82263. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82264. */
  82265. AbstractMesh.prototype.getFacetDataParameters = function () {
  82266. return this._facetData.facetParameters;
  82267. };
  82268. /**
  82269. * Disables the feature FacetData and frees the related memory
  82270. * @returns the current mesh
  82271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82272. */
  82273. AbstractMesh.prototype.disableFacetData = function () {
  82274. if (this._facetData.facetDataEnabled) {
  82275. this._facetData.facetDataEnabled = false;
  82276. this._facetData.facetPositions = new Array();
  82277. this._facetData.facetNormals = new Array();
  82278. this._facetData.facetPartitioning = new Array();
  82279. this._facetData.facetParameters = null;
  82280. this._facetData.depthSortedIndices = new Uint32Array(0);
  82281. }
  82282. return this;
  82283. };
  82284. /**
  82285. * Updates the AbstractMesh indices array
  82286. * @param indices defines the data source
  82287. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  82288. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  82289. * @returns the current mesh
  82290. */
  82291. AbstractMesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  82292. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  82293. return this;
  82294. };
  82295. /**
  82296. * Creates new normals data for the mesh
  82297. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82298. * @returns the current mesh
  82299. */
  82300. AbstractMesh.prototype.createNormals = function (updatable) {
  82301. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  82302. var indices = this.getIndices();
  82303. var normals;
  82304. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  82305. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  82306. }
  82307. else {
  82308. normals = [];
  82309. }
  82310. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  82311. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  82312. return this;
  82313. };
  82314. /**
  82315. * Align the mesh with a normal
  82316. * @param normal defines the normal to use
  82317. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82318. * @returns the current mesh
  82319. */
  82320. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  82321. if (!upDirection) {
  82322. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  82323. }
  82324. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  82325. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  82326. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  82327. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  82328. if (this.rotationQuaternion) {
  82329. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  82330. }
  82331. else {
  82332. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  82333. }
  82334. return this;
  82335. };
  82336. /** @hidden */
  82337. AbstractMesh.prototype._checkOcclusionQuery = function () {
  82338. return false;
  82339. };
  82340. /** No occlusion */
  82341. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  82342. /** Occlusion set to optimisitic */
  82343. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  82344. /** Occlusion set to strict */
  82345. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  82346. /** Use an accurante occlusion algorithm */
  82347. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  82348. /** Use a conservative occlusion algorithm */
  82349. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  82350. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82351. * Test order :
  82352. * Is the bounding sphere outside the frustum ?
  82353. * If not, are the bounding box vertices outside the frustum ?
  82354. * It not, then the cullable object is in the frustum.
  82355. */
  82356. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  82357. /** Culling strategy : Bounding Sphere Only.
  82358. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82359. * It's also less accurate than the standard because some not visible objects can still be selected.
  82360. * Test : is the bounding sphere outside the frustum ?
  82361. * If not, then the cullable object is in the frustum.
  82362. */
  82363. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  82364. /** Culling strategy : Optimistic Inclusion.
  82365. * This in an inclusion test first, then the standard exclusion test.
  82366. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82367. * 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.
  82368. * Anyway, it's as accurate as the standard strategy.
  82369. * Test :
  82370. * Is the cullable object bounding sphere center in the frustum ?
  82371. * If not, apply the default culling strategy.
  82372. */
  82373. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  82374. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82375. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82376. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82377. * 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.
  82378. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82379. * Test :
  82380. * Is the cullable object bounding sphere center in the frustum ?
  82381. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82382. */
  82383. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  82384. return AbstractMesh;
  82385. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  82386. /***/ }),
  82387. /***/ "./Meshes/buffer.ts":
  82388. /*!**************************!*\
  82389. !*** ./Meshes/buffer.ts ***!
  82390. \**************************/
  82391. /*! exports provided: Buffer, VertexBuffer */
  82392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82393. "use strict";
  82394. __webpack_require__.r(__webpack_exports__);
  82395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  82396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  82397. /**
  82398. * Class used to store data that will be store in GPU memory
  82399. */
  82400. var Buffer = /** @class */ (function () {
  82401. /**
  82402. * Constructor
  82403. * @param engine the engine
  82404. * @param data the data to use for this buffer
  82405. * @param updatable whether the data is updatable
  82406. * @param stride the stride (optional)
  82407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82408. * @param instanced whether the buffer is instanced (optional)
  82409. * @param useBytes set to true if the stride in in bytes (optional)
  82410. */
  82411. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  82412. if (stride === void 0) { stride = 0; }
  82413. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  82414. if (instanced === void 0) { instanced = false; }
  82415. if (useBytes === void 0) { useBytes = false; }
  82416. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  82417. this._engine = engine.getScene().getEngine();
  82418. }
  82419. else {
  82420. this._engine = engine;
  82421. }
  82422. this._updatable = updatable;
  82423. this._instanced = instanced;
  82424. this._data = data;
  82425. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  82426. if (!postponeInternalCreation) { // by default
  82427. this.create();
  82428. }
  82429. }
  82430. /**
  82431. * Create a new VertexBuffer based on the current buffer
  82432. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82433. * @param offset defines offset in the buffer (0 by default)
  82434. * @param size defines the size in floats of attributes (position is 3 for instance)
  82435. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82436. * @param instanced defines if the vertex buffer contains indexed data
  82437. * @param useBytes defines if the offset and stride are in bytes
  82438. * @returns the new vertex buffer
  82439. */
  82440. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  82441. if (useBytes === void 0) { useBytes = false; }
  82442. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  82443. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  82444. // a lot of these parameters are ignored as they are overriden by the buffer
  82445. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  82446. };
  82447. // Properties
  82448. /**
  82449. * Gets a boolean indicating if the Buffer is updatable?
  82450. * @returns true if the buffer is updatable
  82451. */
  82452. Buffer.prototype.isUpdatable = function () {
  82453. return this._updatable;
  82454. };
  82455. /**
  82456. * Gets current buffer's data
  82457. * @returns a DataArray or null
  82458. */
  82459. Buffer.prototype.getData = function () {
  82460. return this._data;
  82461. };
  82462. /**
  82463. * Gets underlying native buffer
  82464. * @returns underlying native buffer
  82465. */
  82466. Buffer.prototype.getBuffer = function () {
  82467. return this._buffer;
  82468. };
  82469. /**
  82470. * Gets the stride in float32 units (i.e. byte stride / 4).
  82471. * May not be an integer if the byte stride is not divisible by 4.
  82472. * DEPRECATED. Use byteStride instead.
  82473. * @returns the stride in float32 units
  82474. */
  82475. Buffer.prototype.getStrideSize = function () {
  82476. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  82477. };
  82478. // Methods
  82479. /**
  82480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82481. * @param data defines the data to store
  82482. */
  82483. Buffer.prototype.create = function (data) {
  82484. if (data === void 0) { data = null; }
  82485. if (!data && this._buffer) {
  82486. return; // nothing to do
  82487. }
  82488. data = data || this._data;
  82489. if (!data) {
  82490. return;
  82491. }
  82492. if (!this._buffer) { // create buffer
  82493. if (this._updatable) {
  82494. this._buffer = this._engine.createDynamicVertexBuffer(data);
  82495. this._data = data;
  82496. }
  82497. else {
  82498. this._buffer = this._engine.createVertexBuffer(data);
  82499. }
  82500. }
  82501. else if (this._updatable) { // update buffer
  82502. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  82503. this._data = data;
  82504. }
  82505. };
  82506. /** @hidden */
  82507. Buffer.prototype._rebuild = function () {
  82508. this._buffer = null;
  82509. this.create(this._data);
  82510. };
  82511. /**
  82512. * Update current buffer data
  82513. * @param data defines the data to store
  82514. */
  82515. Buffer.prototype.update = function (data) {
  82516. this.create(data);
  82517. };
  82518. /**
  82519. * Updates the data directly.
  82520. * @param data the new data
  82521. * @param offset the new offset
  82522. * @param vertexCount the vertex count (optional)
  82523. * @param useBytes set to true if the offset is in bytes
  82524. */
  82525. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  82526. if (useBytes === void 0) { useBytes = false; }
  82527. if (!this._buffer) {
  82528. return;
  82529. }
  82530. if (this._updatable) { // update buffer
  82531. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  82532. this._data = null;
  82533. }
  82534. };
  82535. /**
  82536. * Release all resources
  82537. */
  82538. Buffer.prototype.dispose = function () {
  82539. if (!this._buffer) {
  82540. return;
  82541. }
  82542. if (this._engine._releaseBuffer(this._buffer)) {
  82543. this._buffer = null;
  82544. }
  82545. };
  82546. return Buffer;
  82547. }());
  82548. /**
  82549. * Specialized buffer used to store vertex data
  82550. */
  82551. var VertexBuffer = /** @class */ (function () {
  82552. /**
  82553. * Constructor
  82554. * @param engine the engine
  82555. * @param data the data to use for this vertex buffer
  82556. * @param kind the vertex buffer kind
  82557. * @param updatable whether the data is updatable
  82558. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82559. * @param stride the stride (optional)
  82560. * @param instanced whether the buffer is instanced (optional)
  82561. * @param offset the offset of the data (optional)
  82562. * @param size the number of components (optional)
  82563. * @param type the type of the component (optional)
  82564. * @param normalized whether the data contains normalized data (optional)
  82565. * @param useBytes set to true if stride and offset are in bytes (optional)
  82566. */
  82567. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  82568. if (normalized === void 0) { normalized = false; }
  82569. if (useBytes === void 0) { useBytes = false; }
  82570. if (data instanceof Buffer) {
  82571. this._buffer = data;
  82572. this._ownsBuffer = false;
  82573. }
  82574. else {
  82575. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  82576. this._ownsBuffer = true;
  82577. }
  82578. this._kind = kind;
  82579. if (type == undefined) {
  82580. var data_1 = this.getData();
  82581. this.type = VertexBuffer.FLOAT;
  82582. if (data_1 instanceof Int8Array) {
  82583. this.type = VertexBuffer.BYTE;
  82584. }
  82585. else if (data_1 instanceof Uint8Array) {
  82586. this.type = VertexBuffer.UNSIGNED_BYTE;
  82587. }
  82588. else if (data_1 instanceof Int16Array) {
  82589. this.type = VertexBuffer.SHORT;
  82590. }
  82591. else if (data_1 instanceof Uint16Array) {
  82592. this.type = VertexBuffer.UNSIGNED_SHORT;
  82593. }
  82594. else if (data_1 instanceof Int32Array) {
  82595. this.type = VertexBuffer.INT;
  82596. }
  82597. else if (data_1 instanceof Uint32Array) {
  82598. this.type = VertexBuffer.UNSIGNED_INT;
  82599. }
  82600. }
  82601. else {
  82602. this.type = type;
  82603. }
  82604. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  82605. if (useBytes) {
  82606. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  82607. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  82608. this.byteOffset = offset || 0;
  82609. }
  82610. else {
  82611. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  82612. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  82613. this.byteOffset = (offset || 0) * typeByteLength;
  82614. }
  82615. this.normalized = normalized;
  82616. this._instanced = instanced !== undefined ? instanced : false;
  82617. this._instanceDivisor = instanced ? 1 : 0;
  82618. }
  82619. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  82620. /**
  82621. * Gets or sets the instance divisor when in instanced mode
  82622. */
  82623. get: function () {
  82624. return this._instanceDivisor;
  82625. },
  82626. set: function (value) {
  82627. this._instanceDivisor = value;
  82628. if (value == 0) {
  82629. this._instanced = false;
  82630. }
  82631. else {
  82632. this._instanced = true;
  82633. }
  82634. },
  82635. enumerable: true,
  82636. configurable: true
  82637. });
  82638. /** @hidden */
  82639. VertexBuffer.prototype._rebuild = function () {
  82640. if (!this._buffer) {
  82641. return;
  82642. }
  82643. this._buffer._rebuild();
  82644. };
  82645. /**
  82646. * Returns the kind of the VertexBuffer (string)
  82647. * @returns a string
  82648. */
  82649. VertexBuffer.prototype.getKind = function () {
  82650. return this._kind;
  82651. };
  82652. // Properties
  82653. /**
  82654. * Gets a boolean indicating if the VertexBuffer is updatable?
  82655. * @returns true if the buffer is updatable
  82656. */
  82657. VertexBuffer.prototype.isUpdatable = function () {
  82658. return this._buffer.isUpdatable();
  82659. };
  82660. /**
  82661. * Gets current buffer's data
  82662. * @returns a DataArray or null
  82663. */
  82664. VertexBuffer.prototype.getData = function () {
  82665. return this._buffer.getData();
  82666. };
  82667. /**
  82668. * Gets underlying native buffer
  82669. * @returns underlying native buffer
  82670. */
  82671. VertexBuffer.prototype.getBuffer = function () {
  82672. return this._buffer.getBuffer();
  82673. };
  82674. /**
  82675. * Gets the stride in float32 units (i.e. byte stride / 4).
  82676. * May not be an integer if the byte stride is not divisible by 4.
  82677. * DEPRECATED. Use byteStride instead.
  82678. * @returns the stride in float32 units
  82679. */
  82680. VertexBuffer.prototype.getStrideSize = function () {
  82681. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  82682. };
  82683. /**
  82684. * Returns the offset as a multiple of the type byte length.
  82685. * DEPRECATED. Use byteOffset instead.
  82686. * @returns the offset in bytes
  82687. */
  82688. VertexBuffer.prototype.getOffset = function () {
  82689. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  82690. };
  82691. /**
  82692. * Returns the number of components per vertex attribute (integer)
  82693. * @returns the size in float
  82694. */
  82695. VertexBuffer.prototype.getSize = function () {
  82696. return this._size;
  82697. };
  82698. /**
  82699. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82700. * @returns true if this buffer is instanced
  82701. */
  82702. VertexBuffer.prototype.getIsInstanced = function () {
  82703. return this._instanced;
  82704. };
  82705. /**
  82706. * Returns the instancing divisor, zero for non-instanced (integer).
  82707. * @returns a number
  82708. */
  82709. VertexBuffer.prototype.getInstanceDivisor = function () {
  82710. return this._instanceDivisor;
  82711. };
  82712. // Methods
  82713. /**
  82714. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82715. * @param data defines the data to store
  82716. */
  82717. VertexBuffer.prototype.create = function (data) {
  82718. this._buffer.create(data);
  82719. };
  82720. /**
  82721. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82722. * This function will create a new buffer if the current one is not updatable
  82723. * @param data defines the data to store
  82724. */
  82725. VertexBuffer.prototype.update = function (data) {
  82726. this._buffer.update(data);
  82727. };
  82728. /**
  82729. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82730. * Returns the directly updated WebGLBuffer.
  82731. * @param data the new data
  82732. * @param offset the new offset
  82733. * @param useBytes set to true if the offset is in bytes
  82734. */
  82735. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  82736. if (useBytes === void 0) { useBytes = false; }
  82737. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  82738. };
  82739. /**
  82740. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82741. */
  82742. VertexBuffer.prototype.dispose = function () {
  82743. if (this._ownsBuffer) {
  82744. this._buffer.dispose();
  82745. }
  82746. };
  82747. /**
  82748. * Enumerates each value of this vertex buffer as numbers.
  82749. * @param count the number of values to enumerate
  82750. * @param callback the callback function called for each value
  82751. */
  82752. VertexBuffer.prototype.forEach = function (count, callback) {
  82753. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  82754. };
  82755. /**
  82756. * Deduces the stride given a kind.
  82757. * @param kind The kind string to deduce
  82758. * @returns The deduced stride
  82759. */
  82760. VertexBuffer.DeduceStride = function (kind) {
  82761. switch (kind) {
  82762. case VertexBuffer.UVKind:
  82763. case VertexBuffer.UV2Kind:
  82764. case VertexBuffer.UV3Kind:
  82765. case VertexBuffer.UV4Kind:
  82766. case VertexBuffer.UV5Kind:
  82767. case VertexBuffer.UV6Kind:
  82768. return 2;
  82769. case VertexBuffer.NormalKind:
  82770. case VertexBuffer.PositionKind:
  82771. return 3;
  82772. case VertexBuffer.ColorKind:
  82773. case VertexBuffer.MatricesIndicesKind:
  82774. case VertexBuffer.MatricesIndicesExtraKind:
  82775. case VertexBuffer.MatricesWeightsKind:
  82776. case VertexBuffer.MatricesWeightsExtraKind:
  82777. case VertexBuffer.TangentKind:
  82778. return 4;
  82779. default:
  82780. throw new Error("Invalid kind '" + kind + "'");
  82781. }
  82782. };
  82783. /**
  82784. * Gets the byte length of the given type.
  82785. * @param type the type
  82786. * @returns the number of bytes
  82787. */
  82788. VertexBuffer.GetTypeByteLength = function (type) {
  82789. switch (type) {
  82790. case VertexBuffer.BYTE:
  82791. case VertexBuffer.UNSIGNED_BYTE:
  82792. return 1;
  82793. case VertexBuffer.SHORT:
  82794. case VertexBuffer.UNSIGNED_SHORT:
  82795. return 2;
  82796. case VertexBuffer.INT:
  82797. case VertexBuffer.FLOAT:
  82798. return 4;
  82799. default:
  82800. throw new Error("Invalid type '" + type + "'");
  82801. }
  82802. };
  82803. /**
  82804. * Enumerates each value of the given parameters as numbers.
  82805. * @param data the data to enumerate
  82806. * @param byteOffset the byte offset of the data
  82807. * @param byteStride the byte stride of the data
  82808. * @param componentCount the number of components per element
  82809. * @param componentType the type of the component
  82810. * @param count the total number of components
  82811. * @param normalized whether the data is normalized
  82812. * @param callback the callback function called for each value
  82813. */
  82814. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  82815. if (data instanceof Array) {
  82816. var offset = byteOffset / 4;
  82817. var stride = byteStride / 4;
  82818. for (var index = 0; index < count; index += componentCount) {
  82819. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  82820. callback(data[offset + componentIndex], index + componentIndex);
  82821. }
  82822. offset += stride;
  82823. }
  82824. }
  82825. else {
  82826. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  82827. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  82828. for (var index = 0; index < count; index += componentCount) {
  82829. var componentByteOffset = byteOffset;
  82830. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  82831. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  82832. callback(value, index + componentIndex);
  82833. componentByteOffset += componentByteLength;
  82834. }
  82835. byteOffset += byteStride;
  82836. }
  82837. }
  82838. };
  82839. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  82840. switch (type) {
  82841. case VertexBuffer.BYTE: {
  82842. var value = dataView.getInt8(byteOffset);
  82843. if (normalized) {
  82844. value = Math.max(value / 127, -1);
  82845. }
  82846. return value;
  82847. }
  82848. case VertexBuffer.UNSIGNED_BYTE: {
  82849. var value = dataView.getUint8(byteOffset);
  82850. if (normalized) {
  82851. value = value / 255;
  82852. }
  82853. return value;
  82854. }
  82855. case VertexBuffer.SHORT: {
  82856. var value = dataView.getInt16(byteOffset, true);
  82857. if (normalized) {
  82858. value = Math.max(value / 16383, -1);
  82859. }
  82860. return value;
  82861. }
  82862. case VertexBuffer.UNSIGNED_SHORT: {
  82863. var value = dataView.getUint16(byteOffset, true);
  82864. if (normalized) {
  82865. value = value / 65535;
  82866. }
  82867. return value;
  82868. }
  82869. case VertexBuffer.FLOAT: {
  82870. return dataView.getFloat32(byteOffset, true);
  82871. }
  82872. default: {
  82873. throw new Error("Invalid component type " + type);
  82874. }
  82875. }
  82876. };
  82877. /**
  82878. * The byte type.
  82879. */
  82880. VertexBuffer.BYTE = 5120;
  82881. /**
  82882. * The unsigned byte type.
  82883. */
  82884. VertexBuffer.UNSIGNED_BYTE = 5121;
  82885. /**
  82886. * The short type.
  82887. */
  82888. VertexBuffer.SHORT = 5122;
  82889. /**
  82890. * The unsigned short type.
  82891. */
  82892. VertexBuffer.UNSIGNED_SHORT = 5123;
  82893. /**
  82894. * The integer type.
  82895. */
  82896. VertexBuffer.INT = 5124;
  82897. /**
  82898. * The unsigned integer type.
  82899. */
  82900. VertexBuffer.UNSIGNED_INT = 5125;
  82901. /**
  82902. * The float type.
  82903. */
  82904. VertexBuffer.FLOAT = 5126;
  82905. // Enums
  82906. /**
  82907. * Positions
  82908. */
  82909. VertexBuffer.PositionKind = "position";
  82910. /**
  82911. * Normals
  82912. */
  82913. VertexBuffer.NormalKind = "normal";
  82914. /**
  82915. * Tangents
  82916. */
  82917. VertexBuffer.TangentKind = "tangent";
  82918. /**
  82919. * Texture coordinates
  82920. */
  82921. VertexBuffer.UVKind = "uv";
  82922. /**
  82923. * Texture coordinates 2
  82924. */
  82925. VertexBuffer.UV2Kind = "uv2";
  82926. /**
  82927. * Texture coordinates 3
  82928. */
  82929. VertexBuffer.UV3Kind = "uv3";
  82930. /**
  82931. * Texture coordinates 4
  82932. */
  82933. VertexBuffer.UV4Kind = "uv4";
  82934. /**
  82935. * Texture coordinates 5
  82936. */
  82937. VertexBuffer.UV5Kind = "uv5";
  82938. /**
  82939. * Texture coordinates 6
  82940. */
  82941. VertexBuffer.UV6Kind = "uv6";
  82942. /**
  82943. * Colors
  82944. */
  82945. VertexBuffer.ColorKind = "color";
  82946. /**
  82947. * Matrix indices (for bones)
  82948. */
  82949. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  82950. /**
  82951. * Matrix weights (for bones)
  82952. */
  82953. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  82954. /**
  82955. * Additional matrix indices (for bones)
  82956. */
  82957. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  82958. /**
  82959. * Additional matrix weights (for bones)
  82960. */
  82961. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  82962. return VertexBuffer;
  82963. }());
  82964. /***/ }),
  82965. /***/ "./Meshes/csg.ts":
  82966. /*!***********************!*\
  82967. !*** ./Meshes/csg.ts ***!
  82968. \***********************/
  82969. /*! exports provided: CSG */
  82970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82971. "use strict";
  82972. __webpack_require__.r(__webpack_exports__);
  82973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  82974. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82975. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82976. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  82977. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82978. /**
  82979. * Unique ID when we import meshes from Babylon to CSG
  82980. */
  82981. var currentCSGMeshId = 0;
  82982. /**
  82983. * Represents a vertex of a polygon. Use your own vertex class instead of this
  82984. * one to provide additional features like texture coordinates and vertex
  82985. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  82986. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  82987. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  82988. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  82989. * is not used anywhere else.
  82990. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  82991. */
  82992. var Vertex = /** @class */ (function () {
  82993. /**
  82994. * Initializes the vertex
  82995. * @param pos The position of the vertex
  82996. * @param normal The normal of the vertex
  82997. * @param uv The texture coordinate of the vertex
  82998. */
  82999. function Vertex(
  83000. /**
  83001. * The position of the vertex
  83002. */
  83003. pos,
  83004. /**
  83005. * The normal of the vertex
  83006. */
  83007. normal,
  83008. /**
  83009. * The texture coordinate of the vertex
  83010. */
  83011. uv) {
  83012. this.pos = pos;
  83013. this.normal = normal;
  83014. this.uv = uv;
  83015. }
  83016. /**
  83017. * Make a clone, or deep copy, of the vertex
  83018. * @returns A new Vertex
  83019. */
  83020. Vertex.prototype.clone = function () {
  83021. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  83022. };
  83023. /**
  83024. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  83025. * orientation of a polygon is flipped.
  83026. */
  83027. Vertex.prototype.flip = function () {
  83028. this.normal = this.normal.scale(-1);
  83029. };
  83030. /**
  83031. * Create a new vertex between this vertex and `other` by linearly
  83032. * interpolating all properties using a parameter of `t`. Subclasses should
  83033. * override this to interpolate additional properties.
  83034. * @param other the vertex to interpolate against
  83035. * @param t The factor used to linearly interpolate between the vertices
  83036. */
  83037. Vertex.prototype.interpolate = function (other, t) {
  83038. 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));
  83039. };
  83040. return Vertex;
  83041. }());
  83042. /**
  83043. * Represents a plane in 3D space.
  83044. */
  83045. var Plane = /** @class */ (function () {
  83046. /**
  83047. * Initializes the plane
  83048. * @param normal The normal for the plane
  83049. * @param w
  83050. */
  83051. function Plane(normal, w) {
  83052. this.normal = normal;
  83053. this.w = w;
  83054. }
  83055. /**
  83056. * Construct a plane from three points
  83057. * @param a Point a
  83058. * @param b Point b
  83059. * @param c Point c
  83060. */
  83061. Plane.FromPoints = function (a, b, c) {
  83062. var v0 = c.subtract(a);
  83063. var v1 = b.subtract(a);
  83064. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  83065. return null;
  83066. }
  83067. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  83068. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  83069. };
  83070. /**
  83071. * Clone, or make a deep copy of the plane
  83072. * @returns a new Plane
  83073. */
  83074. Plane.prototype.clone = function () {
  83075. return new Plane(this.normal.clone(), this.w);
  83076. };
  83077. /**
  83078. * Flip the face of the plane
  83079. */
  83080. Plane.prototype.flip = function () {
  83081. this.normal.scaleInPlace(-1);
  83082. this.w = -this.w;
  83083. };
  83084. /**
  83085. * Split `polygon` by this plane if needed, then put the polygon or polygon
  83086. * fragments in the appropriate lists. Coplanar polygons go into either
  83087. `* coplanarFront` or `coplanarBack` depending on their orientation with
  83088. * respect to this plane. Polygons in front or in back of this plane go into
  83089. * either `front` or `back`
  83090. * @param polygon The polygon to be split
  83091. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  83092. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  83093. * @param front Will contain the polygons in front of the plane
  83094. * @param back Will contain the polygons begind the plane
  83095. */
  83096. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  83097. var COPLANAR = 0;
  83098. var FRONT = 1;
  83099. var BACK = 2;
  83100. var SPANNING = 3;
  83101. // Classify each point as well as the entire polygon into one of the above
  83102. // four classes.
  83103. var polygonType = 0;
  83104. var types = [];
  83105. var i;
  83106. var t;
  83107. for (i = 0; i < polygon.vertices.length; i++) {
  83108. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  83109. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  83110. polygonType |= type;
  83111. types.push(type);
  83112. }
  83113. // Put the polygon in the correct list, splitting it when necessary
  83114. switch (polygonType) {
  83115. case COPLANAR:
  83116. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  83117. break;
  83118. case FRONT:
  83119. front.push(polygon);
  83120. break;
  83121. case BACK:
  83122. back.push(polygon);
  83123. break;
  83124. case SPANNING:
  83125. var f = [], b = [];
  83126. for (i = 0; i < polygon.vertices.length; i++) {
  83127. var j = (i + 1) % polygon.vertices.length;
  83128. var ti = types[i], tj = types[j];
  83129. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  83130. if (ti !== BACK) {
  83131. f.push(vi);
  83132. }
  83133. if (ti !== FRONT) {
  83134. b.push(ti !== BACK ? vi.clone() : vi);
  83135. }
  83136. if ((ti | tj) === SPANNING) {
  83137. 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));
  83138. var v = vi.interpolate(vj, t);
  83139. f.push(v);
  83140. b.push(v.clone());
  83141. }
  83142. }
  83143. var poly;
  83144. if (f.length >= 3) {
  83145. poly = new Polygon(f, polygon.shared);
  83146. if (poly.plane) {
  83147. front.push(poly);
  83148. }
  83149. }
  83150. if (b.length >= 3) {
  83151. poly = new Polygon(b, polygon.shared);
  83152. if (poly.plane) {
  83153. back.push(poly);
  83154. }
  83155. }
  83156. break;
  83157. }
  83158. };
  83159. /**
  83160. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  83161. * point is on the plane
  83162. */
  83163. Plane.EPSILON = 1e-5;
  83164. return Plane;
  83165. }());
  83166. /**
  83167. * Represents a convex polygon. The vertices used to initialize a polygon must
  83168. * be coplanar and form a convex loop.
  83169. *
  83170. * Each convex polygon has a `shared` property, which is shared between all
  83171. * polygons that are clones of each other or were split from the same polygon.
  83172. * This can be used to define per-polygon properties (such as surface color)
  83173. */
  83174. var Polygon = /** @class */ (function () {
  83175. /**
  83176. * Initializes the polygon
  83177. * @param vertices The vertices of the polygon
  83178. * @param shared The properties shared across all polygons
  83179. */
  83180. function Polygon(vertices, shared) {
  83181. this.vertices = vertices;
  83182. this.shared = shared;
  83183. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  83184. }
  83185. /**
  83186. * Clones, or makes a deep copy, or the polygon
  83187. */
  83188. Polygon.prototype.clone = function () {
  83189. var vertices = this.vertices.map(function (v) { return v.clone(); });
  83190. return new Polygon(vertices, this.shared);
  83191. };
  83192. /**
  83193. * Flips the faces of the polygon
  83194. */
  83195. Polygon.prototype.flip = function () {
  83196. this.vertices.reverse().map(function (v) { v.flip(); });
  83197. this.plane.flip();
  83198. };
  83199. return Polygon;
  83200. }());
  83201. /**
  83202. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  83203. * by picking a polygon to split along. That polygon (and all other coplanar
  83204. * polygons) are added directly to that node and the other polygons are added to
  83205. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  83206. * no distinction between internal and leaf nodes
  83207. */
  83208. var Node = /** @class */ (function () {
  83209. /**
  83210. * Initializes the node
  83211. * @param polygons A collection of polygons held in the node
  83212. */
  83213. function Node(polygons) {
  83214. this.plane = null;
  83215. this.front = null;
  83216. this.back = null;
  83217. this.polygons = new Array();
  83218. if (polygons) {
  83219. this.build(polygons);
  83220. }
  83221. }
  83222. /**
  83223. * Clones, or makes a deep copy, of the node
  83224. * @returns The cloned node
  83225. */
  83226. Node.prototype.clone = function () {
  83227. var node = new Node();
  83228. node.plane = this.plane && this.plane.clone();
  83229. node.front = this.front && this.front.clone();
  83230. node.back = this.back && this.back.clone();
  83231. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  83232. return node;
  83233. };
  83234. /**
  83235. * Convert solid space to empty space and empty space to solid space
  83236. */
  83237. Node.prototype.invert = function () {
  83238. for (var i = 0; i < this.polygons.length; i++) {
  83239. this.polygons[i].flip();
  83240. }
  83241. if (this.plane) {
  83242. this.plane.flip();
  83243. }
  83244. if (this.front) {
  83245. this.front.invert();
  83246. }
  83247. if (this.back) {
  83248. this.back.invert();
  83249. }
  83250. var temp = this.front;
  83251. this.front = this.back;
  83252. this.back = temp;
  83253. };
  83254. /**
  83255. * Recursively remove all polygons in `polygons` that are inside this BSP
  83256. * tree.
  83257. * @param polygons Polygons to remove from the BSP
  83258. * @returns Polygons clipped from the BSP
  83259. */
  83260. Node.prototype.clipPolygons = function (polygons) {
  83261. if (!this.plane) {
  83262. return polygons.slice();
  83263. }
  83264. var front = new Array(), back = new Array();
  83265. for (var i = 0; i < polygons.length; i++) {
  83266. this.plane.splitPolygon(polygons[i], front, back, front, back);
  83267. }
  83268. if (this.front) {
  83269. front = this.front.clipPolygons(front);
  83270. }
  83271. if (this.back) {
  83272. back = this.back.clipPolygons(back);
  83273. }
  83274. else {
  83275. back = [];
  83276. }
  83277. return front.concat(back);
  83278. };
  83279. /**
  83280. * Remove all polygons in this BSP tree that are inside the other BSP tree
  83281. * `bsp`.
  83282. * @param bsp BSP containing polygons to remove from this BSP
  83283. */
  83284. Node.prototype.clipTo = function (bsp) {
  83285. this.polygons = bsp.clipPolygons(this.polygons);
  83286. if (this.front) {
  83287. this.front.clipTo(bsp);
  83288. }
  83289. if (this.back) {
  83290. this.back.clipTo(bsp);
  83291. }
  83292. };
  83293. /**
  83294. * Return a list of all polygons in this BSP tree
  83295. * @returns List of all polygons in this BSP tree
  83296. */
  83297. Node.prototype.allPolygons = function () {
  83298. var polygons = this.polygons.slice();
  83299. if (this.front) {
  83300. polygons = polygons.concat(this.front.allPolygons());
  83301. }
  83302. if (this.back) {
  83303. polygons = polygons.concat(this.back.allPolygons());
  83304. }
  83305. return polygons;
  83306. };
  83307. /**
  83308. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  83309. * new polygons are filtered down to the bottom of the tree and become new
  83310. * nodes there. Each set of polygons is partitioned using the first polygon
  83311. * (no heuristic is used to pick a good split)
  83312. * @param polygons Polygons used to construct the BSP tree
  83313. */
  83314. Node.prototype.build = function (polygons) {
  83315. if (!polygons.length) {
  83316. return;
  83317. }
  83318. if (!this.plane) {
  83319. this.plane = polygons[0].plane.clone();
  83320. }
  83321. var front = new Array(), back = new Array();
  83322. for (var i = 0; i < polygons.length; i++) {
  83323. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  83324. }
  83325. if (front.length) {
  83326. if (!this.front) {
  83327. this.front = new Node();
  83328. }
  83329. this.front.build(front);
  83330. }
  83331. if (back.length) {
  83332. if (!this.back) {
  83333. this.back = new Node();
  83334. }
  83335. this.back.build(back);
  83336. }
  83337. };
  83338. return Node;
  83339. }());
  83340. /**
  83341. * Class for building Constructive Solid Geometry
  83342. */
  83343. var CSG = /** @class */ (function () {
  83344. function CSG() {
  83345. this.polygons = new Array();
  83346. }
  83347. /**
  83348. * Convert the Mesh to CSG
  83349. * @param mesh The Mesh to convert to CSG
  83350. * @returns A new CSG from the Mesh
  83351. */
  83352. CSG.FromMesh = function (mesh) {
  83353. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  83354. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  83355. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  83356. mesh.computeWorldMatrix(true);
  83357. matrix = mesh.getWorldMatrix();
  83358. meshPosition = mesh.position.clone();
  83359. meshRotation = mesh.rotation.clone();
  83360. if (mesh.rotationQuaternion) {
  83361. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  83362. }
  83363. meshScaling = mesh.scaling.clone();
  83364. }
  83365. else {
  83366. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  83367. }
  83368. 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);
  83369. var subMeshes = mesh.subMeshes;
  83370. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  83371. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  83372. vertices = [];
  83373. for (var j = 0; j < 3; j++) {
  83374. 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]);
  83375. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  83376. 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]);
  83377. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  83378. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  83379. vertex = new Vertex(position, normal, uv);
  83380. vertices.push(vertex);
  83381. }
  83382. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  83383. // To handle the case of degenerated triangle
  83384. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  83385. if (polygon.plane) {
  83386. polygons.push(polygon);
  83387. }
  83388. }
  83389. }
  83390. var csg = CSG.FromPolygons(polygons);
  83391. csg.matrix = matrix;
  83392. csg.position = meshPosition;
  83393. csg.rotation = meshRotation;
  83394. csg.scaling = meshScaling;
  83395. csg.rotationQuaternion = meshRotationQuaternion;
  83396. currentCSGMeshId++;
  83397. return csg;
  83398. };
  83399. /**
  83400. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  83401. * @param polygons Polygons used to construct a CSG solid
  83402. */
  83403. CSG.FromPolygons = function (polygons) {
  83404. var csg = new CSG();
  83405. csg.polygons = polygons;
  83406. return csg;
  83407. };
  83408. /**
  83409. * Clones, or makes a deep copy, of the CSG
  83410. * @returns A new CSG
  83411. */
  83412. CSG.prototype.clone = function () {
  83413. var csg = new CSG();
  83414. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  83415. csg.copyTransformAttributes(this);
  83416. return csg;
  83417. };
  83418. /**
  83419. * Unions this CSG with another CSG
  83420. * @param csg The CSG to union against this CSG
  83421. * @returns The unioned CSG
  83422. */
  83423. CSG.prototype.union = function (csg) {
  83424. var a = new Node(this.clone().polygons);
  83425. var b = new Node(csg.clone().polygons);
  83426. a.clipTo(b);
  83427. b.clipTo(a);
  83428. b.invert();
  83429. b.clipTo(a);
  83430. b.invert();
  83431. a.build(b.allPolygons());
  83432. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83433. };
  83434. /**
  83435. * Unions this CSG with another CSG in place
  83436. * @param csg The CSG to union against this CSG
  83437. */
  83438. CSG.prototype.unionInPlace = function (csg) {
  83439. var a = new Node(this.polygons);
  83440. var b = new Node(csg.polygons);
  83441. a.clipTo(b);
  83442. b.clipTo(a);
  83443. b.invert();
  83444. b.clipTo(a);
  83445. b.invert();
  83446. a.build(b.allPolygons());
  83447. this.polygons = a.allPolygons();
  83448. };
  83449. /**
  83450. * Subtracts this CSG with another CSG
  83451. * @param csg The CSG to subtract against this CSG
  83452. * @returns A new CSG
  83453. */
  83454. CSG.prototype.subtract = function (csg) {
  83455. var a = new Node(this.clone().polygons);
  83456. var b = new Node(csg.clone().polygons);
  83457. a.invert();
  83458. a.clipTo(b);
  83459. b.clipTo(a);
  83460. b.invert();
  83461. b.clipTo(a);
  83462. b.invert();
  83463. a.build(b.allPolygons());
  83464. a.invert();
  83465. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83466. };
  83467. /**
  83468. * Subtracts this CSG with another CSG in place
  83469. * @param csg The CSG to subtact against this CSG
  83470. */
  83471. CSG.prototype.subtractInPlace = function (csg) {
  83472. var a = new Node(this.polygons);
  83473. var b = new Node(csg.polygons);
  83474. a.invert();
  83475. a.clipTo(b);
  83476. b.clipTo(a);
  83477. b.invert();
  83478. b.clipTo(a);
  83479. b.invert();
  83480. a.build(b.allPolygons());
  83481. a.invert();
  83482. this.polygons = a.allPolygons();
  83483. };
  83484. /**
  83485. * Intersect this CSG with another CSG
  83486. * @param csg The CSG to intersect against this CSG
  83487. * @returns A new CSG
  83488. */
  83489. CSG.prototype.intersect = function (csg) {
  83490. var a = new Node(this.clone().polygons);
  83491. var b = new Node(csg.clone().polygons);
  83492. a.invert();
  83493. b.clipTo(a);
  83494. b.invert();
  83495. a.clipTo(b);
  83496. b.clipTo(a);
  83497. a.build(b.allPolygons());
  83498. a.invert();
  83499. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83500. };
  83501. /**
  83502. * Intersects this CSG with another CSG in place
  83503. * @param csg The CSG to intersect against this CSG
  83504. */
  83505. CSG.prototype.intersectInPlace = function (csg) {
  83506. var a = new Node(this.polygons);
  83507. var b = new Node(csg.polygons);
  83508. a.invert();
  83509. b.clipTo(a);
  83510. b.invert();
  83511. a.clipTo(b);
  83512. b.clipTo(a);
  83513. a.build(b.allPolygons());
  83514. a.invert();
  83515. this.polygons = a.allPolygons();
  83516. };
  83517. /**
  83518. * Return a new CSG solid with solid and empty space switched. This solid is
  83519. * not modified.
  83520. * @returns A new CSG solid with solid and empty space switched
  83521. */
  83522. CSG.prototype.inverse = function () {
  83523. var csg = this.clone();
  83524. csg.inverseInPlace();
  83525. return csg;
  83526. };
  83527. /**
  83528. * Inverses the CSG in place
  83529. */
  83530. CSG.prototype.inverseInPlace = function () {
  83531. this.polygons.map(function (p) { p.flip(); });
  83532. };
  83533. /**
  83534. * This is used to keep meshes transformations so they can be restored
  83535. * when we build back a Babylon Mesh
  83536. * NB : All CSG operations are performed in world coordinates
  83537. * @param csg The CSG to copy the transform attributes from
  83538. * @returns This CSG
  83539. */
  83540. CSG.prototype.copyTransformAttributes = function (csg) {
  83541. this.matrix = csg.matrix;
  83542. this.position = csg.position;
  83543. this.rotation = csg.rotation;
  83544. this.scaling = csg.scaling;
  83545. this.rotationQuaternion = csg.rotationQuaternion;
  83546. return this;
  83547. };
  83548. /**
  83549. * Build Raw mesh from CSG
  83550. * Coordinates here are in world space
  83551. * @param name The name of the mesh geometry
  83552. * @param scene The Scene
  83553. * @param keepSubMeshes Specifies if the submeshes should be kept
  83554. * @returns A new Mesh
  83555. */
  83556. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  83557. var matrix = this.matrix.clone();
  83558. matrix.invert();
  83559. 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;
  83560. if (keepSubMeshes) {
  83561. // Sort Polygons, since subMeshes are indices range
  83562. polygons.sort(function (a, b) {
  83563. if (a.shared.meshId === b.shared.meshId) {
  83564. return a.shared.subMeshId - b.shared.subMeshId;
  83565. }
  83566. else {
  83567. return a.shared.meshId - b.shared.meshId;
  83568. }
  83569. });
  83570. }
  83571. for (var i = 0, il = polygons.length; i < il; i++) {
  83572. polygon = polygons[i];
  83573. // Building SubMeshes
  83574. if (!subMesh_dict[polygon.shared.meshId]) {
  83575. subMesh_dict[polygon.shared.meshId] = {};
  83576. }
  83577. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  83578. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  83579. indexStart: +Infinity,
  83580. indexEnd: -Infinity,
  83581. materialIndex: polygon.shared.materialIndex
  83582. };
  83583. }
  83584. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  83585. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  83586. polygonIndices[0] = 0;
  83587. polygonIndices[1] = j - 1;
  83588. polygonIndices[2] = j;
  83589. for (var k = 0; k < 3; k++) {
  83590. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  83591. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  83592. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  83593. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  83594. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  83595. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  83596. // Check if 2 points can be merged
  83597. if (!(typeof vertex_idx !== 'undefined' &&
  83598. normals[vertex_idx * 3] === localNormal.x &&
  83599. normals[vertex_idx * 3 + 1] === localNormal.y &&
  83600. normals[vertex_idx * 3 + 2] === localNormal.z &&
  83601. uvs[vertex_idx * 2] === uv.x &&
  83602. uvs[vertex_idx * 2 + 1] === uv.y)) {
  83603. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  83604. uvs.push(uv.x, uv.y);
  83605. normals.push(normal.x, normal.y, normal.z);
  83606. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  83607. }
  83608. indices.push(vertex_idx);
  83609. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  83610. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  83611. currentIndex++;
  83612. }
  83613. }
  83614. }
  83615. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  83616. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  83617. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  83618. mesh.setIndices(indices, null);
  83619. if (keepSubMeshes) {
  83620. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  83621. var materialIndexOffset = 0, materialMaxIndex;
  83622. mesh.subMeshes = new Array();
  83623. for (var m in subMesh_dict) {
  83624. materialMaxIndex = -1;
  83625. for (var sm in subMesh_dict[m]) {
  83626. subMesh_obj = subMesh_dict[m][sm];
  83627. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  83628. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  83629. }
  83630. materialIndexOffset += ++materialMaxIndex;
  83631. }
  83632. }
  83633. return mesh;
  83634. };
  83635. /**
  83636. * Build Mesh from CSG taking material and transforms into account
  83637. * @param name The name of the Mesh
  83638. * @param material The material of the Mesh
  83639. * @param scene The Scene
  83640. * @param keepSubMeshes Specifies if submeshes should be kept
  83641. * @returns The new Mesh
  83642. */
  83643. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  83644. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  83645. mesh.material = material;
  83646. mesh.position.copyFrom(this.position);
  83647. mesh.rotation.copyFrom(this.rotation);
  83648. if (this.rotationQuaternion) {
  83649. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  83650. }
  83651. mesh.scaling.copyFrom(this.scaling);
  83652. mesh.computeWorldMatrix(true);
  83653. return mesh;
  83654. };
  83655. return CSG;
  83656. }());
  83657. /***/ }),
  83658. /***/ "./Meshes/geometry.ts":
  83659. /*!****************************!*\
  83660. !*** ./Meshes/geometry.ts ***!
  83661. \****************************/
  83662. /*! exports provided: Geometry */
  83663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83664. "use strict";
  83665. __webpack_require__.r(__webpack_exports__);
  83666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  83667. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83668. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83669. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83670. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  83671. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  83672. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83673. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83674. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83675. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  83676. /**
  83677. * Class used to store geometry data (vertex buffers + index buffer)
  83678. */
  83679. var Geometry = /** @class */ (function () {
  83680. /**
  83681. * Creates a new geometry
  83682. * @param id defines the unique ID
  83683. * @param scene defines the hosting scene
  83684. * @param vertexData defines the VertexData used to get geometry data
  83685. * @param updatable defines if geometry must be updatable (false by default)
  83686. * @param mesh defines the mesh that will be associated with the geometry
  83687. */
  83688. function Geometry(id, scene, vertexData, updatable, mesh) {
  83689. if (updatable === void 0) { updatable = false; }
  83690. if (mesh === void 0) { mesh = null; }
  83691. /**
  83692. * Gets the delay loading state of the geometry (none by default which means not delayed)
  83693. */
  83694. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  83695. this._totalVertices = 0;
  83696. this._isDisposed = false;
  83697. this._indexBufferIsUpdatable = false;
  83698. this.id = id;
  83699. this.uniqueId = scene.getUniqueId();
  83700. this._engine = scene.getEngine();
  83701. this._meshes = [];
  83702. this._scene = scene;
  83703. //Init vertex buffer cache
  83704. this._vertexBuffers = {};
  83705. this._indices = [];
  83706. this._updatable = updatable;
  83707. // vertexData
  83708. if (vertexData) {
  83709. this.setAllVerticesData(vertexData, updatable);
  83710. }
  83711. else {
  83712. this._totalVertices = 0;
  83713. this._indices = [];
  83714. }
  83715. if (this._engine.getCaps().vertexArrayObject) {
  83716. this._vertexArrayObjects = {};
  83717. }
  83718. // applyToMesh
  83719. if (mesh) {
  83720. this.applyToMesh(mesh);
  83721. mesh.computeWorldMatrix(true);
  83722. }
  83723. }
  83724. Object.defineProperty(Geometry.prototype, "boundingBias", {
  83725. /**
  83726. * 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
  83727. */
  83728. get: function () {
  83729. return this._boundingBias;
  83730. },
  83731. /**
  83732. * 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
  83733. */
  83734. set: function (value) {
  83735. if (this._boundingBias) {
  83736. this._boundingBias.copyFrom(value);
  83737. }
  83738. else {
  83739. this._boundingBias = value.clone();
  83740. }
  83741. this._updateBoundingInfo(true, null);
  83742. },
  83743. enumerable: true,
  83744. configurable: true
  83745. });
  83746. /**
  83747. * Static function used to attach a new empty geometry to a mesh
  83748. * @param mesh defines the mesh to attach the geometry to
  83749. * @returns the new Geometry
  83750. */
  83751. Geometry.CreateGeometryForMesh = function (mesh) {
  83752. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  83753. geometry.applyToMesh(mesh);
  83754. return geometry;
  83755. };
  83756. Object.defineProperty(Geometry.prototype, "extend", {
  83757. /**
  83758. * Gets the current extend of the geometry
  83759. */
  83760. get: function () {
  83761. return this._extend;
  83762. },
  83763. enumerable: true,
  83764. configurable: true
  83765. });
  83766. /**
  83767. * Gets the hosting scene
  83768. * @returns the hosting Scene
  83769. */
  83770. Geometry.prototype.getScene = function () {
  83771. return this._scene;
  83772. };
  83773. /**
  83774. * Gets the hosting engine
  83775. * @returns the hosting Engine
  83776. */
  83777. Geometry.prototype.getEngine = function () {
  83778. return this._engine;
  83779. };
  83780. /**
  83781. * Defines if the geometry is ready to use
  83782. * @returns true if the geometry is ready to be used
  83783. */
  83784. Geometry.prototype.isReady = function () {
  83785. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  83786. };
  83787. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  83788. /**
  83789. * Gets a value indicating that the geometry should not be serialized
  83790. */
  83791. get: function () {
  83792. for (var index = 0; index < this._meshes.length; index++) {
  83793. if (!this._meshes[index].doNotSerialize) {
  83794. return false;
  83795. }
  83796. }
  83797. return true;
  83798. },
  83799. enumerable: true,
  83800. configurable: true
  83801. });
  83802. /** @hidden */
  83803. Geometry.prototype._rebuild = function () {
  83804. if (this._vertexArrayObjects) {
  83805. this._vertexArrayObjects = {};
  83806. }
  83807. // Index buffer
  83808. if (this._meshes.length !== 0 && this._indices) {
  83809. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  83810. }
  83811. // Vertex buffers
  83812. for (var key in this._vertexBuffers) {
  83813. var vertexBuffer = this._vertexBuffers[key];
  83814. vertexBuffer._rebuild();
  83815. }
  83816. };
  83817. /**
  83818. * Affects all geometry data in one call
  83819. * @param vertexData defines the geometry data
  83820. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  83821. */
  83822. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  83823. vertexData.applyToGeometry(this, updatable);
  83824. this.notifyUpdate();
  83825. };
  83826. /**
  83827. * Set specific vertex data
  83828. * @param kind defines the data kind (Position, normal, etc...)
  83829. * @param data defines the vertex data to use
  83830. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  83831. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  83832. */
  83833. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  83834. if (updatable === void 0) { updatable = false; }
  83835. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  83836. this.setVerticesBuffer(buffer);
  83837. };
  83838. /**
  83839. * Removes a specific vertex data
  83840. * @param kind defines the data kind (Position, normal, etc...)
  83841. */
  83842. Geometry.prototype.removeVerticesData = function (kind) {
  83843. if (this._vertexBuffers[kind]) {
  83844. this._vertexBuffers[kind].dispose();
  83845. delete this._vertexBuffers[kind];
  83846. }
  83847. };
  83848. /**
  83849. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  83850. * @param buffer defines the vertex buffer to use
  83851. * @param totalVertices defines the total number of vertices for position kind (could be null)
  83852. */
  83853. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  83854. if (totalVertices === void 0) { totalVertices = null; }
  83855. var kind = buffer.getKind();
  83856. if (this._vertexBuffers[kind]) {
  83857. this._vertexBuffers[kind].dispose();
  83858. }
  83859. this._vertexBuffers[kind] = buffer;
  83860. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  83861. var data = buffer.getData();
  83862. if (totalVertices != null) {
  83863. this._totalVertices = totalVertices;
  83864. }
  83865. else {
  83866. if (data != null) {
  83867. this._totalVertices = data.length / (buffer.byteStride / 4);
  83868. }
  83869. }
  83870. this._updateExtend(data);
  83871. this._resetPointsArrayCache();
  83872. var meshes = this._meshes;
  83873. var numOfMeshes = meshes.length;
  83874. for (var index = 0; index < numOfMeshes; index++) {
  83875. var mesh = meshes[index];
  83876. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83877. mesh._createGlobalSubMesh(false);
  83878. mesh.computeWorldMatrix(true);
  83879. }
  83880. }
  83881. this.notifyUpdate(kind);
  83882. if (this._vertexArrayObjects) {
  83883. this._disposeVertexArrayObjects();
  83884. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  83885. }
  83886. };
  83887. /**
  83888. * Update a specific vertex buffer
  83889. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  83890. * It will do nothing if the buffer is not updatable
  83891. * @param kind defines the data kind (Position, normal, etc...)
  83892. * @param data defines the data to use
  83893. * @param offset defines the offset in the target buffer where to store the data
  83894. * @param useBytes set to true if the offset is in bytes
  83895. */
  83896. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  83897. if (useBytes === void 0) { useBytes = false; }
  83898. var vertexBuffer = this.getVertexBuffer(kind);
  83899. if (!vertexBuffer) {
  83900. return;
  83901. }
  83902. vertexBuffer.updateDirectly(data, offset, useBytes);
  83903. this.notifyUpdate(kind);
  83904. };
  83905. /**
  83906. * Update a specific vertex buffer
  83907. * This function will create a new buffer if the current one is not updatable
  83908. * @param kind defines the data kind (Position, normal, etc...)
  83909. * @param data defines the data to use
  83910. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  83911. */
  83912. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  83913. if (updateExtends === void 0) { updateExtends = false; }
  83914. var vertexBuffer = this.getVertexBuffer(kind);
  83915. if (!vertexBuffer) {
  83916. return;
  83917. }
  83918. vertexBuffer.update(data);
  83919. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  83920. this._updateBoundingInfo(updateExtends, data);
  83921. }
  83922. this.notifyUpdate(kind);
  83923. };
  83924. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  83925. if (updateExtends) {
  83926. this._updateExtend(data);
  83927. }
  83928. this._resetPointsArrayCache();
  83929. if (updateExtends) {
  83930. var meshes = this._meshes;
  83931. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  83932. var mesh = meshes_1[_i];
  83933. if (mesh._boundingInfo) {
  83934. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  83935. }
  83936. else {
  83937. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83938. }
  83939. var subMeshes = mesh.subMeshes;
  83940. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  83941. var subMesh = subMeshes_1[_a];
  83942. subMesh.refreshBoundingInfo();
  83943. }
  83944. }
  83945. }
  83946. };
  83947. /** @hidden */
  83948. Geometry.prototype._bind = function (effect, indexToBind) {
  83949. if (!effect) {
  83950. return;
  83951. }
  83952. if (indexToBind === undefined) {
  83953. indexToBind = this._indexBuffer;
  83954. }
  83955. var vbs = this.getVertexBuffers();
  83956. if (!vbs) {
  83957. return;
  83958. }
  83959. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  83960. this._engine.bindBuffers(vbs, indexToBind, effect);
  83961. return;
  83962. }
  83963. // Using VAO
  83964. if (!this._vertexArrayObjects[effect.key]) {
  83965. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  83966. }
  83967. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  83968. };
  83969. /**
  83970. * Gets total number of vertices
  83971. * @returns the total number of vertices
  83972. */
  83973. Geometry.prototype.getTotalVertices = function () {
  83974. if (!this.isReady()) {
  83975. return 0;
  83976. }
  83977. return this._totalVertices;
  83978. };
  83979. /**
  83980. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  83981. * @param kind defines the data kind (Position, normal, etc...)
  83982. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  83983. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83984. * @returns a float array containing vertex data
  83985. */
  83986. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  83987. var vertexBuffer = this.getVertexBuffer(kind);
  83988. if (!vertexBuffer) {
  83989. return null;
  83990. }
  83991. var data = vertexBuffer.getData();
  83992. if (!data) {
  83993. return null;
  83994. }
  83995. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  83996. var count = this._totalVertices * vertexBuffer.getSize();
  83997. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  83998. var copy_1 = [];
  83999. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  84000. return copy_1;
  84001. }
  84002. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  84003. if (data instanceof Array) {
  84004. var offset = vertexBuffer.byteOffset / 4;
  84005. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  84006. }
  84007. else if (data instanceof ArrayBuffer) {
  84008. return new Float32Array(data, vertexBuffer.byteOffset, count);
  84009. }
  84010. else {
  84011. var offset = data.byteOffset + vertexBuffer.byteOffset;
  84012. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  84013. var result = new Float32Array(count);
  84014. var source = new Float32Array(data.buffer, offset, count);
  84015. result.set(source);
  84016. return result;
  84017. }
  84018. return new Float32Array(data.buffer, offset, count);
  84019. }
  84020. }
  84021. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  84022. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  84023. }
  84024. return data;
  84025. };
  84026. /**
  84027. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84028. * @param kind defines the data kind (Position, normal, etc...)
  84029. * @returns true if the vertex buffer with the specified kind is updatable
  84030. */
  84031. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  84032. var vb = this._vertexBuffers[kind];
  84033. if (!vb) {
  84034. return false;
  84035. }
  84036. return vb.isUpdatable();
  84037. };
  84038. /**
  84039. * Gets a specific vertex buffer
  84040. * @param kind defines the data kind (Position, normal, etc...)
  84041. * @returns a VertexBuffer
  84042. */
  84043. Geometry.prototype.getVertexBuffer = function (kind) {
  84044. if (!this.isReady()) {
  84045. return null;
  84046. }
  84047. return this._vertexBuffers[kind];
  84048. };
  84049. /**
  84050. * Returns all vertex buffers
  84051. * @return an object holding all vertex buffers indexed by kind
  84052. */
  84053. Geometry.prototype.getVertexBuffers = function () {
  84054. if (!this.isReady()) {
  84055. return null;
  84056. }
  84057. return this._vertexBuffers;
  84058. };
  84059. /**
  84060. * Gets a boolean indicating if specific vertex buffer is present
  84061. * @param kind defines the data kind (Position, normal, etc...)
  84062. * @returns true if data is present
  84063. */
  84064. Geometry.prototype.isVerticesDataPresent = function (kind) {
  84065. if (!this._vertexBuffers) {
  84066. if (this._delayInfo) {
  84067. return this._delayInfo.indexOf(kind) !== -1;
  84068. }
  84069. return false;
  84070. }
  84071. return this._vertexBuffers[kind] !== undefined;
  84072. };
  84073. /**
  84074. * Gets a list of all attached data kinds (Position, normal, etc...)
  84075. * @returns a list of string containing all kinds
  84076. */
  84077. Geometry.prototype.getVerticesDataKinds = function () {
  84078. var result = [];
  84079. var kind;
  84080. if (!this._vertexBuffers && this._delayInfo) {
  84081. for (kind in this._delayInfo) {
  84082. result.push(kind);
  84083. }
  84084. }
  84085. else {
  84086. for (kind in this._vertexBuffers) {
  84087. result.push(kind);
  84088. }
  84089. }
  84090. return result;
  84091. };
  84092. /**
  84093. * Update index buffer
  84094. * @param indices defines the indices to store in the index buffer
  84095. * @param offset defines the offset in the target buffer where to store the data
  84096. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  84097. */
  84098. Geometry.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  84099. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  84100. if (!this._indexBuffer) {
  84101. return;
  84102. }
  84103. if (!this._indexBufferIsUpdatable) {
  84104. this.setIndices(indices, null, true);
  84105. }
  84106. else {
  84107. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  84108. if (!gpuMemoryOnly) {
  84109. this._indices = indices.slice();
  84110. }
  84111. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  84112. if (needToUpdateSubMeshes) {
  84113. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  84114. var mesh = _a[_i];
  84115. mesh._createGlobalSubMesh(true);
  84116. }
  84117. }
  84118. }
  84119. };
  84120. /**
  84121. * Creates a new index buffer
  84122. * @param indices defines the indices to store in the index buffer
  84123. * @param totalVertices defines the total number of vertices (could be null)
  84124. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84125. */
  84126. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  84127. if (totalVertices === void 0) { totalVertices = null; }
  84128. if (updatable === void 0) { updatable = false; }
  84129. if (this._indexBuffer) {
  84130. this._engine._releaseBuffer(this._indexBuffer);
  84131. }
  84132. this._disposeVertexArrayObjects();
  84133. this._indices = indices;
  84134. this._indexBufferIsUpdatable = updatable;
  84135. if (this._meshes.length !== 0 && this._indices) {
  84136. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  84137. }
  84138. if (totalVertices != undefined) { // including null and undefined
  84139. this._totalVertices = totalVertices;
  84140. }
  84141. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  84142. var mesh = _a[_i];
  84143. mesh._createGlobalSubMesh(true);
  84144. }
  84145. this.notifyUpdate();
  84146. };
  84147. /**
  84148. * Return the total number of indices
  84149. * @returns the total number of indices
  84150. */
  84151. Geometry.prototype.getTotalIndices = function () {
  84152. if (!this.isReady()) {
  84153. return 0;
  84154. }
  84155. return this._indices.length;
  84156. };
  84157. /**
  84158. * Gets the index buffer array
  84159. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84160. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84161. * @returns the index buffer array
  84162. */
  84163. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84164. if (!this.isReady()) {
  84165. return null;
  84166. }
  84167. var orig = this._indices;
  84168. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  84169. return orig;
  84170. }
  84171. else {
  84172. var len = orig.length;
  84173. var copy = [];
  84174. for (var i = 0; i < len; i++) {
  84175. copy.push(orig[i]);
  84176. }
  84177. return copy;
  84178. }
  84179. };
  84180. /**
  84181. * Gets the index buffer
  84182. * @return the index buffer
  84183. */
  84184. Geometry.prototype.getIndexBuffer = function () {
  84185. if (!this.isReady()) {
  84186. return null;
  84187. }
  84188. return this._indexBuffer;
  84189. };
  84190. /** @hidden */
  84191. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  84192. if (effect === void 0) { effect = null; }
  84193. if (!effect || !this._vertexArrayObjects) {
  84194. return;
  84195. }
  84196. if (this._vertexArrayObjects[effect.key]) {
  84197. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  84198. delete this._vertexArrayObjects[effect.key];
  84199. }
  84200. };
  84201. /**
  84202. * Release the associated resources for a specific mesh
  84203. * @param mesh defines the source mesh
  84204. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84205. */
  84206. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  84207. var meshes = this._meshes;
  84208. var index = meshes.indexOf(mesh);
  84209. if (index === -1) {
  84210. return;
  84211. }
  84212. meshes.splice(index, 1);
  84213. mesh._geometry = null;
  84214. if (meshes.length === 0 && shouldDispose) {
  84215. this.dispose();
  84216. }
  84217. };
  84218. /**
  84219. * Apply current geometry to a given mesh
  84220. * @param mesh defines the mesh to apply geometry to
  84221. */
  84222. Geometry.prototype.applyToMesh = function (mesh) {
  84223. if (mesh._geometry === this) {
  84224. return;
  84225. }
  84226. var previousGeometry = mesh._geometry;
  84227. if (previousGeometry) {
  84228. previousGeometry.releaseForMesh(mesh);
  84229. }
  84230. var meshes = this._meshes;
  84231. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  84232. mesh._geometry = this;
  84233. this._scene.pushGeometry(this);
  84234. meshes.push(mesh);
  84235. if (this.isReady()) {
  84236. this._applyToMesh(mesh);
  84237. }
  84238. else {
  84239. mesh._boundingInfo = this._boundingInfo;
  84240. }
  84241. };
  84242. Geometry.prototype._updateExtend = function (data) {
  84243. if (data === void 0) { data = null; }
  84244. if (!data) {
  84245. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  84246. }
  84247. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  84248. };
  84249. Geometry.prototype._applyToMesh = function (mesh) {
  84250. var numOfMeshes = this._meshes.length;
  84251. // vertexBuffers
  84252. for (var kind in this._vertexBuffers) {
  84253. if (numOfMeshes === 1) {
  84254. this._vertexBuffers[kind].create();
  84255. }
  84256. var buffer = this._vertexBuffers[kind].getBuffer();
  84257. if (buffer) {
  84258. buffer.references = numOfMeshes;
  84259. }
  84260. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  84261. if (!this._extend) {
  84262. this._updateExtend();
  84263. }
  84264. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84265. mesh._createGlobalSubMesh(false);
  84266. //bounding info was just created again, world matrix should be applied again.
  84267. mesh._updateBoundingInfo();
  84268. }
  84269. }
  84270. // indexBuffer
  84271. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  84272. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  84273. }
  84274. if (this._indexBuffer) {
  84275. this._indexBuffer.references = numOfMeshes;
  84276. }
  84277. // morphTargets
  84278. mesh._syncGeometryWithMorphTargetManager();
  84279. // instances
  84280. mesh.synchronizeInstances();
  84281. };
  84282. Geometry.prototype.notifyUpdate = function (kind) {
  84283. if (this.onGeometryUpdated) {
  84284. this.onGeometryUpdated(this, kind);
  84285. }
  84286. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  84287. var mesh = _a[_i];
  84288. mesh._markSubMeshesAsAttributesDirty();
  84289. }
  84290. };
  84291. /**
  84292. * Load the geometry if it was flagged as delay loaded
  84293. * @param scene defines the hosting scene
  84294. * @param onLoaded defines a callback called when the geometry is loaded
  84295. */
  84296. Geometry.prototype.load = function (scene, onLoaded) {
  84297. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  84298. return;
  84299. }
  84300. if (this.isReady()) {
  84301. if (onLoaded) {
  84302. onLoaded();
  84303. }
  84304. return;
  84305. }
  84306. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  84307. this._queueLoad(scene, onLoaded);
  84308. };
  84309. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  84310. var _this = this;
  84311. if (!this.delayLoadingFile) {
  84312. return;
  84313. }
  84314. scene._addPendingData(this);
  84315. scene._loadFile(this.delayLoadingFile, function (data) {
  84316. if (!_this._delayLoadingFunction) {
  84317. return;
  84318. }
  84319. _this._delayLoadingFunction(JSON.parse(data), _this);
  84320. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  84321. _this._delayInfo = [];
  84322. scene._removePendingData(_this);
  84323. var meshes = _this._meshes;
  84324. var numOfMeshes = meshes.length;
  84325. for (var index = 0; index < numOfMeshes; index++) {
  84326. _this._applyToMesh(meshes[index]);
  84327. }
  84328. if (onLoaded) {
  84329. onLoaded();
  84330. }
  84331. }, undefined, true);
  84332. };
  84333. /**
  84334. * Invert the geometry to move from a right handed system to a left handed one.
  84335. */
  84336. Geometry.prototype.toLeftHanded = function () {
  84337. // Flip faces
  84338. var tIndices = this.getIndices(false);
  84339. if (tIndices != null && tIndices.length > 0) {
  84340. for (var i = 0; i < tIndices.length; i += 3) {
  84341. var tTemp = tIndices[i + 0];
  84342. tIndices[i + 0] = tIndices[i + 2];
  84343. tIndices[i + 2] = tTemp;
  84344. }
  84345. this.setIndices(tIndices);
  84346. }
  84347. // Negate position.z
  84348. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  84349. if (tPositions != null && tPositions.length > 0) {
  84350. for (var i = 0; i < tPositions.length; i += 3) {
  84351. tPositions[i + 2] = -tPositions[i + 2];
  84352. }
  84353. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  84354. }
  84355. // Negate normal.z
  84356. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  84357. if (tNormals != null && tNormals.length > 0) {
  84358. for (var i = 0; i < tNormals.length; i += 3) {
  84359. tNormals[i + 2] = -tNormals[i + 2];
  84360. }
  84361. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  84362. }
  84363. };
  84364. // Cache
  84365. /** @hidden */
  84366. Geometry.prototype._resetPointsArrayCache = function () {
  84367. this._positions = null;
  84368. };
  84369. /** @hidden */
  84370. Geometry.prototype._generatePointsArray = function () {
  84371. if (this._positions) {
  84372. return true;
  84373. }
  84374. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  84375. if (!data || data.length === 0) {
  84376. return false;
  84377. }
  84378. this._positions = [];
  84379. for (var index = 0; index < data.length; index += 3) {
  84380. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  84381. }
  84382. return true;
  84383. };
  84384. /**
  84385. * Gets a value indicating if the geometry is disposed
  84386. * @returns true if the geometry was disposed
  84387. */
  84388. Geometry.prototype.isDisposed = function () {
  84389. return this._isDisposed;
  84390. };
  84391. Geometry.prototype._disposeVertexArrayObjects = function () {
  84392. if (this._vertexArrayObjects) {
  84393. for (var kind in this._vertexArrayObjects) {
  84394. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  84395. }
  84396. this._vertexArrayObjects = {};
  84397. }
  84398. };
  84399. /**
  84400. * Free all associated resources
  84401. */
  84402. Geometry.prototype.dispose = function () {
  84403. var meshes = this._meshes;
  84404. var numOfMeshes = meshes.length;
  84405. var index;
  84406. for (index = 0; index < numOfMeshes; index++) {
  84407. this.releaseForMesh(meshes[index]);
  84408. }
  84409. this._meshes = [];
  84410. this._disposeVertexArrayObjects();
  84411. for (var kind in this._vertexBuffers) {
  84412. this._vertexBuffers[kind].dispose();
  84413. }
  84414. this._vertexBuffers = {};
  84415. this._totalVertices = 0;
  84416. if (this._indexBuffer) {
  84417. this._engine._releaseBuffer(this._indexBuffer);
  84418. }
  84419. this._indexBuffer = null;
  84420. this._indices = [];
  84421. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  84422. this.delayLoadingFile = null;
  84423. this._delayLoadingFunction = null;
  84424. this._delayInfo = [];
  84425. this._boundingInfo = null;
  84426. this._scene.removeGeometry(this);
  84427. this._isDisposed = true;
  84428. };
  84429. /**
  84430. * Clone the current geometry into a new geometry
  84431. * @param id defines the unique ID of the new geometry
  84432. * @returns a new geometry object
  84433. */
  84434. Geometry.prototype.copy = function (id) {
  84435. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  84436. vertexData.indices = [];
  84437. var indices = this.getIndices();
  84438. if (indices) {
  84439. for (var index = 0; index < indices.length; index++) {
  84440. vertexData.indices.push(indices[index]);
  84441. }
  84442. }
  84443. var updatable = false;
  84444. var stopChecking = false;
  84445. var kind;
  84446. for (kind in this._vertexBuffers) {
  84447. // using slice() to make a copy of the array and not just reference it
  84448. var data = this.getVerticesData(kind);
  84449. if (data) {
  84450. if (data instanceof Float32Array) {
  84451. vertexData.set(new Float32Array(data), kind);
  84452. }
  84453. else {
  84454. vertexData.set(data.slice(0), kind);
  84455. }
  84456. if (!stopChecking) {
  84457. var vb = this.getVertexBuffer(kind);
  84458. if (vb) {
  84459. updatable = vb.isUpdatable();
  84460. stopChecking = !updatable;
  84461. }
  84462. }
  84463. }
  84464. }
  84465. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  84466. geometry.delayLoadState = this.delayLoadState;
  84467. geometry.delayLoadingFile = this.delayLoadingFile;
  84468. geometry._delayLoadingFunction = this._delayLoadingFunction;
  84469. for (kind in this._delayInfo) {
  84470. geometry._delayInfo = geometry._delayInfo || [];
  84471. geometry._delayInfo.push(kind);
  84472. }
  84473. // Bounding info
  84474. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84475. return geometry;
  84476. };
  84477. /**
  84478. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84479. * @return a JSON representation of the current geometry data (without the vertices data)
  84480. */
  84481. Geometry.prototype.serialize = function () {
  84482. var serializationObject = {};
  84483. serializationObject.id = this.id;
  84484. serializationObject.updatable = this._updatable;
  84485. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  84486. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  84487. }
  84488. return serializationObject;
  84489. };
  84490. Geometry.prototype.toNumberArray = function (origin) {
  84491. if (Array.isArray(origin)) {
  84492. return origin;
  84493. }
  84494. else {
  84495. return Array.prototype.slice.call(origin);
  84496. }
  84497. };
  84498. /**
  84499. * Serialize all vertices data into a JSON oject
  84500. * @returns a JSON representation of the current geometry data
  84501. */
  84502. Geometry.prototype.serializeVerticeData = function () {
  84503. var serializationObject = this.serialize();
  84504. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  84505. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  84506. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  84507. serializationObject.positions._updatable = true;
  84508. }
  84509. }
  84510. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  84511. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  84512. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  84513. serializationObject.normals._updatable = true;
  84514. }
  84515. }
  84516. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  84517. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  84518. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  84519. serializationObject.tangets._updatable = true;
  84520. }
  84521. }
  84522. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  84523. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  84524. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  84525. serializationObject.uvs._updatable = true;
  84526. }
  84527. }
  84528. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  84529. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  84530. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  84531. serializationObject.uv2s._updatable = true;
  84532. }
  84533. }
  84534. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  84535. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  84536. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  84537. serializationObject.uv3s._updatable = true;
  84538. }
  84539. }
  84540. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  84541. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  84542. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  84543. serializationObject.uv4s._updatable = true;
  84544. }
  84545. }
  84546. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  84547. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  84548. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  84549. serializationObject.uv5s._updatable = true;
  84550. }
  84551. }
  84552. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  84553. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  84554. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  84555. serializationObject.uv6s._updatable = true;
  84556. }
  84557. }
  84558. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  84559. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  84560. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  84561. serializationObject.colors._updatable = true;
  84562. }
  84563. }
  84564. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  84565. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  84566. serializationObject.matricesIndices._isExpanded = true;
  84567. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  84568. serializationObject.matricesIndices._updatable = true;
  84569. }
  84570. }
  84571. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  84572. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  84573. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  84574. serializationObject.matricesWeights._updatable = true;
  84575. }
  84576. }
  84577. serializationObject.indices = this.toNumberArray(this.getIndices());
  84578. return serializationObject;
  84579. };
  84580. // Statics
  84581. /**
  84582. * Extracts a clone of a mesh geometry
  84583. * @param mesh defines the source mesh
  84584. * @param id defines the unique ID of the new geometry object
  84585. * @returns the new geometry object
  84586. */
  84587. Geometry.ExtractFromMesh = function (mesh, id) {
  84588. var geometry = mesh._geometry;
  84589. if (!geometry) {
  84590. return null;
  84591. }
  84592. return geometry.copy(id);
  84593. };
  84594. /**
  84595. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84596. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84597. * Be aware Math.random() could cause collisions, but:
  84598. * "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"
  84599. * @returns a string containing a new GUID
  84600. */
  84601. Geometry.RandomId = function () {
  84602. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  84603. };
  84604. /** @hidden */
  84605. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  84606. var scene = mesh.getScene();
  84607. // Geometry
  84608. var geometryId = parsedGeometry.geometryId;
  84609. if (geometryId) {
  84610. var geometry = scene.getGeometryByID(geometryId);
  84611. if (geometry) {
  84612. geometry.applyToMesh(mesh);
  84613. }
  84614. }
  84615. else if (parsedGeometry instanceof ArrayBuffer) {
  84616. var binaryInfo = mesh._binaryInfo;
  84617. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  84618. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  84619. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  84620. }
  84621. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  84622. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  84623. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  84624. }
  84625. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  84626. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  84627. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  84628. }
  84629. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  84630. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  84631. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  84632. }
  84633. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  84634. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  84635. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  84636. }
  84637. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  84638. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  84639. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  84640. }
  84641. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  84642. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  84643. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  84644. }
  84645. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  84646. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  84647. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  84648. }
  84649. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  84650. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  84651. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  84652. }
  84653. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  84654. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  84655. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  84656. }
  84657. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  84658. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  84659. var floatIndices = [];
  84660. for (var i = 0; i < matricesIndicesData.length; i++) {
  84661. var index = matricesIndicesData[i];
  84662. floatIndices.push(index & 0x000000FF);
  84663. floatIndices.push((index & 0x0000FF00) >> 8);
  84664. floatIndices.push((index & 0x00FF0000) >> 16);
  84665. floatIndices.push(index >> 24);
  84666. }
  84667. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  84668. }
  84669. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  84670. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  84671. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  84672. }
  84673. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  84674. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  84675. mesh.setIndices(indicesData, null);
  84676. }
  84677. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  84678. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  84679. mesh.subMeshes = [];
  84680. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  84681. var materialIndex = subMeshesData[(i * 5) + 0];
  84682. var verticesStart = subMeshesData[(i * 5) + 1];
  84683. var verticesCount = subMeshesData[(i * 5) + 2];
  84684. var indexStart = subMeshesData[(i * 5) + 3];
  84685. var indexCount = subMeshesData[(i * 5) + 4];
  84686. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  84687. }
  84688. }
  84689. }
  84690. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  84691. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  84692. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  84693. if (parsedGeometry.tangents) {
  84694. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  84695. }
  84696. if (parsedGeometry.uvs) {
  84697. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  84698. }
  84699. if (parsedGeometry.uvs2) {
  84700. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  84701. }
  84702. if (parsedGeometry.uvs3) {
  84703. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  84704. }
  84705. if (parsedGeometry.uvs4) {
  84706. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  84707. }
  84708. if (parsedGeometry.uvs5) {
  84709. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  84710. }
  84711. if (parsedGeometry.uvs6) {
  84712. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  84713. }
  84714. if (parsedGeometry.colors) {
  84715. 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);
  84716. }
  84717. if (parsedGeometry.matricesIndices) {
  84718. if (!parsedGeometry.matricesIndices._isExpanded) {
  84719. var floatIndices = [];
  84720. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  84721. var matricesIndex = parsedGeometry.matricesIndices[i];
  84722. floatIndices.push(matricesIndex & 0x000000FF);
  84723. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  84724. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  84725. floatIndices.push(matricesIndex >> 24);
  84726. }
  84727. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  84728. }
  84729. else {
  84730. delete parsedGeometry.matricesIndices._isExpanded;
  84731. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  84732. }
  84733. }
  84734. if (parsedGeometry.matricesIndicesExtra) {
  84735. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  84736. var floatIndices = [];
  84737. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  84738. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  84739. floatIndices.push(matricesIndex & 0x000000FF);
  84740. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  84741. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  84742. floatIndices.push(matricesIndex >> 24);
  84743. }
  84744. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  84745. }
  84746. else {
  84747. delete parsedGeometry.matricesIndices._isExpanded;
  84748. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  84749. }
  84750. }
  84751. if (parsedGeometry.matricesWeights) {
  84752. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  84753. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  84754. }
  84755. if (parsedGeometry.matricesWeightsExtra) {
  84756. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  84757. }
  84758. mesh.setIndices(parsedGeometry.indices, null);
  84759. }
  84760. // SubMeshes
  84761. if (parsedGeometry.subMeshes) {
  84762. mesh.subMeshes = [];
  84763. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  84764. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  84765. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  84766. }
  84767. }
  84768. // Flat shading
  84769. if (mesh._shouldGenerateFlatShading) {
  84770. mesh.convertToFlatShadedMesh();
  84771. delete mesh._shouldGenerateFlatShading;
  84772. }
  84773. // Update
  84774. mesh.computeWorldMatrix(true);
  84775. scene.onMeshImportedObservable.notifyObservers(mesh);
  84776. };
  84777. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  84778. var epsilon = 1e-3;
  84779. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  84780. return;
  84781. }
  84782. var noInfluenceBoneIndex = 0.0;
  84783. if (parsedGeometry.skeletonId > -1) {
  84784. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  84785. if (!skeleton) {
  84786. return;
  84787. }
  84788. noInfluenceBoneIndex = skeleton.bones.length;
  84789. }
  84790. else {
  84791. return;
  84792. }
  84793. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  84794. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  84795. var matricesWeights = parsedGeometry.matricesWeights;
  84796. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  84797. var influencers = parsedGeometry.numBoneInfluencer;
  84798. var size = matricesWeights.length;
  84799. for (var i = 0; i < size; i += 4) {
  84800. var weight = 0.0;
  84801. var firstZeroWeight = -1;
  84802. for (var j = 0; j < 4; j++) {
  84803. var w = matricesWeights[i + j];
  84804. weight += w;
  84805. if (w < epsilon && firstZeroWeight < 0) {
  84806. firstZeroWeight = j;
  84807. }
  84808. }
  84809. if (matricesWeightsExtra) {
  84810. for (var j = 0; j < 4; j++) {
  84811. var w = matricesWeightsExtra[i + j];
  84812. weight += w;
  84813. if (w < epsilon && firstZeroWeight < 0) {
  84814. firstZeroWeight = j + 4;
  84815. }
  84816. }
  84817. }
  84818. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  84819. firstZeroWeight = influencers - 1;
  84820. }
  84821. if (weight > epsilon) {
  84822. var mweight = 1.0 / weight;
  84823. for (var j = 0; j < 4; j++) {
  84824. matricesWeights[i + j] *= mweight;
  84825. }
  84826. if (matricesWeightsExtra) {
  84827. for (var j = 0; j < 4; j++) {
  84828. matricesWeightsExtra[i + j] *= mweight;
  84829. }
  84830. }
  84831. }
  84832. else {
  84833. if (firstZeroWeight >= 4) {
  84834. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  84835. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  84836. }
  84837. else {
  84838. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  84839. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  84840. }
  84841. }
  84842. }
  84843. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  84844. if (parsedGeometry.matricesWeightsExtra) {
  84845. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  84846. }
  84847. };
  84848. /**
  84849. * Create a new geometry from persisted data (Using .babylon file format)
  84850. * @param parsedVertexData defines the persisted data
  84851. * @param scene defines the hosting scene
  84852. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84853. * @returns the new geometry object
  84854. */
  84855. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  84856. if (scene.getGeometryByID(parsedVertexData.id)) {
  84857. return null; // null since geometry could be something else than a box...
  84858. }
  84859. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  84860. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  84861. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  84862. }
  84863. if (parsedVertexData.delayLoadingFile) {
  84864. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  84865. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  84866. 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));
  84867. geometry._delayInfo = [];
  84868. if (parsedVertexData.hasUVs) {
  84869. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  84870. }
  84871. if (parsedVertexData.hasUVs2) {
  84872. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  84873. }
  84874. if (parsedVertexData.hasUVs3) {
  84875. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  84876. }
  84877. if (parsedVertexData.hasUVs4) {
  84878. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  84879. }
  84880. if (parsedVertexData.hasUVs5) {
  84881. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  84882. }
  84883. if (parsedVertexData.hasUVs6) {
  84884. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  84885. }
  84886. if (parsedVertexData.hasColors) {
  84887. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  84888. }
  84889. if (parsedVertexData.hasMatricesIndices) {
  84890. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  84891. }
  84892. if (parsedVertexData.hasMatricesWeights) {
  84893. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  84894. }
  84895. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  84896. }
  84897. else {
  84898. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  84899. }
  84900. scene.pushGeometry(geometry, true);
  84901. return geometry;
  84902. };
  84903. return Geometry;
  84904. }());
  84905. /***/ }),
  84906. /***/ "./Meshes/groundMesh.ts":
  84907. /*!******************************!*\
  84908. !*** ./Meshes/groundMesh.ts ***!
  84909. \******************************/
  84910. /*! exports provided: GroundMesh */
  84911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84912. "use strict";
  84913. __webpack_require__.r(__webpack_exports__);
  84914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  84915. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  84916. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84917. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  84918. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84919. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  84920. return GroundMesh.Parse(parsedMesh, scene);
  84921. };
  84922. /**
  84923. * Mesh representing the gorund
  84924. */
  84925. var GroundMesh = /** @class */ (function (_super) {
  84926. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  84927. function GroundMesh(name, scene) {
  84928. var _this = _super.call(this, name, scene) || this;
  84929. /** If octree should be generated */
  84930. _this.generateOctree = false;
  84931. return _this;
  84932. }
  84933. /**
  84934. * "GroundMesh"
  84935. * @returns "GroundMesh"
  84936. */
  84937. GroundMesh.prototype.getClassName = function () {
  84938. return "GroundMesh";
  84939. };
  84940. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  84941. /**
  84942. * The minimum of x and y subdivisions
  84943. */
  84944. get: function () {
  84945. return Math.min(this._subdivisionsX, this._subdivisionsY);
  84946. },
  84947. enumerable: true,
  84948. configurable: true
  84949. });
  84950. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  84951. /**
  84952. * X subdivisions
  84953. */
  84954. get: function () {
  84955. return this._subdivisionsX;
  84956. },
  84957. enumerable: true,
  84958. configurable: true
  84959. });
  84960. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  84961. /**
  84962. * Y subdivisions
  84963. */
  84964. get: function () {
  84965. return this._subdivisionsY;
  84966. },
  84967. enumerable: true,
  84968. configurable: true
  84969. });
  84970. /**
  84971. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  84972. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  84973. * @param chunksCount the number of subdivisions for x and y
  84974. * @param octreeBlocksSize (Default: 32)
  84975. */
  84976. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  84977. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  84978. this._subdivisionsX = chunksCount;
  84979. this._subdivisionsY = chunksCount;
  84980. this.subdivide(chunksCount);
  84981. // Call the octree system optimization if it is defined.
  84982. var thisAsAny = this;
  84983. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  84984. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  84985. }
  84986. };
  84987. /**
  84988. * Returns a height (y) value in the Worl system :
  84989. * the ground altitude at the coordinates (x, z) expressed in the World system.
  84990. * @param x x coordinate
  84991. * @param z z coordinate
  84992. * @returns the ground y position if (x, z) are outside the ground surface.
  84993. */
  84994. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  84995. var world = this.getWorldMatrix();
  84996. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  84997. world.invertToRef(invMat);
  84998. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  84999. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  85000. x = tmpVect.x;
  85001. z = tmpVect.z;
  85002. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  85003. return this.position.y;
  85004. }
  85005. if (!this._heightQuads || this._heightQuads.length == 0) {
  85006. this._initHeightQuads();
  85007. this._computeHeightQuads();
  85008. }
  85009. var facet = this._getFacetAt(x, z);
  85010. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  85011. // return y in the World system
  85012. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  85013. return tmpVect.y;
  85014. };
  85015. /**
  85016. * Returns a normalized vector (Vector3) orthogonal to the ground
  85017. * at the ground coordinates (x, z) expressed in the World system.
  85018. * @param x x coordinate
  85019. * @param z z coordinate
  85020. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85021. */
  85022. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  85023. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  85024. this.getNormalAtCoordinatesToRef(x, z, normal);
  85025. return normal;
  85026. };
  85027. /**
  85028. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85029. * at the ground coordinates (x, z) expressed in the World system.
  85030. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85031. * @param x x coordinate
  85032. * @param z z coordinate
  85033. * @param ref vector to store the result
  85034. * @returns the GroundMesh.
  85035. */
  85036. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  85037. var world = this.getWorldMatrix();
  85038. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  85039. world.invertToRef(tmpMat);
  85040. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  85041. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  85042. x = tmpVect.x;
  85043. z = tmpVect.z;
  85044. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  85045. return this;
  85046. }
  85047. if (!this._heightQuads || this._heightQuads.length == 0) {
  85048. this._initHeightQuads();
  85049. this._computeHeightQuads();
  85050. }
  85051. var facet = this._getFacetAt(x, z);
  85052. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  85053. return this;
  85054. };
  85055. /**
  85056. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85057. * if the ground has been updated.
  85058. * This can be used in the render loop.
  85059. * @returns the GroundMesh.
  85060. */
  85061. GroundMesh.prototype.updateCoordinateHeights = function () {
  85062. if (!this._heightQuads || this._heightQuads.length == 0) {
  85063. this._initHeightQuads();
  85064. }
  85065. this._computeHeightQuads();
  85066. return this;
  85067. };
  85068. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  85069. GroundMesh.prototype._getFacetAt = function (x, z) {
  85070. // retrieve col and row from x, z coordinates in the ground local system
  85071. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  85072. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  85073. var quad = this._heightQuads[row * this._subdivisionsX + col];
  85074. var facet;
  85075. if (z < quad.slope.x * x + quad.slope.y) {
  85076. facet = quad.facet1;
  85077. }
  85078. else {
  85079. facet = quad.facet2;
  85080. }
  85081. return facet;
  85082. };
  85083. // Creates and populates the heightMap array with "facet" elements :
  85084. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  85085. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  85086. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  85087. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  85088. // Returns the GroundMesh.
  85089. GroundMesh.prototype._initHeightQuads = function () {
  85090. var subdivisionsX = this._subdivisionsX;
  85091. var subdivisionsY = this._subdivisionsY;
  85092. this._heightQuads = new Array();
  85093. for (var row = 0; row < subdivisionsY; row++) {
  85094. for (var col = 0; col < subdivisionsX; col++) {
  85095. 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) };
  85096. this._heightQuads[row * subdivisionsX + col] = quad;
  85097. }
  85098. }
  85099. return this;
  85100. };
  85101. // Compute each quad element values and update the the heightMap array :
  85102. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  85103. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  85104. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  85105. // Returns the GroundMesh.
  85106. GroundMesh.prototype._computeHeightQuads = function () {
  85107. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85108. if (!positions) {
  85109. return this;
  85110. }
  85111. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  85112. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  85113. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  85114. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  85115. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  85116. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  85117. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  85118. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  85119. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  85120. var i = 0;
  85121. var j = 0;
  85122. var k = 0;
  85123. var cd = 0; // 2D slope coefficient : z = cd * x + h
  85124. var h = 0;
  85125. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  85126. var d2 = 0;
  85127. var subdivisionsX = this._subdivisionsX;
  85128. var subdivisionsY = this._subdivisionsY;
  85129. for (var row = 0; row < subdivisionsY; row++) {
  85130. for (var col = 0; col < subdivisionsX; col++) {
  85131. i = col * 3;
  85132. j = row * (subdivisionsX + 1) * 3;
  85133. k = (row + 1) * (subdivisionsX + 1) * 3;
  85134. v1.x = positions[j + i];
  85135. v1.y = positions[j + i + 1];
  85136. v1.z = positions[j + i + 2];
  85137. v2.x = positions[j + i + 3];
  85138. v2.y = positions[j + i + 4];
  85139. v2.z = positions[j + i + 5];
  85140. v3.x = positions[k + i];
  85141. v3.y = positions[k + i + 1];
  85142. v3.z = positions[k + i + 2];
  85143. v4.x = positions[k + i + 3];
  85144. v4.y = positions[k + i + 4];
  85145. v4.z = positions[k + i + 5];
  85146. // 2D slope V1V4
  85147. cd = (v4.z - v1.z) / (v4.x - v1.x);
  85148. h = v1.z - cd * v1.x; // v1 belongs to the slope
  85149. // facet equations :
  85150. // we compute each facet normal vector
  85151. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  85152. // we compute the value d by applying the equation to v1 which belongs to the plane
  85153. // then we store the facet equation in a Vector4
  85154. v2.subtractToRef(v1, v1v2);
  85155. v3.subtractToRef(v1, v1v3);
  85156. v4.subtractToRef(v1, v1v4);
  85157. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  85158. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  85159. norm1.normalize();
  85160. norm2.normalize();
  85161. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  85162. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  85163. var quad = this._heightQuads[row * subdivisionsX + col];
  85164. quad.slope.copyFromFloats(cd, h);
  85165. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  85166. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  85167. }
  85168. }
  85169. return this;
  85170. };
  85171. /**
  85172. * Serializes this ground mesh
  85173. * @param serializationObject object to write serialization to
  85174. */
  85175. GroundMesh.prototype.serialize = function (serializationObject) {
  85176. _super.prototype.serialize.call(this, serializationObject);
  85177. serializationObject.subdivisionsX = this._subdivisionsX;
  85178. serializationObject.subdivisionsY = this._subdivisionsY;
  85179. serializationObject.minX = this._minX;
  85180. serializationObject.maxX = this._maxX;
  85181. serializationObject.minZ = this._minZ;
  85182. serializationObject.maxZ = this._maxZ;
  85183. serializationObject.width = this._width;
  85184. serializationObject.height = this._height;
  85185. };
  85186. /**
  85187. * Parses a serialized ground mesh
  85188. * @param parsedMesh the serialized mesh
  85189. * @param scene the scene to create the ground mesh in
  85190. * @returns the created ground mesh
  85191. */
  85192. GroundMesh.Parse = function (parsedMesh, scene) {
  85193. var result = new GroundMesh(parsedMesh.name, scene);
  85194. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  85195. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  85196. result._minX = parsedMesh.minX;
  85197. result._maxX = parsedMesh.maxX;
  85198. result._minZ = parsedMesh.minZ;
  85199. result._maxZ = parsedMesh.maxZ;
  85200. result._width = parsedMesh.width;
  85201. result._height = parsedMesh.height;
  85202. return result;
  85203. };
  85204. return GroundMesh;
  85205. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  85206. /***/ }),
  85207. /***/ "./Meshes/index.ts":
  85208. /*!*************************!*\
  85209. !*** ./Meshes/index.ts ***!
  85210. \*************************/
  85211. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, DracoCompression, DiscBuilder, RibbonBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  85212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85213. "use strict";
  85214. __webpack_require__.r(__webpack_exports__);
  85215. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  85216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  85217. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  85218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  85219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  85220. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  85221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  85222. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  85223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  85224. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  85225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  85226. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  85227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  85228. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  85229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  85230. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  85231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  85232. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  85233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  85234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  85235. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  85236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  85237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  85238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  85239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  85240. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  85242. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  85243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  85244. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  85245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  85246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  85247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  85248. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  85249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  85250. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  85251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  85252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  85253. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  85254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  85255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  85256. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  85257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  85258. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  85259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  85260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  85261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  85262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  85263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  85264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  85265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  85266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  85267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  85268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  85269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  85270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  85271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  85272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  85273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  85274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  85275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  85276. /***/ }),
  85277. /***/ "./Meshes/instancedMesh.ts":
  85278. /*!*********************************!*\
  85279. !*** ./Meshes/instancedMesh.ts ***!
  85280. \*********************************/
  85281. /*! exports provided: InstancedMesh */
  85282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85283. "use strict";
  85284. __webpack_require__.r(__webpack_exports__);
  85285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  85286. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85287. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  85288. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  85289. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  85290. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  85291. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  85292. return new InstancedMesh(name, mesh);
  85293. };
  85294. /**
  85295. * Creates an instance based on a source mesh.
  85296. */
  85297. var InstancedMesh = /** @class */ (function (_super) {
  85298. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  85299. function InstancedMesh(name, source) {
  85300. var _this = _super.call(this, name, source.getScene()) || this;
  85301. /** @hidden */
  85302. _this._indexInSourceMeshInstanceArray = -1;
  85303. source.addInstance(_this);
  85304. _this._sourceMesh = source;
  85305. _this.position.copyFrom(source.position);
  85306. _this.rotation.copyFrom(source.rotation);
  85307. _this.scaling.copyFrom(source.scaling);
  85308. if (source.rotationQuaternion) {
  85309. _this.rotationQuaternion = source.rotationQuaternion.clone();
  85310. }
  85311. _this.infiniteDistance = source.infiniteDistance;
  85312. _this.setPivotMatrix(source.getPivotMatrix());
  85313. _this.refreshBoundingInfo();
  85314. _this._syncSubMeshes();
  85315. return _this;
  85316. }
  85317. /**
  85318. * Returns the string "InstancedMesh".
  85319. */
  85320. InstancedMesh.prototype.getClassName = function () {
  85321. return "InstancedMesh";
  85322. };
  85323. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  85324. // Methods
  85325. /**
  85326. * If the source mesh receives shadows
  85327. */
  85328. get: function () {
  85329. return this._sourceMesh.receiveShadows;
  85330. },
  85331. enumerable: true,
  85332. configurable: true
  85333. });
  85334. Object.defineProperty(InstancedMesh.prototype, "material", {
  85335. /**
  85336. * The material of the source mesh
  85337. */
  85338. get: function () {
  85339. return this._sourceMesh.material;
  85340. },
  85341. enumerable: true,
  85342. configurable: true
  85343. });
  85344. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  85345. /**
  85346. * Visibility of the source mesh
  85347. */
  85348. get: function () {
  85349. return this._sourceMesh.visibility;
  85350. },
  85351. enumerable: true,
  85352. configurable: true
  85353. });
  85354. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  85355. /**
  85356. * Skeleton of the source mesh
  85357. */
  85358. get: function () {
  85359. return this._sourceMesh.skeleton;
  85360. },
  85361. enumerable: true,
  85362. configurable: true
  85363. });
  85364. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  85365. /**
  85366. * Rendering ground id of the source mesh
  85367. */
  85368. get: function () {
  85369. return this._sourceMesh.renderingGroupId;
  85370. },
  85371. set: function (value) {
  85372. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  85373. return;
  85374. }
  85375. //no-op with warning
  85376. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  85377. },
  85378. enumerable: true,
  85379. configurable: true
  85380. });
  85381. /**
  85382. * Returns the total number of vertices (integer).
  85383. */
  85384. InstancedMesh.prototype.getTotalVertices = function () {
  85385. return this._sourceMesh.getTotalVertices();
  85386. };
  85387. /**
  85388. * Returns a positive integer : the total number of indices in this mesh geometry.
  85389. * @returns the numner of indices or zero if the mesh has no geometry.
  85390. */
  85391. InstancedMesh.prototype.getTotalIndices = function () {
  85392. return this._sourceMesh.getTotalIndices();
  85393. };
  85394. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  85395. /**
  85396. * The source mesh of the instance
  85397. */
  85398. get: function () {
  85399. return this._sourceMesh;
  85400. },
  85401. enumerable: true,
  85402. configurable: true
  85403. });
  85404. /**
  85405. * Is this node ready to be used/rendered
  85406. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85407. * @return {boolean} is it ready
  85408. */
  85409. InstancedMesh.prototype.isReady = function (completeCheck) {
  85410. if (completeCheck === void 0) { completeCheck = false; }
  85411. return this._sourceMesh.isReady(completeCheck, true);
  85412. };
  85413. /**
  85414. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85415. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85416. * @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.
  85417. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85418. */
  85419. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  85420. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  85421. };
  85422. /**
  85423. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85424. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85425. * The `data` are either a numeric array either a Float32Array.
  85426. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85427. * 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).
  85428. * Note that a new underlying VertexBuffer object is created each call.
  85429. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85430. *
  85431. * Possible `kind` values :
  85432. * - VertexBuffer.PositionKind
  85433. * - VertexBuffer.UVKind
  85434. * - VertexBuffer.UV2Kind
  85435. * - VertexBuffer.UV3Kind
  85436. * - VertexBuffer.UV4Kind
  85437. * - VertexBuffer.UV5Kind
  85438. * - VertexBuffer.UV6Kind
  85439. * - VertexBuffer.ColorKind
  85440. * - VertexBuffer.MatricesIndicesKind
  85441. * - VertexBuffer.MatricesIndicesExtraKind
  85442. * - VertexBuffer.MatricesWeightsKind
  85443. * - VertexBuffer.MatricesWeightsExtraKind
  85444. *
  85445. * Returns the Mesh.
  85446. */
  85447. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  85448. if (this.sourceMesh) {
  85449. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  85450. }
  85451. return this.sourceMesh;
  85452. };
  85453. /**
  85454. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85455. * If the mesh has no geometry, it is simply returned as it is.
  85456. * The `data` are either a numeric array either a Float32Array.
  85457. * No new underlying VertexBuffer object is created.
  85458. * 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.
  85459. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85460. *
  85461. * Possible `kind` values :
  85462. * - VertexBuffer.PositionKind
  85463. * - VertexBuffer.UVKind
  85464. * - VertexBuffer.UV2Kind
  85465. * - VertexBuffer.UV3Kind
  85466. * - VertexBuffer.UV4Kind
  85467. * - VertexBuffer.UV5Kind
  85468. * - VertexBuffer.UV6Kind
  85469. * - VertexBuffer.ColorKind
  85470. * - VertexBuffer.MatricesIndicesKind
  85471. * - VertexBuffer.MatricesIndicesExtraKind
  85472. * - VertexBuffer.MatricesWeightsKind
  85473. * - VertexBuffer.MatricesWeightsExtraKind
  85474. *
  85475. * Returns the Mesh.
  85476. */
  85477. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  85478. if (this.sourceMesh) {
  85479. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  85480. }
  85481. return this.sourceMesh;
  85482. };
  85483. /**
  85484. * Sets the mesh indices.
  85485. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85486. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85487. * This method creates a new index buffer each call.
  85488. * Returns the Mesh.
  85489. */
  85490. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  85491. if (totalVertices === void 0) { totalVertices = null; }
  85492. if (this.sourceMesh) {
  85493. this.sourceMesh.setIndices(indices, totalVertices);
  85494. }
  85495. return this.sourceMesh;
  85496. };
  85497. /**
  85498. * Boolean : True if the mesh owns the requested kind of data.
  85499. */
  85500. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  85501. return this._sourceMesh.isVerticesDataPresent(kind);
  85502. };
  85503. /**
  85504. * Returns an array of indices (IndicesArray).
  85505. */
  85506. InstancedMesh.prototype.getIndices = function () {
  85507. return this._sourceMesh.getIndices();
  85508. };
  85509. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  85510. get: function () {
  85511. return this._sourceMesh._positions;
  85512. },
  85513. enumerable: true,
  85514. configurable: true
  85515. });
  85516. /**
  85517. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85518. * This means the mesh underlying bounding box and sphere are recomputed.
  85519. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85520. * @returns the current mesh
  85521. */
  85522. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  85523. if (applySkeleton === void 0) { applySkeleton = false; }
  85524. if (this._boundingInfo && this._boundingInfo.isLocked) {
  85525. return this;
  85526. }
  85527. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  85528. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  85529. return this;
  85530. };
  85531. /** @hidden */
  85532. InstancedMesh.prototype._preActivate = function () {
  85533. if (this._currentLOD) {
  85534. this._currentLOD._preActivate();
  85535. }
  85536. return this;
  85537. };
  85538. /** @hidden */
  85539. InstancedMesh.prototype._activate = function (renderId) {
  85540. if (this._currentLOD) {
  85541. this._currentLOD._registerInstanceForRenderId(this, renderId);
  85542. }
  85543. return this;
  85544. };
  85545. /**
  85546. * Returns the current associated LOD AbstractMesh.
  85547. */
  85548. InstancedMesh.prototype.getLOD = function (camera) {
  85549. if (!camera) {
  85550. return this;
  85551. }
  85552. var boundingInfo = this.getBoundingInfo();
  85553. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  85554. if (this._currentLOD === this.sourceMesh) {
  85555. return this;
  85556. }
  85557. return this._currentLOD;
  85558. };
  85559. /** @hidden */
  85560. InstancedMesh.prototype._syncSubMeshes = function () {
  85561. this.releaseSubMeshes();
  85562. if (this._sourceMesh.subMeshes) {
  85563. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  85564. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  85565. }
  85566. }
  85567. return this;
  85568. };
  85569. /** @hidden */
  85570. InstancedMesh.prototype._generatePointsArray = function () {
  85571. return this._sourceMesh._generatePointsArray();
  85572. };
  85573. /**
  85574. * Creates a new InstancedMesh from the current mesh.
  85575. * - name (string) : the cloned mesh name
  85576. * - newParent (optional Node) : the optional Node to parent the clone to.
  85577. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85578. *
  85579. * Returns the clone.
  85580. */
  85581. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  85582. var result = this._sourceMesh.createInstance(name);
  85583. // Deep copy
  85584. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  85585. // Bounding info
  85586. this.refreshBoundingInfo();
  85587. // Parent
  85588. if (newParent) {
  85589. result.parent = newParent;
  85590. }
  85591. if (!doNotCloneChildren) {
  85592. // Children
  85593. for (var index = 0; index < this.getScene().meshes.length; index++) {
  85594. var mesh = this.getScene().meshes[index];
  85595. if (mesh.parent === this) {
  85596. mesh.clone(mesh.name, result);
  85597. }
  85598. }
  85599. }
  85600. result.computeWorldMatrix(true);
  85601. return result;
  85602. };
  85603. /**
  85604. * Disposes the InstancedMesh.
  85605. * Returns nothing.
  85606. */
  85607. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85608. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85609. // Remove from mesh
  85610. this._sourceMesh.removeInstance(this);
  85611. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85612. };
  85613. return InstancedMesh;
  85614. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  85615. /***/ }),
  85616. /***/ "./Meshes/linesMesh.ts":
  85617. /*!*****************************!*\
  85618. !*** ./Meshes/linesMesh.ts ***!
  85619. \*****************************/
  85620. /*! exports provided: LinesMesh, InstancedLinesMesh */
  85621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85622. "use strict";
  85623. __webpack_require__.r(__webpack_exports__);
  85624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  85625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  85626. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85627. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85628. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  85629. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  85630. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  85631. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  85632. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  85633. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  85634. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  85635. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  85636. /**
  85637. * Line mesh
  85638. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85639. */
  85640. var LinesMesh = /** @class */ (function (_super) {
  85641. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  85642. /**
  85643. * Creates a new LinesMesh
  85644. * @param name defines the name
  85645. * @param scene defines the hosting scene
  85646. * @param parent defines the parent mesh if any
  85647. * @param source defines the optional source LinesMesh used to clone data from
  85648. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85649. * When false, achieved by calling a clone(), also passing False.
  85650. * This will make creation of children, recursive.
  85651. * @param useVertexColor defines if this LinesMesh supports vertex color
  85652. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85653. */
  85654. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  85655. /**
  85656. * If vertex color should be applied to the mesh
  85657. */
  85658. useVertexColor,
  85659. /**
  85660. * If vertex alpha should be applied to the mesh
  85661. */
  85662. useVertexAlpha) {
  85663. if (scene === void 0) { scene = null; }
  85664. if (parent === void 0) { parent = null; }
  85665. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  85666. _this.useVertexColor = useVertexColor;
  85667. _this.useVertexAlpha = useVertexAlpha;
  85668. /**
  85669. * Color of the line (Default: White)
  85670. */
  85671. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  85672. /**
  85673. * Alpha of the line (Default: 1)
  85674. */
  85675. _this.alpha = 1;
  85676. if (source) {
  85677. _this.color = source.color.clone();
  85678. _this.alpha = source.alpha;
  85679. _this.useVertexColor = source.useVertexColor;
  85680. _this.useVertexAlpha = source.useVertexAlpha;
  85681. }
  85682. _this.intersectionThreshold = 0.1;
  85683. var defines = [];
  85684. var options = {
  85685. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  85686. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
  85687. needAlphaBlending: true,
  85688. defines: defines
  85689. };
  85690. if (useVertexAlpha === false) {
  85691. options.needAlphaBlending = false;
  85692. }
  85693. if (!useVertexColor) {
  85694. options.uniforms.push("color");
  85695. }
  85696. else {
  85697. options.defines.push("#define VERTEXCOLOR");
  85698. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  85699. }
  85700. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  85701. return _this;
  85702. }
  85703. LinesMesh.prototype._addClipPlaneDefine = function (label) {
  85704. var define = "#define " + label;
  85705. var index = this._colorShader.options.defines.indexOf(define);
  85706. if (index !== -1) {
  85707. return;
  85708. }
  85709. this._colorShader.options.defines.push(define);
  85710. };
  85711. LinesMesh.prototype._removeClipPlaneDefine = function (label) {
  85712. var define = "#define " + label;
  85713. var index = this._colorShader.options.defines.indexOf(define);
  85714. if (index === -1) {
  85715. return;
  85716. }
  85717. this._colorShader.options.defines.splice(index, 1);
  85718. };
  85719. LinesMesh.prototype.isReady = function () {
  85720. var scene = this.getScene();
  85721. // Clip planes
  85722. scene.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE");
  85723. scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
  85724. scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
  85725. scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
  85726. if (!this._colorShader.isReady()) {
  85727. return false;
  85728. }
  85729. return _super.prototype.isReady.call(this);
  85730. };
  85731. /**
  85732. * Returns the string "LineMesh"
  85733. */
  85734. LinesMesh.prototype.getClassName = function () {
  85735. return "LinesMesh";
  85736. };
  85737. Object.defineProperty(LinesMesh.prototype, "material", {
  85738. /**
  85739. * @hidden
  85740. */
  85741. get: function () {
  85742. return this._colorShader;
  85743. },
  85744. /**
  85745. * @hidden
  85746. */
  85747. set: function (value) {
  85748. // Do nothing
  85749. },
  85750. enumerable: true,
  85751. configurable: true
  85752. });
  85753. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  85754. /**
  85755. * @hidden
  85756. */
  85757. get: function () {
  85758. return false;
  85759. },
  85760. enumerable: true,
  85761. configurable: true
  85762. });
  85763. /** @hidden */
  85764. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  85765. if (!this._geometry) {
  85766. return this;
  85767. }
  85768. var colorEffect = this._colorShader.getEffect();
  85769. // VBOs
  85770. this._geometry._bind(colorEffect);
  85771. // Color
  85772. if (!this.useVertexColor) {
  85773. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  85774. }
  85775. // Clip planes
  85776. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__["MaterialHelper"].BindClipPlane(colorEffect, this.getScene());
  85777. return this;
  85778. };
  85779. /** @hidden */
  85780. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  85781. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  85782. return this;
  85783. }
  85784. var engine = this.getScene().getEngine();
  85785. // Draw order
  85786. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  85787. return this;
  85788. };
  85789. /**
  85790. * Disposes of the line mesh
  85791. * @param doNotRecurse If children should be disposed
  85792. */
  85793. LinesMesh.prototype.dispose = function (doNotRecurse) {
  85794. this._colorShader.dispose(false, false, true);
  85795. _super.prototype.dispose.call(this, doNotRecurse);
  85796. };
  85797. /**
  85798. * Returns a new LineMesh object cloned from the current one.
  85799. */
  85800. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  85801. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  85802. };
  85803. /**
  85804. * Creates a new InstancedLinesMesh object from the mesh model.
  85805. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85806. * @param name defines the name of the new instance
  85807. * @returns a new InstancedLinesMesh
  85808. */
  85809. LinesMesh.prototype.createInstance = function (name) {
  85810. return new InstancedLinesMesh(name, this);
  85811. };
  85812. return LinesMesh;
  85813. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  85814. /**
  85815. * Creates an instance based on a source LinesMesh
  85816. */
  85817. var InstancedLinesMesh = /** @class */ (function (_super) {
  85818. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  85819. function InstancedLinesMesh(name, source) {
  85820. var _this = _super.call(this, name, source) || this;
  85821. _this.intersectionThreshold = source.intersectionThreshold;
  85822. return _this;
  85823. }
  85824. /**
  85825. * Returns the string "InstancedLinesMesh".
  85826. */
  85827. InstancedLinesMesh.prototype.getClassName = function () {
  85828. return "InstancedLinesMesh";
  85829. };
  85830. return InstancedLinesMesh;
  85831. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  85832. /***/ }),
  85833. /***/ "./Meshes/mesh.ts":
  85834. /*!************************!*\
  85835. !*** ./Meshes/mesh.ts ***!
  85836. \************************/
  85837. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  85838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85839. "use strict";
  85840. __webpack_require__.r(__webpack_exports__);
  85841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  85842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  85843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  85844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  85845. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85846. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  85847. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  85848. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  85849. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  85850. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85851. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  85852. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  85853. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85854. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  85855. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  85856. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  85857. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  85858. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  85859. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  85860. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  85861. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  85862. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  85863. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  85864. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  85865. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  85866. /**
  85867. * Class used to represent a specific level of detail of a mesh
  85868. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85869. */
  85870. var MeshLODLevel = /** @class */ (function () {
  85871. /**
  85872. * Creates a new LOD level
  85873. * @param distance defines the distance where this level should star being displayed
  85874. * @param mesh defines the mesh to use to render this level
  85875. */
  85876. function MeshLODLevel(
  85877. /** Defines the distance where this level should star being displayed */
  85878. distance,
  85879. /** Defines the mesh to use to render this level */
  85880. mesh) {
  85881. this.distance = distance;
  85882. this.mesh = mesh;
  85883. }
  85884. return MeshLODLevel;
  85885. }());
  85886. /**
  85887. * @hidden
  85888. **/
  85889. var _CreationDataStorage = /** @class */ (function () {
  85890. function _CreationDataStorage() {
  85891. }
  85892. return _CreationDataStorage;
  85893. }());
  85894. /**
  85895. * @hidden
  85896. **/
  85897. var _InstanceDataStorage = /** @class */ (function () {
  85898. function _InstanceDataStorage() {
  85899. this.visibleInstances = {};
  85900. this.renderIdForInstances = new Array();
  85901. this.batchCache = new _InstancesBatch();
  85902. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  85903. }
  85904. return _InstanceDataStorage;
  85905. }());
  85906. /**
  85907. * @hidden
  85908. **/
  85909. var _InstancesBatch = /** @class */ (function () {
  85910. function _InstancesBatch() {
  85911. this.mustReturn = false;
  85912. this.visibleInstances = new Array();
  85913. this.renderSelf = new Array();
  85914. }
  85915. return _InstancesBatch;
  85916. }());
  85917. /**
  85918. * Class used to represent renderable models
  85919. */
  85920. var Mesh = /** @class */ (function (_super) {
  85921. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  85922. /**
  85923. * @constructor
  85924. * @param name The value used by scene.getMeshByName() to do a lookup.
  85925. * @param scene The scene to add this mesh to.
  85926. * @param parent The parent of this mesh, if it has one
  85927. * @param source An optional Mesh from which geometry is shared, cloned.
  85928. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85929. * When false, achieved by calling a clone(), also passing False.
  85930. * This will make creation of children, recursive.
  85931. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  85932. */
  85933. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  85934. if (scene === void 0) { scene = null; }
  85935. if (parent === void 0) { parent = null; }
  85936. if (source === void 0) { source = null; }
  85937. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85938. var _this = _super.call(this, name, scene) || this;
  85939. // Members
  85940. /**
  85941. * Gets the delay loading state of the mesh (when delay loading is turned on)
  85942. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  85943. */
  85944. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  85945. /**
  85946. * Gets the list of instances created from this mesh
  85947. * it is not supposed to be modified manually.
  85948. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  85949. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85950. */
  85951. _this.instances = new Array();
  85952. _this._LODLevels = new Array();
  85953. /** @hidden */
  85954. _this._instanceDataStorage = new _InstanceDataStorage();
  85955. // Use by builder only to know what orientation were the mesh build in.
  85956. /** @hidden */
  85957. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  85958. /**
  85959. * Use this property to change the original side orientation defined at construction time
  85960. */
  85961. _this.overrideMaterialSideOrientation = null;
  85962. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  85963. // Will be used to save a source mesh reference, If any
  85964. _this._source = null;
  85965. /** @hidden */
  85966. _this._isMesh = true;
  85967. scene = _this.getScene();
  85968. if (source) {
  85969. // Geometry
  85970. if (source._geometry) {
  85971. source._geometry.applyToMesh(_this);
  85972. }
  85973. // Deep copy
  85974. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  85975. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  85976. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  85977. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  85978. "onDisposeObservable"
  85979. ], ["_poseMatrix"]);
  85980. // Source mesh
  85981. _this._source = source;
  85982. if (scene.useClonedMeshhMap) {
  85983. if (!source.meshMap) {
  85984. source.meshMap = {};
  85985. }
  85986. source.meshMap[_this.uniqueId] = _this;
  85987. }
  85988. // Construction Params
  85989. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  85990. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  85991. _this._creationDataStorage = source._creationDataStorage;
  85992. // Animation ranges
  85993. if (_this._source._ranges) {
  85994. var ranges = _this._source._ranges;
  85995. for (var name in ranges) {
  85996. if (!ranges.hasOwnProperty(name)) {
  85997. continue;
  85998. }
  85999. if (!ranges[name]) {
  86000. continue;
  86001. }
  86002. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  86003. }
  86004. }
  86005. // Metadata
  86006. if (source.metadata && source.metadata.clone) {
  86007. _this.metadata = source.metadata.clone();
  86008. }
  86009. else {
  86010. _this.metadata = source.metadata;
  86011. }
  86012. // Tags
  86013. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  86014. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  86015. }
  86016. // Parent
  86017. _this.parent = source.parent;
  86018. // Pivot
  86019. _this.setPivotMatrix(source.getPivotMatrix());
  86020. _this.id = name + "." + source.id;
  86021. // Material
  86022. _this.material = source.material;
  86023. var index;
  86024. if (!doNotCloneChildren) {
  86025. // Children
  86026. var directDescendants = source.getDescendants(true);
  86027. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  86028. var child = directDescendants[index_1];
  86029. if (child.clone) {
  86030. child.clone(name + "." + child.name, _this);
  86031. }
  86032. }
  86033. }
  86034. // Physics clone
  86035. var physicsEngine = _this.getScene().getPhysicsEngine();
  86036. if (clonePhysicsImpostor && physicsEngine) {
  86037. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  86038. if (impostor) {
  86039. _this.physicsImpostor = impostor.clone(_this);
  86040. }
  86041. }
  86042. // Particles
  86043. for (index = 0; index < scene.particleSystems.length; index++) {
  86044. var system = scene.particleSystems[index];
  86045. if (system.emitter === source) {
  86046. system.clone(system.name, _this);
  86047. }
  86048. }
  86049. _this.refreshBoundingInfo();
  86050. _this.computeWorldMatrix(true);
  86051. }
  86052. // Parent
  86053. if (parent !== null) {
  86054. _this.parent = parent;
  86055. }
  86056. return _this;
  86057. }
  86058. /**
  86059. * Gets the default side orientation.
  86060. * @param orientation the orientation to value to attempt to get
  86061. * @returns the default orientation
  86062. * @hidden
  86063. */
  86064. Mesh._GetDefaultSideOrientation = function (orientation) {
  86065. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  86066. };
  86067. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  86068. /**
  86069. * An event triggered before rendering the mesh
  86070. */
  86071. get: function () {
  86072. if (!this._onBeforeRenderObservable) {
  86073. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86074. }
  86075. return this._onBeforeRenderObservable;
  86076. },
  86077. enumerable: true,
  86078. configurable: true
  86079. });
  86080. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  86081. /**
  86082. * An event triggered before binding the mesh
  86083. */
  86084. get: function () {
  86085. if (!this._onBeforeBindObservable) {
  86086. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86087. }
  86088. return this._onBeforeBindObservable;
  86089. },
  86090. enumerable: true,
  86091. configurable: true
  86092. });
  86093. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  86094. /**
  86095. * An event triggered after rendering the mesh
  86096. */
  86097. get: function () {
  86098. if (!this._onAfterRenderObservable) {
  86099. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86100. }
  86101. return this._onAfterRenderObservable;
  86102. },
  86103. enumerable: true,
  86104. configurable: true
  86105. });
  86106. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  86107. /**
  86108. * An event triggered before drawing the mesh
  86109. */
  86110. get: function () {
  86111. if (!this._onBeforeDrawObservable) {
  86112. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86113. }
  86114. return this._onBeforeDrawObservable;
  86115. },
  86116. enumerable: true,
  86117. configurable: true
  86118. });
  86119. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  86120. /**
  86121. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  86122. */
  86123. set: function (callback) {
  86124. if (this._onBeforeDrawObserver) {
  86125. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  86126. }
  86127. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  86128. },
  86129. enumerable: true,
  86130. configurable: true
  86131. });
  86132. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  86133. /**
  86134. * Gets or sets the morph target manager
  86135. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86136. */
  86137. get: function () {
  86138. return this._morphTargetManager;
  86139. },
  86140. set: function (value) {
  86141. if (this._morphTargetManager === value) {
  86142. return;
  86143. }
  86144. this._morphTargetManager = value;
  86145. this._syncGeometryWithMorphTargetManager();
  86146. },
  86147. enumerable: true,
  86148. configurable: true
  86149. });
  86150. Object.defineProperty(Mesh.prototype, "source", {
  86151. /**
  86152. * Gets the source mesh (the one used to clone this one from)
  86153. */
  86154. get: function () {
  86155. return this._source;
  86156. },
  86157. enumerable: true,
  86158. configurable: true
  86159. });
  86160. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  86161. /**
  86162. * Gets or sets a boolean indicating that this mesh does not use index buffer
  86163. */
  86164. get: function () {
  86165. return this._unIndexed;
  86166. },
  86167. set: function (value) {
  86168. if (this._unIndexed !== value) {
  86169. this._unIndexed = value;
  86170. this._markSubMeshesAsAttributesDirty();
  86171. }
  86172. },
  86173. enumerable: true,
  86174. configurable: true
  86175. });
  86176. // Methods
  86177. /**
  86178. * Gets the class name
  86179. * @returns the string "Mesh".
  86180. */
  86181. Mesh.prototype.getClassName = function () {
  86182. return "Mesh";
  86183. };
  86184. /**
  86185. * Returns a description of this mesh
  86186. * @param fullDetails define if full details about this mesh must be used
  86187. * @returns a descriptive string representing this mesh
  86188. */
  86189. Mesh.prototype.toString = function (fullDetails) {
  86190. var ret = _super.prototype.toString.call(this, fullDetails);
  86191. ret += ", n vertices: " + this.getTotalVertices();
  86192. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  86193. if (this.animations) {
  86194. for (var i = 0; i < this.animations.length; i++) {
  86195. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  86196. }
  86197. }
  86198. if (fullDetails) {
  86199. if (this._geometry) {
  86200. var ib = this.getIndices();
  86201. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86202. if (vb && ib) {
  86203. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  86204. }
  86205. }
  86206. else {
  86207. ret += ", flat shading: UNKNOWN";
  86208. }
  86209. }
  86210. return ret;
  86211. };
  86212. /** @hidden */
  86213. Mesh.prototype._unBindEffect = function () {
  86214. _super.prototype._unBindEffect.call(this);
  86215. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  86216. var instance = _a[_i];
  86217. instance._unBindEffect();
  86218. }
  86219. };
  86220. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  86221. /**
  86222. * Gets a boolean indicating if this mesh has LOD
  86223. */
  86224. get: function () {
  86225. return this._LODLevels.length > 0;
  86226. },
  86227. enumerable: true,
  86228. configurable: true
  86229. });
  86230. /**
  86231. * Gets the list of MeshLODLevel associated with the current mesh
  86232. * @returns an array of MeshLODLevel
  86233. */
  86234. Mesh.prototype.getLODLevels = function () {
  86235. return this._LODLevels;
  86236. };
  86237. Mesh.prototype._sortLODLevels = function () {
  86238. this._LODLevels.sort(function (a, b) {
  86239. if (a.distance < b.distance) {
  86240. return 1;
  86241. }
  86242. if (a.distance > b.distance) {
  86243. return -1;
  86244. }
  86245. return 0;
  86246. });
  86247. };
  86248. /**
  86249. * Add a mesh as LOD level triggered at the given distance.
  86250. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86251. * @param distance The distance from the center of the object to show this level
  86252. * @param mesh The mesh to be added as LOD level (can be null)
  86253. * @return This mesh (for chaining)
  86254. */
  86255. Mesh.prototype.addLODLevel = function (distance, mesh) {
  86256. if (mesh && mesh._masterMesh) {
  86257. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  86258. return this;
  86259. }
  86260. var level = new MeshLODLevel(distance, mesh);
  86261. this._LODLevels.push(level);
  86262. if (mesh) {
  86263. mesh._masterMesh = this;
  86264. }
  86265. this._sortLODLevels();
  86266. return this;
  86267. };
  86268. /**
  86269. * Returns the LOD level mesh at the passed distance or null if not found.
  86270. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86271. * @param distance The distance from the center of the object to show this level
  86272. * @returns a Mesh or `null`
  86273. */
  86274. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  86275. for (var index = 0; index < this._LODLevels.length; index++) {
  86276. var level = this._LODLevels[index];
  86277. if (level.distance === distance) {
  86278. return level.mesh;
  86279. }
  86280. }
  86281. return null;
  86282. };
  86283. /**
  86284. * Remove a mesh from the LOD array
  86285. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86286. * @param mesh defines the mesh to be removed
  86287. * @return This mesh (for chaining)
  86288. */
  86289. Mesh.prototype.removeLODLevel = function (mesh) {
  86290. for (var index = 0; index < this._LODLevels.length; index++) {
  86291. if (this._LODLevels[index].mesh === mesh) {
  86292. this._LODLevels.splice(index, 1);
  86293. if (mesh) {
  86294. mesh._masterMesh = null;
  86295. }
  86296. }
  86297. }
  86298. this._sortLODLevels();
  86299. return this;
  86300. };
  86301. /**
  86302. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  86303. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86304. * @param camera defines the camera to use to compute distance
  86305. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  86306. * @return This mesh (for chaining)
  86307. */
  86308. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  86309. if (!this._LODLevels || this._LODLevels.length === 0) {
  86310. return this;
  86311. }
  86312. var bSphere;
  86313. if (boundingSphere) {
  86314. bSphere = boundingSphere;
  86315. }
  86316. else {
  86317. var boundingInfo = this.getBoundingInfo();
  86318. bSphere = boundingInfo.boundingSphere;
  86319. }
  86320. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  86321. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  86322. if (this.onLODLevelSelection) {
  86323. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  86324. }
  86325. return this;
  86326. }
  86327. for (var index = 0; index < this._LODLevels.length; index++) {
  86328. var level = this._LODLevels[index];
  86329. if (level.distance < distanceToCamera) {
  86330. if (level.mesh) {
  86331. level.mesh._preActivate();
  86332. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  86333. }
  86334. if (this.onLODLevelSelection) {
  86335. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  86336. }
  86337. return level.mesh;
  86338. }
  86339. }
  86340. if (this.onLODLevelSelection) {
  86341. this.onLODLevelSelection(distanceToCamera, this, this);
  86342. }
  86343. return this;
  86344. };
  86345. Object.defineProperty(Mesh.prototype, "geometry", {
  86346. /**
  86347. * Gets the mesh internal Geometry object
  86348. */
  86349. get: function () {
  86350. return this._geometry;
  86351. },
  86352. enumerable: true,
  86353. configurable: true
  86354. });
  86355. /**
  86356. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  86357. * @returns the total number of vertices
  86358. */
  86359. Mesh.prototype.getTotalVertices = function () {
  86360. if (this._geometry === null || this._geometry === undefined) {
  86361. return 0;
  86362. }
  86363. return this._geometry.getTotalVertices();
  86364. };
  86365. /**
  86366. * Returns the content of an associated vertex buffer
  86367. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86368. * - VertexBuffer.PositionKind
  86369. * - VertexBuffer.UVKind
  86370. * - VertexBuffer.UV2Kind
  86371. * - VertexBuffer.UV3Kind
  86372. * - VertexBuffer.UV4Kind
  86373. * - VertexBuffer.UV5Kind
  86374. * - VertexBuffer.UV6Kind
  86375. * - VertexBuffer.ColorKind
  86376. * - VertexBuffer.MatricesIndicesKind
  86377. * - VertexBuffer.MatricesIndicesExtraKind
  86378. * - VertexBuffer.MatricesWeightsKind
  86379. * - VertexBuffer.MatricesWeightsExtraKind
  86380. * @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
  86381. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  86382. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  86383. */
  86384. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  86385. if (!this._geometry) {
  86386. return null;
  86387. }
  86388. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  86389. };
  86390. /**
  86391. * Returns the mesh VertexBuffer object from the requested `kind`
  86392. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86393. * - VertexBuffer.PositionKind
  86394. * - VertexBuffer.UVKind
  86395. * - VertexBuffer.UV2Kind
  86396. * - VertexBuffer.UV3Kind
  86397. * - VertexBuffer.UV4Kind
  86398. * - VertexBuffer.UV5Kind
  86399. * - VertexBuffer.UV6Kind
  86400. * - VertexBuffer.ColorKind
  86401. * - VertexBuffer.MatricesIndicesKind
  86402. * - VertexBuffer.MatricesIndicesExtraKind
  86403. * - VertexBuffer.MatricesWeightsKind
  86404. * - VertexBuffer.MatricesWeightsExtraKind
  86405. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  86406. */
  86407. Mesh.prototype.getVertexBuffer = function (kind) {
  86408. if (!this._geometry) {
  86409. return null;
  86410. }
  86411. return this._geometry.getVertexBuffer(kind);
  86412. };
  86413. /**
  86414. * Tests if a specific vertex buffer is associated with this mesh
  86415. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  86416. * - VertexBuffer.PositionKind
  86417. * - VertexBuffer.UVKind
  86418. * - VertexBuffer.UV2Kind
  86419. * - VertexBuffer.UV3Kind
  86420. * - VertexBuffer.UV4Kind
  86421. * - VertexBuffer.UV5Kind
  86422. * - VertexBuffer.UV6Kind
  86423. * - VertexBuffer.ColorKind
  86424. * - VertexBuffer.MatricesIndicesKind
  86425. * - VertexBuffer.MatricesIndicesExtraKind
  86426. * - VertexBuffer.MatricesWeightsKind
  86427. * - VertexBuffer.MatricesWeightsExtraKind
  86428. * @returns a boolean
  86429. */
  86430. Mesh.prototype.isVerticesDataPresent = function (kind) {
  86431. if (!this._geometry) {
  86432. if (this._delayInfo) {
  86433. return this._delayInfo.indexOf(kind) !== -1;
  86434. }
  86435. return false;
  86436. }
  86437. return this._geometry.isVerticesDataPresent(kind);
  86438. };
  86439. /**
  86440. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  86441. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  86442. * - VertexBuffer.PositionKind
  86443. * - VertexBuffer.UVKind
  86444. * - VertexBuffer.UV2Kind
  86445. * - VertexBuffer.UV3Kind
  86446. * - VertexBuffer.UV4Kind
  86447. * - VertexBuffer.UV5Kind
  86448. * - VertexBuffer.UV6Kind
  86449. * - VertexBuffer.ColorKind
  86450. * - VertexBuffer.MatricesIndicesKind
  86451. * - VertexBuffer.MatricesIndicesExtraKind
  86452. * - VertexBuffer.MatricesWeightsKind
  86453. * - VertexBuffer.MatricesWeightsExtraKind
  86454. * @returns a boolean
  86455. */
  86456. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  86457. if (!this._geometry) {
  86458. if (this._delayInfo) {
  86459. return this._delayInfo.indexOf(kind) !== -1;
  86460. }
  86461. return false;
  86462. }
  86463. return this._geometry.isVertexBufferUpdatable(kind);
  86464. };
  86465. /**
  86466. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  86467. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86468. * - VertexBuffer.PositionKind
  86469. * - VertexBuffer.UVKind
  86470. * - VertexBuffer.UV2Kind
  86471. * - VertexBuffer.UV3Kind
  86472. * - VertexBuffer.UV4Kind
  86473. * - VertexBuffer.UV5Kind
  86474. * - VertexBuffer.UV6Kind
  86475. * - VertexBuffer.ColorKind
  86476. * - VertexBuffer.MatricesIndicesKind
  86477. * - VertexBuffer.MatricesIndicesExtraKind
  86478. * - VertexBuffer.MatricesWeightsKind
  86479. * - VertexBuffer.MatricesWeightsExtraKind
  86480. * @returns an array of strings
  86481. */
  86482. Mesh.prototype.getVerticesDataKinds = function () {
  86483. if (!this._geometry) {
  86484. var result = new Array();
  86485. if (this._delayInfo) {
  86486. this._delayInfo.forEach(function (kind) {
  86487. result.push(kind);
  86488. });
  86489. }
  86490. return result;
  86491. }
  86492. return this._geometry.getVerticesDataKinds();
  86493. };
  86494. /**
  86495. * Returns a positive integer : the total number of indices in this mesh geometry.
  86496. * @returns the numner of indices or zero if the mesh has no geometry.
  86497. */
  86498. Mesh.prototype.getTotalIndices = function () {
  86499. if (!this._geometry) {
  86500. return 0;
  86501. }
  86502. return this._geometry.getTotalIndices();
  86503. };
  86504. /**
  86505. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86506. * @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.
  86507. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86508. * @returns the indices array or an empty array if the mesh has no geometry
  86509. */
  86510. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  86511. if (!this._geometry) {
  86512. return [];
  86513. }
  86514. return this._geometry.getIndices(copyWhenShared, forceCopy);
  86515. };
  86516. Object.defineProperty(Mesh.prototype, "isBlocked", {
  86517. get: function () {
  86518. return this._masterMesh !== null && this._masterMesh !== undefined;
  86519. },
  86520. enumerable: true,
  86521. configurable: true
  86522. });
  86523. /**
  86524. * Determine if the current mesh is ready to be rendered
  86525. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86526. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  86527. * @returns true if all associated assets are ready (material, textures, shaders)
  86528. */
  86529. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  86530. if (completeCheck === void 0) { completeCheck = false; }
  86531. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  86532. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  86533. return false;
  86534. }
  86535. if (!_super.prototype.isReady.call(this, completeCheck)) {
  86536. return false;
  86537. }
  86538. if (!this.subMeshes || this.subMeshes.length === 0) {
  86539. return true;
  86540. }
  86541. if (!completeCheck) {
  86542. return true;
  86543. }
  86544. var engine = this.getEngine();
  86545. var scene = this.getScene();
  86546. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  86547. this.computeWorldMatrix();
  86548. var mat = this.material || scene.defaultMaterial;
  86549. if (mat) {
  86550. if (mat._storeEffectOnSubMeshes) {
  86551. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  86552. var subMesh = _a[_i];
  86553. var effectiveMaterial = subMesh.getMaterial();
  86554. if (effectiveMaterial) {
  86555. if (effectiveMaterial._storeEffectOnSubMeshes) {
  86556. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  86557. return false;
  86558. }
  86559. }
  86560. else {
  86561. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  86562. return false;
  86563. }
  86564. }
  86565. }
  86566. }
  86567. }
  86568. else {
  86569. if (!mat.isReady(this, hardwareInstancedRendering)) {
  86570. return false;
  86571. }
  86572. }
  86573. }
  86574. // Shadows
  86575. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  86576. var light = _c[_b];
  86577. var generator = light.getShadowGenerator();
  86578. if (generator) {
  86579. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  86580. var subMesh = _e[_d];
  86581. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  86582. return false;
  86583. }
  86584. }
  86585. }
  86586. }
  86587. // LOD
  86588. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  86589. var lod = _g[_f];
  86590. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  86591. return false;
  86592. }
  86593. }
  86594. return true;
  86595. };
  86596. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  86597. /**
  86598. * 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.
  86599. */
  86600. get: function () {
  86601. return this._areNormalsFrozen;
  86602. },
  86603. enumerable: true,
  86604. configurable: true
  86605. });
  86606. /**
  86607. * 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.
  86608. * @returns the current mesh
  86609. */
  86610. Mesh.prototype.freezeNormals = function () {
  86611. this._areNormalsFrozen = true;
  86612. return this;
  86613. };
  86614. /**
  86615. * 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
  86616. * @returns the current mesh
  86617. */
  86618. Mesh.prototype.unfreezeNormals = function () {
  86619. this._areNormalsFrozen = false;
  86620. return this;
  86621. };
  86622. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  86623. /**
  86624. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  86625. */
  86626. set: function (count) {
  86627. this._instanceDataStorage.overridenInstanceCount = count;
  86628. },
  86629. enumerable: true,
  86630. configurable: true
  86631. });
  86632. // Methods
  86633. /** @hidden */
  86634. Mesh.prototype._preActivate = function () {
  86635. var sceneRenderId = this.getScene().getRenderId();
  86636. if (this._preActivateId === sceneRenderId) {
  86637. return this;
  86638. }
  86639. this._preActivateId = sceneRenderId;
  86640. this._instanceDataStorage.visibleInstances = null;
  86641. return this;
  86642. };
  86643. /** @hidden */
  86644. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  86645. if (this._instanceDataStorage.visibleInstances) {
  86646. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  86647. }
  86648. return this;
  86649. };
  86650. /** @hidden */
  86651. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  86652. if (!this._instanceDataStorage.visibleInstances) {
  86653. this._instanceDataStorage.visibleInstances = {
  86654. defaultRenderId: renderId,
  86655. selfDefaultRenderId: this._renderId
  86656. };
  86657. }
  86658. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  86659. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  86660. }
  86661. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  86662. return this;
  86663. };
  86664. /**
  86665. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86666. * This means the mesh underlying bounding box and sphere are recomputed.
  86667. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86668. * @returns the current mesh
  86669. */
  86670. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  86671. if (applySkeleton === void 0) { applySkeleton = false; }
  86672. if (this._boundingInfo && this._boundingInfo.isLocked) {
  86673. return this;
  86674. }
  86675. var bias = this.geometry ? this.geometry.boundingBias : null;
  86676. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  86677. return this;
  86678. };
  86679. /** @hidden */
  86680. Mesh.prototype._createGlobalSubMesh = function (force) {
  86681. var totalVertices = this.getTotalVertices();
  86682. if (!totalVertices || !this.getIndices()) {
  86683. return null;
  86684. }
  86685. // Check if we need to recreate the submeshes
  86686. if (this.subMeshes && this.subMeshes.length > 0) {
  86687. var ib = this.getIndices();
  86688. if (!ib) {
  86689. return null;
  86690. }
  86691. var totalIndices = ib.length;
  86692. var needToRecreate = false;
  86693. if (force) {
  86694. needToRecreate = true;
  86695. }
  86696. else {
  86697. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  86698. var submesh = _a[_i];
  86699. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  86700. needToRecreate = true;
  86701. break;
  86702. }
  86703. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  86704. needToRecreate = true;
  86705. break;
  86706. }
  86707. }
  86708. }
  86709. if (!needToRecreate) {
  86710. return this.subMeshes[0];
  86711. }
  86712. }
  86713. this.releaseSubMeshes();
  86714. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  86715. };
  86716. /**
  86717. * This function will subdivide the mesh into multiple submeshes
  86718. * @param count defines the expected number of submeshes
  86719. */
  86720. Mesh.prototype.subdivide = function (count) {
  86721. if (count < 1) {
  86722. return;
  86723. }
  86724. var totalIndices = this.getTotalIndices();
  86725. var subdivisionSize = (totalIndices / count) | 0;
  86726. var offset = 0;
  86727. // Ensure that subdivisionSize is a multiple of 3
  86728. while (subdivisionSize % 3 !== 0) {
  86729. subdivisionSize++;
  86730. }
  86731. this.releaseSubMeshes();
  86732. for (var index = 0; index < count; index++) {
  86733. if (offset >= totalIndices) {
  86734. break;
  86735. }
  86736. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  86737. offset += subdivisionSize;
  86738. }
  86739. this.synchronizeInstances();
  86740. };
  86741. /**
  86742. * Copy a FloatArray into a specific associated vertex buffer
  86743. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86744. * - VertexBuffer.PositionKind
  86745. * - VertexBuffer.UVKind
  86746. * - VertexBuffer.UV2Kind
  86747. * - VertexBuffer.UV3Kind
  86748. * - VertexBuffer.UV4Kind
  86749. * - VertexBuffer.UV5Kind
  86750. * - VertexBuffer.UV6Kind
  86751. * - VertexBuffer.ColorKind
  86752. * - VertexBuffer.MatricesIndicesKind
  86753. * - VertexBuffer.MatricesIndicesExtraKind
  86754. * - VertexBuffer.MatricesWeightsKind
  86755. * - VertexBuffer.MatricesWeightsExtraKind
  86756. * @param data defines the data source
  86757. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  86758. * @param stride defines the data stride size (can be null)
  86759. * @returns the current mesh
  86760. */
  86761. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  86762. if (updatable === void 0) { updatable = false; }
  86763. if (!this._geometry) {
  86764. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  86765. vertexData.set(data, kind);
  86766. var scene = this.getScene();
  86767. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  86768. }
  86769. else {
  86770. this._geometry.setVerticesData(kind, data, updatable, stride);
  86771. }
  86772. return this;
  86773. };
  86774. /**
  86775. * Flags an associated vertex buffer as updatable
  86776. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  86777. * - VertexBuffer.PositionKind
  86778. * - VertexBuffer.UVKind
  86779. * - VertexBuffer.UV2Kind
  86780. * - VertexBuffer.UV3Kind
  86781. * - VertexBuffer.UV4Kind
  86782. * - VertexBuffer.UV5Kind
  86783. * - VertexBuffer.UV6Kind
  86784. * - VertexBuffer.ColorKind
  86785. * - VertexBuffer.MatricesIndicesKind
  86786. * - VertexBuffer.MatricesIndicesExtraKind
  86787. * - VertexBuffer.MatricesWeightsKind
  86788. * - VertexBuffer.MatricesWeightsExtraKind
  86789. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  86790. */
  86791. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  86792. if (updatable === void 0) { updatable = true; }
  86793. var vb = this.getVertexBuffer(kind);
  86794. if (!vb || vb.isUpdatable() === updatable) {
  86795. return;
  86796. }
  86797. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  86798. };
  86799. /**
  86800. * Sets the mesh global Vertex Buffer
  86801. * @param buffer defines the buffer to use
  86802. * @returns the current mesh
  86803. */
  86804. Mesh.prototype.setVerticesBuffer = function (buffer) {
  86805. if (!this._geometry) {
  86806. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  86807. }
  86808. this._geometry.setVerticesBuffer(buffer);
  86809. return this;
  86810. };
  86811. /**
  86812. * Update a specific associated vertex buffer
  86813. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86814. * - VertexBuffer.PositionKind
  86815. * - VertexBuffer.UVKind
  86816. * - VertexBuffer.UV2Kind
  86817. * - VertexBuffer.UV3Kind
  86818. * - VertexBuffer.UV4Kind
  86819. * - VertexBuffer.UV5Kind
  86820. * - VertexBuffer.UV6Kind
  86821. * - VertexBuffer.ColorKind
  86822. * - VertexBuffer.MatricesIndicesKind
  86823. * - VertexBuffer.MatricesIndicesExtraKind
  86824. * - VertexBuffer.MatricesWeightsKind
  86825. * - VertexBuffer.MatricesWeightsExtraKind
  86826. * @param data defines the data source
  86827. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86828. * @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)
  86829. * @returns the current mesh
  86830. */
  86831. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  86832. if (!this._geometry) {
  86833. return this;
  86834. }
  86835. if (!makeItUnique) {
  86836. this._geometry.updateVerticesData(kind, data, updateExtends);
  86837. }
  86838. else {
  86839. this.makeGeometryUnique();
  86840. this.updateVerticesData(kind, data, updateExtends, false);
  86841. }
  86842. return this;
  86843. };
  86844. /**
  86845. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  86846. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  86847. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  86848. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  86849. * @returns the current mesh
  86850. */
  86851. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  86852. if (computeNormals === void 0) { computeNormals = true; }
  86853. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86854. if (!positions) {
  86855. return this;
  86856. }
  86857. positionFunction(positions);
  86858. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  86859. if (computeNormals) {
  86860. var indices = this.getIndices();
  86861. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86862. if (!normals) {
  86863. return this;
  86864. }
  86865. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  86866. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  86867. }
  86868. return this;
  86869. };
  86870. /**
  86871. * Creates a un-shared specific occurence of the geometry for the mesh.
  86872. * @returns the current mesh
  86873. */
  86874. Mesh.prototype.makeGeometryUnique = function () {
  86875. if (!this._geometry) {
  86876. return this;
  86877. }
  86878. var oldGeometry = this._geometry;
  86879. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  86880. oldGeometry.releaseForMesh(this, true);
  86881. geometry.applyToMesh(this);
  86882. return this;
  86883. };
  86884. /**
  86885. * Set the index buffer of this mesh
  86886. * @param indices defines the source data
  86887. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  86888. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  86889. * @returns the current mesh
  86890. */
  86891. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  86892. if (totalVertices === void 0) { totalVertices = null; }
  86893. if (updatable === void 0) { updatable = false; }
  86894. if (!this._geometry) {
  86895. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  86896. vertexData.indices = indices;
  86897. var scene = this.getScene();
  86898. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  86899. }
  86900. else {
  86901. this._geometry.setIndices(indices, totalVertices, updatable);
  86902. }
  86903. return this;
  86904. };
  86905. /**
  86906. * Update the current index buffer
  86907. * @param indices defines the source data
  86908. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  86909. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  86910. * @returns the current mesh
  86911. */
  86912. Mesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  86913. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  86914. if (!this._geometry) {
  86915. return this;
  86916. }
  86917. this._geometry.updateIndices(indices, offset, gpuMemoryOnly);
  86918. return this;
  86919. };
  86920. /**
  86921. * Invert the geometry to move from a right handed system to a left handed one.
  86922. * @returns the current mesh
  86923. */
  86924. Mesh.prototype.toLeftHanded = function () {
  86925. if (!this._geometry) {
  86926. return this;
  86927. }
  86928. this._geometry.toLeftHanded();
  86929. return this;
  86930. };
  86931. /** @hidden */
  86932. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  86933. if (!this._geometry) {
  86934. return this;
  86935. }
  86936. var engine = this.getScene().getEngine();
  86937. // Wireframe
  86938. var indexToBind;
  86939. if (this._unIndexed) {
  86940. indexToBind = null;
  86941. }
  86942. else {
  86943. switch (fillMode) {
  86944. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  86945. indexToBind = null;
  86946. break;
  86947. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  86948. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  86949. break;
  86950. default:
  86951. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  86952. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  86953. break;
  86954. }
  86955. }
  86956. // VBOs
  86957. this._geometry._bind(effect, indexToBind);
  86958. return this;
  86959. };
  86960. /** @hidden */
  86961. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  86962. if (alternate === void 0) { alternate = false; }
  86963. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  86964. return this;
  86965. }
  86966. if (this._onBeforeDrawObservable) {
  86967. this._onBeforeDrawObservable.notifyObservers(this);
  86968. }
  86969. var scene = this.getScene();
  86970. var engine = scene.getEngine();
  86971. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  86972. // or triangles as points
  86973. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  86974. }
  86975. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  86976. // Triangles as wireframe
  86977. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  86978. }
  86979. else {
  86980. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  86981. }
  86982. if (scene._isAlternateRenderingEnabled && !alternate) {
  86983. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  86984. if (!effect || !scene.activeCamera) {
  86985. return this;
  86986. }
  86987. scene._switchToAlternateCameraConfiguration(true);
  86988. this._effectiveMaterial.bindView(effect);
  86989. this._effectiveMaterial.bindViewProjection(effect);
  86990. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  86991. this._draw(subMesh, fillMode, instancesCount, true);
  86992. engine.setViewport(scene.activeCamera.viewport);
  86993. scene._switchToAlternateCameraConfiguration(false);
  86994. this._effectiveMaterial.bindView(effect);
  86995. this._effectiveMaterial.bindViewProjection(effect);
  86996. }
  86997. return this;
  86998. };
  86999. /**
  87000. * Registers for this mesh a javascript function called just before the rendering process
  87001. * @param func defines the function to call before rendering this mesh
  87002. * @returns the current mesh
  87003. */
  87004. Mesh.prototype.registerBeforeRender = function (func) {
  87005. this.onBeforeRenderObservable.add(func);
  87006. return this;
  87007. };
  87008. /**
  87009. * Disposes a previously registered javascript function called before the rendering
  87010. * @param func defines the function to remove
  87011. * @returns the current mesh
  87012. */
  87013. Mesh.prototype.unregisterBeforeRender = function (func) {
  87014. this.onBeforeRenderObservable.removeCallback(func);
  87015. return this;
  87016. };
  87017. /**
  87018. * Registers for this mesh a javascript function called just after the rendering is complete
  87019. * @param func defines the function to call after rendering this mesh
  87020. * @returns the current mesh
  87021. */
  87022. Mesh.prototype.registerAfterRender = function (func) {
  87023. this.onAfterRenderObservable.add(func);
  87024. return this;
  87025. };
  87026. /**
  87027. * Disposes a previously registered javascript function called after the rendering.
  87028. * @param func defines the function to remove
  87029. * @returns the current mesh
  87030. */
  87031. Mesh.prototype.unregisterAfterRender = function (func) {
  87032. this.onAfterRenderObservable.removeCallback(func);
  87033. return this;
  87034. };
  87035. /** @hidden */
  87036. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  87037. var scene = this.getScene();
  87038. var batchCache = this._instanceDataStorage.batchCache;
  87039. batchCache.mustReturn = false;
  87040. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  87041. batchCache.visibleInstances[subMeshId] = null;
  87042. if (this._instanceDataStorage.visibleInstances) {
  87043. var visibleInstances = this._instanceDataStorage.visibleInstances;
  87044. var currentRenderId = scene.getRenderId();
  87045. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  87046. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  87047. var selfRenderId = this._renderId;
  87048. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  87049. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  87050. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  87051. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  87052. }
  87053. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  87054. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  87055. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  87056. batchCache.mustReturn = true;
  87057. return batchCache;
  87058. }
  87059. if (currentRenderId !== selfRenderId) {
  87060. batchCache.renderSelf[subMeshId] = false;
  87061. }
  87062. }
  87063. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  87064. }
  87065. return batchCache;
  87066. };
  87067. /** @hidden */
  87068. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  87069. var visibleInstances = batch.visibleInstances[subMesh._id];
  87070. if (!visibleInstances) {
  87071. return this;
  87072. }
  87073. var matricesCount = visibleInstances.length + 1;
  87074. var bufferSize = matricesCount * 16 * 4;
  87075. var instanceStorage = this._instanceDataStorage;
  87076. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  87077. var instancesBuffer = instanceStorage.instancesBuffer;
  87078. while (instanceStorage.instancesBufferSize < bufferSize) {
  87079. instanceStorage.instancesBufferSize *= 2;
  87080. }
  87081. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  87082. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  87083. }
  87084. var offset = 0;
  87085. var instancesCount = 0;
  87086. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  87087. var world = effectiveMesh.getWorldMatrix();
  87088. if (batch.renderSelf[subMesh._id]) {
  87089. world.copyToArray(instanceStorage.instancesData, offset);
  87090. offset += 16;
  87091. instancesCount++;
  87092. }
  87093. if (visibleInstances) {
  87094. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  87095. var instance = visibleInstances[instanceIndex];
  87096. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  87097. offset += 16;
  87098. instancesCount++;
  87099. }
  87100. }
  87101. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  87102. if (instancesBuffer) {
  87103. instancesBuffer.dispose();
  87104. }
  87105. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  87106. instanceStorage.instancesBuffer = instancesBuffer;
  87107. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  87108. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  87109. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  87110. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  87111. }
  87112. else {
  87113. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  87114. }
  87115. this._bind(subMesh, effect, fillMode);
  87116. this._draw(subMesh, fillMode, instancesCount);
  87117. engine.unbindInstanceAttributes();
  87118. return this;
  87119. };
  87120. /** @hidden */
  87121. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  87122. var scene = this.getScene();
  87123. var engine = scene.getEngine();
  87124. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  87125. if (hardwareInstancedRendering) {
  87126. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  87127. }
  87128. else {
  87129. if (batch.renderSelf[subMesh._id]) {
  87130. // Draw
  87131. if (onBeforeDraw) {
  87132. onBeforeDraw(false, effectiveMesh.getWorldMatrix(), effectiveMaterial);
  87133. }
  87134. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  87135. }
  87136. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  87137. if (visibleInstancesForSubMesh) {
  87138. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  87139. var instance = visibleInstancesForSubMesh[instanceIndex];
  87140. // World
  87141. var world = instance.getWorldMatrix();
  87142. if (onBeforeDraw) {
  87143. onBeforeDraw(true, world, effectiveMaterial);
  87144. }
  87145. // Draw
  87146. this._draw(subMesh, fillMode);
  87147. }
  87148. }
  87149. }
  87150. return this;
  87151. };
  87152. /**
  87153. * 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
  87154. * @param subMesh defines the subMesh to render
  87155. * @param enableAlphaMode defines if alpha mode can be changed
  87156. * @returns the current mesh
  87157. */
  87158. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  87159. if (this._checkOcclusionQuery()) {
  87160. return this;
  87161. }
  87162. var scene = this.getScene();
  87163. // Managing instances
  87164. var batch = this._getInstancesRenderList(subMesh._id);
  87165. if (batch.mustReturn) {
  87166. return this;
  87167. }
  87168. // Checking geometry state
  87169. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  87170. return this;
  87171. }
  87172. if (this._onBeforeRenderObservable) {
  87173. this._onBeforeRenderObservable.notifyObservers(this);
  87174. }
  87175. var engine = scene.getEngine();
  87176. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  87177. // Material
  87178. var material = subMesh.getMaterial();
  87179. if (!material) {
  87180. return this;
  87181. }
  87182. this._effectiveMaterial = material;
  87183. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87184. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  87185. return this;
  87186. }
  87187. }
  87188. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  87189. return this;
  87190. }
  87191. // Alpha mode
  87192. if (enableAlphaMode) {
  87193. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  87194. }
  87195. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  87196. var step = _a[_i];
  87197. step.action(this, subMesh, batch);
  87198. }
  87199. var effect;
  87200. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87201. effect = subMesh.effect;
  87202. }
  87203. else {
  87204. effect = this._effectiveMaterial.getEffect();
  87205. }
  87206. if (!effect) {
  87207. return this;
  87208. }
  87209. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  87210. var sideOrientation = this.overrideMaterialSideOrientation;
  87211. if (sideOrientation == null) {
  87212. sideOrientation = this._effectiveMaterial.sideOrientation;
  87213. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  87214. 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);
  87215. }
  87216. }
  87217. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  87218. if (this._effectiveMaterial.forceDepthWrite) {
  87219. engine.setDepthWrite(true);
  87220. }
  87221. // Bind
  87222. 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);
  87223. if (this._onBeforeBindObservable) {
  87224. this._onBeforeBindObservable.notifyObservers(this);
  87225. }
  87226. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  87227. this._bind(subMesh, effect, fillMode);
  87228. }
  87229. var world = effectiveMesh.getWorldMatrix();
  87230. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87231. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  87232. }
  87233. else {
  87234. this._effectiveMaterial.bind(world, this);
  87235. }
  87236. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  87237. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  87238. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  87239. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  87240. }
  87241. // Draw
  87242. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  87243. // Unbind
  87244. this._effectiveMaterial.unbind();
  87245. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  87246. var step = _c[_b];
  87247. step.action(this, subMesh, batch);
  87248. }
  87249. if (this._onAfterRenderObservable) {
  87250. this._onAfterRenderObservable.notifyObservers(this);
  87251. }
  87252. return this;
  87253. };
  87254. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  87255. if (isInstance && effectiveMaterial) {
  87256. effectiveMaterial.bindOnlyWorldMatrix(world);
  87257. }
  87258. };
  87259. /**
  87260. * Renormalize the mesh and patch it up if there are no weights
  87261. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87262. * However in the case of zero weights then we set just a single influence to 1.
  87263. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87264. */
  87265. Mesh.prototype.cleanMatrixWeights = function () {
  87266. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  87267. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87268. this.normalizeSkinWeightsAndExtra();
  87269. }
  87270. else {
  87271. this.normalizeSkinFourWeights();
  87272. }
  87273. }
  87274. };
  87275. // faster 4 weight version.
  87276. Mesh.prototype.normalizeSkinFourWeights = function () {
  87277. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87278. var numWeights = matricesWeights.length;
  87279. for (var a = 0; a < numWeights; a += 4) {
  87280. // accumulate weights
  87281. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  87282. // check for invalid weight and just set it to 1.
  87283. if (t === 0) {
  87284. matricesWeights[a] = 1;
  87285. }
  87286. else {
  87287. // renormalize so everything adds to 1 use reciprical
  87288. var recip = 1 / t;
  87289. matricesWeights[a] *= recip;
  87290. matricesWeights[a + 1] *= recip;
  87291. matricesWeights[a + 2] *= recip;
  87292. matricesWeights[a + 3] *= recip;
  87293. }
  87294. }
  87295. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  87296. };
  87297. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  87298. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  87299. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  87300. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87301. var numWeights = matricesWeights.length;
  87302. for (var a = 0; a < numWeights; a += 4) {
  87303. // accumulate weights
  87304. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  87305. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  87306. // check for invalid weight and just set it to 1.
  87307. if (t === 0) {
  87308. matricesWeights[a] = 1;
  87309. }
  87310. else {
  87311. // renormalize so everything adds to 1 use reciprical
  87312. var recip = 1 / t;
  87313. matricesWeights[a] *= recip;
  87314. matricesWeights[a + 1] *= recip;
  87315. matricesWeights[a + 2] *= recip;
  87316. matricesWeights[a + 3] *= recip;
  87317. // same goes for extras
  87318. matricesWeightsExtra[a] *= recip;
  87319. matricesWeightsExtra[a + 1] *= recip;
  87320. matricesWeightsExtra[a + 2] *= recip;
  87321. matricesWeightsExtra[a + 3] *= recip;
  87322. }
  87323. }
  87324. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  87325. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  87326. };
  87327. /**
  87328. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87329. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87330. * the user know there was an issue with importing the mesh
  87331. * @returns a validation object with skinned, valid and report string
  87332. */
  87333. Mesh.prototype.validateSkinning = function () {
  87334. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  87335. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87336. if (matricesWeights === null || this.skeleton == null) {
  87337. return { skinned: false, valid: true, report: "not skinned" };
  87338. }
  87339. var numWeights = matricesWeights.length;
  87340. var numberNotSorted = 0;
  87341. var missingWeights = 0;
  87342. var maxUsedWeights = 0;
  87343. var numberNotNormalized = 0;
  87344. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  87345. var usedWeightCounts = new Array();
  87346. for (var a = 0; a <= numInfluences; a++) {
  87347. usedWeightCounts[a] = 0;
  87348. }
  87349. var toleranceEpsilon = 0.001;
  87350. for (var a = 0; a < numWeights; a += 4) {
  87351. var lastWeight = matricesWeights[a];
  87352. var t = lastWeight;
  87353. var usedWeights = t === 0 ? 0 : 1;
  87354. for (var b = 1; b < numInfluences; b++) {
  87355. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  87356. if (d > lastWeight) {
  87357. numberNotSorted++;
  87358. }
  87359. if (d !== 0) {
  87360. usedWeights++;
  87361. }
  87362. t += d;
  87363. lastWeight = d;
  87364. }
  87365. // count the buffer weights usage
  87366. usedWeightCounts[usedWeights]++;
  87367. // max influences
  87368. if (usedWeights > maxUsedWeights) {
  87369. maxUsedWeights = usedWeights;
  87370. }
  87371. // check for invalid weight and just set it to 1.
  87372. if (t === 0) {
  87373. missingWeights++;
  87374. }
  87375. else {
  87376. // renormalize so everything adds to 1 use reciprical
  87377. var recip = 1 / t;
  87378. var tolerance = 0;
  87379. for (b = 0; b < numInfluences; b++) {
  87380. if (b < 4) {
  87381. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  87382. }
  87383. else {
  87384. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  87385. }
  87386. }
  87387. // arbitary epsilon value for dicdating not normalized
  87388. if (tolerance > toleranceEpsilon) {
  87389. numberNotNormalized++;
  87390. }
  87391. }
  87392. }
  87393. // validate bone indices are in range of the skeleton
  87394. var numBones = this.skeleton.bones.length;
  87395. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  87396. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  87397. var numBadBoneIndices = 0;
  87398. for (var a = 0; a < numWeights; a++) {
  87399. for (var b = 0; b < numInfluences; b++) {
  87400. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  87401. if (index >= numBones || index < 0) {
  87402. numBadBoneIndices++;
  87403. }
  87404. }
  87405. }
  87406. // log mesh stats
  87407. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  87408. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  87409. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  87410. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  87411. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  87412. };
  87413. /** @hidden */
  87414. Mesh.prototype._checkDelayState = function () {
  87415. var scene = this.getScene();
  87416. if (this._geometry) {
  87417. this._geometry.load(scene);
  87418. }
  87419. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  87420. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  87421. this._queueLoad(scene);
  87422. }
  87423. return this;
  87424. };
  87425. Mesh.prototype._queueLoad = function (scene) {
  87426. var _this = this;
  87427. scene._addPendingData(this);
  87428. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  87429. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  87430. if (data instanceof ArrayBuffer) {
  87431. _this._delayLoadingFunction(data, _this);
  87432. }
  87433. else {
  87434. _this._delayLoadingFunction(JSON.parse(data), _this);
  87435. }
  87436. _this.instances.forEach(function (instance) {
  87437. instance._syncSubMeshes();
  87438. });
  87439. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  87440. scene._removePendingData(_this);
  87441. }, function () { }, scene.offlineProvider, getBinaryData);
  87442. return this;
  87443. };
  87444. /**
  87445. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87446. * A mesh is in the frustum if its bounding box intersects the frustum
  87447. * @param frustumPlanes defines the frustum to test
  87448. * @returns true if the mesh is in the frustum planes
  87449. */
  87450. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  87451. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  87452. return false;
  87453. }
  87454. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  87455. return false;
  87456. }
  87457. this._checkDelayState();
  87458. return true;
  87459. };
  87460. /**
  87461. * Sets the mesh material by the material or multiMaterial `id` property
  87462. * @param id is a string identifying the material or the multiMaterial
  87463. * @returns the current mesh
  87464. */
  87465. Mesh.prototype.setMaterialByID = function (id) {
  87466. var materials = this.getScene().materials;
  87467. var index;
  87468. for (index = materials.length - 1; index > -1; index--) {
  87469. if (materials[index].id === id) {
  87470. this.material = materials[index];
  87471. return this;
  87472. }
  87473. }
  87474. // Multi
  87475. var multiMaterials = this.getScene().multiMaterials;
  87476. for (index = multiMaterials.length - 1; index > -1; index--) {
  87477. if (multiMaterials[index].id === id) {
  87478. this.material = multiMaterials[index];
  87479. return this;
  87480. }
  87481. }
  87482. return this;
  87483. };
  87484. /**
  87485. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87486. * @returns an array of IAnimatable
  87487. */
  87488. Mesh.prototype.getAnimatables = function () {
  87489. var results = new Array();
  87490. if (this.material) {
  87491. results.push(this.material);
  87492. }
  87493. if (this.skeleton) {
  87494. results.push(this.skeleton);
  87495. }
  87496. return results;
  87497. };
  87498. /**
  87499. * Modifies the mesh geometry according to the passed transformation matrix.
  87500. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87501. * The mesh normals are modified using the same transformation.
  87502. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87503. * @param transform defines the transform matrix to use
  87504. * @see http://doc.babylonjs.com/resources/baking_transformations
  87505. * @returns the current mesh
  87506. */
  87507. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  87508. // Position
  87509. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  87510. return this;
  87511. }
  87512. var submeshes = this.subMeshes.splice(0);
  87513. this._resetPointsArrayCache();
  87514. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87515. var temp = new Array();
  87516. var index;
  87517. for (index = 0; index < data.length; index += 3) {
  87518. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  87519. }
  87520. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  87521. // Normals
  87522. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  87523. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87524. temp = [];
  87525. for (index = 0; index < data.length; index += 3) {
  87526. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  87527. }
  87528. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  87529. }
  87530. // flip faces?
  87531. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  87532. this.flipFaces();
  87533. }
  87534. // Restore submeshes
  87535. this.releaseSubMeshes();
  87536. this.subMeshes = submeshes;
  87537. return this;
  87538. };
  87539. /**
  87540. * Modifies the mesh geometry according to its own current World Matrix.
  87541. * The mesh World Matrix is then reset.
  87542. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87543. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87544. * @see http://doc.babylonjs.com/resources/baking_transformations
  87545. * @returns the current mesh
  87546. */
  87547. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  87548. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  87549. this.scaling.copyFromFloats(1, 1, 1);
  87550. this.position.copyFromFloats(0, 0, 0);
  87551. this.rotation.copyFromFloats(0, 0, 0);
  87552. //only if quaternion is already set
  87553. if (this.rotationQuaternion) {
  87554. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  87555. }
  87556. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  87557. return this;
  87558. };
  87559. Object.defineProperty(Mesh.prototype, "_positions", {
  87560. // Cache
  87561. /** @hidden */
  87562. get: function () {
  87563. if (this._geometry) {
  87564. return this._geometry._positions;
  87565. }
  87566. return null;
  87567. },
  87568. enumerable: true,
  87569. configurable: true
  87570. });
  87571. /** @hidden */
  87572. Mesh.prototype._resetPointsArrayCache = function () {
  87573. if (this._geometry) {
  87574. this._geometry._resetPointsArrayCache();
  87575. }
  87576. return this;
  87577. };
  87578. /** @hidden */
  87579. Mesh.prototype._generatePointsArray = function () {
  87580. if (this._geometry) {
  87581. return this._geometry._generatePointsArray();
  87582. }
  87583. return false;
  87584. };
  87585. /**
  87586. * Returns a new Mesh object generated from the current mesh properties.
  87587. * This method must not get confused with createInstance()
  87588. * @param name is a string, the name given to the new mesh
  87589. * @param newParent can be any Node object (default `null`)
  87590. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87591. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87592. * @returns a new mesh
  87593. */
  87594. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  87595. if (name === void 0) { name = ""; }
  87596. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  87597. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  87598. };
  87599. /**
  87600. * Releases resources associated with this mesh.
  87601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87603. */
  87604. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  87605. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  87606. this.morphTargetManager = null;
  87607. if (this._geometry) {
  87608. this._geometry.releaseForMesh(this, true);
  87609. }
  87610. if (this._onBeforeDrawObservable) {
  87611. this._onBeforeDrawObservable.clear();
  87612. }
  87613. if (this._onBeforeBindObservable) {
  87614. this._onBeforeBindObservable.clear();
  87615. }
  87616. if (this._onBeforeRenderObservable) {
  87617. this._onBeforeRenderObservable.clear();
  87618. }
  87619. if (this._onAfterRenderObservable) {
  87620. this._onAfterRenderObservable.clear();
  87621. }
  87622. // Sources
  87623. if (this._scene.useClonedMeshhMap) {
  87624. if (this.meshMap) {
  87625. for (var uniqueId in this.meshMap) {
  87626. var mesh = this.meshMap[uniqueId];
  87627. if (mesh) {
  87628. mesh._source = null;
  87629. this.meshMap[uniqueId] = undefined;
  87630. }
  87631. }
  87632. }
  87633. if (this._source && this._source.meshMap) {
  87634. this._source.meshMap[this.uniqueId] = undefined;
  87635. }
  87636. }
  87637. else {
  87638. var meshes = this.getScene().meshes;
  87639. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  87640. var abstractMesh = meshes_1[_i];
  87641. var mesh = abstractMesh;
  87642. if (mesh._source && mesh._source === this) {
  87643. mesh._source = null;
  87644. }
  87645. }
  87646. }
  87647. this._source = null;
  87648. // Instances
  87649. if (this._instanceDataStorage.instancesBuffer) {
  87650. this._instanceDataStorage.instancesBuffer.dispose();
  87651. this._instanceDataStorage.instancesBuffer = null;
  87652. }
  87653. while (this.instances.length) {
  87654. this.instances[0].dispose();
  87655. }
  87656. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  87657. };
  87658. /**
  87659. * Modifies the mesh geometry according to a displacement map.
  87660. * 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.
  87661. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87662. * @param url is a string, the URL from the image file is to be downloaded.
  87663. * @param minHeight is the lower limit of the displacement.
  87664. * @param maxHeight is the upper limit of the displacement.
  87665. * @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.
  87666. * @param uvOffset is an optional vector2 used to offset UV.
  87667. * @param uvScale is an optional vector2 used to scale UV.
  87668. * @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.
  87669. * @returns the Mesh.
  87670. */
  87671. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  87672. var _this = this;
  87673. if (forceUpdate === void 0) { forceUpdate = false; }
  87674. var scene = this.getScene();
  87675. var onload = function (img) {
  87676. // Getting height map data
  87677. var canvas = document.createElement("canvas");
  87678. var context = canvas.getContext("2d");
  87679. var heightMapWidth = img.width;
  87680. var heightMapHeight = img.height;
  87681. canvas.width = heightMapWidth;
  87682. canvas.height = heightMapHeight;
  87683. context.drawImage(img, 0, 0);
  87684. // Create VertexData from map data
  87685. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  87686. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  87687. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  87688. //execute success callback, if set
  87689. if (onSuccess) {
  87690. onSuccess(_this);
  87691. }
  87692. };
  87693. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  87694. return this;
  87695. };
  87696. /**
  87697. * Modifies the mesh geometry according to a displacementMap buffer.
  87698. * 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.
  87699. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87700. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87701. * @param heightMapWidth is the width of the buffer image.
  87702. * @param heightMapHeight is the height of the buffer image.
  87703. * @param minHeight is the lower limit of the displacement.
  87704. * @param maxHeight is the upper limit of the displacement.
  87705. * @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.
  87706. * @param uvOffset is an optional vector2 used to offset UV.
  87707. * @param uvScale is an optional vector2 used to scale UV.
  87708. * @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.
  87709. * @returns the Mesh.
  87710. */
  87711. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  87712. if (forceUpdate === void 0) { forceUpdate = false; }
  87713. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  87714. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  87715. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  87716. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  87717. return this;
  87718. }
  87719. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  87720. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87721. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  87722. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  87723. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  87724. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  87725. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  87726. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  87727. for (var index = 0; index < positions.length; index += 3) {
  87728. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  87729. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  87730. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  87731. // Compute height
  87732. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  87733. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  87734. var pos = (u + v * heightMapWidth) * 4;
  87735. var r = buffer[pos] / 255.0;
  87736. var g = buffer[pos + 1] / 255.0;
  87737. var b = buffer[pos + 2] / 255.0;
  87738. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  87739. normal.normalize();
  87740. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  87741. position = position.add(normal);
  87742. position.toArray(positions, index);
  87743. }
  87744. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  87745. if (forceUpdate) {
  87746. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  87747. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  87748. }
  87749. else {
  87750. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  87751. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  87752. }
  87753. return this;
  87754. };
  87755. /**
  87756. * Modify the mesh to get a flat shading rendering.
  87757. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87758. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87759. * @returns current mesh
  87760. */
  87761. Mesh.prototype.convertToFlatShadedMesh = function () {
  87762. var kinds = this.getVerticesDataKinds();
  87763. var vbs = {};
  87764. var data = {};
  87765. var newdata = {};
  87766. var updatableNormals = false;
  87767. var kindIndex;
  87768. var kind;
  87769. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87770. kind = kinds[kindIndex];
  87771. var vertexBuffer = this.getVertexBuffer(kind);
  87772. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  87773. updatableNormals = vertexBuffer.isUpdatable();
  87774. kinds.splice(kindIndex, 1);
  87775. kindIndex--;
  87776. continue;
  87777. }
  87778. vbs[kind] = vertexBuffer;
  87779. data[kind] = vbs[kind].getData();
  87780. newdata[kind] = [];
  87781. }
  87782. // Save previous submeshes
  87783. var previousSubmeshes = this.subMeshes.slice(0);
  87784. var indices = this.getIndices();
  87785. var totalIndices = this.getTotalIndices();
  87786. // Generating unique vertices per face
  87787. var index;
  87788. for (index = 0; index < totalIndices; index++) {
  87789. var vertexIndex = indices[index];
  87790. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87791. kind = kinds[kindIndex];
  87792. var stride = vbs[kind].getStrideSize();
  87793. for (var offset = 0; offset < stride; offset++) {
  87794. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  87795. }
  87796. }
  87797. }
  87798. // Updating faces & normal
  87799. var normals = [];
  87800. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  87801. for (index = 0; index < totalIndices; index += 3) {
  87802. indices[index] = index;
  87803. indices[index + 1] = index + 1;
  87804. indices[index + 2] = index + 2;
  87805. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  87806. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  87807. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  87808. var p1p2 = p1.subtract(p2);
  87809. var p3p2 = p3.subtract(p2);
  87810. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  87811. // Store same normals for every vertex
  87812. for (var localIndex = 0; localIndex < 3; localIndex++) {
  87813. normals.push(normal.x);
  87814. normals.push(normal.y);
  87815. normals.push(normal.z);
  87816. }
  87817. }
  87818. this.setIndices(indices);
  87819. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  87820. // Updating vertex buffers
  87821. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87822. kind = kinds[kindIndex];
  87823. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  87824. }
  87825. // Updating submeshes
  87826. this.releaseSubMeshes();
  87827. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  87828. var previousOne = previousSubmeshes[submeshIndex];
  87829. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  87830. }
  87831. this.synchronizeInstances();
  87832. return this;
  87833. };
  87834. /**
  87835. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87836. * In other words, more vertices, no more indices and a single bigger VBO.
  87837. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87838. * @returns current mesh
  87839. */
  87840. Mesh.prototype.convertToUnIndexedMesh = function () {
  87841. var kinds = this.getVerticesDataKinds();
  87842. var vbs = {};
  87843. var data = {};
  87844. var newdata = {};
  87845. var kindIndex;
  87846. var kind;
  87847. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87848. kind = kinds[kindIndex];
  87849. var vertexBuffer = this.getVertexBuffer(kind);
  87850. vbs[kind] = vertexBuffer;
  87851. data[kind] = vbs[kind].getData();
  87852. newdata[kind] = [];
  87853. }
  87854. // Save previous submeshes
  87855. var previousSubmeshes = this.subMeshes.slice(0);
  87856. var indices = this.getIndices();
  87857. var totalIndices = this.getTotalIndices();
  87858. // Generating unique vertices per face
  87859. var index;
  87860. for (index = 0; index < totalIndices; index++) {
  87861. var vertexIndex = indices[index];
  87862. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87863. kind = kinds[kindIndex];
  87864. var stride = vbs[kind].getStrideSize();
  87865. for (var offset = 0; offset < stride; offset++) {
  87866. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  87867. }
  87868. }
  87869. }
  87870. // Updating indices
  87871. for (index = 0; index < totalIndices; index += 3) {
  87872. indices[index] = index;
  87873. indices[index + 1] = index + 1;
  87874. indices[index + 2] = index + 2;
  87875. }
  87876. this.setIndices(indices);
  87877. // Updating vertex buffers
  87878. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87879. kind = kinds[kindIndex];
  87880. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  87881. }
  87882. // Updating submeshes
  87883. this.releaseSubMeshes();
  87884. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  87885. var previousOne = previousSubmeshes[submeshIndex];
  87886. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  87887. }
  87888. this._unIndexed = true;
  87889. this.synchronizeInstances();
  87890. return this;
  87891. };
  87892. /**
  87893. * Inverses facet orientations.
  87894. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87895. * @param flipNormals will also inverts the normals
  87896. * @returns current mesh
  87897. */
  87898. Mesh.prototype.flipFaces = function (flipNormals) {
  87899. if (flipNormals === void 0) { flipNormals = false; }
  87900. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  87901. var i;
  87902. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  87903. for (i = 0; i < vertex_data.normals.length; i++) {
  87904. vertex_data.normals[i] *= -1;
  87905. }
  87906. }
  87907. if (vertex_data.indices) {
  87908. var temp;
  87909. for (i = 0; i < vertex_data.indices.length; i += 3) {
  87910. // reassign indices
  87911. temp = vertex_data.indices[i + 1];
  87912. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  87913. vertex_data.indices[i + 2] = temp;
  87914. }
  87915. }
  87916. vertex_data.applyToMesh(this);
  87917. return this;
  87918. };
  87919. /**
  87920. * Increase the number of facets and hence vertices in a mesh
  87921. * Vertex normals are interpolated from existing vertex normals
  87922. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87923. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  87924. */
  87925. Mesh.prototype.increaseVertices = function (numberPerEdge) {
  87926. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  87927. var uvs = vertex_data.uvs;
  87928. var currentIndices = vertex_data.indices;
  87929. var positions = vertex_data.positions;
  87930. var normals = vertex_data.normals;
  87931. if (currentIndices === null || positions === null || normals === null || uvs === null) {
  87932. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  87933. }
  87934. else {
  87935. var segments = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
  87936. var tempIndices = new Array();
  87937. for (var i = 0; i < segments + 1; i++) {
  87938. tempIndices[i] = new Array();
  87939. }
  87940. var a; //vertex index of one end of a side
  87941. var b; //vertex index of other end of the side
  87942. var deltaPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  87943. var deltaNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  87944. var deltaUV = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 0);
  87945. var indices = new Array();
  87946. var vertexIndex = new Array();
  87947. var side = new Array();
  87948. var len;
  87949. var positionPtr = positions.length;
  87950. var uvPtr = uvs.length;
  87951. for (var i = 0; i < currentIndices.length; i += 3) {
  87952. vertexIndex[0] = currentIndices[i];
  87953. vertexIndex[1] = currentIndices[i + 1];
  87954. vertexIndex[2] = currentIndices[i + 2];
  87955. for (var j = 0; j < 3; j++) {
  87956. a = vertexIndex[j];
  87957. b = vertexIndex[(j + 1) % 3];
  87958. if (side[a] === undefined && side[b] === undefined) {
  87959. side[a] = new Array();
  87960. side[b] = new Array();
  87961. }
  87962. else {
  87963. if (side[a] === undefined) {
  87964. side[a] = new Array();
  87965. }
  87966. if (side[b] === undefined) {
  87967. side[b] = new Array();
  87968. }
  87969. }
  87970. if (side[a][b] === undefined && side[b][a] === undefined) {
  87971. side[a][b] = [];
  87972. deltaPosition.x = (positions[3 * b] - positions[3 * a]) / segments;
  87973. deltaPosition.y = (positions[3 * b + 1] - positions[3 * a + 1]) / segments;
  87974. deltaPosition.z = (positions[3 * b + 2] - positions[3 * a + 2]) / segments;
  87975. deltaNormal.x = (normals[3 * b] - normals[3 * a]) / segments;
  87976. deltaNormal.y = (normals[3 * b + 1] - normals[3 * a + 1]) / segments;
  87977. deltaNormal.z = (normals[3 * b + 2] - normals[3 * a + 2]) / segments;
  87978. deltaUV.x = (uvs[2 * b] - uvs[2 * a]) / segments;
  87979. deltaUV.y = (uvs[2 * b + 1] - uvs[2 * a + 1]) / segments;
  87980. side[a][b].push(a);
  87981. for (var k = 1; k < segments; k++) {
  87982. side[a][b].push(positions.length / 3);
  87983. positions[positionPtr] = positions[3 * a] + k * deltaPosition.x;
  87984. normals[positionPtr++] = normals[3 * a] + k * deltaNormal.x;
  87985. positions[positionPtr] = positions[3 * a + 1] + k * deltaPosition.y;
  87986. normals[positionPtr++] = normals[3 * a + 1] + k * deltaNormal.y;
  87987. positions[positionPtr] = positions[3 * a + 2] + k * deltaPosition.z;
  87988. normals[positionPtr++] = normals[3 * a + 2] + k * deltaNormal.z;
  87989. uvs[uvPtr++] = uvs[2 * a] + k * deltaUV.x;
  87990. uvs[uvPtr++] = uvs[2 * a + 1] + k * deltaUV.y;
  87991. }
  87992. side[a][b].push(b);
  87993. side[b][a] = new Array();
  87994. len = side[a][b].length;
  87995. for (var idx = 0; idx < len; idx++) {
  87996. side[b][a][idx] = side[a][b][len - 1 - idx];
  87997. }
  87998. }
  87999. }
  88000. //Calculate positions, normals and uvs of new internal vertices
  88001. tempIndices[0][0] = currentIndices[i];
  88002. tempIndices[1][0] = side[currentIndices[i]][currentIndices[i + 1]][1];
  88003. tempIndices[1][1] = side[currentIndices[i]][currentIndices[i + 2]][1];
  88004. for (var k = 2; k < segments; k++) {
  88005. tempIndices[k][0] = side[currentIndices[i]][currentIndices[i + 1]][k];
  88006. tempIndices[k][k] = side[currentIndices[i]][currentIndices[i + 2]][k];
  88007. deltaPosition.x = (positions[3 * tempIndices[k][k]] - positions[3 * tempIndices[k][0]]) / k;
  88008. deltaPosition.y = (positions[3 * tempIndices[k][k] + 1] - positions[3 * tempIndices[k][0] + 1]) / k;
  88009. deltaPosition.z = (positions[3 * tempIndices[k][k] + 2] - positions[3 * tempIndices[k][0] + 2]) / k;
  88010. deltaNormal.x = (normals[3 * tempIndices[k][k]] - normals[3 * tempIndices[k][0]]) / k;
  88011. deltaNormal.y = (normals[3 * tempIndices[k][k] + 1] - normals[3 * tempIndices[k][0] + 1]) / k;
  88012. deltaNormal.z = (normals[3 * tempIndices[k][k] + 2] - normals[3 * tempIndices[k][0] + 2]) / k;
  88013. deltaUV.x = (uvs[2 * tempIndices[k][k]] - uvs[2 * tempIndices[k][0]]) / k;
  88014. deltaUV.y = (uvs[2 * tempIndices[k][k] + 1] - uvs[2 * tempIndices[k][0] + 1]) / k;
  88015. for (var j = 1; j < k; j++) {
  88016. tempIndices[k][j] = positions.length / 3;
  88017. positions[positionPtr] = positions[3 * tempIndices[k][0]] + j * deltaPosition.x;
  88018. normals[positionPtr++] = normals[3 * tempIndices[k][0]] + j * deltaNormal.x;
  88019. positions[positionPtr] = positions[3 * tempIndices[k][0] + 1] + j * deltaPosition.y;
  88020. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 1] + j * deltaNormal.y;
  88021. positions[positionPtr] = positions[3 * tempIndices[k][0] + 2] + j * deltaPosition.z;
  88022. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 2] + j * deltaNormal.z;
  88023. uvs[uvPtr++] = uvs[2 * tempIndices[k][0]] + j * deltaUV.x;
  88024. uvs[uvPtr++] = uvs[2 * tempIndices[k][0] + 1] + j * deltaUV.y;
  88025. }
  88026. }
  88027. tempIndices[segments] = side[currentIndices[i + 1]][currentIndices[i + 2]];
  88028. // reform indices
  88029. indices.push(tempIndices[0][0], tempIndices[1][0], tempIndices[1][1]);
  88030. for (var k = 1; k < segments; k++) {
  88031. for (var j = 0; j < k; j++) {
  88032. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  88033. indices.push(tempIndices[k][j], tempIndices[k + 1][j + 1], tempIndices[k][j + 1]);
  88034. }
  88035. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  88036. }
  88037. }
  88038. vertex_data.indices = indices;
  88039. vertex_data.applyToMesh(this);
  88040. }
  88041. };
  88042. /**
  88043. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88044. * This will undo any application of covertToFlatShadedMesh
  88045. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88046. */
  88047. Mesh.prototype.forceSharedVertices = function () {
  88048. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  88049. var currentUVs = vertex_data.uvs;
  88050. var currentIndices = vertex_data.indices;
  88051. var currentPositions = vertex_data.positions;
  88052. var currentNormals = vertex_data.normals;
  88053. if (currentIndices === null || currentPositions === null || currentNormals === null || currentUVs === null) {
  88054. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  88055. }
  88056. else {
  88057. var positions = new Array();
  88058. var indices = new Array();
  88059. var uvs = new Array();
  88060. var pstring = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"
  88061. var indexPtr = 0; // pointer to next available index value
  88062. var uniquePositions = new Array(); // unique vertex positions
  88063. var ptr; // pointer to element in uniquePositions
  88064. var facet;
  88065. for (var i = 0; i < currentIndices.length; i += 3) {
  88066. facet = [currentIndices[i], currentIndices[i + 1], currentIndices[i + 2]]; //facet vertex indices
  88067. pstring = new Array();
  88068. for (var j = 0; j < 3; j++) {
  88069. pstring[j] = "";
  88070. for (var k = 0; k < 3; k++) {
  88071. //small values make 0
  88072. if (Math.abs(currentPositions[3 * facet[j] + k]) < 0.00000001) {
  88073. currentPositions[3 * facet[j] + k] = 0;
  88074. }
  88075. pstring[j] += currentPositions[3 * facet[j] + k] + "|";
  88076. }
  88077. pstring[j] = pstring[j].slice(0, -1);
  88078. }
  88079. //check facet vertices to see that none are repeated
  88080. // do not process any facet that has a repeated vertex, ie is a line
  88081. if (!(pstring[0] == pstring[1] || pstring[0] == pstring[2] || pstring[1] == pstring[2])) {
  88082. //for each facet position check if already listed in uniquePositions
  88083. // if not listed add to uniquePositions and set index pointer
  88084. // if listed use its index in uniquePositions and new index pointer
  88085. for (var j = 0; j < 3; j++) {
  88086. ptr = uniquePositions.indexOf(pstring[j]);
  88087. if (ptr < 0) {
  88088. uniquePositions.push(pstring[j]);
  88089. ptr = indexPtr++;
  88090. //not listed so add individual x, y, z coordinates to positions
  88091. for (var k = 0; k < 3; k++) {
  88092. positions.push(currentPositions[3 * facet[j] + k]);
  88093. }
  88094. for (var k = 0; k < 2; k++) {
  88095. uvs.push(currentUVs[2 * facet[j] + k]);
  88096. }
  88097. }
  88098. // add new index pointer to indices array
  88099. indices.push(ptr);
  88100. }
  88101. }
  88102. }
  88103. var normals = new Array();
  88104. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  88105. //create new vertex data object and update
  88106. vertex_data.positions = positions;
  88107. vertex_data.indices = indices;
  88108. vertex_data.normals = normals;
  88109. vertex_data.uvs = uvs;
  88110. vertex_data.applyToMesh(this);
  88111. }
  88112. };
  88113. // Instances
  88114. /** @hidden */
  88115. Mesh._instancedMeshFactory = function (name, mesh) {
  88116. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  88117. };
  88118. /** @hidden */
  88119. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  88120. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  88121. };
  88122. /**
  88123. * Creates a new InstancedMesh object from the mesh model.
  88124. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88125. * @param name defines the name of the new instance
  88126. * @returns a new InstancedMesh
  88127. */
  88128. Mesh.prototype.createInstance = function (name) {
  88129. return Mesh._instancedMeshFactory(name, this);
  88130. };
  88131. /**
  88132. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88133. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88134. * @returns the current mesh
  88135. */
  88136. Mesh.prototype.synchronizeInstances = function () {
  88137. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  88138. var instance = this.instances[instanceIndex];
  88139. instance._syncSubMeshes();
  88140. }
  88141. return this;
  88142. };
  88143. /**
  88144. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88145. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88146. * This should be used together with the simplification to avoid disappearing triangles.
  88147. * @param successCallback an optional success callback to be called after the optimization finished.
  88148. * @returns the current mesh
  88149. */
  88150. Mesh.prototype.optimizeIndices = function (successCallback) {
  88151. var _this = this;
  88152. var indices = this.getIndices();
  88153. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88154. if (!positions || !indices) {
  88155. return this;
  88156. }
  88157. var vectorPositions = new Array();
  88158. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  88159. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  88160. }
  88161. var dupes = new Array();
  88162. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  88163. var realPos = vectorPositions.length - 1 - iteration;
  88164. var testedPosition = vectorPositions[realPos];
  88165. for (var j = 0; j < realPos; ++j) {
  88166. var againstPosition = vectorPositions[j];
  88167. if (testedPosition.equals(againstPosition)) {
  88168. dupes[realPos] = j;
  88169. break;
  88170. }
  88171. }
  88172. }, function () {
  88173. for (var i = 0; i < indices.length; ++i) {
  88174. indices[i] = dupes[indices[i]] || indices[i];
  88175. }
  88176. //indices are now reordered
  88177. var originalSubMeshes = _this.subMeshes.slice(0);
  88178. _this.setIndices(indices);
  88179. _this.subMeshes = originalSubMeshes;
  88180. if (successCallback) {
  88181. successCallback(_this);
  88182. }
  88183. });
  88184. return this;
  88185. };
  88186. /**
  88187. * Serialize current mesh
  88188. * @param serializationObject defines the object which will receive the serialization data
  88189. */
  88190. Mesh.prototype.serialize = function (serializationObject) {
  88191. serializationObject.name = this.name;
  88192. serializationObject.id = this.id;
  88193. serializationObject.type = this.getClassName();
  88194. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  88195. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  88196. }
  88197. serializationObject.position = this.position.asArray();
  88198. if (this.rotationQuaternion) {
  88199. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  88200. }
  88201. else if (this.rotation) {
  88202. serializationObject.rotation = this.rotation.asArray();
  88203. }
  88204. serializationObject.scaling = this.scaling.asArray();
  88205. if (this._postMultiplyPivotMatrix) {
  88206. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  88207. }
  88208. else {
  88209. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  88210. }
  88211. serializationObject.isEnabled = this.isEnabled(false);
  88212. serializationObject.isVisible = this.isVisible;
  88213. serializationObject.infiniteDistance = this.infiniteDistance;
  88214. serializationObject.pickable = this.isPickable;
  88215. serializationObject.receiveShadows = this.receiveShadows;
  88216. serializationObject.billboardMode = this.billboardMode;
  88217. serializationObject.visibility = this.visibility;
  88218. serializationObject.checkCollisions = this.checkCollisions;
  88219. serializationObject.isBlocker = this.isBlocker;
  88220. // Parent
  88221. if (this.parent) {
  88222. serializationObject.parentId = this.parent.id;
  88223. }
  88224. // Geometry
  88225. serializationObject.isUnIndexed = this.isUnIndexed;
  88226. var geometry = this._geometry;
  88227. if (geometry) {
  88228. var geometryId = geometry.id;
  88229. serializationObject.geometryId = geometryId;
  88230. // SubMeshes
  88231. serializationObject.subMeshes = [];
  88232. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  88233. var subMesh = this.subMeshes[subIndex];
  88234. serializationObject.subMeshes.push({
  88235. materialIndex: subMesh.materialIndex,
  88236. verticesStart: subMesh.verticesStart,
  88237. verticesCount: subMesh.verticesCount,
  88238. indexStart: subMesh.indexStart,
  88239. indexCount: subMesh.indexCount
  88240. });
  88241. }
  88242. }
  88243. // Material
  88244. if (this.material) {
  88245. serializationObject.materialId = this.material.id;
  88246. }
  88247. else {
  88248. this.material = null;
  88249. }
  88250. // Morph targets
  88251. if (this.morphTargetManager) {
  88252. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  88253. }
  88254. // Skeleton
  88255. if (this.skeleton) {
  88256. serializationObject.skeletonId = this.skeleton.id;
  88257. }
  88258. // Physics
  88259. //TODO implement correct serialization for physics impostors.
  88260. var impostor = this.getPhysicsImpostor();
  88261. if (impostor) {
  88262. serializationObject.physicsMass = impostor.getParam("mass");
  88263. serializationObject.physicsFriction = impostor.getParam("friction");
  88264. serializationObject.physicsRestitution = impostor.getParam("mass");
  88265. serializationObject.physicsImpostor = impostor.type;
  88266. }
  88267. // Metadata
  88268. if (this.metadata) {
  88269. serializationObject.metadata = this.metadata;
  88270. }
  88271. // Instances
  88272. serializationObject.instances = [];
  88273. for (var index = 0; index < this.instances.length; index++) {
  88274. var instance = this.instances[index];
  88275. if (instance.doNotSerialize) {
  88276. continue;
  88277. }
  88278. var serializationInstance = {
  88279. name: instance.name,
  88280. id: instance.id,
  88281. position: instance.position.asArray(),
  88282. scaling: instance.scaling.asArray()
  88283. };
  88284. if (instance.parent) {
  88285. serializationInstance.parentId = instance.parent.id;
  88286. }
  88287. if (instance.rotationQuaternion) {
  88288. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  88289. }
  88290. else if (instance.rotation) {
  88291. serializationInstance.rotation = instance.rotation.asArray();
  88292. }
  88293. serializationObject.instances.push(serializationInstance);
  88294. // Animations
  88295. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  88296. serializationInstance.ranges = instance.serializeAnimationRanges();
  88297. }
  88298. //
  88299. // Animations
  88300. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  88301. serializationObject.ranges = this.serializeAnimationRanges();
  88302. // Layer mask
  88303. serializationObject.layerMask = this.layerMask;
  88304. // Alpha
  88305. serializationObject.alphaIndex = this.alphaIndex;
  88306. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  88307. // Overlay
  88308. serializationObject.overlayAlpha = this.overlayAlpha;
  88309. serializationObject.overlayColor = this.overlayColor.asArray();
  88310. serializationObject.renderOverlay = this.renderOverlay;
  88311. // Fog
  88312. serializationObject.applyFog = this.applyFog;
  88313. // Action Manager
  88314. if (this.actionManager) {
  88315. serializationObject.actions = this.actionManager.serialize(this.name);
  88316. }
  88317. };
  88318. /** @hidden */
  88319. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  88320. if (!this.geometry) {
  88321. return;
  88322. }
  88323. this._markSubMeshesAsAttributesDirty();
  88324. var morphTargetManager = this._morphTargetManager;
  88325. if (morphTargetManager && morphTargetManager.vertexCount) {
  88326. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  88327. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  88328. this.morphTargetManager = null;
  88329. return;
  88330. }
  88331. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  88332. var morphTarget = morphTargetManager.getActiveTarget(index);
  88333. var positions = morphTarget.getPositions();
  88334. if (!positions) {
  88335. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  88336. return;
  88337. }
  88338. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  88339. var normals = morphTarget.getNormals();
  88340. if (normals) {
  88341. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  88342. }
  88343. var tangents = morphTarget.getTangents();
  88344. if (tangents) {
  88345. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  88346. }
  88347. }
  88348. }
  88349. else {
  88350. var index = 0;
  88351. // Positions
  88352. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  88353. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  88354. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  88355. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  88356. }
  88357. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  88358. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  88359. }
  88360. index++;
  88361. }
  88362. }
  88363. };
  88364. /**
  88365. * Returns a new Mesh object parsed from the source provided.
  88366. * @param parsedMesh is the source
  88367. * @param scene defines the hosting scene
  88368. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88369. * @returns a new Mesh
  88370. */
  88371. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  88372. var mesh;
  88373. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  88374. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  88375. }
  88376. else {
  88377. mesh = new Mesh(parsedMesh.name, scene);
  88378. }
  88379. mesh.id = parsedMesh.id;
  88380. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  88381. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  88382. }
  88383. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  88384. if (parsedMesh.metadata !== undefined) {
  88385. mesh.metadata = parsedMesh.metadata;
  88386. }
  88387. if (parsedMesh.rotationQuaternion) {
  88388. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  88389. }
  88390. else if (parsedMesh.rotation) {
  88391. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  88392. }
  88393. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  88394. if (parsedMesh.localMatrix) {
  88395. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  88396. }
  88397. else if (parsedMesh.pivotMatrix) {
  88398. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  88399. }
  88400. mesh.setEnabled(parsedMesh.isEnabled);
  88401. mesh.isVisible = parsedMesh.isVisible;
  88402. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  88403. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  88404. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  88405. if (parsedMesh.applyFog !== undefined) {
  88406. mesh.applyFog = parsedMesh.applyFog;
  88407. }
  88408. if (parsedMesh.pickable !== undefined) {
  88409. mesh.isPickable = parsedMesh.pickable;
  88410. }
  88411. if (parsedMesh.alphaIndex !== undefined) {
  88412. mesh.alphaIndex = parsedMesh.alphaIndex;
  88413. }
  88414. mesh.receiveShadows = parsedMesh.receiveShadows;
  88415. mesh.billboardMode = parsedMesh.billboardMode;
  88416. if (parsedMesh.visibility !== undefined) {
  88417. mesh.visibility = parsedMesh.visibility;
  88418. }
  88419. mesh.checkCollisions = parsedMesh.checkCollisions;
  88420. if (parsedMesh.isBlocker !== undefined) {
  88421. mesh.isBlocker = parsedMesh.isBlocker;
  88422. }
  88423. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  88424. // freezeWorldMatrix
  88425. if (parsedMesh.freezeWorldMatrix) {
  88426. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  88427. }
  88428. // Parent
  88429. if (parsedMesh.parentId) {
  88430. mesh._waitingParentId = parsedMesh.parentId;
  88431. }
  88432. // Actions
  88433. if (parsedMesh.actions !== undefined) {
  88434. mesh._waitingActions = parsedMesh.actions;
  88435. }
  88436. // Overlay
  88437. if (parsedMesh.overlayAlpha !== undefined) {
  88438. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  88439. }
  88440. if (parsedMesh.overlayColor !== undefined) {
  88441. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  88442. }
  88443. if (parsedMesh.renderOverlay !== undefined) {
  88444. mesh.renderOverlay = parsedMesh.renderOverlay;
  88445. }
  88446. // Geometry
  88447. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  88448. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  88449. if (parsedMesh.delayLoadingFile) {
  88450. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  88451. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  88452. 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));
  88453. if (parsedMesh._binaryInfo) {
  88454. mesh._binaryInfo = parsedMesh._binaryInfo;
  88455. }
  88456. mesh._delayInfo = [];
  88457. if (parsedMesh.hasUVs) {
  88458. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  88459. }
  88460. if (parsedMesh.hasUVs2) {
  88461. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  88462. }
  88463. if (parsedMesh.hasUVs3) {
  88464. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  88465. }
  88466. if (parsedMesh.hasUVs4) {
  88467. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  88468. }
  88469. if (parsedMesh.hasUVs5) {
  88470. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  88471. }
  88472. if (parsedMesh.hasUVs6) {
  88473. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  88474. }
  88475. if (parsedMesh.hasColors) {
  88476. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  88477. }
  88478. if (parsedMesh.hasMatricesIndices) {
  88479. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  88480. }
  88481. if (parsedMesh.hasMatricesWeights) {
  88482. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88483. }
  88484. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  88485. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  88486. mesh._checkDelayState();
  88487. }
  88488. }
  88489. else {
  88490. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  88491. }
  88492. // Material
  88493. if (parsedMesh.materialId) {
  88494. mesh.setMaterialByID(parsedMesh.materialId);
  88495. }
  88496. else {
  88497. mesh.material = null;
  88498. }
  88499. // Morph targets
  88500. if (parsedMesh.morphTargetManagerId > -1) {
  88501. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  88502. }
  88503. // Skeleton
  88504. if (parsedMesh.skeletonId > -1) {
  88505. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  88506. if (parsedMesh.numBoneInfluencers) {
  88507. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  88508. }
  88509. }
  88510. // Animations
  88511. if (parsedMesh.animations) {
  88512. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  88513. var parsedAnimation = parsedMesh.animations[animationIndex];
  88514. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  88515. if (internalClass) {
  88516. mesh.animations.push(internalClass.Parse(parsedAnimation));
  88517. }
  88518. }
  88519. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  88520. }
  88521. if (parsedMesh.autoAnimate) {
  88522. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  88523. }
  88524. // Layer Mask
  88525. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  88526. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  88527. }
  88528. else {
  88529. mesh.layerMask = 0x0FFFFFFF;
  88530. }
  88531. // Physics
  88532. if (parsedMesh.physicsImpostor) {
  88533. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  88534. }
  88535. // Instances
  88536. if (parsedMesh.instances) {
  88537. for (var index = 0; index < parsedMesh.instances.length; index++) {
  88538. var parsedInstance = parsedMesh.instances[index];
  88539. var instance = mesh.createInstance(parsedInstance.name);
  88540. if (parsedInstance.id) {
  88541. instance.id = parsedInstance.id;
  88542. }
  88543. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  88544. if (parsedInstance.tags) {
  88545. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  88546. }
  88547. else {
  88548. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  88549. }
  88550. }
  88551. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  88552. if (parsedInstance.parentId) {
  88553. instance._waitingParentId = parsedInstance.parentId;
  88554. }
  88555. if (parsedInstance.rotationQuaternion) {
  88556. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  88557. }
  88558. else if (parsedInstance.rotation) {
  88559. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  88560. }
  88561. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  88562. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  88563. instance.checkCollisions = parsedInstance.checkCollisions;
  88564. }
  88565. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  88566. instance.isPickable = parsedInstance.pickable;
  88567. }
  88568. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  88569. instance.showBoundingBox = parsedInstance.showBoundingBox;
  88570. }
  88571. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  88572. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  88573. }
  88574. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  88575. instance.alphaIndex = parsedInstance.alphaIndex;
  88576. }
  88577. // Physics
  88578. if (parsedInstance.physicsImpostor) {
  88579. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  88580. }
  88581. // Animation
  88582. if (parsedInstance.animations) {
  88583. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  88584. parsedAnimation = parsedInstance.animations[animationIndex];
  88585. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  88586. if (internalClass) {
  88587. instance.animations.push(internalClass.Parse(parsedAnimation));
  88588. }
  88589. }
  88590. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  88591. if (parsedInstance.autoAnimate) {
  88592. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  88593. }
  88594. }
  88595. }
  88596. }
  88597. return mesh;
  88598. };
  88599. /**
  88600. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88601. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88602. * @param name defines the name of the mesh to create
  88603. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88604. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88605. * @param closePath creates a seam between the first and the last points of each path of the path array
  88606. * @param offset is taken in account only if the `pathArray` is containing a single path
  88607. * @param scene defines the hosting scene
  88608. * @param updatable defines if the mesh must be flagged as updatable
  88609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88610. * @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)
  88611. * @returns a new Mesh
  88612. */
  88613. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  88614. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88615. };
  88616. /**
  88617. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88618. * @param name defines the name of the mesh to create
  88619. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88620. * @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
  88621. * @param scene defines the hosting scene
  88622. * @param updatable defines if the mesh must be flagged as updatable
  88623. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88624. * @returns a new Mesh
  88625. */
  88626. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  88627. if (scene === void 0) { scene = null; }
  88628. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88629. };
  88630. /**
  88631. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88632. * @param name defines the name of the mesh to create
  88633. * @param size sets the size (float) of each box side (default 1)
  88634. * @param scene defines the hosting scene
  88635. * @param updatable defines if the mesh must be flagged as updatable
  88636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88637. * @returns a new Mesh
  88638. */
  88639. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  88640. if (scene === void 0) { scene = null; }
  88641. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88642. };
  88643. /**
  88644. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88645. * @param name defines the name of the mesh to create
  88646. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88647. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88648. * @param scene defines the hosting scene
  88649. * @param updatable defines if the mesh must be flagged as updatable
  88650. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88651. * @returns a new Mesh
  88652. */
  88653. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  88654. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88655. };
  88656. /**
  88657. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88658. * @param name defines the name of the mesh to create
  88659. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88660. * @param diameterTop set the top cap diameter (floats, default 1)
  88661. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88662. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88663. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88664. * @param scene defines the hosting scene
  88665. * @param updatable defines if the mesh must be flagged as updatable
  88666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88667. * @returns a new Mesh
  88668. */
  88669. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  88670. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88671. };
  88672. // Torus (Code from SharpDX.org)
  88673. /**
  88674. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88675. * @param name defines the name of the mesh to create
  88676. * @param diameter sets the diameter size (float) of the torus (default 1)
  88677. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88678. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88679. * @param scene defines the hosting scene
  88680. * @param updatable defines if the mesh must be flagged as updatable
  88681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88682. * @returns a new Mesh
  88683. */
  88684. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  88685. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88686. };
  88687. /**
  88688. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88689. * @param name defines the name of the mesh to create
  88690. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88691. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88692. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88693. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88694. * @param p the number of windings on X axis (positive integers, default 2)
  88695. * @param q the number of windings on Y axis (positive integers, default 3)
  88696. * @param scene defines the hosting scene
  88697. * @param updatable defines if the mesh must be flagged as updatable
  88698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88699. * @returns a new Mesh
  88700. */
  88701. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  88702. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88703. };
  88704. /**
  88705. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88706. * @param name defines the name of the mesh to create
  88707. * @param points is an array successive Vector3
  88708. * @param scene defines the hosting scene
  88709. * @param updatable defines if the mesh must be flagged as updatable
  88710. * @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).
  88711. * @returns a new Mesh
  88712. */
  88713. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  88714. if (scene === void 0) { scene = null; }
  88715. if (updatable === void 0) { updatable = false; }
  88716. if (instance === void 0) { instance = null; }
  88717. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88718. };
  88719. /**
  88720. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88721. * @param name defines the name of the mesh to create
  88722. * @param points is an array successive Vector3
  88723. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88724. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88725. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88726. * @param scene defines the hosting scene
  88727. * @param updatable defines if the mesh must be flagged as updatable
  88728. * @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)
  88729. * @returns a new Mesh
  88730. */
  88731. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  88732. if (scene === void 0) { scene = null; }
  88733. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88734. };
  88735. /**
  88736. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88737. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88738. * 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.
  88739. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88740. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88741. * Remember you can only change the shape positions, not their number when updating a polygon.
  88742. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88743. * @param name defines the name of the mesh to create
  88744. * @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
  88745. * @param scene defines the hosting scene
  88746. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88747. * @param updatable defines if the mesh must be flagged as updatable
  88748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88749. * @param earcutInjection can be used to inject your own earcut reference
  88750. * @returns a new Mesh
  88751. */
  88752. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  88753. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88754. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88755. };
  88756. /**
  88757. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88758. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88759. * @param name defines the name of the mesh to create
  88760. * @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
  88761. * @param depth defines the height of extrusion
  88762. * @param scene defines the hosting scene
  88763. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88764. * @param updatable defines if the mesh must be flagged as updatable
  88765. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88766. * @param earcutInjection can be used to inject your own earcut reference
  88767. * @returns a new Mesh
  88768. */
  88769. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  88770. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88771. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88772. };
  88773. /**
  88774. * Creates an extruded shape mesh.
  88775. * 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
  88776. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88777. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88778. * @param name defines the name of the mesh to create
  88779. * @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
  88780. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88781. * @param scale is the value to scale the shape
  88782. * @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
  88783. * @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
  88784. * @param scene defines the hosting scene
  88785. * @param updatable defines if the mesh must be flagged as updatable
  88786. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88787. * @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)
  88788. * @returns a new Mesh
  88789. */
  88790. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  88791. if (scene === void 0) { scene = null; }
  88792. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88793. };
  88794. /**
  88795. * Creates an custom extruded shape mesh.
  88796. * The custom extrusion is a parametric shape.
  88797. * It has no predefined shape. Its final shape will depend on the input parameters.
  88798. * Please consider using the same method from the MeshBuilder class instead
  88799. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88800. * @param name defines the name of the mesh to create
  88801. * @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
  88802. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88803. * @param scaleFunction is a custom Javascript function called on each path point
  88804. * @param rotationFunction is a custom Javascript function called on each path point
  88805. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88806. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88807. * @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
  88808. * @param scene defines the hosting scene
  88809. * @param updatable defines if the mesh must be flagged as updatable
  88810. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88811. * @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)
  88812. * @returns a new Mesh
  88813. */
  88814. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  88815. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88816. };
  88817. /**
  88818. * Creates lathe mesh.
  88819. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88820. * Please consider using the same method from the MeshBuilder class instead
  88821. * @param name defines the name of the mesh to create
  88822. * @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
  88823. * @param radius is the radius value of the lathe
  88824. * @param tessellation is the side number of the lathe.
  88825. * @param scene defines the hosting scene
  88826. * @param updatable defines if the mesh must be flagged as updatable
  88827. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88828. * @returns a new Mesh
  88829. */
  88830. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  88831. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88832. };
  88833. /**
  88834. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88835. * @param name defines the name of the mesh to create
  88836. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88837. * @param scene defines the hosting scene
  88838. * @param updatable defines if the mesh must be flagged as updatable
  88839. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88840. * @returns a new Mesh
  88841. */
  88842. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  88843. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88844. };
  88845. /**
  88846. * Creates a ground mesh.
  88847. * Please consider using the same method from the MeshBuilder class instead
  88848. * @param name defines the name of the mesh to create
  88849. * @param width set the width of the ground
  88850. * @param height set the height of the ground
  88851. * @param subdivisions sets the number of subdivisions per side
  88852. * @param scene defines the hosting scene
  88853. * @param updatable defines if the mesh must be flagged as updatable
  88854. * @returns a new Mesh
  88855. */
  88856. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  88857. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88858. };
  88859. /**
  88860. * Creates a tiled ground mesh.
  88861. * Please consider using the same method from the MeshBuilder class instead
  88862. * @param name defines the name of the mesh to create
  88863. * @param xmin set the ground minimum X coordinate
  88864. * @param zmin set the ground minimum Y coordinate
  88865. * @param xmax set the ground maximum X coordinate
  88866. * @param zmax set the ground maximum Z coordinate
  88867. * @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
  88868. * @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
  88869. * @param scene defines the hosting scene
  88870. * @param updatable defines if the mesh must be flagged as updatable
  88871. * @returns a new Mesh
  88872. */
  88873. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  88874. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88875. };
  88876. /**
  88877. * Creates a ground mesh from a height map.
  88878. * Please consider using the same method from the MeshBuilder class instead
  88879. * @see http://doc.babylonjs.com/babylon101/height_map
  88880. * @param name defines the name of the mesh to create
  88881. * @param url sets the URL of the height map image resource
  88882. * @param width set the ground width size
  88883. * @param height set the ground height size
  88884. * @param subdivisions sets the number of subdivision per side
  88885. * @param minHeight is the minimum altitude on the ground
  88886. * @param maxHeight is the maximum altitude on the ground
  88887. * @param scene defines the hosting scene
  88888. * @param updatable defines if the mesh must be flagged as updatable
  88889. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88890. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88891. * @returns a new Mesh
  88892. */
  88893. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  88894. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88895. };
  88896. /**
  88897. * Creates a tube mesh.
  88898. * The tube is a parametric shape.
  88899. * It has no predefined shape. Its final shape will depend on the input parameters.
  88900. * Please consider using the same method from the MeshBuilder class instead
  88901. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88902. * @param name defines the name of the mesh to create
  88903. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88904. * @param radius sets the tube radius size
  88905. * @param tessellation is the number of sides on the tubular surface
  88906. * @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
  88907. * @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
  88908. * @param scene defines the hosting scene
  88909. * @param updatable defines if the mesh must be flagged as updatable
  88910. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88911. * @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)
  88912. * @returns a new Mesh
  88913. */
  88914. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  88915. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88916. };
  88917. /**
  88918. * Creates a polyhedron mesh.
  88919. * Please consider using the same method from the MeshBuilder class instead.
  88920. * * 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
  88921. * * The parameter `size` (positive float, default 1) sets the polygon size
  88922. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88923. * * 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`
  88924. * * 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
  88925. * * 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)`)
  88926. * * 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
  88927. * * 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
  88928. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88929. * * 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
  88930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88931. * @param name defines the name of the mesh to create
  88932. * @param options defines the options used to create the mesh
  88933. * @param scene defines the hosting scene
  88934. * @returns a new Mesh
  88935. */
  88936. Mesh.CreatePolyhedron = function (name, options, scene) {
  88937. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88938. };
  88939. /**
  88940. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88941. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88942. * * 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`)
  88943. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88944. * * 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
  88945. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88946. * * 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
  88947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88948. * @param name defines the name of the mesh
  88949. * @param options defines the options used to create the mesh
  88950. * @param scene defines the hosting scene
  88951. * @returns a new Mesh
  88952. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88953. */
  88954. Mesh.CreateIcoSphere = function (name, options, scene) {
  88955. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88956. };
  88957. /**
  88958. * Creates a decal mesh.
  88959. * Please consider using the same method from the MeshBuilder class instead.
  88960. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88961. * @param name defines the name of the mesh
  88962. * @param sourceMesh defines the mesh receiving the decal
  88963. * @param position sets the position of the decal in world coordinates
  88964. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88965. * @param size sets the decal scaling
  88966. * @param angle sets the angle to rotate the decal
  88967. * @returns a new Mesh
  88968. */
  88969. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  88970. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88971. };
  88972. // Skeletons
  88973. /**
  88974. * Prepare internal position array for software CPU skinning
  88975. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88976. */
  88977. Mesh.prototype.setPositionsForCPUSkinning = function () {
  88978. if (!this._sourcePositions) {
  88979. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88980. if (!source) {
  88981. return this._sourcePositions;
  88982. }
  88983. this._sourcePositions = new Float32Array(source);
  88984. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  88985. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  88986. }
  88987. }
  88988. return this._sourcePositions;
  88989. };
  88990. /**
  88991. * Prepare internal normal array for software CPU skinning
  88992. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88993. */
  88994. Mesh.prototype.setNormalsForCPUSkinning = function () {
  88995. if (!this._sourceNormals) {
  88996. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88997. if (!source) {
  88998. return this._sourceNormals;
  88999. }
  89000. this._sourceNormals = new Float32Array(source);
  89001. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  89002. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  89003. }
  89004. }
  89005. return this._sourceNormals;
  89006. };
  89007. /**
  89008. * Updates the vertex buffer by applying transformation from the bones
  89009. * @param skeleton defines the skeleton to apply to current mesh
  89010. * @returns the current mesh
  89011. */
  89012. Mesh.prototype.applySkeleton = function (skeleton) {
  89013. if (!this.geometry) {
  89014. return this;
  89015. }
  89016. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  89017. return this;
  89018. }
  89019. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  89020. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  89021. return this;
  89022. }
  89023. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  89024. return this;
  89025. }
  89026. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  89027. return this;
  89028. }
  89029. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  89030. return this;
  89031. }
  89032. if (!this._sourcePositions) {
  89033. var submeshes = this.subMeshes.slice();
  89034. this.setPositionsForCPUSkinning();
  89035. this.subMeshes = submeshes;
  89036. }
  89037. if (!this._sourceNormals) {
  89038. this.setNormalsForCPUSkinning();
  89039. }
  89040. // positionsData checks for not being Float32Array will only pass at most once
  89041. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89042. if (!positionsData) {
  89043. return this;
  89044. }
  89045. if (!(positionsData instanceof Float32Array)) {
  89046. positionsData = new Float32Array(positionsData);
  89047. }
  89048. // normalsData checks for not being Float32Array will only pass at most once
  89049. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89050. if (!normalsData) {
  89051. return this;
  89052. }
  89053. if (!(normalsData instanceof Float32Array)) {
  89054. normalsData = new Float32Array(normalsData);
  89055. }
  89056. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  89057. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89058. if (!matricesWeightsData || !matricesIndicesData) {
  89059. return this;
  89060. }
  89061. var needExtras = this.numBoneInfluencers > 4;
  89062. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  89063. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  89064. var skeletonMatrices = skeleton.getTransformMatrices(this);
  89065. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89066. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  89067. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  89068. var matWeightIdx = 0;
  89069. var inf;
  89070. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  89071. var weight;
  89072. for (inf = 0; inf < 4; inf++) {
  89073. weight = matricesWeightsData[matWeightIdx + inf];
  89074. if (weight > 0) {
  89075. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  89076. finalMatrix.addToSelf(tempMatrix);
  89077. }
  89078. }
  89079. if (needExtras) {
  89080. for (inf = 0; inf < 4; inf++) {
  89081. weight = matricesWeightsExtraData[matWeightIdx + inf];
  89082. if (weight > 0) {
  89083. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  89084. finalMatrix.addToSelf(tempMatrix);
  89085. }
  89086. }
  89087. }
  89088. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  89089. tempVector3.toArray(positionsData, index);
  89090. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  89091. tempVector3.toArray(normalsData, index);
  89092. finalMatrix.reset();
  89093. }
  89094. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  89095. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  89096. return this;
  89097. };
  89098. // Tools
  89099. /**
  89100. * 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
  89101. * @param meshes defines the list of meshes to scan
  89102. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89103. */
  89104. Mesh.MinMax = function (meshes) {
  89105. var minVector = null;
  89106. var maxVector = null;
  89107. meshes.forEach(function (mesh) {
  89108. var boundingInfo = mesh.getBoundingInfo();
  89109. var boundingBox = boundingInfo.boundingBox;
  89110. if (!minVector || !maxVector) {
  89111. minVector = boundingBox.minimumWorld;
  89112. maxVector = boundingBox.maximumWorld;
  89113. }
  89114. else {
  89115. minVector.minimizeInPlace(boundingBox.minimumWorld);
  89116. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  89117. }
  89118. });
  89119. if (!minVector || !maxVector) {
  89120. return {
  89121. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  89122. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  89123. };
  89124. }
  89125. return {
  89126. min: minVector,
  89127. max: maxVector
  89128. };
  89129. };
  89130. /**
  89131. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89132. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89133. * @returns a vector3
  89134. */
  89135. Mesh.Center = function (meshesOrMinMaxVector) {
  89136. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  89137. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  89138. };
  89139. /**
  89140. * Merge the array of meshes into a single mesh for performance reasons.
  89141. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89142. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89143. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89144. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89145. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89146. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89147. * @returns a new mesh
  89148. */
  89149. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  89150. if (disposeSource === void 0) { disposeSource = true; }
  89151. var index;
  89152. if (!allow32BitsIndices) {
  89153. var totalVertices = 0;
  89154. // Counting vertices
  89155. for (index = 0; index < meshes.length; index++) {
  89156. if (meshes[index]) {
  89157. totalVertices += meshes[index].getTotalVertices();
  89158. if (totalVertices > 65536) {
  89159. _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");
  89160. return null;
  89161. }
  89162. }
  89163. }
  89164. }
  89165. if (multiMultiMaterials) {
  89166. var newMultiMaterial = null;
  89167. var subIndex;
  89168. var matIndex;
  89169. subdivideWithSubMeshes = false;
  89170. }
  89171. var materialArray = new Array();
  89172. var materialIndexArray = new Array();
  89173. // Merge
  89174. var vertexData = null;
  89175. var otherVertexData;
  89176. var indiceArray = new Array();
  89177. var source = null;
  89178. for (index = 0; index < meshes.length; index++) {
  89179. if (meshes[index]) {
  89180. var mesh = meshes[index];
  89181. var wm = mesh.computeWorldMatrix(true);
  89182. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  89183. otherVertexData.transform(wm);
  89184. if (vertexData) {
  89185. vertexData.merge(otherVertexData, allow32BitsIndices);
  89186. }
  89187. else {
  89188. vertexData = otherVertexData;
  89189. source = mesh;
  89190. }
  89191. if (subdivideWithSubMeshes) {
  89192. indiceArray.push(mesh.getTotalIndices());
  89193. }
  89194. if (multiMultiMaterials) {
  89195. if (mesh.material) {
  89196. var material = mesh.material;
  89197. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  89198. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  89199. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  89200. materialArray.push(material.subMaterials[matIndex]);
  89201. }
  89202. }
  89203. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89204. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  89205. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89206. }
  89207. }
  89208. else {
  89209. if (materialArray.indexOf(material) < 0) {
  89210. materialArray.push(material);
  89211. }
  89212. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89213. materialIndexArray.push(materialArray.indexOf(material));
  89214. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89215. }
  89216. }
  89217. }
  89218. else {
  89219. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89220. materialIndexArray.push(0);
  89221. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89222. }
  89223. }
  89224. }
  89225. }
  89226. }
  89227. source = source;
  89228. if (!meshSubclass) {
  89229. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  89230. }
  89231. vertexData.applyToMesh(meshSubclass);
  89232. // Setting properties
  89233. meshSubclass.checkCollisions = source.checkCollisions;
  89234. // Cleaning
  89235. if (disposeSource) {
  89236. for (index = 0; index < meshes.length; index++) {
  89237. if (meshes[index]) {
  89238. meshes[index].dispose();
  89239. }
  89240. }
  89241. }
  89242. // Subdivide
  89243. if (subdivideWithSubMeshes || multiMultiMaterials) {
  89244. //-- removal of global submesh
  89245. meshSubclass.releaseSubMeshes();
  89246. index = 0;
  89247. var offset = 0;
  89248. //-- apply subdivision according to index table
  89249. while (index < indiceArray.length) {
  89250. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  89251. offset += indiceArray[index];
  89252. index++;
  89253. }
  89254. }
  89255. if (multiMultiMaterials) {
  89256. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  89257. newMultiMaterial.subMaterials = materialArray;
  89258. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  89259. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  89260. }
  89261. meshSubclass.material = newMultiMaterial;
  89262. }
  89263. else {
  89264. meshSubclass.material = source.material;
  89265. }
  89266. return meshSubclass;
  89267. };
  89268. /** @hidden */
  89269. Mesh.prototype.addInstance = function (instance) {
  89270. instance._indexInSourceMeshInstanceArray = this.instances.length;
  89271. this.instances.push(instance);
  89272. };
  89273. /** @hidden */
  89274. Mesh.prototype.removeInstance = function (instance) {
  89275. // Remove from mesh
  89276. var index = instance._indexInSourceMeshInstanceArray;
  89277. if (index != -1) {
  89278. if (index !== this.instances.length - 1) {
  89279. var last = this.instances[this.instances.length - 1];
  89280. this.instances[index] = last;
  89281. last._indexInSourceMeshInstanceArray = index;
  89282. }
  89283. instance._indexInSourceMeshInstanceArray = -1;
  89284. this.instances.pop();
  89285. }
  89286. };
  89287. // Consts
  89288. /**
  89289. * Mesh side orientation : usually the external or front surface
  89290. */
  89291. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  89292. /**
  89293. * Mesh side orientation : usually the internal or back surface
  89294. */
  89295. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  89296. /**
  89297. * Mesh side orientation : both internal and external or front and back surfaces
  89298. */
  89299. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  89300. /**
  89301. * Mesh side orientation : by default, `FRONTSIDE`
  89302. */
  89303. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  89304. /**
  89305. * Mesh cap setting : no cap
  89306. */
  89307. Mesh.NO_CAP = 0;
  89308. /**
  89309. * Mesh cap setting : one cap at the beginning of the mesh
  89310. */
  89311. Mesh.CAP_START = 1;
  89312. /**
  89313. * Mesh cap setting : one cap at the end of the mesh
  89314. */
  89315. Mesh.CAP_END = 2;
  89316. /**
  89317. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89318. */
  89319. Mesh.CAP_ALL = 3;
  89320. // Statics
  89321. /** @hidden */
  89322. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  89323. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  89324. };
  89325. return Mesh;
  89326. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  89327. /***/ }),
  89328. /***/ "./Meshes/mesh.vertexData.ts":
  89329. /*!***********************************!*\
  89330. !*** ./Meshes/mesh.vertexData.ts ***!
  89331. \***********************************/
  89332. /*! exports provided: VertexData */
  89333. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89334. "use strict";
  89335. __webpack_require__.r(__webpack_exports__);
  89336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  89337. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89338. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89339. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  89340. /**
  89341. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89342. */
  89343. var VertexData = /** @class */ (function () {
  89344. function VertexData() {
  89345. }
  89346. /**
  89347. * Uses the passed data array to set the set the values for the specified kind of data
  89348. * @param data a linear array of floating numbers
  89349. * @param kind the type of data that is being set, eg positions, colors etc
  89350. */
  89351. VertexData.prototype.set = function (data, kind) {
  89352. switch (kind) {
  89353. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  89354. this.positions = data;
  89355. break;
  89356. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  89357. this.normals = data;
  89358. break;
  89359. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  89360. this.tangents = data;
  89361. break;
  89362. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  89363. this.uvs = data;
  89364. break;
  89365. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  89366. this.uvs2 = data;
  89367. break;
  89368. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  89369. this.uvs3 = data;
  89370. break;
  89371. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  89372. this.uvs4 = data;
  89373. break;
  89374. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  89375. this.uvs5 = data;
  89376. break;
  89377. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  89378. this.uvs6 = data;
  89379. break;
  89380. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  89381. this.colors = data;
  89382. break;
  89383. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  89384. this.matricesIndices = data;
  89385. break;
  89386. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  89387. this.matricesWeights = data;
  89388. break;
  89389. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  89390. this.matricesIndicesExtra = data;
  89391. break;
  89392. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  89393. this.matricesWeightsExtra = data;
  89394. break;
  89395. }
  89396. };
  89397. /**
  89398. * Associates the vertexData to the passed Mesh.
  89399. * Sets it as updatable or not (default `false`)
  89400. * @param mesh the mesh the vertexData is applied to
  89401. * @param updatable when used and having the value true allows new data to update the vertexData
  89402. * @returns the VertexData
  89403. */
  89404. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  89405. this._applyTo(mesh, updatable);
  89406. return this;
  89407. };
  89408. /**
  89409. * Associates the vertexData to the passed Geometry.
  89410. * Sets it as updatable or not (default `false`)
  89411. * @param geometry the geometry the vertexData is applied to
  89412. * @param updatable when used and having the value true allows new data to update the vertexData
  89413. * @returns VertexData
  89414. */
  89415. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  89416. this._applyTo(geometry, updatable);
  89417. return this;
  89418. };
  89419. /**
  89420. * Updates the associated mesh
  89421. * @param mesh the mesh to be updated
  89422. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89423. * @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
  89424. * @returns VertexData
  89425. */
  89426. VertexData.prototype.updateMesh = function (mesh) {
  89427. this._update(mesh);
  89428. return this;
  89429. };
  89430. /**
  89431. * Updates the associated geometry
  89432. * @param geometry the geometry to be updated
  89433. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89434. * @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
  89435. * @returns VertexData.
  89436. */
  89437. VertexData.prototype.updateGeometry = function (geometry) {
  89438. this._update(geometry);
  89439. return this;
  89440. };
  89441. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  89442. if (updatable === void 0) { updatable = false; }
  89443. if (this.positions) {
  89444. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  89445. }
  89446. if (this.normals) {
  89447. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  89448. }
  89449. if (this.tangents) {
  89450. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  89451. }
  89452. if (this.uvs) {
  89453. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  89454. }
  89455. if (this.uvs2) {
  89456. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  89457. }
  89458. if (this.uvs3) {
  89459. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  89460. }
  89461. if (this.uvs4) {
  89462. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  89463. }
  89464. if (this.uvs5) {
  89465. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  89466. }
  89467. if (this.uvs6) {
  89468. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  89469. }
  89470. if (this.colors) {
  89471. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  89472. }
  89473. if (this.matricesIndices) {
  89474. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  89475. }
  89476. if (this.matricesWeights) {
  89477. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  89478. }
  89479. if (this.matricesIndicesExtra) {
  89480. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  89481. }
  89482. if (this.matricesWeightsExtra) {
  89483. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  89484. }
  89485. if (this.indices) {
  89486. meshOrGeometry.setIndices(this.indices, null, updatable);
  89487. }
  89488. else {
  89489. meshOrGeometry.setIndices([], null);
  89490. }
  89491. return this;
  89492. };
  89493. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  89494. if (this.positions) {
  89495. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  89496. }
  89497. if (this.normals) {
  89498. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  89499. }
  89500. if (this.tangents) {
  89501. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  89502. }
  89503. if (this.uvs) {
  89504. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  89505. }
  89506. if (this.uvs2) {
  89507. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  89508. }
  89509. if (this.uvs3) {
  89510. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  89511. }
  89512. if (this.uvs4) {
  89513. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  89514. }
  89515. if (this.uvs5) {
  89516. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  89517. }
  89518. if (this.uvs6) {
  89519. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  89520. }
  89521. if (this.colors) {
  89522. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  89523. }
  89524. if (this.matricesIndices) {
  89525. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  89526. }
  89527. if (this.matricesWeights) {
  89528. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  89529. }
  89530. if (this.matricesIndicesExtra) {
  89531. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  89532. }
  89533. if (this.matricesWeightsExtra) {
  89534. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  89535. }
  89536. if (this.indices) {
  89537. meshOrGeometry.setIndices(this.indices, null);
  89538. }
  89539. return this;
  89540. };
  89541. /**
  89542. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89543. * @param matrix the transforming matrix
  89544. * @returns the VertexData
  89545. */
  89546. VertexData.prototype.transform = function (matrix) {
  89547. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  89548. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89549. var index;
  89550. if (this.positions) {
  89551. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89552. for (index = 0; index < this.positions.length; index += 3) {
  89553. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  89554. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  89555. this.positions[index] = transformed.x;
  89556. this.positions[index + 1] = transformed.y;
  89557. this.positions[index + 2] = transformed.z;
  89558. }
  89559. }
  89560. if (this.normals) {
  89561. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89562. for (index = 0; index < this.normals.length; index += 3) {
  89563. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  89564. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  89565. this.normals[index] = transformed.x;
  89566. this.normals[index + 1] = transformed.y;
  89567. this.normals[index + 2] = transformed.z;
  89568. }
  89569. }
  89570. if (this.tangents) {
  89571. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  89572. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  89573. for (index = 0; index < this.tangents.length; index += 4) {
  89574. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  89575. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  89576. this.tangents[index] = tangentTransformed.x;
  89577. this.tangents[index + 1] = tangentTransformed.y;
  89578. this.tangents[index + 2] = tangentTransformed.z;
  89579. this.tangents[index + 3] = tangentTransformed.w;
  89580. }
  89581. }
  89582. if (flip && this.indices) {
  89583. for (index = 0; index < this.indices.length; index += 3) {
  89584. var tmp = this.indices[index + 1];
  89585. this.indices[index + 1] = this.indices[index + 2];
  89586. this.indices[index + 2] = tmp;
  89587. }
  89588. }
  89589. return this;
  89590. };
  89591. /**
  89592. * Merges the passed VertexData into the current one
  89593. * @param other the VertexData to be merged into the current one
  89594. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89595. * @returns the modified VertexData
  89596. */
  89597. VertexData.prototype.merge = function (other, use32BitsIndices) {
  89598. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  89599. this._validate();
  89600. other._validate();
  89601. if (!this.normals !== !other.normals ||
  89602. !this.tangents !== !other.tangents ||
  89603. !this.uvs !== !other.uvs ||
  89604. !this.uvs2 !== !other.uvs2 ||
  89605. !this.uvs3 !== !other.uvs3 ||
  89606. !this.uvs4 !== !other.uvs4 ||
  89607. !this.uvs5 !== !other.uvs5 ||
  89608. !this.uvs6 !== !other.uvs6 ||
  89609. !this.colors !== !other.colors ||
  89610. !this.matricesIndices !== !other.matricesIndices ||
  89611. !this.matricesWeights !== !other.matricesWeights ||
  89612. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  89613. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  89614. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  89615. }
  89616. if (other.indices) {
  89617. if (!this.indices) {
  89618. this.indices = [];
  89619. }
  89620. var offset = this.positions ? this.positions.length / 3 : 0;
  89621. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  89622. if (isSrcTypedArray) {
  89623. var len = this.indices.length + other.indices.length;
  89624. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  89625. temp.set(this.indices);
  89626. var decal = this.indices.length;
  89627. for (var index = 0; index < other.indices.length; index++) {
  89628. temp[decal + index] = other.indices[index] + offset;
  89629. }
  89630. this.indices = temp;
  89631. }
  89632. else {
  89633. for (var index = 0; index < other.indices.length; index++) {
  89634. this.indices.push(other.indices[index] + offset);
  89635. }
  89636. }
  89637. }
  89638. this.positions = this._mergeElement(this.positions, other.positions);
  89639. this.normals = this._mergeElement(this.normals, other.normals);
  89640. this.tangents = this._mergeElement(this.tangents, other.tangents);
  89641. this.uvs = this._mergeElement(this.uvs, other.uvs);
  89642. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  89643. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  89644. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  89645. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  89646. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  89647. this.colors = this._mergeElement(this.colors, other.colors);
  89648. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  89649. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  89650. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  89651. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  89652. return this;
  89653. };
  89654. VertexData.prototype._mergeElement = function (source, other) {
  89655. if (!source) {
  89656. return other;
  89657. }
  89658. if (!other) {
  89659. return source;
  89660. }
  89661. var len = other.length + source.length;
  89662. var isSrcTypedArray = source instanceof Float32Array;
  89663. var isOthTypedArray = other instanceof Float32Array;
  89664. // use non-loop method when the source is Float32Array
  89665. if (isSrcTypedArray) {
  89666. var ret32 = new Float32Array(len);
  89667. ret32.set(source);
  89668. ret32.set(other, source.length);
  89669. return ret32;
  89670. // source is number[], when other is also use concat
  89671. }
  89672. else if (!isOthTypedArray) {
  89673. return source.concat(other);
  89674. // source is a number[], but other is a Float32Array, loop required
  89675. }
  89676. else {
  89677. var ret = source.slice(0); // copy source to a separate array
  89678. for (var i = 0, len = other.length; i < len; i++) {
  89679. ret.push(other[i]);
  89680. }
  89681. return ret;
  89682. }
  89683. };
  89684. VertexData.prototype._validate = function () {
  89685. if (!this.positions) {
  89686. throw new Error("Positions are required");
  89687. }
  89688. var getElementCount = function (kind, values) {
  89689. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  89690. if ((values.length % stride) !== 0) {
  89691. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  89692. }
  89693. return values.length / stride;
  89694. };
  89695. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  89696. var validateElementCount = function (kind, values) {
  89697. var elementCount = getElementCount(kind, values);
  89698. if (elementCount !== positionsElementCount) {
  89699. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  89700. }
  89701. };
  89702. if (this.normals) {
  89703. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  89704. }
  89705. if (this.tangents) {
  89706. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  89707. }
  89708. if (this.uvs) {
  89709. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  89710. }
  89711. if (this.uvs2) {
  89712. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  89713. }
  89714. if (this.uvs3) {
  89715. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  89716. }
  89717. if (this.uvs4) {
  89718. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  89719. }
  89720. if (this.uvs5) {
  89721. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  89722. }
  89723. if (this.uvs6) {
  89724. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  89725. }
  89726. if (this.colors) {
  89727. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  89728. }
  89729. if (this.matricesIndices) {
  89730. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  89731. }
  89732. if (this.matricesWeights) {
  89733. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  89734. }
  89735. if (this.matricesIndicesExtra) {
  89736. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  89737. }
  89738. if (this.matricesWeightsExtra) {
  89739. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  89740. }
  89741. };
  89742. /**
  89743. * Serializes the VertexData
  89744. * @returns a serialized object
  89745. */
  89746. VertexData.prototype.serialize = function () {
  89747. var serializationObject = this.serialize();
  89748. if (this.positions) {
  89749. serializationObject.positions = this.positions;
  89750. }
  89751. if (this.normals) {
  89752. serializationObject.normals = this.normals;
  89753. }
  89754. if (this.tangents) {
  89755. serializationObject.tangents = this.tangents;
  89756. }
  89757. if (this.uvs) {
  89758. serializationObject.uvs = this.uvs;
  89759. }
  89760. if (this.uvs2) {
  89761. serializationObject.uvs2 = this.uvs2;
  89762. }
  89763. if (this.uvs3) {
  89764. serializationObject.uvs3 = this.uvs3;
  89765. }
  89766. if (this.uvs4) {
  89767. serializationObject.uvs4 = this.uvs4;
  89768. }
  89769. if (this.uvs5) {
  89770. serializationObject.uvs5 = this.uvs5;
  89771. }
  89772. if (this.uvs6) {
  89773. serializationObject.uvs6 = this.uvs6;
  89774. }
  89775. if (this.colors) {
  89776. serializationObject.colors = this.colors;
  89777. }
  89778. if (this.matricesIndices) {
  89779. serializationObject.matricesIndices = this.matricesIndices;
  89780. serializationObject.matricesIndices._isExpanded = true;
  89781. }
  89782. if (this.matricesWeights) {
  89783. serializationObject.matricesWeights = this.matricesWeights;
  89784. }
  89785. if (this.matricesIndicesExtra) {
  89786. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  89787. serializationObject.matricesIndicesExtra._isExpanded = true;
  89788. }
  89789. if (this.matricesWeightsExtra) {
  89790. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  89791. }
  89792. serializationObject.indices = this.indices;
  89793. return serializationObject;
  89794. };
  89795. // Statics
  89796. /**
  89797. * Extracts the vertexData from a mesh
  89798. * @param mesh the mesh from which to extract the VertexData
  89799. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89800. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89801. * @returns the object VertexData associated to the passed mesh
  89802. */
  89803. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  89804. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  89805. };
  89806. /**
  89807. * Extracts the vertexData from the geometry
  89808. * @param geometry the geometry from which to extract the VertexData
  89809. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89810. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89811. * @returns the object VertexData associated to the passed mesh
  89812. */
  89813. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  89814. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  89815. };
  89816. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  89817. var result = new VertexData();
  89818. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  89819. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  89820. }
  89821. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  89822. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  89823. }
  89824. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  89825. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  89826. }
  89827. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  89828. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  89829. }
  89830. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  89831. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  89832. }
  89833. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  89834. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  89835. }
  89836. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  89837. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  89838. }
  89839. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  89840. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  89841. }
  89842. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  89843. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  89844. }
  89845. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  89846. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  89847. }
  89848. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  89849. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  89850. }
  89851. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  89852. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  89853. }
  89854. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  89855. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  89856. }
  89857. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  89858. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  89859. }
  89860. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  89861. return result;
  89862. };
  89863. /**
  89864. * Creates the VertexData for a Ribbon
  89865. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89866. * * pathArray array of paths, each of which an array of successive Vector3
  89867. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89868. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89869. * * 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
  89870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89871. * * 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)
  89872. * * 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)
  89873. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89874. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89875. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89876. * @returns the VertexData of the ribbon
  89877. */
  89878. VertexData.CreateRibbon = function (options) {
  89879. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  89880. };
  89881. /**
  89882. * Creates the VertexData for a box
  89883. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89884. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89885. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89886. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89887. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89888. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89889. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89891. * * 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)
  89892. * * 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)
  89893. * @returns the VertexData of the box
  89894. */
  89895. VertexData.CreateBox = function (options) {
  89896. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  89897. };
  89898. /**
  89899. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89900. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89901. * * segments sets the number of horizontal strips optional, default 32
  89902. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89903. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89904. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89905. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89906. * * 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
  89907. * * 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
  89908. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89909. * * 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)
  89910. * * 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)
  89911. * @returns the VertexData of the ellipsoid
  89912. */
  89913. VertexData.CreateSphere = function (options) {
  89914. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  89915. };
  89916. /**
  89917. * Creates the VertexData for a cylinder, cone or prism
  89918. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89919. * * height sets the height (y direction) of the cylinder, optional, default 2
  89920. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89921. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89922. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89923. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89924. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89925. * * 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
  89926. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89927. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89928. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89929. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89931. * * 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)
  89932. * * 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)
  89933. * @returns the VertexData of the cylinder, cone or prism
  89934. */
  89935. VertexData.CreateCylinder = function (options) {
  89936. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  89937. };
  89938. /**
  89939. * Creates the VertexData for a torus
  89940. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89941. * * diameter the diameter of the torus, optional default 1
  89942. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89943. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89944. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89945. * * 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)
  89946. * * 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)
  89947. * @returns the VertexData of the torus
  89948. */
  89949. VertexData.CreateTorus = function (options) {
  89950. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  89951. };
  89952. /**
  89953. * Creates the VertexData of the LineSystem
  89954. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89955. * - lines an array of lines, each line being an array of successive Vector3
  89956. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89957. * @returns the VertexData of the LineSystem
  89958. */
  89959. VertexData.CreateLineSystem = function (options) {
  89960. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  89961. };
  89962. /**
  89963. * Create the VertexData for a DashedLines
  89964. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89965. * - points an array successive Vector3
  89966. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89967. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89968. * - dashNb the intended total number of dashes, optional, default 200
  89969. * @returns the VertexData for the DashedLines
  89970. */
  89971. VertexData.CreateDashedLines = function (options) {
  89972. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  89973. };
  89974. /**
  89975. * Creates the VertexData for a Ground
  89976. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89977. * - width the width (x direction) of the ground, optional, default 1
  89978. * - height the height (z direction) of the ground, optional, default 1
  89979. * - subdivisions the number of subdivisions per side, optional, default 1
  89980. * @returns the VertexData of the Ground
  89981. */
  89982. VertexData.CreateGround = function (options) {
  89983. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  89984. };
  89985. /**
  89986. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89987. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89988. * * xmin the ground minimum X coordinate, optional, default -1
  89989. * * zmin the ground minimum Z coordinate, optional, default -1
  89990. * * xmax the ground maximum X coordinate, optional, default 1
  89991. * * zmax the ground maximum Z coordinate, optional, default 1
  89992. * * 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}
  89993. * * 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}
  89994. * @returns the VertexData of the TiledGround
  89995. */
  89996. VertexData.CreateTiledGround = function (options) {
  89997. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  89998. };
  89999. /**
  90000. * Creates the VertexData of the Ground designed from a heightmap
  90001. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90002. * * width the width (x direction) of the ground
  90003. * * height the height (z direction) of the ground
  90004. * * subdivisions the number of subdivisions per side
  90005. * * minHeight the minimum altitude on the ground, optional, default 0
  90006. * * maxHeight the maximum altitude on the ground, optional default 1
  90007. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90008. * * buffer the array holding the image color data
  90009. * * bufferWidth the width of image
  90010. * * bufferHeight the height of image
  90011. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90012. * @returns the VertexData of the Ground designed from a heightmap
  90013. */
  90014. VertexData.CreateGroundFromHeightMap = function (options) {
  90015. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  90016. };
  90017. /**
  90018. * Creates the VertexData for a Plane
  90019. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90020. * * size sets the width and height of the plane to the value of size, optional default 1
  90021. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90022. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90024. * * 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)
  90025. * * 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)
  90026. * @returns the VertexData of the box
  90027. */
  90028. VertexData.CreatePlane = function (options) {
  90029. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  90030. };
  90031. /**
  90032. * Creates the VertexData of the Disc or regular Polygon
  90033. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90034. * * radius the radius of the disc, optional default 0.5
  90035. * * tessellation the number of polygon sides, optional, default 64
  90036. * * 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
  90037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90038. * * 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)
  90039. * * 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)
  90040. * @returns the VertexData of the box
  90041. */
  90042. VertexData.CreateDisc = function (options) {
  90043. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  90044. };
  90045. /**
  90046. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90047. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90048. * @param polygon a mesh built from polygonTriangulation.build()
  90049. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90050. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90051. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90052. * @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)
  90053. * @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)
  90054. * @returns the VertexData of the Polygon
  90055. */
  90056. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  90057. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  90058. };
  90059. /**
  90060. * Creates the VertexData of the IcoSphere
  90061. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90062. * * radius the radius of the IcoSphere, optional default 1
  90063. * * radiusX allows stretching in the x direction, optional, default radius
  90064. * * radiusY allows stretching in the y direction, optional, default radius
  90065. * * radiusZ allows stretching in the z direction, optional, default radius
  90066. * * flat when true creates a flat shaded mesh, optional, default true
  90067. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90069. * * 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)
  90070. * * 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)
  90071. * @returns the VertexData of the IcoSphere
  90072. */
  90073. VertexData.CreateIcoSphere = function (options) {
  90074. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  90075. };
  90076. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  90077. /**
  90078. * Creates the VertexData for a Polyhedron
  90079. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90080. * * type provided types are:
  90081. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90082. * * 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)
  90083. * * size the size of the IcoSphere, optional default 1
  90084. * * sizeX allows stretching in the x direction, optional, default size
  90085. * * sizeY allows stretching in the y direction, optional, default size
  90086. * * sizeZ allows stretching in the z direction, optional, default size
  90087. * * 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
  90088. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90089. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90090. * * flat when true creates a flat shaded mesh, optional, default true
  90091. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90092. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90093. * * 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)
  90094. * * 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)
  90095. * @returns the VertexData of the Polyhedron
  90096. */
  90097. VertexData.CreatePolyhedron = function (options) {
  90098. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  90099. };
  90100. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  90101. /**
  90102. * Creates the VertexData for a TorusKnot
  90103. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90104. * * radius the radius of the torus knot, optional, default 2
  90105. * * tube the thickness of the tube, optional, default 0.5
  90106. * * radialSegments the number of sides on each tube segments, optional, default 32
  90107. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90108. * * p the number of windings around the z axis, optional, default 2
  90109. * * q the number of windings around the x axis, optional, default 3
  90110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90111. * * 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)
  90112. * * 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)
  90113. * @returns the VertexData of the Torus Knot
  90114. */
  90115. VertexData.CreateTorusKnot = function (options) {
  90116. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  90117. };
  90118. // Tools
  90119. /**
  90120. * Compute normals for given positions and indices
  90121. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90122. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90123. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90124. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90125. * * facetNormals : optional array of facet normals (vector3)
  90126. * * facetPositions : optional array of facet positions (vector3)
  90127. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90128. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90129. * * bInfo : optional bounding info, required for facetPartitioning computation
  90130. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90131. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90132. * * useRightHandedSystem: optional boolean to for right handed system computation
  90133. * * depthSort : optional boolean to enable the facet depth sort computation
  90134. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90135. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90136. */
  90137. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  90138. // temporary scalar variables
  90139. var index = 0; // facet index
  90140. var p1p2x = 0.0; // p1p2 vector x coordinate
  90141. var p1p2y = 0.0; // p1p2 vector y coordinate
  90142. var p1p2z = 0.0; // p1p2 vector z coordinate
  90143. var p3p2x = 0.0; // p3p2 vector x coordinate
  90144. var p3p2y = 0.0; // p3p2 vector y coordinate
  90145. var p3p2z = 0.0; // p3p2 vector z coordinate
  90146. var faceNormalx = 0.0; // facet normal x coordinate
  90147. var faceNormaly = 0.0; // facet normal y coordinate
  90148. var faceNormalz = 0.0; // facet normal z coordinate
  90149. var length = 0.0; // facet normal length before normalization
  90150. var v1x = 0; // vector1 x index in the positions array
  90151. var v1y = 0; // vector1 y index in the positions array
  90152. var v1z = 0; // vector1 z index in the positions array
  90153. var v2x = 0; // vector2 x index in the positions array
  90154. var v2y = 0; // vector2 y index in the positions array
  90155. var v2z = 0; // vector2 z index in the positions array
  90156. var v3x = 0; // vector3 x index in the positions array
  90157. var v3y = 0; // vector3 y index in the positions array
  90158. var v3z = 0; // vector3 z index in the positions array
  90159. var computeFacetNormals = false;
  90160. var computeFacetPositions = false;
  90161. var computeFacetPartitioning = false;
  90162. var computeDepthSort = false;
  90163. var faceNormalSign = 1;
  90164. var ratio = 0;
  90165. var distanceTo = null;
  90166. if (options) {
  90167. computeFacetNormals = (options.facetNormals) ? true : false;
  90168. computeFacetPositions = (options.facetPositions) ? true : false;
  90169. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  90170. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  90171. ratio = options.ratio || 0;
  90172. computeDepthSort = (options.depthSort) ? true : false;
  90173. distanceTo = (options.distanceTo);
  90174. if (computeDepthSort) {
  90175. if (distanceTo === undefined) {
  90176. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90177. }
  90178. var depthSortedFacets = options.depthSortedFacets;
  90179. }
  90180. }
  90181. // facetPartitioning reinit if needed
  90182. var xSubRatio = 0;
  90183. var ySubRatio = 0;
  90184. var zSubRatio = 0;
  90185. var subSq = 0;
  90186. if (computeFacetPartitioning && options && options.bbSize) {
  90187. var ox = 0; // X partitioning index for facet position
  90188. var oy = 0; // Y partinioning index for facet position
  90189. var oz = 0; // Z partinioning index for facet position
  90190. var b1x = 0; // X partitioning index for facet v1 vertex
  90191. var b1y = 0; // Y partitioning index for facet v1 vertex
  90192. var b1z = 0; // z partitioning index for facet v1 vertex
  90193. var b2x = 0; // X partitioning index for facet v2 vertex
  90194. var b2y = 0; // Y partitioning index for facet v2 vertex
  90195. var b2z = 0; // Z partitioning index for facet v2 vertex
  90196. var b3x = 0; // X partitioning index for facet v3 vertex
  90197. var b3y = 0; // Y partitioning index for facet v3 vertex
  90198. var b3z = 0; // Z partitioning index for facet v3 vertex
  90199. var block_idx_o = 0; // facet barycenter block index
  90200. var block_idx_v1 = 0; // v1 vertex block index
  90201. var block_idx_v2 = 0; // v2 vertex block index
  90202. var block_idx_v3 = 0; // v3 vertex block index
  90203. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  90204. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  90205. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  90206. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  90207. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  90208. subSq = options.subDiv.max * options.subDiv.max;
  90209. options.facetPartitioning.length = 0;
  90210. }
  90211. // reset the normals
  90212. for (index = 0; index < positions.length; index++) {
  90213. normals[index] = 0.0;
  90214. }
  90215. // Loop : 1 indice triplet = 1 facet
  90216. var nbFaces = (indices.length / 3) | 0;
  90217. for (index = 0; index < nbFaces; index++) {
  90218. // get the indexes of the coordinates of each vertex of the facet
  90219. v1x = indices[index * 3] * 3;
  90220. v1y = v1x + 1;
  90221. v1z = v1x + 2;
  90222. v2x = indices[index * 3 + 1] * 3;
  90223. v2y = v2x + 1;
  90224. v2z = v2x + 2;
  90225. v3x = indices[index * 3 + 2] * 3;
  90226. v3y = v3x + 1;
  90227. v3z = v3x + 2;
  90228. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  90229. p1p2y = positions[v1y] - positions[v2y];
  90230. p1p2z = positions[v1z] - positions[v2z];
  90231. p3p2x = positions[v3x] - positions[v2x];
  90232. p3p2y = positions[v3y] - positions[v2y];
  90233. p3p2z = positions[v3z] - positions[v2z];
  90234. // compute the face normal with the cross product
  90235. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  90236. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  90237. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  90238. // normalize this normal and store it in the array facetData
  90239. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  90240. length = (length === 0) ? 1.0 : length;
  90241. faceNormalx /= length;
  90242. faceNormaly /= length;
  90243. faceNormalz /= length;
  90244. if (computeFacetNormals && options) {
  90245. options.facetNormals[index].x = faceNormalx;
  90246. options.facetNormals[index].y = faceNormaly;
  90247. options.facetNormals[index].z = faceNormalz;
  90248. }
  90249. if (computeFacetPositions && options) {
  90250. // compute and the facet barycenter coordinates in the array facetPositions
  90251. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  90252. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  90253. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  90254. }
  90255. if (computeFacetPartitioning && options) {
  90256. // store the facet indexes in arrays in the main facetPartitioning array :
  90257. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  90258. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  90259. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  90260. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  90261. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90262. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90263. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90264. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90265. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90266. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90267. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90268. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90269. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90270. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  90271. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  90272. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  90273. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  90274. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  90275. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  90276. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  90277. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  90278. // push each facet index in each block containing the vertex
  90279. options.facetPartitioning[block_idx_v1].push(index);
  90280. if (block_idx_v2 != block_idx_v1) {
  90281. options.facetPartitioning[block_idx_v2].push(index);
  90282. }
  90283. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  90284. options.facetPartitioning[block_idx_v3].push(index);
  90285. }
  90286. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  90287. options.facetPartitioning[block_idx_o].push(index);
  90288. }
  90289. }
  90290. if (computeDepthSort && options && options.facetPositions) {
  90291. var dsf = depthSortedFacets[index];
  90292. dsf.ind = index * 3;
  90293. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  90294. }
  90295. // compute the normals anyway
  90296. normals[v1x] += faceNormalx; // accumulate all the normals per face
  90297. normals[v1y] += faceNormaly;
  90298. normals[v1z] += faceNormalz;
  90299. normals[v2x] += faceNormalx;
  90300. normals[v2y] += faceNormaly;
  90301. normals[v2z] += faceNormalz;
  90302. normals[v3x] += faceNormalx;
  90303. normals[v3y] += faceNormaly;
  90304. normals[v3z] += faceNormalz;
  90305. }
  90306. // last normalization of each normal
  90307. for (index = 0; index < normals.length / 3; index++) {
  90308. faceNormalx = normals[index * 3];
  90309. faceNormaly = normals[index * 3 + 1];
  90310. faceNormalz = normals[index * 3 + 2];
  90311. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  90312. length = (length === 0) ? 1.0 : length;
  90313. faceNormalx /= length;
  90314. faceNormaly /= length;
  90315. faceNormalz /= length;
  90316. normals[index * 3] = faceNormalx;
  90317. normals[index * 3 + 1] = faceNormaly;
  90318. normals[index * 3 + 2] = faceNormalz;
  90319. }
  90320. };
  90321. /** @hidden */
  90322. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  90323. var li = indices.length;
  90324. var ln = normals.length;
  90325. var i;
  90326. var n;
  90327. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  90328. switch (sideOrientation) {
  90329. case VertexData.FRONTSIDE:
  90330. // nothing changed
  90331. break;
  90332. case VertexData.BACKSIDE:
  90333. var tmp;
  90334. // indices
  90335. for (i = 0; i < li; i += 3) {
  90336. tmp = indices[i];
  90337. indices[i] = indices[i + 2];
  90338. indices[i + 2] = tmp;
  90339. }
  90340. // normals
  90341. for (n = 0; n < ln; n++) {
  90342. normals[n] = -normals[n];
  90343. }
  90344. break;
  90345. case VertexData.DOUBLESIDE:
  90346. // positions
  90347. var lp = positions.length;
  90348. var l = lp / 3;
  90349. for (var p = 0; p < lp; p++) {
  90350. positions[lp + p] = positions[p];
  90351. }
  90352. // indices
  90353. for (i = 0; i < li; i += 3) {
  90354. indices[i + li] = indices[i + 2] + l;
  90355. indices[i + 1 + li] = indices[i + 1] + l;
  90356. indices[i + 2 + li] = indices[i] + l;
  90357. }
  90358. // normals
  90359. for (n = 0; n < ln; n++) {
  90360. normals[ln + n] = -normals[n];
  90361. }
  90362. // uvs
  90363. var lu = uvs.length;
  90364. var u = 0;
  90365. for (u = 0; u < lu; u++) {
  90366. uvs[u + lu] = uvs[u];
  90367. }
  90368. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  90369. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  90370. u = 0;
  90371. for (i = 0; i < lu / 2; i++) {
  90372. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  90373. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  90374. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  90375. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  90376. u += 2;
  90377. }
  90378. break;
  90379. }
  90380. };
  90381. /**
  90382. * Applies VertexData created from the imported parameters to the geometry
  90383. * @param parsedVertexData the parsed data from an imported file
  90384. * @param geometry the geometry to apply the VertexData to
  90385. */
  90386. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  90387. var vertexData = new VertexData();
  90388. // positions
  90389. var positions = parsedVertexData.positions;
  90390. if (positions) {
  90391. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  90392. }
  90393. // normals
  90394. var normals = parsedVertexData.normals;
  90395. if (normals) {
  90396. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  90397. }
  90398. // tangents
  90399. var tangents = parsedVertexData.tangents;
  90400. if (tangents) {
  90401. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  90402. }
  90403. // uvs
  90404. var uvs = parsedVertexData.uvs;
  90405. if (uvs) {
  90406. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  90407. }
  90408. // uv2s
  90409. var uv2s = parsedVertexData.uv2s;
  90410. if (uv2s) {
  90411. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  90412. }
  90413. // uv3s
  90414. var uv3s = parsedVertexData.uv3s;
  90415. if (uv3s) {
  90416. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  90417. }
  90418. // uv4s
  90419. var uv4s = parsedVertexData.uv4s;
  90420. if (uv4s) {
  90421. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  90422. }
  90423. // uv5s
  90424. var uv5s = parsedVertexData.uv5s;
  90425. if (uv5s) {
  90426. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  90427. }
  90428. // uv6s
  90429. var uv6s = parsedVertexData.uv6s;
  90430. if (uv6s) {
  90431. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  90432. }
  90433. // colors
  90434. var colors = parsedVertexData.colors;
  90435. if (colors) {
  90436. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  90437. }
  90438. // matricesIndices
  90439. var matricesIndices = parsedVertexData.matricesIndices;
  90440. if (matricesIndices) {
  90441. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  90442. }
  90443. // matricesWeights
  90444. var matricesWeights = parsedVertexData.matricesWeights;
  90445. if (matricesWeights) {
  90446. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  90447. }
  90448. // indices
  90449. var indices = parsedVertexData.indices;
  90450. if (indices) {
  90451. vertexData.indices = indices;
  90452. }
  90453. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  90454. };
  90455. /**
  90456. * Mesh side orientation : usually the external or front surface
  90457. */
  90458. VertexData.FRONTSIDE = 0;
  90459. /**
  90460. * Mesh side orientation : usually the internal or back surface
  90461. */
  90462. VertexData.BACKSIDE = 1;
  90463. /**
  90464. * Mesh side orientation : both internal and external or front and back surfaces
  90465. */
  90466. VertexData.DOUBLESIDE = 2;
  90467. /**
  90468. * Mesh side orientation : by default, `FRONTSIDE`
  90469. */
  90470. VertexData.DEFAULTSIDE = 0;
  90471. return VertexData;
  90472. }());
  90473. /***/ }),
  90474. /***/ "./Meshes/meshBuilder.ts":
  90475. /*!*******************************!*\
  90476. !*** ./Meshes/meshBuilder.ts ***!
  90477. \*******************************/
  90478. /*! exports provided: MeshBuilder */
  90479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90480. "use strict";
  90481. __webpack_require__.r(__webpack_exports__);
  90482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  90483. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  90484. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  90485. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  90486. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  90487. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  90488. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  90489. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  90490. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  90491. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  90492. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  90493. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  90494. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  90495. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  90496. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  90497. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  90498. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  90499. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  90500. /**
  90501. * Class containing static functions to help procedurally build meshes
  90502. */
  90503. var MeshBuilder = /** @class */ (function () {
  90504. function MeshBuilder() {
  90505. }
  90506. /**
  90507. * Creates a box mesh
  90508. * * The parameter `size` sets the size (float) of each box side (default 1)
  90509. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  90510. * * 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)
  90511. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  90512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90513. * * 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
  90514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90515. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  90516. * @param name defines the name of the mesh
  90517. * @param options defines the options used to create the mesh
  90518. * @param scene defines the hosting scene
  90519. * @returns the box mesh
  90520. */
  90521. MeshBuilder.CreateBox = function (name, options, scene) {
  90522. if (scene === void 0) { scene = null; }
  90523. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  90524. };
  90525. /**
  90526. * Creates a sphere mesh
  90527. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  90528. * * 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`)
  90529. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  90530. * * 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
  90531. * * 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)
  90532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90533. * * 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
  90534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90535. * @param name defines the name of the mesh
  90536. * @param options defines the options used to create the mesh
  90537. * @param scene defines the hosting scene
  90538. * @returns the sphere mesh
  90539. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  90540. */
  90541. MeshBuilder.CreateSphere = function (name, options, scene) {
  90542. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  90543. };
  90544. /**
  90545. * Creates a plane polygonal mesh. By default, this is a disc
  90546. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90547. * * 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
  90548. * * 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
  90549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90550. * * 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
  90551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90552. * @param name defines the name of the mesh
  90553. * @param options defines the options used to create the mesh
  90554. * @param scene defines the hosting scene
  90555. * @returns the plane polygonal mesh
  90556. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90557. */
  90558. MeshBuilder.CreateDisc = function (name, options, scene) {
  90559. if (scene === void 0) { scene = null; }
  90560. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  90561. };
  90562. /**
  90563. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90564. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90565. * * 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`)
  90566. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90567. * * 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
  90568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90569. * * 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
  90570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90571. * @param name defines the name of the mesh
  90572. * @param options defines the options used to create the mesh
  90573. * @param scene defines the hosting scene
  90574. * @returns the icosahedron mesh
  90575. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90576. */
  90577. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  90578. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  90579. };
  90580. /**
  90581. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  90582. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  90583. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  90584. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  90585. * * 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
  90586. * * 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
  90587. * * 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
  90588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90589. * * 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
  90590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90591. * * 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
  90592. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  90593. * * 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
  90594. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  90595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90596. * @param name defines the name of the mesh
  90597. * @param options defines the options used to create the mesh
  90598. * @param scene defines the hosting scene
  90599. * @returns the ribbon mesh
  90600. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  90601. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90602. */
  90603. MeshBuilder.CreateRibbon = function (name, options, scene) {
  90604. if (scene === void 0) { scene = null; }
  90605. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  90606. };
  90607. /**
  90608. * Creates a cylinder or a cone mesh
  90609. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  90610. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  90611. * * 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.
  90612. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  90613. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  90614. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  90615. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  90616. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  90617. * * 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).
  90618. * * 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
  90619. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  90620. * * 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
  90621. * * 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.
  90622. * * If `enclose` is false, a ring surface is one element.
  90623. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  90624. * * 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
  90625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90626. * * 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
  90627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90628. * @param name defines the name of the mesh
  90629. * @param options defines the options used to create the mesh
  90630. * @param scene defines the hosting scene
  90631. * @returns the cylinder mesh
  90632. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  90633. */
  90634. MeshBuilder.CreateCylinder = function (name, options, scene) {
  90635. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  90636. };
  90637. /**
  90638. * Creates a torus mesh
  90639. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  90640. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  90641. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  90642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90643. * * 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
  90644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90645. * @param name defines the name of the mesh
  90646. * @param options defines the options used to create the mesh
  90647. * @param scene defines the hosting scene
  90648. * @returns the torus mesh
  90649. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  90650. */
  90651. MeshBuilder.CreateTorus = function (name, options, scene) {
  90652. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  90653. };
  90654. /**
  90655. * Creates a torus knot mesh
  90656. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  90657. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  90658. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  90659. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  90660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90661. * * 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
  90662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90663. * @param name defines the name of the mesh
  90664. * @param options defines the options used to create the mesh
  90665. * @param scene defines the hosting scene
  90666. * @returns the torus knot mesh
  90667. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  90668. */
  90669. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  90670. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  90671. };
  90672. /**
  90673. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  90674. * * 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
  90675. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  90676. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  90677. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  90678. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  90679. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  90680. * * 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
  90681. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  90682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  90684. * @param name defines the name of the new line system
  90685. * @param options defines the options used to create the line system
  90686. * @param scene defines the hosting scene
  90687. * @returns a new line system mesh
  90688. */
  90689. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  90690. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  90691. };
  90692. /**
  90693. * Creates a line mesh
  90694. * 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
  90695. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  90696. * * The parameter `points` is an array successive Vector3
  90697. * * 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
  90698. * * The optional parameter `colors` is an array of successive Color4, one per line point
  90699. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  90700. * * When updating an instance, remember that only point positions can change, not the number of points
  90701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  90703. * @param name defines the name of the new line system
  90704. * @param options defines the options used to create the line system
  90705. * @param scene defines the hosting scene
  90706. * @returns a new line mesh
  90707. */
  90708. MeshBuilder.CreateLines = function (name, options, scene) {
  90709. if (scene === void 0) { scene = null; }
  90710. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  90711. };
  90712. /**
  90713. * Creates a dashed line mesh
  90714. * * 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
  90715. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  90716. * * The parameter `points` is an array successive Vector3
  90717. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  90718. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  90719. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90720. * * 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
  90721. * * When updating an instance, remember that only point positions can change, not the number of points
  90722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90723. * @param name defines the name of the mesh
  90724. * @param options defines the options used to create the mesh
  90725. * @param scene defines the hosting scene
  90726. * @returns the dashed line mesh
  90727. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  90728. */
  90729. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  90730. if (scene === void 0) { scene = null; }
  90731. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  90732. };
  90733. /**
  90734. * 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.
  90735. * * 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.
  90736. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  90737. * * 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.
  90738. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  90739. * * 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
  90740. * * 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
  90741. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  90742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90743. * * 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
  90744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  90745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90746. * @param name defines the name of the mesh
  90747. * @param options defines the options used to create the mesh
  90748. * @param scene defines the hosting scene
  90749. * @returns the extruded shape mesh
  90750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90752. */
  90753. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  90754. if (scene === void 0) { scene = null; }
  90755. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  90756. };
  90757. /**
  90758. * Creates an custom extruded shape mesh.
  90759. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  90760. * * 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.
  90761. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  90762. * * 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
  90763. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  90764. * * 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
  90765. * * It must returns a float value that will be the scale value applied to the shape on each path point
  90766. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90767. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  90768. * * 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
  90769. * * 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
  90770. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  90771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90772. * * 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
  90773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90775. * @param name defines the name of the mesh
  90776. * @param options defines the options used to create the mesh
  90777. * @param scene defines the hosting scene
  90778. * @returns the custom extruded shape mesh
  90779. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  90780. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90781. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90782. */
  90783. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  90784. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  90785. };
  90786. /**
  90787. * Creates lathe mesh.
  90788. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  90789. * * 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
  90790. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  90791. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  90792. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  90793. * * 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
  90794. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  90795. * * 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
  90796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90797. * * 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
  90798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90800. * @param name defines the name of the mesh
  90801. * @param options defines the options used to create the mesh
  90802. * @param scene defines the hosting scene
  90803. * @returns the lathe mesh
  90804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  90805. */
  90806. MeshBuilder.CreateLathe = function (name, options, scene) {
  90807. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  90808. };
  90809. /**
  90810. * Creates a plane mesh
  90811. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  90812. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  90813. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  90814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90815. * * 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
  90816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90817. * @param name defines the name of the mesh
  90818. * @param options defines the options used to create the mesh
  90819. * @param scene defines the hosting scene
  90820. * @returns the plane mesh
  90821. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  90822. */
  90823. MeshBuilder.CreatePlane = function (name, options, scene) {
  90824. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  90825. };
  90826. /**
  90827. * Creates a ground mesh
  90828. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  90829. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  90830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90831. * @param name defines the name of the mesh
  90832. * @param options defines the options used to create the mesh
  90833. * @param scene defines the hosting scene
  90834. * @returns the ground mesh
  90835. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  90836. */
  90837. MeshBuilder.CreateGround = function (name, options, scene) {
  90838. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  90839. };
  90840. /**
  90841. * Creates a tiled ground mesh
  90842. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  90843. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  90844. * * 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
  90845. * * 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
  90846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90847. * @param name defines the name of the mesh
  90848. * @param options defines the options used to create the mesh
  90849. * @param scene defines the hosting scene
  90850. * @returns the tiled ground mesh
  90851. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  90852. */
  90853. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  90854. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  90855. };
  90856. /**
  90857. * Creates a ground mesh from a height map
  90858. * * The parameter `url` sets the URL of the height map image resource.
  90859. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  90860. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  90861. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  90862. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  90863. * * 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.
  90864. * * 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).
  90865. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90867. * @param name defines the name of the mesh
  90868. * @param url defines the url to the height map
  90869. * @param options defines the options used to create the mesh
  90870. * @param scene defines the hosting scene
  90871. * @returns the ground mesh
  90872. * @see https://doc.babylonjs.com/babylon101/height_map
  90873. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  90874. */
  90875. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  90876. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  90877. };
  90878. /**
  90879. * Creates a polygon mesh
  90880. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  90881. * * 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
  90882. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90884. * * 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)
  90885. * * Remember you can only change the shape positions, not their number when updating a polygon
  90886. * @param name defines the name of the mesh
  90887. * @param options defines the options used to create the mesh
  90888. * @param scene defines the hosting scene
  90889. * @param earcutInjection can be used to inject your own earcut reference
  90890. * @returns the polygon mesh
  90891. */
  90892. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  90893. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90894. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  90895. };
  90896. /**
  90897. * Creates an extruded polygon mesh, with depth in the Y direction.
  90898. * * 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)
  90899. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  90900. * @param name defines the name of the mesh
  90901. * @param options defines the options used to create the mesh
  90902. * @param scene defines the hosting scene
  90903. * @param earcutInjection can be used to inject your own earcut reference
  90904. * @returns the polygon mesh
  90905. */
  90906. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  90907. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90908. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  90909. };
  90910. /**
  90911. * Creates a tube mesh.
  90912. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  90913. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  90914. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  90915. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  90916. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  90917. * * 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)
  90918. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  90919. * * 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
  90920. * * 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
  90921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90922. * * 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
  90923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90925. * @param name defines the name of the mesh
  90926. * @param options defines the options used to create the mesh
  90927. * @param scene defines the hosting scene
  90928. * @returns the tube mesh
  90929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90930. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  90931. */
  90932. MeshBuilder.CreateTube = function (name, options, scene) {
  90933. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  90934. };
  90935. /**
  90936. * Creates a polyhedron mesh
  90937. * * 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
  90938. * * The parameter `size` (positive float, default 1) sets the polygon size
  90939. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90940. * * 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`
  90941. * * 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
  90942. * * 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)`)
  90943. * * 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
  90944. * * 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
  90945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90946. * * 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
  90947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90948. * @param name defines the name of the mesh
  90949. * @param options defines the options used to create the mesh
  90950. * @param scene defines the hosting scene
  90951. * @returns the polyhedron mesh
  90952. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  90953. */
  90954. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  90955. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  90956. };
  90957. /**
  90958. * Creates a decal mesh.
  90959. * 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
  90960. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  90961. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  90962. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  90963. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  90964. * @param name defines the name of the mesh
  90965. * @param sourceMesh defines the mesh where the decal must be applied
  90966. * @param options defines the options used to create the mesh
  90967. * @param scene defines the hosting scene
  90968. * @returns the decal mesh
  90969. * @see https://doc.babylonjs.com/how_to/decals
  90970. */
  90971. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  90972. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  90973. };
  90974. return MeshBuilder;
  90975. }());
  90976. /***/ }),
  90977. /***/ "./Meshes/meshSimplification.ts":
  90978. /*!**************************************!*\
  90979. !*** ./Meshes/meshSimplification.ts ***!
  90980. \**************************************/
  90981. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  90982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90983. "use strict";
  90984. __webpack_require__.r(__webpack_exports__);
  90985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  90986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  90987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  90988. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90989. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  90990. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  90991. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  90992. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  90993. /**
  90994. * Class used to specify simplification options
  90995. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  90996. */
  90997. var SimplificationSettings = /** @class */ (function () {
  90998. /**
  90999. * Creates a SimplificationSettings
  91000. * @param quality expected quality
  91001. * @param distance distance when this optimized version should be used
  91002. * @param optimizeMesh already optimized mesh
  91003. */
  91004. function SimplificationSettings(
  91005. /** expected quality */
  91006. quality,
  91007. /** distance when this optimized version should be used */
  91008. distance,
  91009. /** already optimized mesh */
  91010. optimizeMesh) {
  91011. this.quality = quality;
  91012. this.distance = distance;
  91013. this.optimizeMesh = optimizeMesh;
  91014. }
  91015. return SimplificationSettings;
  91016. }());
  91017. /**
  91018. * Queue used to order the simplification tasks
  91019. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91020. */
  91021. var SimplificationQueue = /** @class */ (function () {
  91022. /**
  91023. * Creates a new queue
  91024. */
  91025. function SimplificationQueue() {
  91026. this.running = false;
  91027. this._simplificationArray = [];
  91028. }
  91029. /**
  91030. * Adds a new simplification task
  91031. * @param task defines a task to add
  91032. */
  91033. SimplificationQueue.prototype.addTask = function (task) {
  91034. this._simplificationArray.push(task);
  91035. };
  91036. /**
  91037. * Execute next task
  91038. */
  91039. SimplificationQueue.prototype.executeNext = function () {
  91040. var task = this._simplificationArray.pop();
  91041. if (task) {
  91042. this.running = true;
  91043. this.runSimplification(task);
  91044. }
  91045. else {
  91046. this.running = false;
  91047. }
  91048. };
  91049. /**
  91050. * Execute a simplification task
  91051. * @param task defines the task to run
  91052. */
  91053. SimplificationQueue.prototype.runSimplification = function (task) {
  91054. var _this = this;
  91055. if (task.parallelProcessing) {
  91056. //parallel simplifier
  91057. task.settings.forEach(function (setting) {
  91058. var simplifier = _this.getSimplifier(task);
  91059. simplifier.simplify(setting, function (newMesh) {
  91060. task.mesh.addLODLevel(setting.distance, newMesh);
  91061. newMesh.isVisible = true;
  91062. //check if it is the last
  91063. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  91064. //all done, run the success callback.
  91065. task.successCallback();
  91066. }
  91067. _this.executeNext();
  91068. });
  91069. });
  91070. }
  91071. else {
  91072. //single simplifier.
  91073. var simplifier = this.getSimplifier(task);
  91074. var runDecimation = function (setting, callback) {
  91075. simplifier.simplify(setting, function (newMesh) {
  91076. task.mesh.addLODLevel(setting.distance, newMesh);
  91077. newMesh.isVisible = true;
  91078. //run the next quality level
  91079. callback();
  91080. });
  91081. };
  91082. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  91083. runDecimation(task.settings[loop.index], function () {
  91084. loop.executeNext();
  91085. });
  91086. }, function () {
  91087. //execution ended, run the success callback.
  91088. if (task.successCallback) {
  91089. task.successCallback();
  91090. }
  91091. _this.executeNext();
  91092. });
  91093. }
  91094. };
  91095. SimplificationQueue.prototype.getSimplifier = function (task) {
  91096. switch (task.simplificationType) {
  91097. case SimplificationType.QUADRATIC:
  91098. default:
  91099. return new QuadraticErrorSimplification(task.mesh);
  91100. }
  91101. };
  91102. return SimplificationQueue;
  91103. }());
  91104. /**
  91105. * The implemented types of simplification
  91106. * At the moment only Quadratic Error Decimation is implemented
  91107. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91108. */
  91109. var SimplificationType;
  91110. (function (SimplificationType) {
  91111. /** Quadratic error decimation */
  91112. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  91113. })(SimplificationType || (SimplificationType = {}));
  91114. var DecimationTriangle = /** @class */ (function () {
  91115. function DecimationTriangle(vertices) {
  91116. this.vertices = vertices;
  91117. this.error = new Array(4);
  91118. this.deleted = false;
  91119. this.isDirty = false;
  91120. this.deletePending = false;
  91121. this.borderFactor = 0;
  91122. }
  91123. return DecimationTriangle;
  91124. }());
  91125. var DecimationVertex = /** @class */ (function () {
  91126. function DecimationVertex(position, id) {
  91127. this.position = position;
  91128. this.id = id;
  91129. this.isBorder = true;
  91130. this.q = new QuadraticMatrix();
  91131. this.triangleCount = 0;
  91132. this.triangleStart = 0;
  91133. this.originalOffsets = [];
  91134. }
  91135. DecimationVertex.prototype.updatePosition = function (newPosition) {
  91136. this.position.copyFrom(newPosition);
  91137. };
  91138. return DecimationVertex;
  91139. }());
  91140. var QuadraticMatrix = /** @class */ (function () {
  91141. function QuadraticMatrix(data) {
  91142. this.data = new Array(10);
  91143. for (var i = 0; i < 10; ++i) {
  91144. if (data && data[i]) {
  91145. this.data[i] = data[i];
  91146. }
  91147. else {
  91148. this.data[i] = 0;
  91149. }
  91150. }
  91151. }
  91152. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  91153. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  91154. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  91155. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  91156. return det;
  91157. };
  91158. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  91159. for (var i = 0; i < 10; ++i) {
  91160. this.data[i] += matrix.data[i];
  91161. }
  91162. };
  91163. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  91164. for (var i = 0; i < 10; ++i) {
  91165. this.data[i] += data[i];
  91166. }
  91167. };
  91168. QuadraticMatrix.prototype.add = function (matrix) {
  91169. var m = new QuadraticMatrix();
  91170. for (var i = 0; i < 10; ++i) {
  91171. m.data[i] = this.data[i] + matrix.data[i];
  91172. }
  91173. return m;
  91174. };
  91175. QuadraticMatrix.FromData = function (a, b, c, d) {
  91176. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  91177. };
  91178. //returning an array to avoid garbage collection
  91179. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  91180. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  91181. };
  91182. return QuadraticMatrix;
  91183. }());
  91184. var Reference = /** @class */ (function () {
  91185. function Reference(vertexId, triangleId) {
  91186. this.vertexId = vertexId;
  91187. this.triangleId = triangleId;
  91188. }
  91189. return Reference;
  91190. }());
  91191. /**
  91192. * An implementation of the Quadratic Error simplification algorithm.
  91193. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  91194. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  91195. * @author RaananW
  91196. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91197. */
  91198. var QuadraticErrorSimplification = /** @class */ (function () {
  91199. function QuadraticErrorSimplification(_mesh) {
  91200. this._mesh = _mesh;
  91201. this.syncIterations = 5000;
  91202. this.aggressiveness = 7;
  91203. this.decimationIterations = 100;
  91204. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  91205. }
  91206. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  91207. var _this = this;
  91208. this.initDecimatedMesh();
  91209. //iterating through the submeshes array, one after the other.
  91210. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  91211. _this.initWithMesh(loop.index, function () {
  91212. _this.runDecimation(settings, loop.index, function () {
  91213. loop.executeNext();
  91214. });
  91215. }, settings.optimizeMesh);
  91216. }, function () {
  91217. setTimeout(function () {
  91218. successCallback(_this._reconstructedMesh);
  91219. }, 0);
  91220. });
  91221. };
  91222. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  91223. var _this = this;
  91224. var targetCount = ~~(this.triangles.length * settings.quality);
  91225. var deletedTriangles = 0;
  91226. var triangleCount = this.triangles.length;
  91227. var iterationFunction = function (iteration, callback) {
  91228. setTimeout(function () {
  91229. if (iteration % 5 === 0) {
  91230. _this.updateMesh(iteration === 0);
  91231. }
  91232. for (var i = 0; i < _this.triangles.length; ++i) {
  91233. _this.triangles[i].isDirty = false;
  91234. }
  91235. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  91236. var trianglesIterator = function (i) {
  91237. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  91238. var t = _this.triangles[tIdx];
  91239. if (!t) {
  91240. return;
  91241. }
  91242. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  91243. return;
  91244. }
  91245. for (var j = 0; j < 3; ++j) {
  91246. if (t.error[j] < threshold) {
  91247. var deleted0 = [];
  91248. var deleted1 = [];
  91249. var v0 = t.vertices[j];
  91250. var v1 = t.vertices[(j + 1) % 3];
  91251. if (v0.isBorder || v1.isBorder) {
  91252. continue;
  91253. }
  91254. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91255. // var n = Vector3.Zero();
  91256. // var uv = Vector2.Zero();
  91257. // var color = new Color4(0, 0, 0, 1);
  91258. _this.calculateError(v0, v1, p);
  91259. var delTr = new Array();
  91260. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  91261. continue;
  91262. }
  91263. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  91264. continue;
  91265. }
  91266. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  91267. continue;
  91268. }
  91269. var uniqueArray = new Array();
  91270. delTr.forEach(function (deletedT) {
  91271. if (uniqueArray.indexOf(deletedT) === -1) {
  91272. deletedT.deletePending = true;
  91273. uniqueArray.push(deletedT);
  91274. }
  91275. });
  91276. if (uniqueArray.length % 2 !== 0) {
  91277. continue;
  91278. }
  91279. v0.q = v1.q.add(v0.q);
  91280. v0.updatePosition(p);
  91281. var tStart = _this.references.length;
  91282. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  91283. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  91284. var tCount = _this.references.length - tStart;
  91285. if (tCount <= v0.triangleCount) {
  91286. if (tCount) {
  91287. for (var c = 0; c < tCount; c++) {
  91288. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  91289. }
  91290. }
  91291. }
  91292. else {
  91293. v0.triangleStart = tStart;
  91294. }
  91295. v0.triangleCount = tCount;
  91296. break;
  91297. }
  91298. }
  91299. };
  91300. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  91301. }, 0);
  91302. };
  91303. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  91304. if (triangleCount - deletedTriangles <= targetCount) {
  91305. loop.breakLoop();
  91306. }
  91307. else {
  91308. iterationFunction(loop.index, function () {
  91309. loop.executeNext();
  91310. });
  91311. }
  91312. }, function () {
  91313. setTimeout(function () {
  91314. //reconstruct this part of the mesh
  91315. _this.reconstructMesh(submeshIndex);
  91316. successCallback();
  91317. }, 0);
  91318. });
  91319. };
  91320. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  91321. var _this = this;
  91322. this.vertices = [];
  91323. this.triangles = [];
  91324. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  91325. var indices = this._mesh.getIndices();
  91326. var submesh = this._mesh.subMeshes[submeshIndex];
  91327. var findInVertices = function (positionToSearch) {
  91328. if (optimizeMesh) {
  91329. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  91330. if (_this.vertices[ii].position.equals(positionToSearch)) {
  91331. return _this.vertices[ii];
  91332. }
  91333. }
  91334. }
  91335. return null;
  91336. };
  91337. var vertexReferences = [];
  91338. var vertexInit = function (i) {
  91339. if (!positionData) {
  91340. return;
  91341. }
  91342. var offset = i + submesh.verticesStart;
  91343. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  91344. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  91345. vertex.originalOffsets.push(offset);
  91346. if (vertex.id === _this.vertices.length) {
  91347. _this.vertices.push(vertex);
  91348. }
  91349. vertexReferences.push(vertex.id);
  91350. };
  91351. //var totalVertices = mesh.getTotalVertices();
  91352. var totalVertices = submesh.verticesCount;
  91353. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  91354. var indicesInit = function (i) {
  91355. if (!indices) {
  91356. return;
  91357. }
  91358. var offset = (submesh.indexStart / 3) + i;
  91359. var pos = (offset * 3);
  91360. var i0 = indices[pos + 0];
  91361. var i1 = indices[pos + 1];
  91362. var i2 = indices[pos + 2];
  91363. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  91364. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  91365. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  91366. var triangle = new DecimationTriangle([v0, v1, v2]);
  91367. triangle.originalOffset = pos;
  91368. _this.triangles.push(triangle);
  91369. };
  91370. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  91371. _this.init(callback);
  91372. });
  91373. });
  91374. };
  91375. QuadraticErrorSimplification.prototype.init = function (callback) {
  91376. var _this = this;
  91377. var triangleInit1 = function (i) {
  91378. var t = _this.triangles[i];
  91379. 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();
  91380. for (var j = 0; j < 3; j++) {
  91381. 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))));
  91382. }
  91383. };
  91384. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  91385. var triangleInit2 = function (i) {
  91386. var t = _this.triangles[i];
  91387. for (var j = 0; j < 3; ++j) {
  91388. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  91389. }
  91390. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  91391. };
  91392. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  91393. callback();
  91394. });
  91395. });
  91396. };
  91397. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  91398. var newTriangles = [];
  91399. var i;
  91400. for (i = 0; i < this.vertices.length; ++i) {
  91401. this.vertices[i].triangleCount = 0;
  91402. }
  91403. var t;
  91404. var j;
  91405. for (i = 0; i < this.triangles.length; ++i) {
  91406. if (!this.triangles[i].deleted) {
  91407. t = this.triangles[i];
  91408. for (j = 0; j < 3; ++j) {
  91409. t.vertices[j].triangleCount = 1;
  91410. }
  91411. newTriangles.push(t);
  91412. }
  91413. }
  91414. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  91415. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  91416. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  91417. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  91418. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  91419. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  91420. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  91421. var vertexCount = 0;
  91422. for (i = 0; i < this.vertices.length; ++i) {
  91423. var vertex = this.vertices[i];
  91424. vertex.id = vertexCount;
  91425. if (vertex.triangleCount) {
  91426. vertex.originalOffsets.forEach(function (originalOffset) {
  91427. if (!normalData) {
  91428. return;
  91429. }
  91430. newPositionData.push(vertex.position.x);
  91431. newPositionData.push(vertex.position.y);
  91432. newPositionData.push(vertex.position.z);
  91433. newNormalData.push(normalData[originalOffset * 3]);
  91434. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  91435. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  91436. if (uvs && uvs.length) {
  91437. newUVsData.push(uvs[(originalOffset * 2)]);
  91438. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  91439. }
  91440. else if (colorsData && colorsData.length) {
  91441. newColorsData.push(colorsData[(originalOffset * 4)]);
  91442. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  91443. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  91444. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  91445. }
  91446. ++vertexCount;
  91447. });
  91448. }
  91449. }
  91450. var startingIndex = this._reconstructedMesh.getTotalIndices();
  91451. var startingVertex = this._reconstructedMesh.getTotalVertices();
  91452. var submeshesArray = this._reconstructedMesh.subMeshes;
  91453. this._reconstructedMesh.subMeshes = [];
  91454. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  91455. var originalIndices = this._mesh.getIndices();
  91456. for (i = 0; i < newTriangles.length; ++i) {
  91457. t = newTriangles[i]; //now get the new referencing point for each vertex
  91458. [0, 1, 2].forEach(function (idx) {
  91459. var id = originalIndices[t.originalOffset + idx];
  91460. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  91461. if (offset < 0) {
  91462. offset = 0;
  91463. }
  91464. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  91465. });
  91466. }
  91467. //overwriting the old vertex buffers and indices.
  91468. this._reconstructedMesh.setIndices(newIndicesArray);
  91469. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  91470. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  91471. if (newUVsData.length > 0) {
  91472. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  91473. }
  91474. if (newColorsData.length > 0) {
  91475. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  91476. }
  91477. //create submesh
  91478. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  91479. if (submeshIndex > 0) {
  91480. this._reconstructedMesh.subMeshes = [];
  91481. submeshesArray.forEach(function (submesh) {
  91482. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  91483. });
  91484. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  91485. }
  91486. };
  91487. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  91488. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  91489. this._reconstructedMesh.material = this._mesh.material;
  91490. this._reconstructedMesh.parent = this._mesh.parent;
  91491. this._reconstructedMesh.isVisible = false;
  91492. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  91493. };
  91494. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  91495. for (var i = 0; i < vertex1.triangleCount; ++i) {
  91496. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  91497. if (t.deleted) {
  91498. continue;
  91499. }
  91500. var s = this.references[vertex1.triangleStart + i].vertexId;
  91501. var v1 = t.vertices[(s + 1) % 3];
  91502. var v2 = t.vertices[(s + 2) % 3];
  91503. if ((v1 === vertex2 || v2 === vertex2)) {
  91504. deletedArray[i] = true;
  91505. delTr.push(t);
  91506. continue;
  91507. }
  91508. var d1 = v1.position.subtract(point);
  91509. d1 = d1.normalize();
  91510. var d2 = v2.position.subtract(point);
  91511. d2 = d2.normalize();
  91512. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  91513. return true;
  91514. }
  91515. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  91516. deletedArray[i] = false;
  91517. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  91518. return true;
  91519. }
  91520. }
  91521. return false;
  91522. };
  91523. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  91524. var newDeleted = deletedTriangles;
  91525. for (var i = 0; i < vertex.triangleCount; ++i) {
  91526. var ref = this.references[vertex.triangleStart + i];
  91527. var t = this.triangles[ref.triangleId];
  91528. if (t.deleted) {
  91529. continue;
  91530. }
  91531. if (deletedArray[i] && t.deletePending) {
  91532. t.deleted = true;
  91533. newDeleted++;
  91534. continue;
  91535. }
  91536. t.vertices[ref.vertexId] = origVertex;
  91537. t.isDirty = true;
  91538. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  91539. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  91540. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  91541. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  91542. this.references.push(ref);
  91543. }
  91544. return newDeleted;
  91545. };
  91546. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  91547. for (var i = 0; i < this.vertices.length; ++i) {
  91548. var vCount = [];
  91549. var vId = [];
  91550. var v = this.vertices[i];
  91551. var j;
  91552. for (j = 0; j < v.triangleCount; ++j) {
  91553. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  91554. for (var ii = 0; ii < 3; ii++) {
  91555. var ofs = 0;
  91556. var vv = triangle.vertices[ii];
  91557. while (ofs < vCount.length) {
  91558. if (vId[ofs] === vv.id) {
  91559. break;
  91560. }
  91561. ++ofs;
  91562. }
  91563. if (ofs === vCount.length) {
  91564. vCount.push(1);
  91565. vId.push(vv.id);
  91566. }
  91567. else {
  91568. vCount[ofs]++;
  91569. }
  91570. }
  91571. }
  91572. for (j = 0; j < vCount.length; ++j) {
  91573. if (vCount[j] === 1) {
  91574. this.vertices[vId[j]].isBorder = true;
  91575. }
  91576. else {
  91577. this.vertices[vId[j]].isBorder = false;
  91578. }
  91579. }
  91580. }
  91581. };
  91582. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  91583. if (identifyBorders === void 0) { identifyBorders = false; }
  91584. var i;
  91585. if (!identifyBorders) {
  91586. var newTrianglesVector = [];
  91587. for (i = 0; i < this.triangles.length; ++i) {
  91588. if (!this.triangles[i].deleted) {
  91589. newTrianglesVector.push(this.triangles[i]);
  91590. }
  91591. }
  91592. this.triangles = newTrianglesVector;
  91593. }
  91594. for (i = 0; i < this.vertices.length; ++i) {
  91595. this.vertices[i].triangleCount = 0;
  91596. this.vertices[i].triangleStart = 0;
  91597. }
  91598. var t;
  91599. var j;
  91600. var v;
  91601. for (i = 0; i < this.triangles.length; ++i) {
  91602. t = this.triangles[i];
  91603. for (j = 0; j < 3; ++j) {
  91604. v = t.vertices[j];
  91605. v.triangleCount++;
  91606. }
  91607. }
  91608. var tStart = 0;
  91609. for (i = 0; i < this.vertices.length; ++i) {
  91610. this.vertices[i].triangleStart = tStart;
  91611. tStart += this.vertices[i].triangleCount;
  91612. this.vertices[i].triangleCount = 0;
  91613. }
  91614. var newReferences = new Array(this.triangles.length * 3);
  91615. for (i = 0; i < this.triangles.length; ++i) {
  91616. t = this.triangles[i];
  91617. for (j = 0; j < 3; ++j) {
  91618. v = t.vertices[j];
  91619. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  91620. v.triangleCount++;
  91621. }
  91622. }
  91623. this.references = newReferences;
  91624. if (identifyBorders) {
  91625. this.identifyBorder();
  91626. }
  91627. };
  91628. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  91629. var x = point.x;
  91630. var y = point.y;
  91631. var z = point.z;
  91632. 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
  91633. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  91634. };
  91635. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  91636. var q = vertex1.q.add(vertex2.q);
  91637. var border = vertex1.isBorder && vertex2.isBorder;
  91638. var error = 0;
  91639. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  91640. if (qDet !== 0 && !border) {
  91641. if (!pointResult) {
  91642. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91643. }
  91644. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  91645. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  91646. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  91647. error = this.vertexError(q, pointResult);
  91648. }
  91649. else {
  91650. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  91651. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  91652. var error1 = this.vertexError(q, vertex1.position);
  91653. var error2 = this.vertexError(q, vertex2.position);
  91654. var error3 = this.vertexError(q, p3);
  91655. error = Math.min(error1, error2, error3);
  91656. if (error === error1) {
  91657. if (pointResult) {
  91658. pointResult.copyFrom(vertex1.position);
  91659. }
  91660. }
  91661. else if (error === error2) {
  91662. if (pointResult) {
  91663. pointResult.copyFrom(vertex2.position);
  91664. }
  91665. }
  91666. else {
  91667. if (pointResult) {
  91668. pointResult.copyFrom(p3);
  91669. }
  91670. }
  91671. }
  91672. return error;
  91673. };
  91674. return QuadraticErrorSimplification;
  91675. }());
  91676. /***/ }),
  91677. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  91678. /*!****************************************************!*\
  91679. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  91680. \****************************************************/
  91681. /*! exports provided: SimplicationQueueSceneComponent */
  91682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91683. "use strict";
  91684. __webpack_require__.r(__webpack_exports__);
  91685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  91686. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  91687. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  91688. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  91689. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  91690. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  91691. get: function () {
  91692. if (!this._simplificationQueue) {
  91693. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  91694. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  91695. if (!component) {
  91696. component = new SimplicationQueueSceneComponent(this);
  91697. this._addComponent(component);
  91698. }
  91699. }
  91700. return this._simplificationQueue;
  91701. },
  91702. set: function (value) {
  91703. this._simplificationQueue = value;
  91704. },
  91705. enumerable: true,
  91706. configurable: true
  91707. });
  91708. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  91709. if (parallelProcessing === void 0) { parallelProcessing = true; }
  91710. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  91711. this.getScene().simplificationQueue.addTask({
  91712. settings: settings,
  91713. parallelProcessing: parallelProcessing,
  91714. mesh: this,
  91715. simplificationType: simplificationType,
  91716. successCallback: successCallback
  91717. });
  91718. return this;
  91719. };
  91720. /**
  91721. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  91722. * created in a scene
  91723. */
  91724. var SimplicationQueueSceneComponent = /** @class */ (function () {
  91725. /**
  91726. * Creates a new instance of the component for the given scene
  91727. * @param scene Defines the scene to register the component in
  91728. */
  91729. function SimplicationQueueSceneComponent(scene) {
  91730. /**
  91731. * The component name helpfull to identify the component in the list of scene components.
  91732. */
  91733. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  91734. this.scene = scene;
  91735. }
  91736. /**
  91737. * Registers the component in a given scene
  91738. */
  91739. SimplicationQueueSceneComponent.prototype.register = function () {
  91740. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  91741. };
  91742. /**
  91743. * Rebuilds the elements related to this component in case of
  91744. * context lost for instance.
  91745. */
  91746. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  91747. // Nothing to do for this component
  91748. };
  91749. /**
  91750. * Disposes the component and the associated ressources
  91751. */
  91752. SimplicationQueueSceneComponent.prototype.dispose = function () {
  91753. // Nothing to do for this component
  91754. };
  91755. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  91756. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  91757. this.scene._simplificationQueue.executeNext();
  91758. }
  91759. };
  91760. return SimplicationQueueSceneComponent;
  91761. }());
  91762. /***/ }),
  91763. /***/ "./Meshes/polygonMesh.ts":
  91764. /*!*******************************!*\
  91765. !*** ./Meshes/polygonMesh.ts ***!
  91766. \*******************************/
  91767. /*! exports provided: Polygon, PolygonMeshBuilder */
  91768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91769. "use strict";
  91770. __webpack_require__.r(__webpack_exports__);
  91771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  91772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  91773. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91774. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91775. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  91776. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  91777. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  91778. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  91779. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  91780. /**
  91781. * Vector2 wth index property
  91782. */
  91783. var IndexedVector2 = /** @class */ (function (_super) {
  91784. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  91785. function IndexedVector2(original,
  91786. /** Index of the vector2 */
  91787. index) {
  91788. var _this = _super.call(this, original.x, original.y) || this;
  91789. _this.index = index;
  91790. return _this;
  91791. }
  91792. return IndexedVector2;
  91793. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  91794. /**
  91795. * Defines points to create a polygon
  91796. */
  91797. var PolygonPoints = /** @class */ (function () {
  91798. function PolygonPoints() {
  91799. this.elements = new Array();
  91800. }
  91801. PolygonPoints.prototype.add = function (originalPoints) {
  91802. var _this = this;
  91803. var result = new Array();
  91804. originalPoints.forEach(function (point) {
  91805. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  91806. var newPoint = new IndexedVector2(point, _this.elements.length);
  91807. result.push(newPoint);
  91808. _this.elements.push(newPoint);
  91809. }
  91810. });
  91811. return result;
  91812. };
  91813. PolygonPoints.prototype.computeBounds = function () {
  91814. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  91815. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  91816. this.elements.forEach(function (point) {
  91817. // x
  91818. if (point.x < lmin.x) {
  91819. lmin.x = point.x;
  91820. }
  91821. else if (point.x > lmax.x) {
  91822. lmax.x = point.x;
  91823. }
  91824. // y
  91825. if (point.y < lmin.y) {
  91826. lmin.y = point.y;
  91827. }
  91828. else if (point.y > lmax.y) {
  91829. lmax.y = point.y;
  91830. }
  91831. });
  91832. return {
  91833. min: lmin,
  91834. max: lmax,
  91835. width: lmax.x - lmin.x,
  91836. height: lmax.y - lmin.y
  91837. };
  91838. };
  91839. return PolygonPoints;
  91840. }());
  91841. /**
  91842. * Polygon
  91843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91844. */
  91845. var Polygon = /** @class */ (function () {
  91846. function Polygon() {
  91847. }
  91848. /**
  91849. * Creates a rectangle
  91850. * @param xmin bottom X coord
  91851. * @param ymin bottom Y coord
  91852. * @param xmax top X coord
  91853. * @param ymax top Y coord
  91854. * @returns points that make the resulting rectation
  91855. */
  91856. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  91857. return [
  91858. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  91859. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  91860. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  91861. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  91862. ];
  91863. };
  91864. /**
  91865. * Creates a circle
  91866. * @param radius radius of circle
  91867. * @param cx scale in x
  91868. * @param cy scale in y
  91869. * @param numberOfSides number of sides that make up the circle
  91870. * @returns points that make the resulting circle
  91871. */
  91872. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  91873. if (cx === void 0) { cx = 0; }
  91874. if (cy === void 0) { cy = 0; }
  91875. if (numberOfSides === void 0) { numberOfSides = 32; }
  91876. var result = new Array();
  91877. var angle = 0;
  91878. var increment = (Math.PI * 2) / numberOfSides;
  91879. for (var i = 0; i < numberOfSides; i++) {
  91880. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  91881. angle -= increment;
  91882. }
  91883. return result;
  91884. };
  91885. /**
  91886. * Creates a polygon from input string
  91887. * @param input Input polygon data
  91888. * @returns the parsed points
  91889. */
  91890. Polygon.Parse = function (input) {
  91891. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  91892. var i, result = [];
  91893. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  91894. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  91895. }
  91896. return result;
  91897. };
  91898. /**
  91899. * Starts building a polygon from x and y coordinates
  91900. * @param x x coordinate
  91901. * @param y y coordinate
  91902. * @returns the started path2
  91903. */
  91904. Polygon.StartingAt = function (x, y) {
  91905. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  91906. };
  91907. return Polygon;
  91908. }());
  91909. /**
  91910. * Builds a polygon
  91911. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  91912. */
  91913. var PolygonMeshBuilder = /** @class */ (function () {
  91914. /**
  91915. * Creates a PolygonMeshBuilder
  91916. * @param name name of the builder
  91917. * @param contours Path of the polygon
  91918. * @param scene scene to add to when creating the mesh
  91919. * @param earcutInjection can be used to inject your own earcut reference
  91920. */
  91921. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  91922. if (earcutInjection === void 0) { earcutInjection = earcut; }
  91923. this._points = new PolygonPoints();
  91924. this._outlinepoints = new PolygonPoints();
  91925. this._holes = new Array();
  91926. this._epoints = new Array();
  91927. this._eholes = new Array();
  91928. this.bjsEarcut = earcutInjection;
  91929. this._name = name;
  91930. this._scene = scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_6__["Engine"].LastCreatedScene;
  91931. var points;
  91932. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  91933. points = contours.getPoints();
  91934. }
  91935. else {
  91936. points = contours;
  91937. }
  91938. this._addToepoint(points);
  91939. this._points.add(points);
  91940. this._outlinepoints.add(points);
  91941. if (typeof this.bjsEarcut === 'undefined') {
  91942. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  91943. }
  91944. }
  91945. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  91946. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  91947. var p = points_1[_i];
  91948. this._epoints.push(p.x, p.y);
  91949. }
  91950. };
  91951. /**
  91952. * Adds a whole within the polygon
  91953. * @param hole Array of points defining the hole
  91954. * @returns this
  91955. */
  91956. PolygonMeshBuilder.prototype.addHole = function (hole) {
  91957. this._points.add(hole);
  91958. var holepoints = new PolygonPoints();
  91959. holepoints.add(hole);
  91960. this._holes.push(holepoints);
  91961. this._eholes.push(this._epoints.length / 2);
  91962. this._addToepoint(hole);
  91963. return this;
  91964. };
  91965. /**
  91966. * Creates the polygon
  91967. * @param updatable If the mesh should be updatable
  91968. * @param depth The depth of the mesh created
  91969. * @returns the created mesh
  91970. */
  91971. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  91972. if (updatable === void 0) { updatable = false; }
  91973. if (depth === void 0) { depth = 0; }
  91974. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  91975. var vertexData = this.buildVertexData(depth);
  91976. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, vertexData.positions, updatable);
  91977. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, vertexData.normals, updatable);
  91978. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, vertexData.uvs, updatable);
  91979. result.setIndices(vertexData.indices);
  91980. return result;
  91981. };
  91982. /**
  91983. * Creates the polygon
  91984. * @param depth The depth of the mesh created
  91985. * @returns the created VertexData
  91986. */
  91987. PolygonMeshBuilder.prototype.buildVertexData = function (depth) {
  91988. var _this = this;
  91989. if (depth === void 0) { depth = 0; }
  91990. var result = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  91991. var normals = new Array();
  91992. var positions = new Array();
  91993. var uvs = new Array();
  91994. var bounds = this._points.computeBounds();
  91995. this._points.elements.forEach(function (p) {
  91996. normals.push(0, 1.0, 0);
  91997. positions.push(p.x, 0, p.y);
  91998. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  91999. });
  92000. var indices = new Array();
  92001. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  92002. for (var i = 0; i < res.length; i++) {
  92003. indices.push(res[i]);
  92004. }
  92005. if (depth > 0) {
  92006. var positionscount = (positions.length / 3); //get the current pointcount
  92007. this._points.elements.forEach(function (p) {
  92008. normals.push(0, -1.0, 0);
  92009. positions.push(p.x, -depth, p.y);
  92010. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  92011. });
  92012. var totalCount = indices.length;
  92013. for (var i = 0; i < totalCount; i += 3) {
  92014. var i0 = indices[i + 0];
  92015. var i1 = indices[i + 1];
  92016. var i2 = indices[i + 2];
  92017. indices.push(i2 + positionscount);
  92018. indices.push(i1 + positionscount);
  92019. indices.push(i0 + positionscount);
  92020. }
  92021. //Add the sides
  92022. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  92023. this._holes.forEach(function (hole) {
  92024. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  92025. });
  92026. }
  92027. result.indices = indices;
  92028. result.positions = positions;
  92029. result.normals = normals;
  92030. result.uvs = uvs;
  92031. return result;
  92032. };
  92033. /**
  92034. * Adds a side to the polygon
  92035. * @param positions points that make the polygon
  92036. * @param normals normals of the polygon
  92037. * @param uvs uvs of the polygon
  92038. * @param indices indices of the polygon
  92039. * @param bounds bounds of the polygon
  92040. * @param points points of the polygon
  92041. * @param depth depth of the polygon
  92042. * @param flip flip of the polygon
  92043. */
  92044. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  92045. var StartIndex = positions.length / 3;
  92046. var ulength = 0;
  92047. for (var i = 0; i < points.elements.length; i++) {
  92048. var p = points.elements[i];
  92049. var p1;
  92050. if ((i + 1) > points.elements.length - 1) {
  92051. p1 = points.elements[0];
  92052. }
  92053. else {
  92054. p1 = points.elements[i + 1];
  92055. }
  92056. positions.push(p.x, 0, p.y);
  92057. positions.push(p.x, -depth, p.y);
  92058. positions.push(p1.x, 0, p1.y);
  92059. positions.push(p1.x, -depth, p1.y);
  92060. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  92061. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  92062. var v3 = v2.subtract(v1);
  92063. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  92064. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  92065. vn = vn.normalize();
  92066. uvs.push(ulength / bounds.width, 0);
  92067. uvs.push(ulength / bounds.width, 1);
  92068. ulength += v3.length();
  92069. uvs.push((ulength / bounds.width), 0);
  92070. uvs.push((ulength / bounds.width), 1);
  92071. if (!flip) {
  92072. normals.push(-vn.x, -vn.y, -vn.z);
  92073. normals.push(-vn.x, -vn.y, -vn.z);
  92074. normals.push(-vn.x, -vn.y, -vn.z);
  92075. normals.push(-vn.x, -vn.y, -vn.z);
  92076. indices.push(StartIndex);
  92077. indices.push(StartIndex + 1);
  92078. indices.push(StartIndex + 2);
  92079. indices.push(StartIndex + 1);
  92080. indices.push(StartIndex + 3);
  92081. indices.push(StartIndex + 2);
  92082. }
  92083. else {
  92084. normals.push(vn.x, vn.y, vn.z);
  92085. normals.push(vn.x, vn.y, vn.z);
  92086. normals.push(vn.x, vn.y, vn.z);
  92087. normals.push(vn.x, vn.y, vn.z);
  92088. indices.push(StartIndex);
  92089. indices.push(StartIndex + 2);
  92090. indices.push(StartIndex + 1);
  92091. indices.push(StartIndex + 1);
  92092. indices.push(StartIndex + 2);
  92093. indices.push(StartIndex + 3);
  92094. }
  92095. StartIndex += 4;
  92096. }
  92097. };
  92098. return PolygonMeshBuilder;
  92099. }());
  92100. /***/ }),
  92101. /***/ "./Meshes/subMesh.ts":
  92102. /*!***************************!*\
  92103. !*** ./Meshes/subMesh.ts ***!
  92104. \***************************/
  92105. /*! exports provided: BaseSubMesh, SubMesh */
  92106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92107. "use strict";
  92108. __webpack_require__.r(__webpack_exports__);
  92109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  92110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  92111. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92112. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  92113. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  92114. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  92115. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  92116. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92117. /**
  92118. * Base class for submeshes
  92119. */
  92120. var BaseSubMesh = /** @class */ (function () {
  92121. function BaseSubMesh() {
  92122. }
  92123. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  92124. /**
  92125. * Gets associated effect
  92126. */
  92127. get: function () {
  92128. return this._materialEffect;
  92129. },
  92130. enumerable: true,
  92131. configurable: true
  92132. });
  92133. /**
  92134. * Sets associated effect (effect used to render this submesh)
  92135. * @param effect defines the effect to associate with
  92136. * @param defines defines the set of defines used to compile this effect
  92137. */
  92138. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  92139. if (defines === void 0) { defines = null; }
  92140. if (this._materialEffect === effect) {
  92141. if (!effect) {
  92142. this._materialDefines = null;
  92143. }
  92144. return;
  92145. }
  92146. this._materialDefines = defines;
  92147. this._materialEffect = effect;
  92148. };
  92149. return BaseSubMesh;
  92150. }());
  92151. /**
  92152. * Defines a subdivision inside a mesh
  92153. */
  92154. var SubMesh = /** @class */ (function (_super) {
  92155. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  92156. /**
  92157. * Creates a new submesh
  92158. * @param materialIndex defines the material index to use
  92159. * @param verticesStart defines vertex index start
  92160. * @param verticesCount defines vertices count
  92161. * @param indexStart defines index start
  92162. * @param indexCount defines indices count
  92163. * @param mesh defines the parent mesh
  92164. * @param renderingMesh defines an optional rendering mesh
  92165. * @param createBoundingBox defines if bounding box should be created for this submesh
  92166. */
  92167. function SubMesh(
  92168. /** the material index to use */
  92169. materialIndex,
  92170. /** vertex index start */
  92171. verticesStart,
  92172. /** vertices count */
  92173. verticesCount,
  92174. /** index start */
  92175. indexStart,
  92176. /** indices count */
  92177. indexCount, mesh, renderingMesh, createBoundingBox) {
  92178. if (createBoundingBox === void 0) { createBoundingBox = true; }
  92179. var _this = _super.call(this) || this;
  92180. _this.materialIndex = materialIndex;
  92181. _this.verticesStart = verticesStart;
  92182. _this.verticesCount = verticesCount;
  92183. _this.indexStart = indexStart;
  92184. _this.indexCount = indexCount;
  92185. /** @hidden */
  92186. _this._renderId = 0;
  92187. _this._mesh = mesh;
  92188. _this._renderingMesh = renderingMesh || mesh;
  92189. mesh.subMeshes.push(_this);
  92190. _this._trianglePlanes = [];
  92191. _this._id = mesh.subMeshes.length - 1;
  92192. if (createBoundingBox) {
  92193. _this.refreshBoundingInfo();
  92194. mesh.computeWorldMatrix(true);
  92195. }
  92196. return _this;
  92197. }
  92198. /**
  92199. * Add a new submesh to a mesh
  92200. * @param materialIndex defines the material index to use
  92201. * @param verticesStart defines vertex index start
  92202. * @param verticesCount defines vertices count
  92203. * @param indexStart defines index start
  92204. * @param indexCount defines indices count
  92205. * @param mesh defines the parent mesh
  92206. * @param renderingMesh defines an optional rendering mesh
  92207. * @param createBoundingBox defines if bounding box should be created for this submesh
  92208. * @returns the new submesh
  92209. */
  92210. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  92211. if (createBoundingBox === void 0) { createBoundingBox = true; }
  92212. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  92213. };
  92214. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  92215. /**
  92216. * Returns true if this submesh covers the entire parent mesh
  92217. * @ignorenaming
  92218. */
  92219. get: function () {
  92220. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  92221. },
  92222. enumerable: true,
  92223. configurable: true
  92224. });
  92225. /**
  92226. * Returns the submesh BoudingInfo object
  92227. * @returns current bounding info (or mesh's one if the submesh is global)
  92228. */
  92229. SubMesh.prototype.getBoundingInfo = function () {
  92230. if (this.IsGlobal) {
  92231. return this._mesh.getBoundingInfo();
  92232. }
  92233. return this._boundingInfo;
  92234. };
  92235. /**
  92236. * Sets the submesh BoundingInfo
  92237. * @param boundingInfo defines the new bounding info to use
  92238. * @returns the SubMesh
  92239. */
  92240. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  92241. this._boundingInfo = boundingInfo;
  92242. return this;
  92243. };
  92244. /**
  92245. * Returns the mesh of the current submesh
  92246. * @return the parent mesh
  92247. */
  92248. SubMesh.prototype.getMesh = function () {
  92249. return this._mesh;
  92250. };
  92251. /**
  92252. * Returns the rendering mesh of the submesh
  92253. * @returns the rendering mesh (could be different from parent mesh)
  92254. */
  92255. SubMesh.prototype.getRenderingMesh = function () {
  92256. return this._renderingMesh;
  92257. };
  92258. /**
  92259. * Returns the submesh material
  92260. * @returns null or the current material
  92261. */
  92262. SubMesh.prototype.getMaterial = function () {
  92263. var rootMaterial = this._renderingMesh.material;
  92264. if (rootMaterial === null || rootMaterial === undefined) {
  92265. return this._mesh.getScene().defaultMaterial;
  92266. }
  92267. else if (rootMaterial.getSubMaterial) {
  92268. var multiMaterial = rootMaterial;
  92269. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  92270. if (this._currentMaterial !== effectiveMaterial) {
  92271. this._currentMaterial = effectiveMaterial;
  92272. this._materialDefines = null;
  92273. }
  92274. return effectiveMaterial;
  92275. }
  92276. return rootMaterial;
  92277. };
  92278. // Methods
  92279. /**
  92280. * Sets a new updated BoundingInfo object to the submesh
  92281. * @returns the SubMesh
  92282. */
  92283. SubMesh.prototype.refreshBoundingInfo = function () {
  92284. this._lastColliderWorldVertices = null;
  92285. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  92286. return this;
  92287. }
  92288. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  92289. if (!data) {
  92290. this._boundingInfo = this._mesh.getBoundingInfo();
  92291. return this;
  92292. }
  92293. var indices = this._renderingMesh.getIndices();
  92294. var extend;
  92295. //is this the only submesh?
  92296. if (this.indexStart === 0 && this.indexCount === indices.length) {
  92297. var boundingInfo = this._renderingMesh.getBoundingInfo();
  92298. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  92299. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  92300. }
  92301. else {
  92302. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  92303. }
  92304. if (this._boundingInfo) {
  92305. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  92306. }
  92307. else {
  92308. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  92309. }
  92310. return this;
  92311. };
  92312. /** @hidden */
  92313. SubMesh.prototype._checkCollision = function (collider) {
  92314. var boundingInfo = this.getBoundingInfo();
  92315. return boundingInfo._checkCollision(collider);
  92316. };
  92317. /**
  92318. * Updates the submesh BoundingInfo
  92319. * @param world defines the world matrix to use to update the bounding info
  92320. * @returns the submesh
  92321. */
  92322. SubMesh.prototype.updateBoundingInfo = function (world) {
  92323. var boundingInfo = this.getBoundingInfo();
  92324. if (!boundingInfo) {
  92325. this.refreshBoundingInfo();
  92326. boundingInfo = this.getBoundingInfo();
  92327. }
  92328. boundingInfo.update(world);
  92329. return this;
  92330. };
  92331. /**
  92332. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92333. * @param frustumPlanes defines the frustum planes
  92334. * @returns true if the submesh is intersecting with the frustum
  92335. */
  92336. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  92337. var boundingInfo = this.getBoundingInfo();
  92338. if (!boundingInfo) {
  92339. return false;
  92340. }
  92341. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  92342. };
  92343. /**
  92344. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92345. * @param frustumPlanes defines the frustum planes
  92346. * @returns true if the submesh is inside the frustum
  92347. */
  92348. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  92349. var boundingInfo = this.getBoundingInfo();
  92350. if (!boundingInfo) {
  92351. return false;
  92352. }
  92353. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  92354. };
  92355. /**
  92356. * Renders the submesh
  92357. * @param enableAlphaMode defines if alpha needs to be used
  92358. * @returns the submesh
  92359. */
  92360. SubMesh.prototype.render = function (enableAlphaMode) {
  92361. this._renderingMesh.render(this, enableAlphaMode);
  92362. return this;
  92363. };
  92364. /**
  92365. * @hidden
  92366. */
  92367. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  92368. if (!this._linesIndexBuffer) {
  92369. var linesIndices = [];
  92370. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  92371. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  92372. }
  92373. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  92374. this._linesIndexCount = linesIndices.length;
  92375. }
  92376. return this._linesIndexBuffer;
  92377. };
  92378. /**
  92379. * Checks if the submesh intersects with a ray
  92380. * @param ray defines the ray to test
  92381. * @returns true is the passed ray intersects the submesh bounding box
  92382. */
  92383. SubMesh.prototype.canIntersects = function (ray) {
  92384. var boundingInfo = this.getBoundingInfo();
  92385. if (!boundingInfo) {
  92386. return false;
  92387. }
  92388. return ray.intersectsBox(boundingInfo.boundingBox);
  92389. };
  92390. /**
  92391. * Intersects current submesh with a ray
  92392. * @param ray defines the ray to test
  92393. * @param positions defines mesh's positions array
  92394. * @param indices defines mesh's indices array
  92395. * @param fastCheck defines if only bounding info should be used
  92396. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92397. * @returns intersection info or null if no intersection
  92398. */
  92399. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  92400. var material = this.getMaterial();
  92401. if (!material) {
  92402. return null;
  92403. }
  92404. switch (material.fillMode) {
  92405. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  92406. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  92407. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  92408. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  92409. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  92410. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  92411. return null;
  92412. }
  92413. // LineMesh first as it's also a Mesh...
  92414. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  92415. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  92416. }
  92417. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  92418. };
  92419. /** @hidden */
  92420. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  92421. var intersectInfo = null;
  92422. // Line test
  92423. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  92424. var p0 = positions[indices[index]];
  92425. var p1 = positions[indices[index + 1]];
  92426. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  92427. if (length < 0) {
  92428. continue;
  92429. }
  92430. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  92431. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  92432. intersectInfo.faceId = index / 2;
  92433. if (fastCheck) {
  92434. break;
  92435. }
  92436. }
  92437. }
  92438. return intersectInfo;
  92439. };
  92440. /** @hidden */
  92441. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  92442. var intersectInfo = null;
  92443. // Triangles test
  92444. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  92445. var p0 = positions[indices[index]];
  92446. var p1 = positions[indices[index + 1]];
  92447. var p2 = positions[indices[index + 2]];
  92448. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  92449. continue;
  92450. }
  92451. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  92452. if (currentIntersectInfo) {
  92453. if (currentIntersectInfo.distance < 0) {
  92454. continue;
  92455. }
  92456. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  92457. intersectInfo = currentIntersectInfo;
  92458. intersectInfo.faceId = index / 3;
  92459. if (fastCheck) {
  92460. break;
  92461. }
  92462. }
  92463. }
  92464. }
  92465. return intersectInfo;
  92466. };
  92467. /** @hidden */
  92468. SubMesh.prototype._rebuild = function () {
  92469. if (this._linesIndexBuffer) {
  92470. this._linesIndexBuffer = null;
  92471. }
  92472. };
  92473. // Clone
  92474. /**
  92475. * Creates a new submesh from the passed mesh
  92476. * @param newMesh defines the new hosting mesh
  92477. * @param newRenderingMesh defines an optional rendering mesh
  92478. * @returns the new submesh
  92479. */
  92480. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  92481. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  92482. if (!this.IsGlobal) {
  92483. var boundingInfo = this.getBoundingInfo();
  92484. if (!boundingInfo) {
  92485. return result;
  92486. }
  92487. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  92488. }
  92489. return result;
  92490. };
  92491. // Dispose
  92492. /**
  92493. * Release associated resources
  92494. */
  92495. SubMesh.prototype.dispose = function () {
  92496. if (this._linesIndexBuffer) {
  92497. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  92498. this._linesIndexBuffer = null;
  92499. }
  92500. // Remove from mesh
  92501. var index = this._mesh.subMeshes.indexOf(this);
  92502. this._mesh.subMeshes.splice(index, 1);
  92503. };
  92504. /**
  92505. * Gets the class name
  92506. * @returns the string "SubMesh".
  92507. */
  92508. SubMesh.prototype.getClassName = function () {
  92509. return "SubMesh";
  92510. };
  92511. // Statics
  92512. /**
  92513. * Creates a new submesh from indices data
  92514. * @param materialIndex the index of the main mesh material
  92515. * @param startIndex the index where to start the copy in the mesh indices array
  92516. * @param indexCount the number of indices to copy then from the startIndex
  92517. * @param mesh the main mesh to create the submesh from
  92518. * @param renderingMesh the optional rendering mesh
  92519. * @returns a new submesh
  92520. */
  92521. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  92522. var minVertexIndex = Number.MAX_VALUE;
  92523. var maxVertexIndex = -Number.MAX_VALUE;
  92524. var whatWillRender = (renderingMesh || mesh);
  92525. var indices = whatWillRender.getIndices();
  92526. for (var index = startIndex; index < startIndex + indexCount; index++) {
  92527. var vertexIndex = indices[index];
  92528. if (vertexIndex < minVertexIndex) {
  92529. minVertexIndex = vertexIndex;
  92530. }
  92531. if (vertexIndex > maxVertexIndex) {
  92532. maxVertexIndex = vertexIndex;
  92533. }
  92534. }
  92535. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  92536. };
  92537. return SubMesh;
  92538. }(BaseSubMesh));
  92539. /***/ }),
  92540. /***/ "./Meshes/trailMesh.ts":
  92541. /*!*****************************!*\
  92542. !*** ./Meshes/trailMesh.ts ***!
  92543. \*****************************/
  92544. /*! exports provided: TrailMesh */
  92545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92546. "use strict";
  92547. __webpack_require__.r(__webpack_exports__);
  92548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  92549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92550. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  92551. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92552. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92553. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  92554. /**
  92555. * Class used to create a trail following a mesh
  92556. */
  92557. var TrailMesh = /** @class */ (function (_super) {
  92558. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  92559. /**
  92560. * @constructor
  92561. * @param name The value used by scene.getMeshByName() to do a lookup.
  92562. * @param generator The mesh to generate a trail.
  92563. * @param scene The scene to add this mesh to.
  92564. * @param diameter Diameter of trailing mesh. Default is 1.
  92565. * @param length Length of trailing mesh. Default is 60.
  92566. * @param autoStart Automatically start trailing mesh. Default true.
  92567. */
  92568. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  92569. if (diameter === void 0) { diameter = 1; }
  92570. if (length === void 0) { length = 60; }
  92571. if (autoStart === void 0) { autoStart = true; }
  92572. var _this = _super.call(this, name, scene) || this;
  92573. _this._sectionPolygonPointsCount = 4;
  92574. _this._running = false;
  92575. _this._autoStart = autoStart;
  92576. _this._generator = generator;
  92577. _this._diameter = diameter;
  92578. _this._length = length;
  92579. _this._sectionVectors = [];
  92580. _this._sectionNormalVectors = [];
  92581. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  92582. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92583. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92584. }
  92585. _this._createMesh();
  92586. return _this;
  92587. }
  92588. /**
  92589. * "TrailMesh"
  92590. * @returns "TrailMesh"
  92591. */
  92592. TrailMesh.prototype.getClassName = function () {
  92593. return "TrailMesh";
  92594. };
  92595. TrailMesh.prototype._createMesh = function () {
  92596. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  92597. var positions = [];
  92598. var normals = [];
  92599. var indices = [];
  92600. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92601. if (this._generator._boundingInfo) {
  92602. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  92603. }
  92604. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  92605. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92606. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  92607. }
  92608. for (var i = 1; i <= this._length; i++) {
  92609. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  92610. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  92611. }
  92612. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  92613. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  92614. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  92615. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  92616. }
  92617. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  92618. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  92619. }
  92620. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  92621. data.positions = positions;
  92622. data.normals = normals;
  92623. data.indices = indices;
  92624. data.applyToMesh(this, true);
  92625. if (this._autoStart) {
  92626. this.start();
  92627. }
  92628. };
  92629. /**
  92630. * Start trailing mesh.
  92631. */
  92632. TrailMesh.prototype.start = function () {
  92633. var _this = this;
  92634. if (!this._running) {
  92635. this._running = true;
  92636. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  92637. _this.update();
  92638. });
  92639. }
  92640. };
  92641. /**
  92642. * Stop trailing mesh.
  92643. */
  92644. TrailMesh.prototype.stop = function () {
  92645. if (this._beforeRenderObserver && this._running) {
  92646. this._running = false;
  92647. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  92648. }
  92649. };
  92650. /**
  92651. * Update trailing mesh geometry.
  92652. */
  92653. TrailMesh.prototype.update = function () {
  92654. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  92655. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  92656. var wm = this._generator.getWorldMatrix();
  92657. if (positions && normals) {
  92658. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  92659. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  92660. }
  92661. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  92662. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  92663. }
  92664. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  92665. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  92666. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92667. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  92668. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  92669. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  92670. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  92671. }
  92672. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92673. positions[l + 3 * i] = this._sectionVectors[i].x;
  92674. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  92675. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  92676. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  92677. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  92678. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  92679. }
  92680. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  92681. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  92682. }
  92683. };
  92684. /**
  92685. * Returns a new TrailMesh object.
  92686. * @param name is a string, the name given to the new mesh
  92687. * @param newGenerator use new generator object for cloned trail mesh
  92688. * @returns a new mesh
  92689. */
  92690. TrailMesh.prototype.clone = function (name, newGenerator) {
  92691. if (name === void 0) { name = ""; }
  92692. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  92693. };
  92694. /**
  92695. * Serializes this trail mesh
  92696. * @param serializationObject object to write serialization to
  92697. */
  92698. TrailMesh.prototype.serialize = function (serializationObject) {
  92699. _super.prototype.serialize.call(this, serializationObject);
  92700. };
  92701. /**
  92702. * Parses a serialized trail mesh
  92703. * @param parsedMesh the serialized mesh
  92704. * @param scene the scene to create the trail mesh in
  92705. * @returns the created trail mesh
  92706. */
  92707. TrailMesh.Parse = function (parsedMesh, scene) {
  92708. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  92709. };
  92710. return TrailMesh;
  92711. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  92712. /***/ }),
  92713. /***/ "./Meshes/transformNode.ts":
  92714. /*!*********************************!*\
  92715. !*** ./Meshes/transformNode.ts ***!
  92716. \*********************************/
  92717. /*! exports provided: TransformNode */
  92718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92719. "use strict";
  92720. __webpack_require__.r(__webpack_exports__);
  92721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  92722. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92723. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  92724. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  92725. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92726. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  92727. /**
  92728. * 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.
  92729. * @see https://doc.babylonjs.com/how_to/transformnode
  92730. */
  92731. var TransformNode = /** @class */ (function (_super) {
  92732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  92733. function TransformNode(name, scene, isPure) {
  92734. if (scene === void 0) { scene = null; }
  92735. if (isPure === void 0) { isPure = true; }
  92736. var _this = _super.call(this, name, scene) || this;
  92737. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  92738. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  92739. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  92740. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  92741. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  92742. // Properties
  92743. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92744. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92745. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  92746. _this._isDirty = false;
  92747. /**
  92748. * Set the billboard mode. Default is 0.
  92749. *
  92750. * | Value | Type | Description |
  92751. * | --- | --- | --- |
  92752. * | 0 | BILLBOARDMODE_NONE | |
  92753. * | 1 | BILLBOARDMODE_X | |
  92754. * | 2 | BILLBOARDMODE_Y | |
  92755. * | 4 | BILLBOARDMODE_Z | |
  92756. * | 7 | BILLBOARDMODE_ALL | |
  92757. *
  92758. */
  92759. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  92760. /**
  92761. * 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
  92762. */
  92763. _this.scalingDeterminant = 1;
  92764. /**
  92765. * Sets the distance of the object to max, often used by skybox
  92766. */
  92767. _this.infiniteDistance = false;
  92768. /**
  92769. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92770. * By default the system will update normals to compensate
  92771. */
  92772. _this.ignoreNonUniformScaling = false;
  92773. /** @hidden */
  92774. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  92775. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92776. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  92777. _this._postMultiplyPivotMatrix = false;
  92778. _this._tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  92779. _this._tempMatrix2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  92780. _this._isWorldMatrixFrozen = false;
  92781. /** @hidden */
  92782. _this._indexInSceneTransformNodesArray = -1;
  92783. /**
  92784. * An event triggered after the world matrix is updated
  92785. */
  92786. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  92787. _this._nonUniformScaling = false;
  92788. if (isPure) {
  92789. _this.getScene().addTransformNode(_this);
  92790. }
  92791. return _this;
  92792. }
  92793. /**
  92794. * Gets a string identifying the name of the class
  92795. * @returns "TransformNode" string
  92796. */
  92797. TransformNode.prototype.getClassName = function () {
  92798. return "TransformNode";
  92799. };
  92800. Object.defineProperty(TransformNode.prototype, "position", {
  92801. /**
  92802. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92803. */
  92804. get: function () {
  92805. return this._position;
  92806. },
  92807. set: function (newPosition) {
  92808. this._position = newPosition;
  92809. this._isDirty = true;
  92810. },
  92811. enumerable: true,
  92812. configurable: true
  92813. });
  92814. Object.defineProperty(TransformNode.prototype, "rotation", {
  92815. /**
  92816. * 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)).
  92817. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92818. */
  92819. get: function () {
  92820. return this._rotation;
  92821. },
  92822. set: function (newRotation) {
  92823. this._rotation = newRotation;
  92824. this._isDirty = true;
  92825. },
  92826. enumerable: true,
  92827. configurable: true
  92828. });
  92829. Object.defineProperty(TransformNode.prototype, "scaling", {
  92830. /**
  92831. * 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)).
  92832. */
  92833. get: function () {
  92834. return this._scaling;
  92835. },
  92836. set: function (newScaling) {
  92837. this._scaling = newScaling;
  92838. this._isDirty = true;
  92839. },
  92840. enumerable: true,
  92841. configurable: true
  92842. });
  92843. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  92844. /**
  92845. * 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).
  92846. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92847. */
  92848. get: function () {
  92849. return this._rotationQuaternion;
  92850. },
  92851. set: function (quaternion) {
  92852. this._rotationQuaternion = quaternion;
  92853. //reset the rotation vector.
  92854. if (quaternion) {
  92855. this.rotation.setAll(0.0);
  92856. }
  92857. },
  92858. enumerable: true,
  92859. configurable: true
  92860. });
  92861. Object.defineProperty(TransformNode.prototype, "forward", {
  92862. /**
  92863. * The forward direction of that transform in world space.
  92864. */
  92865. get: function () {
  92866. 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()));
  92867. },
  92868. enumerable: true,
  92869. configurable: true
  92870. });
  92871. Object.defineProperty(TransformNode.prototype, "up", {
  92872. /**
  92873. * The up direction of that transform in world space.
  92874. */
  92875. get: function () {
  92876. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  92877. },
  92878. enumerable: true,
  92879. configurable: true
  92880. });
  92881. Object.defineProperty(TransformNode.prototype, "right", {
  92882. /**
  92883. * The right direction of that transform in world space.
  92884. */
  92885. get: function () {
  92886. 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()));
  92887. },
  92888. enumerable: true,
  92889. configurable: true
  92890. });
  92891. /**
  92892. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92893. * @param matrix the matrix to copy the pose from
  92894. * @returns this TransformNode.
  92895. */
  92896. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  92897. this._poseMatrix.copyFrom(matrix);
  92898. return this;
  92899. };
  92900. /**
  92901. * Returns the mesh Pose matrix.
  92902. * @returns the pose matrix
  92903. */
  92904. TransformNode.prototype.getPoseMatrix = function () {
  92905. return this._poseMatrix;
  92906. };
  92907. /** @hidden */
  92908. TransformNode.prototype._isSynchronized = function () {
  92909. if (this._isDirty) {
  92910. return false;
  92911. }
  92912. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  92913. return false;
  92914. }
  92915. if (this._cache.pivotMatrixUpdated) {
  92916. return false;
  92917. }
  92918. if (this.infiniteDistance) {
  92919. return false;
  92920. }
  92921. if (!this._cache.position.equals(this._position)) {
  92922. return false;
  92923. }
  92924. if (this._rotationQuaternion) {
  92925. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  92926. return false;
  92927. }
  92928. }
  92929. if (!this._cache.rotation.equals(this._rotation)) {
  92930. return false;
  92931. }
  92932. if (!this._cache.scaling.equals(this._scaling)) {
  92933. return false;
  92934. }
  92935. return true;
  92936. };
  92937. /** @hidden */
  92938. TransformNode.prototype._initCache = function () {
  92939. _super.prototype._initCache.call(this);
  92940. this._cache.localMatrixUpdated = false;
  92941. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92942. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92943. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92944. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  92945. this._cache.billboardMode = -1;
  92946. this._cache.infiniteDistance = false;
  92947. };
  92948. /**
  92949. * Flag the transform node as dirty (Forcing it to update everything)
  92950. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92951. * @returns this transform node
  92952. */
  92953. TransformNode.prototype.markAsDirty = function (property) {
  92954. if (property === "rotation") {
  92955. this.rotationQuaternion = null;
  92956. }
  92957. this._currentRenderId = Number.MAX_VALUE;
  92958. this._isDirty = true;
  92959. return this;
  92960. };
  92961. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  92962. /**
  92963. * Returns the current mesh absolute position.
  92964. * Returns a Vector3.
  92965. */
  92966. get: function () {
  92967. return this._absolutePosition;
  92968. },
  92969. enumerable: true,
  92970. configurable: true
  92971. });
  92972. /**
  92973. * Sets a new matrix to apply before all other transformation
  92974. * @param matrix defines the transform matrix
  92975. * @returns the current TransformNode
  92976. */
  92977. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  92978. return this.setPivotMatrix(matrix, false);
  92979. };
  92980. /**
  92981. * Sets a new pivot matrix to the current node
  92982. * @param matrix defines the new pivot matrix to use
  92983. * @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
  92984. * @returns the current TransformNode
  92985. */
  92986. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  92987. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  92988. this._pivotMatrix.copyFrom(matrix);
  92989. this._cache.pivotMatrixUpdated = true;
  92990. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  92991. if (this._postMultiplyPivotMatrix) {
  92992. if (!this._pivotMatrixInverse) {
  92993. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  92994. }
  92995. else {
  92996. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  92997. }
  92998. }
  92999. return this;
  93000. };
  93001. /**
  93002. * Returns the mesh pivot matrix.
  93003. * Default : Identity.
  93004. * @returns the matrix
  93005. */
  93006. TransformNode.prototype.getPivotMatrix = function () {
  93007. return this._pivotMatrix;
  93008. };
  93009. /**
  93010. * Prevents the World matrix to be computed any longer.
  93011. * @returns the TransformNode.
  93012. */
  93013. TransformNode.prototype.freezeWorldMatrix = function () {
  93014. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  93015. this.computeWorldMatrix(true);
  93016. this._isWorldMatrixFrozen = true;
  93017. return this;
  93018. };
  93019. /**
  93020. * Allows back the World matrix computation.
  93021. * @returns the TransformNode.
  93022. */
  93023. TransformNode.prototype.unfreezeWorldMatrix = function () {
  93024. this._isWorldMatrixFrozen = false;
  93025. this.computeWorldMatrix(true);
  93026. return this;
  93027. };
  93028. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  93029. /**
  93030. * True if the World matrix has been frozen.
  93031. */
  93032. get: function () {
  93033. return this._isWorldMatrixFrozen;
  93034. },
  93035. enumerable: true,
  93036. configurable: true
  93037. });
  93038. /**
  93039. * Retuns the mesh absolute position in the World.
  93040. * @returns a Vector3.
  93041. */
  93042. TransformNode.prototype.getAbsolutePosition = function () {
  93043. this.computeWorldMatrix();
  93044. return this._absolutePosition;
  93045. };
  93046. /**
  93047. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93048. * @param absolutePosition the absolute position to set
  93049. * @returns the TransformNode.
  93050. */
  93051. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  93052. if (!absolutePosition) {
  93053. return this;
  93054. }
  93055. var absolutePositionX;
  93056. var absolutePositionY;
  93057. var absolutePositionZ;
  93058. if (absolutePosition.x === undefined) {
  93059. if (arguments.length < 3) {
  93060. return this;
  93061. }
  93062. absolutePositionX = arguments[0];
  93063. absolutePositionY = arguments[1];
  93064. absolutePositionZ = arguments[2];
  93065. }
  93066. else {
  93067. absolutePositionX = absolutePosition.x;
  93068. absolutePositionY = absolutePosition.y;
  93069. absolutePositionZ = absolutePosition.z;
  93070. }
  93071. if (this.parent) {
  93072. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93073. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  93074. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  93075. }
  93076. else {
  93077. this.position.x = absolutePositionX;
  93078. this.position.y = absolutePositionY;
  93079. this.position.z = absolutePositionZ;
  93080. }
  93081. return this;
  93082. };
  93083. /**
  93084. * Sets the mesh position in its local space.
  93085. * @param vector3 the position to set in localspace
  93086. * @returns the TransformNode.
  93087. */
  93088. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  93089. this.computeWorldMatrix();
  93090. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  93091. return this;
  93092. };
  93093. /**
  93094. * Returns the mesh position in the local space from the current World matrix values.
  93095. * @returns a new Vector3.
  93096. */
  93097. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  93098. this.computeWorldMatrix();
  93099. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93100. this._localMatrix.invertToRef(invLocalWorldMatrix);
  93101. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  93102. };
  93103. /**
  93104. * Translates the mesh along the passed Vector3 in its local space.
  93105. * @param vector3 the distance to translate in localspace
  93106. * @returns the TransformNode.
  93107. */
  93108. TransformNode.prototype.locallyTranslate = function (vector3) {
  93109. this.computeWorldMatrix(true);
  93110. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  93111. return this;
  93112. };
  93113. /**
  93114. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93115. * @param targetPoint the position (must be in same space as current mesh) to look at
  93116. * @param yawCor optional yaw (y-axis) correction in radians
  93117. * @param pitchCor optional pitch (x-axis) correction in radians
  93118. * @param rollCor optional roll (z-axis) correction in radians
  93119. * @param space the choosen space of the target
  93120. * @returns the TransformNode.
  93121. */
  93122. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  93123. if (yawCor === void 0) { yawCor = 0; }
  93124. if (pitchCor === void 0) { pitchCor = 0; }
  93125. if (rollCor === void 0) { rollCor = 0; }
  93126. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  93127. var dv = TransformNode._lookAtVectorCache;
  93128. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  93129. targetPoint.subtractToRef(pos, dv);
  93130. this.setDirection(dv, yawCor, pitchCor, rollCor);
  93131. // Correct for parent's rotation offset
  93132. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  93133. if (this.rotationQuaternion) {
  93134. // Get local rotation matrix of the looking object
  93135. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93136. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  93137. // Offset rotation by parent's inverted rotation matrix to correct in world space
  93138. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  93139. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  93140. parentRotationMatrix.invert();
  93141. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  93142. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  93143. }
  93144. else {
  93145. // Get local rotation matrix of the looking object
  93146. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93147. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  93148. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93149. quaternionRotation.toRotationMatrix(rotationMatrix);
  93150. // Offset rotation by parent's inverted rotation matrix to correct in world space
  93151. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  93152. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  93153. parentRotationMatrix.invert();
  93154. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  93155. quaternionRotation.fromRotationMatrix(rotationMatrix);
  93156. quaternionRotation.toEulerAnglesToRef(this.rotation);
  93157. }
  93158. }
  93159. return this;
  93160. };
  93161. /**
  93162. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93163. * This Vector3 is expressed in the World space.
  93164. * @param localAxis axis to rotate
  93165. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93166. */
  93167. TransformNode.prototype.getDirection = function (localAxis) {
  93168. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93169. this.getDirectionToRef(localAxis, result);
  93170. return result;
  93171. };
  93172. /**
  93173. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93174. * localAxis is expressed in the mesh local space.
  93175. * result is computed in the Wordl space from the mesh World matrix.
  93176. * @param localAxis axis to rotate
  93177. * @param result the resulting transformnode
  93178. * @returns this TransformNode.
  93179. */
  93180. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  93181. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  93182. return this;
  93183. };
  93184. /**
  93185. * Sets this transform node rotation to the given local axis.
  93186. * @param localAxis the axis in local space
  93187. * @param yawCor optional yaw (y-axis) correction in radians
  93188. * @param pitchCor optional pitch (x-axis) correction in radians
  93189. * @param rollCor optional roll (z-axis) correction in radians
  93190. * @returns this TransformNode
  93191. */
  93192. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  93193. if (yawCor === void 0) { yawCor = 0; }
  93194. if (pitchCor === void 0) { pitchCor = 0; }
  93195. if (rollCor === void 0) { rollCor = 0; }
  93196. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  93197. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  93198. var pitch = -Math.atan2(localAxis.y, len);
  93199. if (this.rotationQuaternion) {
  93200. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  93201. }
  93202. else {
  93203. this.rotation.x = pitch + pitchCor;
  93204. this.rotation.y = yaw + yawCor;
  93205. this.rotation.z = rollCor;
  93206. }
  93207. return this;
  93208. };
  93209. /**
  93210. * Sets a new pivot point to the current node
  93211. * @param point defines the new pivot point to use
  93212. * @param space defines if the point is in world or local space (local by default)
  93213. * @returns the current TransformNode
  93214. */
  93215. TransformNode.prototype.setPivotPoint = function (point, space) {
  93216. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  93217. if (this.getScene().getRenderId() == 0) {
  93218. this.computeWorldMatrix(true);
  93219. }
  93220. var wm = this.getWorldMatrix();
  93221. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  93222. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93223. wm.invertToRef(tmat);
  93224. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  93225. }
  93226. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  93227. };
  93228. /**
  93229. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93230. * @returns the pivot point
  93231. */
  93232. TransformNode.prototype.getPivotPoint = function () {
  93233. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93234. this.getPivotPointToRef(point);
  93235. return point;
  93236. };
  93237. /**
  93238. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93239. * @param result the vector3 to store the result
  93240. * @returns this TransformNode.
  93241. */
  93242. TransformNode.prototype.getPivotPointToRef = function (result) {
  93243. result.x = -this._pivotMatrix.m[12];
  93244. result.y = -this._pivotMatrix.m[13];
  93245. result.z = -this._pivotMatrix.m[14];
  93246. return this;
  93247. };
  93248. /**
  93249. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93250. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93251. */
  93252. TransformNode.prototype.getAbsolutePivotPoint = function () {
  93253. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93254. this.getAbsolutePivotPointToRef(point);
  93255. return point;
  93256. };
  93257. /**
  93258. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93259. * @param result vector3 to store the result
  93260. * @returns this TransformNode.
  93261. */
  93262. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  93263. result.x = this._pivotMatrix.m[12];
  93264. result.y = this._pivotMatrix.m[13];
  93265. result.z = this._pivotMatrix.m[14];
  93266. this.getPivotPointToRef(result);
  93267. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  93268. return this;
  93269. };
  93270. /**
  93271. * Defines the passed node as the parent of the current node.
  93272. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93273. * @see https://doc.babylonjs.com/how_to/parenting
  93274. * @param node the node ot set as the parent
  93275. * @returns this TransformNode.
  93276. */
  93277. TransformNode.prototype.setParent = function (node) {
  93278. if (!node && !this.parent) {
  93279. return this;
  93280. }
  93281. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93282. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  93283. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  93284. if (!node) {
  93285. if (this.parent && this.parent.computeWorldMatrix) {
  93286. this.parent.computeWorldMatrix(true);
  93287. }
  93288. this.computeWorldMatrix(true);
  93289. this.getWorldMatrix().decompose(scale, quatRotation, position);
  93290. }
  93291. else {
  93292. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93293. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  93294. this.computeWorldMatrix(true);
  93295. node.computeWorldMatrix(true);
  93296. node.getWorldMatrix().invertToRef(invParentMatrix);
  93297. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  93298. diffMatrix.decompose(scale, quatRotation, position);
  93299. }
  93300. if (this.rotationQuaternion) {
  93301. this.rotationQuaternion.copyFrom(quatRotation);
  93302. }
  93303. else {
  93304. quatRotation.toEulerAnglesToRef(this.rotation);
  93305. }
  93306. this.scaling.copyFrom(scale);
  93307. this.position.copyFrom(position);
  93308. this.parent = node;
  93309. return this;
  93310. };
  93311. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  93312. /**
  93313. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93314. */
  93315. get: function () {
  93316. return this._nonUniformScaling;
  93317. },
  93318. enumerable: true,
  93319. configurable: true
  93320. });
  93321. /** @hidden */
  93322. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  93323. if (this._nonUniformScaling === value) {
  93324. return false;
  93325. }
  93326. this._nonUniformScaling = value;
  93327. return true;
  93328. };
  93329. /**
  93330. * Attach the current TransformNode to another TransformNode associated with a bone
  93331. * @param bone Bone affecting the TransformNode
  93332. * @param affectedTransformNode TransformNode associated with the bone
  93333. * @returns this object
  93334. */
  93335. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  93336. this._transformToBoneReferal = affectedTransformNode;
  93337. this.parent = bone;
  93338. if (bone.getWorldMatrix().determinant() < 0) {
  93339. this.scalingDeterminant *= -1;
  93340. }
  93341. return this;
  93342. };
  93343. /**
  93344. * Detach the transform node if its associated with a bone
  93345. * @returns this object
  93346. */
  93347. TransformNode.prototype.detachFromBone = function () {
  93348. if (!this.parent) {
  93349. return this;
  93350. }
  93351. if (this.parent.getWorldMatrix().determinant() < 0) {
  93352. this.scalingDeterminant *= -1;
  93353. }
  93354. this._transformToBoneReferal = null;
  93355. this.parent = null;
  93356. return this;
  93357. };
  93358. /**
  93359. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93360. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93361. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93362. * The passed axis is also normalized.
  93363. * @param axis the axis to rotate around
  93364. * @param amount the amount to rotate in radians
  93365. * @param space Space to rotate in (Default: local)
  93366. * @returns the TransformNode.
  93367. */
  93368. TransformNode.prototype.rotate = function (axis, amount, space) {
  93369. axis.normalize();
  93370. if (!this.rotationQuaternion) {
  93371. this.rotationQuaternion = this.rotation.toQuaternion();
  93372. this.rotation.setAll(0);
  93373. }
  93374. var rotationQuaternion;
  93375. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  93376. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  93377. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  93378. }
  93379. else {
  93380. if (this.parent) {
  93381. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93382. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  93383. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  93384. }
  93385. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  93386. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  93387. }
  93388. return this;
  93389. };
  93390. /**
  93391. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93392. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93393. * The passed axis is also normalized. .
  93394. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93395. * @param point the point to rotate around
  93396. * @param axis the axis to rotate around
  93397. * @param amount the amount to rotate in radians
  93398. * @returns the TransformNode
  93399. */
  93400. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  93401. axis.normalize();
  93402. if (!this.rotationQuaternion) {
  93403. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  93404. this.rotation.setAll(0);
  93405. }
  93406. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  93407. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  93408. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  93409. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93410. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  93411. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  93412. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  93413. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  93414. point.subtractToRef(this.position, tmpVector);
  93415. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  93416. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  93417. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  93418. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  93419. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  93420. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  93421. this.position.addInPlace(finalTranslation);
  93422. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  93423. return this;
  93424. };
  93425. /**
  93426. * Translates the mesh along the axis vector for the passed distance in the given space.
  93427. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93428. * @param axis the axis to translate in
  93429. * @param distance the distance to translate
  93430. * @param space Space to rotate in (Default: local)
  93431. * @returns the TransformNode.
  93432. */
  93433. TransformNode.prototype.translate = function (axis, distance, space) {
  93434. var displacementVector = axis.scale(distance);
  93435. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  93436. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  93437. this.setPositionWithLocalVector(tempV3);
  93438. }
  93439. else {
  93440. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  93441. }
  93442. return this;
  93443. };
  93444. /**
  93445. * Adds a rotation step to the mesh current rotation.
  93446. * x, y, z are Euler angles expressed in radians.
  93447. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93448. * This means this rotation is made in the mesh local space only.
  93449. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93450. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93451. * ```javascript
  93452. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93453. * ```
  93454. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93455. * 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.
  93456. * @param x Rotation to add
  93457. * @param y Rotation to add
  93458. * @param z Rotation to add
  93459. * @returns the TransformNode.
  93460. */
  93461. TransformNode.prototype.addRotation = function (x, y, z) {
  93462. var rotationQuaternion;
  93463. if (this.rotationQuaternion) {
  93464. rotationQuaternion = this.rotationQuaternion;
  93465. }
  93466. else {
  93467. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  93468. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  93469. }
  93470. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93471. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  93472. rotationQuaternion.multiplyInPlace(accumulation);
  93473. if (!this.rotationQuaternion) {
  93474. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  93475. }
  93476. return this;
  93477. };
  93478. /**
  93479. * Computes the world matrix of the node
  93480. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93481. * @returns the world matrix
  93482. */
  93483. TransformNode.prototype.computeWorldMatrix = function (force) {
  93484. if (this._isWorldMatrixFrozen) {
  93485. return this._worldMatrix;
  93486. }
  93487. if (!force && this.isSynchronized()) {
  93488. this._currentRenderId = this.getScene().getRenderId();
  93489. return this._worldMatrix;
  93490. }
  93491. this._updateCache();
  93492. this._cache.position.copyFrom(this.position);
  93493. this._cache.scaling.copyFrom(this.scaling);
  93494. this._cache.pivotMatrixUpdated = false;
  93495. this._cache.billboardMode = this.billboardMode;
  93496. this._cache.infiniteDistance = this.infiniteDistance;
  93497. this._currentRenderId = this.getScene().getRenderId();
  93498. this._childRenderId = this.getScene().getRenderId();
  93499. this._isDirty = false;
  93500. // Scaling
  93501. _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]);
  93502. // Rotation
  93503. //rotate, if quaternion is set and rotation was used
  93504. if (this.rotationQuaternion) {
  93505. var len = this.rotation.length();
  93506. if (len) {
  93507. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  93508. this.rotation.copyFromFloats(0, 0, 0);
  93509. }
  93510. }
  93511. if (this.rotationQuaternion) {
  93512. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93513. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  93514. }
  93515. else {
  93516. _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]);
  93517. this._cache.rotation.copyFrom(this.rotation);
  93518. }
  93519. // Translation
  93520. var camera = this.getScene().activeCamera;
  93521. if (this.infiniteDistance && !this.parent && camera) {
  93522. var cameraWorldMatrix = camera.getWorldMatrix();
  93523. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  93524. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, this._tempMatrix2);
  93525. }
  93526. else {
  93527. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._tempMatrix2);
  93528. }
  93529. // Composing transformations
  93530. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  93531. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._tempMatrix);
  93532. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  93533. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  93534. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  93535. // Need to decompose each rotation here
  93536. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  93537. if (this.parent && this.parent.getWorldMatrix) {
  93538. if (this._transformToBoneReferal) {
  93539. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  93540. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  93541. }
  93542. else {
  93543. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  93544. }
  93545. }
  93546. else {
  93547. currentPosition.copyFrom(this.position);
  93548. }
  93549. currentPosition.subtractInPlace(camera.globalPosition);
  93550. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  93551. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  93552. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  93553. }
  93554. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  93555. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  93556. }
  93557. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  93558. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  93559. }
  93560. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93561. }
  93562. else {
  93563. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  93564. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  93565. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93566. }
  93567. if (this._scene.useRightHandedSystem) {
  93568. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1, 1, -1, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]);
  93569. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93570. }
  93571. this._tempMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._tempMatrix);
  93572. }
  93573. // Post multiply inverse of pivotMatrix
  93574. if (this._postMultiplyPivotMatrix) {
  93575. this._tempMatrix.multiplyToRef(this._pivotMatrixInverse, this._tempMatrix);
  93576. }
  93577. // Local world
  93578. this._tempMatrix.multiplyToRef(this._tempMatrix2, this._localMatrix);
  93579. // Parent
  93580. if (this.parent && this.parent.getWorldMatrix) {
  93581. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  93582. if (this._transformToBoneReferal) {
  93583. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  93584. }
  93585. else {
  93586. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(this.parent.getWorldMatrix());
  93587. }
  93588. // Extract scaling and translation from parent
  93589. var translation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5];
  93590. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[6];
  93591. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].decompose(scale, undefined, translation);
  93592. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scale.x, scale.y, scale.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  93593. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].setTranslation(translation);
  93594. this._localMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7], this._worldMatrix);
  93595. }
  93596. else {
  93597. if (this._transformToBoneReferal) {
  93598. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  93599. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  93600. }
  93601. else {
  93602. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  93603. }
  93604. }
  93605. this._markSyncedWithParent();
  93606. }
  93607. else {
  93608. this._worldMatrix.copyFrom(this._localMatrix);
  93609. }
  93610. // Normal matrix
  93611. if (!this.ignoreNonUniformScaling) {
  93612. if (this.scaling.isNonUniform) {
  93613. this._updateNonUniformScalingState(true);
  93614. }
  93615. else if (this.parent && this.parent._nonUniformScaling) {
  93616. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  93617. }
  93618. else {
  93619. this._updateNonUniformScalingState(false);
  93620. }
  93621. }
  93622. else {
  93623. this._updateNonUniformScalingState(false);
  93624. }
  93625. this._afterComputeWorldMatrix();
  93626. // Absolute position
  93627. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  93628. // Callbacks
  93629. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  93630. if (!this._poseMatrix) {
  93631. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  93632. }
  93633. // Cache the determinant
  93634. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  93635. return this._worldMatrix;
  93636. };
  93637. TransformNode.prototype._afterComputeWorldMatrix = function () {
  93638. };
  93639. /**
  93640. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93641. * @param func callback function to add
  93642. *
  93643. * @returns the TransformNode.
  93644. */
  93645. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  93646. this.onAfterWorldMatrixUpdateObservable.add(func);
  93647. return this;
  93648. };
  93649. /**
  93650. * Removes a registered callback function.
  93651. * @param func callback function to remove
  93652. * @returns the TransformNode.
  93653. */
  93654. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  93655. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  93656. return this;
  93657. };
  93658. /**
  93659. * Gets the position of the current mesh in camera space
  93660. * @param camera defines the camera to use
  93661. * @returns a position
  93662. */
  93663. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  93664. if (camera === void 0) { camera = null; }
  93665. if (!camera) {
  93666. camera = this.getScene().activeCamera;
  93667. }
  93668. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  93669. };
  93670. /**
  93671. * Returns the distance from the mesh to the active camera
  93672. * @param camera defines the camera to use
  93673. * @returns the distance
  93674. */
  93675. TransformNode.prototype.getDistanceToCamera = function (camera) {
  93676. if (camera === void 0) { camera = null; }
  93677. if (!camera) {
  93678. camera = this.getScene().activeCamera;
  93679. }
  93680. return this.absolutePosition.subtract(camera.position).length();
  93681. };
  93682. /**
  93683. * Clone the current transform node
  93684. * @param name Name of the new clone
  93685. * @param newParent New parent for the clone
  93686. * @param doNotCloneChildren Do not clone children hierarchy
  93687. * @returns the new transform node
  93688. */
  93689. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  93690. var _this = this;
  93691. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  93692. result.name = name;
  93693. result.id = name;
  93694. if (newParent) {
  93695. result.parent = newParent;
  93696. }
  93697. if (!doNotCloneChildren) {
  93698. // Children
  93699. var directDescendants = this.getDescendants(true);
  93700. for (var index = 0; index < directDescendants.length; index++) {
  93701. var child = directDescendants[index];
  93702. if (child.clone) {
  93703. child.clone(name + "." + child.name, result);
  93704. }
  93705. }
  93706. }
  93707. return result;
  93708. };
  93709. /**
  93710. * Serializes the objects information.
  93711. * @param currentSerializationObject defines the object to serialize in
  93712. * @returns the serialized object
  93713. */
  93714. TransformNode.prototype.serialize = function (currentSerializationObject) {
  93715. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  93716. serializationObject.type = this.getClassName();
  93717. // Parent
  93718. if (this.parent) {
  93719. serializationObject.parentId = this.parent.id;
  93720. }
  93721. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  93722. serializationObject.isEnabled = this.isEnabled();
  93723. // Parent
  93724. if (this.parent) {
  93725. serializationObject.parentId = this.parent.id;
  93726. }
  93727. return serializationObject;
  93728. };
  93729. // Statics
  93730. /**
  93731. * Returns a new TransformNode object parsed from the source provided.
  93732. * @param parsedTransformNode is the source.
  93733. * @param scene the scne the object belongs to
  93734. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93735. * @returns a new TransformNode object parsed from the source provided.
  93736. */
  93737. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  93738. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  93739. if (parsedTransformNode.localMatrix) {
  93740. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  93741. }
  93742. else if (parsedTransformNode.pivotMatrix) {
  93743. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  93744. }
  93745. transformNode.setEnabled(parsedTransformNode.isEnabled);
  93746. // Parent
  93747. if (parsedTransformNode.parentId) {
  93748. transformNode._waitingParentId = parsedTransformNode.parentId;
  93749. }
  93750. return transformNode;
  93751. };
  93752. /**
  93753. * Get all child-transformNodes of this node
  93754. * @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
  93755. * @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
  93756. * @returns an array of TransformNode
  93757. */
  93758. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  93759. var results = [];
  93760. this._getDescendants(results, directDescendantsOnly, function (node) {
  93761. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  93762. });
  93763. return results;
  93764. };
  93765. /**
  93766. * Releases resources associated with this transform node.
  93767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93769. */
  93770. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  93771. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  93772. // Animations
  93773. this.getScene().stopAnimation(this);
  93774. // Remove from scene
  93775. this.getScene().removeTransformNode(this);
  93776. this.onAfterWorldMatrixUpdateObservable.clear();
  93777. if (doNotRecurse) {
  93778. var transformNodes = this.getChildTransformNodes(true);
  93779. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  93780. var transformNode = transformNodes_1[_i];
  93781. transformNode.parent = null;
  93782. transformNode.computeWorldMatrix(true);
  93783. }
  93784. }
  93785. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  93786. };
  93787. // Statics
  93788. /**
  93789. * Object will not rotate to face the camera
  93790. */
  93791. TransformNode.BILLBOARDMODE_NONE = 0;
  93792. /**
  93793. * Object will rotate to face the camera but only on the x axis
  93794. */
  93795. TransformNode.BILLBOARDMODE_X = 1;
  93796. /**
  93797. * Object will rotate to face the camera but only on the y axis
  93798. */
  93799. TransformNode.BILLBOARDMODE_Y = 2;
  93800. /**
  93801. * Object will rotate to face the camera but only on the z axis
  93802. */
  93803. TransformNode.BILLBOARDMODE_Z = 4;
  93804. /**
  93805. * Object will rotate to face the camera
  93806. */
  93807. TransformNode.BILLBOARDMODE_ALL = 7;
  93808. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  93809. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  93810. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93811. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  93812. ], TransformNode.prototype, "_position", void 0);
  93813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  93815. ], TransformNode.prototype, "_rotation", void 0);
  93816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  93818. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  93819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  93821. ], TransformNode.prototype, "_scaling", void 0);
  93822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  93824. ], TransformNode.prototype, "billboardMode", void 0);
  93825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  93827. ], TransformNode.prototype, "scalingDeterminant", void 0);
  93828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  93830. ], TransformNode.prototype, "infiniteDistance", void 0);
  93831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  93833. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  93834. return TransformNode;
  93835. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  93836. /***/ }),
  93837. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  93838. /*!***************************************************************!*\
  93839. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  93840. \***************************************************************/
  93841. /*! exports provided: CubeMapToSphericalPolynomialTools */
  93842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93843. "use strict";
  93844. __webpack_require__.r(__webpack_exports__);
  93845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  93846. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  93847. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  93848. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  93849. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  93850. var FileFaceOrientation = /** @class */ (function () {
  93851. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  93852. this.name = name;
  93853. this.worldAxisForNormal = worldAxisForNormal;
  93854. this.worldAxisForFileX = worldAxisForFileX;
  93855. this.worldAxisForFileY = worldAxisForFileY;
  93856. }
  93857. return FileFaceOrientation;
  93858. }());
  93859. /**
  93860. * Helper class dealing with the extraction of spherical polynomial dataArray
  93861. * from a cube map.
  93862. */
  93863. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  93864. function CubeMapToSphericalPolynomialTools() {
  93865. }
  93866. /**
  93867. * Converts a texture to the according Spherical Polynomial data.
  93868. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93869. *
  93870. * @param texture The texture to extract the information from.
  93871. * @return The Spherical Polynomial data.
  93872. */
  93873. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  93874. if (!texture.isCube) {
  93875. // Only supports cube Textures currently.
  93876. return null;
  93877. }
  93878. var size = texture.getSize().width;
  93879. var right = texture.readPixels(0);
  93880. var left = texture.readPixels(1);
  93881. var up;
  93882. var down;
  93883. if (texture.isRenderTarget) {
  93884. up = texture.readPixels(3);
  93885. down = texture.readPixels(2);
  93886. }
  93887. else {
  93888. up = texture.readPixels(2);
  93889. down = texture.readPixels(3);
  93890. }
  93891. var front = texture.readPixels(4);
  93892. var back = texture.readPixels(5);
  93893. var gammaSpace = texture.gammaSpace;
  93894. // Always read as RGBA.
  93895. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  93896. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93897. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  93898. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  93899. }
  93900. var cubeInfo = {
  93901. size: size,
  93902. right: right,
  93903. left: left,
  93904. up: up,
  93905. down: down,
  93906. front: front,
  93907. back: back,
  93908. format: format,
  93909. type: type,
  93910. gammaSpace: gammaSpace,
  93911. };
  93912. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  93913. };
  93914. /**
  93915. * Converts a cubemap to the according Spherical Polynomial data.
  93916. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93917. *
  93918. * @param cubeInfo The Cube map to extract the information from.
  93919. * @return The Spherical Polynomial data.
  93920. */
  93921. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  93922. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  93923. var totalSolidAngle = 0.0;
  93924. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  93925. var du = 2.0 / cubeInfo.size;
  93926. var dv = du;
  93927. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  93928. var minUV = du * 0.5 - 1.0;
  93929. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  93930. var fileFace = this.FileFaces[faceIndex];
  93931. var dataArray = cubeInfo[fileFace.name];
  93932. var v = minUV;
  93933. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  93934. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  93935. // Because SP is still linear, so summation is fine in that basis.
  93936. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  93937. for (var y = 0; y < cubeInfo.size; y++) {
  93938. var u = minUV;
  93939. for (var x = 0; x < cubeInfo.size; x++) {
  93940. // World direction (not normalised)
  93941. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  93942. worldDirection.normalize();
  93943. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  93944. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  93945. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  93946. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  93947. // Handle Integer types.
  93948. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  93949. r /= 255;
  93950. g /= 255;
  93951. b /= 255;
  93952. }
  93953. // Handle Gamma space textures.
  93954. if (cubeInfo.gammaSpace) {
  93955. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  93956. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  93957. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  93958. }
  93959. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  93960. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  93961. totalSolidAngle += deltaSolidAngle;
  93962. u += du;
  93963. }
  93964. v += dv;
  93965. }
  93966. }
  93967. // Solid angle for entire sphere is 4*pi
  93968. var sphereSolidAngle = 4.0 * Math.PI;
  93969. // Adjust the solid angle to allow for how many faces we processed.
  93970. var facesProcessed = 6.0;
  93971. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  93972. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  93973. // This is needed because the numerical integration over the cube uses a
  93974. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  93975. // and also to compensate for accumulative error due to float precision in the summation.
  93976. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  93977. sphericalHarmonics.scale(correctionFactor);
  93978. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  93979. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  93980. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  93981. };
  93982. CubeMapToSphericalPolynomialTools.FileFaces = [
  93983. 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)),
  93984. 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)),
  93985. 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)),
  93986. 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)),
  93987. 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)),
  93988. 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
  93989. ];
  93990. return CubeMapToSphericalPolynomialTools;
  93991. }());
  93992. /***/ }),
  93993. /***/ "./Misc/HighDynamicRange/hdr.ts":
  93994. /*!**************************************!*\
  93995. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  93996. \**************************************/
  93997. /*! exports provided: HDRTools */
  93998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93999. "use strict";
  94000. __webpack_require__.r(__webpack_exports__);
  94001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  94002. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  94003. /**
  94004. * This groups tools to convert HDR texture to native colors array.
  94005. */
  94006. var HDRTools = /** @class */ (function () {
  94007. function HDRTools() {
  94008. }
  94009. HDRTools.Ldexp = function (mantissa, exponent) {
  94010. if (exponent > 1023) {
  94011. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  94012. }
  94013. if (exponent < -1074) {
  94014. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  94015. }
  94016. return mantissa * Math.pow(2, exponent);
  94017. };
  94018. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  94019. if (exponent > 0) { /*nonzero pixel*/
  94020. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  94021. float32array[index + 0] = red * exponent;
  94022. float32array[index + 1] = green * exponent;
  94023. float32array[index + 2] = blue * exponent;
  94024. }
  94025. else {
  94026. float32array[index + 0] = 0;
  94027. float32array[index + 1] = 0;
  94028. float32array[index + 2] = 0;
  94029. }
  94030. };
  94031. HDRTools.readStringLine = function (uint8array, startIndex) {
  94032. var line = "";
  94033. var character = "";
  94034. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  94035. character = String.fromCharCode(uint8array[i]);
  94036. if (character == "\n") {
  94037. break;
  94038. }
  94039. line += character;
  94040. }
  94041. return line;
  94042. };
  94043. /**
  94044. * Reads header information from an RGBE texture stored in a native array.
  94045. * More information on this format are available here:
  94046. * https://en.wikipedia.org/wiki/RGBE_image_format
  94047. *
  94048. * @param uint8array The binary file stored in native array.
  94049. * @return The header information.
  94050. */
  94051. HDRTools.RGBE_ReadHeader = function (uint8array) {
  94052. var height = 0;
  94053. var width = 0;
  94054. var line = this.readStringLine(uint8array, 0);
  94055. if (line[0] != '#' || line[1] != '?') {
  94056. throw "Bad HDR Format.";
  94057. }
  94058. var endOfHeader = false;
  94059. var findFormat = false;
  94060. var lineIndex = 0;
  94061. do {
  94062. lineIndex += (line.length + 1);
  94063. line = this.readStringLine(uint8array, lineIndex);
  94064. if (line == "FORMAT=32-bit_rle_rgbe") {
  94065. findFormat = true;
  94066. }
  94067. else if (line.length == 0) {
  94068. endOfHeader = true;
  94069. }
  94070. } while (!endOfHeader);
  94071. if (!findFormat) {
  94072. throw "HDR Bad header format, unsupported FORMAT";
  94073. }
  94074. lineIndex += (line.length + 1);
  94075. line = this.readStringLine(uint8array, lineIndex);
  94076. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  94077. var match = sizeRegexp.exec(line);
  94078. // TODO. Support +Y and -X if needed.
  94079. if (!match || match.length < 3) {
  94080. throw "HDR Bad header format, no size";
  94081. }
  94082. width = parseInt(match[2]);
  94083. height = parseInt(match[1]);
  94084. if (width < 8 || width > 0x7fff) {
  94085. throw "HDR Bad header format, unsupported size";
  94086. }
  94087. lineIndex += (line.length + 1);
  94088. return {
  94089. height: height,
  94090. width: width,
  94091. dataPosition: lineIndex
  94092. };
  94093. };
  94094. /**
  94095. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  94096. * This RGBE texture needs to store the information as a panorama.
  94097. *
  94098. * More information on this format are available here:
  94099. * https://en.wikipedia.org/wiki/RGBE_image_format
  94100. *
  94101. * @param buffer The binary file stored in an array buffer.
  94102. * @param size The expected size of the extracted cubemap.
  94103. * @return The Cube Map information.
  94104. */
  94105. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  94106. var uint8array = new Uint8Array(buffer);
  94107. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  94108. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  94109. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  94110. return cubeMapData;
  94111. };
  94112. /**
  94113. * Returns the pixels data extracted from an RGBE texture.
  94114. * This pixels will be stored left to right up to down in the R G B order in one array.
  94115. *
  94116. * More information on this format are available here:
  94117. * https://en.wikipedia.org/wiki/RGBE_image_format
  94118. *
  94119. * @param uint8array The binary file stored in an array buffer.
  94120. * @param hdrInfo The header information of the file.
  94121. * @return The pixels data in RGB right to left up to down order.
  94122. */
  94123. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  94124. // Keep for multi format supports.
  94125. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  94126. };
  94127. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  94128. var num_scanlines = hdrInfo.height;
  94129. var scanline_width = hdrInfo.width;
  94130. var a, b, c, d, count;
  94131. var dataIndex = hdrInfo.dataPosition;
  94132. var index = 0, endIndex = 0, i = 0;
  94133. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  94134. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  94135. // 3 channels of 4 bytes per pixel in float.
  94136. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  94137. var resultArray = new Float32Array(resultBuffer);
  94138. // read in each successive scanline
  94139. while (num_scanlines > 0) {
  94140. a = uint8array[dataIndex++];
  94141. b = uint8array[dataIndex++];
  94142. c = uint8array[dataIndex++];
  94143. d = uint8array[dataIndex++];
  94144. if (a != 2 || b != 2 || (c & 0x80)) {
  94145. // this file is not run length encoded
  94146. throw "HDR Bad header format, not RLE";
  94147. }
  94148. if (((c << 8) | d) != scanline_width) {
  94149. throw "HDR Bad header format, wrong scan line width";
  94150. }
  94151. index = 0;
  94152. // read each of the four channels for the scanline into the buffer
  94153. for (i = 0; i < 4; i++) {
  94154. endIndex = (i + 1) * scanline_width;
  94155. while (index < endIndex) {
  94156. a = uint8array[dataIndex++];
  94157. b = uint8array[dataIndex++];
  94158. if (a > 128) {
  94159. // a run of the same value
  94160. count = a - 128;
  94161. if ((count == 0) || (count > endIndex - index)) {
  94162. throw "HDR Bad Format, bad scanline data (run)";
  94163. }
  94164. while (count-- > 0) {
  94165. scanLineArray[index++] = b;
  94166. }
  94167. }
  94168. else {
  94169. // a non-run
  94170. count = a;
  94171. if ((count == 0) || (count > endIndex - index)) {
  94172. throw "HDR Bad Format, bad scanline data (non-run)";
  94173. }
  94174. scanLineArray[index++] = b;
  94175. if (--count > 0) {
  94176. for (var j = 0; j < count; j++) {
  94177. scanLineArray[index++] = uint8array[dataIndex++];
  94178. }
  94179. }
  94180. }
  94181. }
  94182. }
  94183. // now convert data from buffer into floats
  94184. for (i = 0; i < scanline_width; i++) {
  94185. a = scanLineArray[i];
  94186. b = scanLineArray[i + scanline_width];
  94187. c = scanLineArray[i + 2 * scanline_width];
  94188. d = scanLineArray[i + 3 * scanline_width];
  94189. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  94190. }
  94191. num_scanlines--;
  94192. }
  94193. return resultArray;
  94194. };
  94195. return HDRTools;
  94196. }());
  94197. /***/ }),
  94198. /***/ "./Misc/HighDynamicRange/index.ts":
  94199. /*!****************************************!*\
  94200. !*** ./Misc/HighDynamicRange/index.ts ***!
  94201. \****************************************/
  94202. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  94203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94204. "use strict";
  94205. __webpack_require__.r(__webpack_exports__);
  94206. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  94207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  94208. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  94209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  94210. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  94211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  94212. /***/ }),
  94213. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  94214. /*!****************************************************!*\
  94215. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  94216. \****************************************************/
  94217. /*! exports provided: PanoramaToCubeMapTools */
  94218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94219. "use strict";
  94220. __webpack_require__.r(__webpack_exports__);
  94221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  94222. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  94223. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  94224. /**
  94225. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94226. */
  94227. var PanoramaToCubeMapTools = /** @class */ (function () {
  94228. function PanoramaToCubeMapTools() {
  94229. }
  94230. /**
  94231. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94232. *
  94233. * @param float32Array The source data.
  94234. * @param inputWidth The width of the input panorama.
  94235. * @param inputHeight The height of the input panorama.
  94236. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94237. * @return The cubemap data
  94238. */
  94239. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  94240. if (!float32Array) {
  94241. throw "ConvertPanoramaToCubemap: input cannot be null";
  94242. }
  94243. if (float32Array.length != inputWidth * inputHeight * 3) {
  94244. throw "ConvertPanoramaToCubemap: input size is wrong";
  94245. }
  94246. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  94247. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  94248. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  94249. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  94250. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  94251. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  94252. return {
  94253. front: textureFront,
  94254. back: textureBack,
  94255. left: textureLeft,
  94256. right: textureRight,
  94257. up: textureUp,
  94258. down: textureDown,
  94259. size: size,
  94260. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  94261. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  94262. gammaSpace: false,
  94263. };
  94264. };
  94265. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  94266. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  94267. var textureArray = new Float32Array(buffer);
  94268. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  94269. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  94270. var dy = 1 / texSize;
  94271. var fy = 0;
  94272. for (var y = 0; y < texSize; y++) {
  94273. var xv1 = faceData[0];
  94274. var xv2 = faceData[2];
  94275. for (var x = 0; x < texSize; x++) {
  94276. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  94277. v.normalize();
  94278. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  94279. // 3 channels per pixels
  94280. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  94281. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  94282. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  94283. xv1 = xv1.add(rotDX1);
  94284. xv2 = xv2.add(rotDX2);
  94285. }
  94286. fy += dy;
  94287. }
  94288. return textureArray;
  94289. };
  94290. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  94291. var theta = Math.atan2(vDir.z, vDir.x);
  94292. var phi = Math.acos(vDir.y);
  94293. while (theta < -Math.PI) {
  94294. theta += 2 * Math.PI;
  94295. }
  94296. while (theta > Math.PI) {
  94297. theta -= 2 * Math.PI;
  94298. }
  94299. var dx = theta / Math.PI;
  94300. var dy = phi / Math.PI;
  94301. // recenter.
  94302. dx = dx * 0.5 + 0.5;
  94303. var px = Math.round(dx * inputWidth);
  94304. if (px < 0) {
  94305. px = 0;
  94306. }
  94307. else if (px >= inputWidth) {
  94308. px = inputWidth - 1;
  94309. }
  94310. var py = Math.round(dy * inputHeight);
  94311. if (py < 0) {
  94312. py = 0;
  94313. }
  94314. else if (py >= inputHeight) {
  94315. py = inputHeight - 1;
  94316. }
  94317. var inputY = (inputHeight - py - 1);
  94318. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  94319. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  94320. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  94321. return {
  94322. r: r,
  94323. g: g,
  94324. b: b
  94325. };
  94326. };
  94327. PanoramaToCubeMapTools.FACE_FRONT = [
  94328. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  94329. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  94330. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  94331. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  94332. ];
  94333. PanoramaToCubeMapTools.FACE_BACK = [
  94334. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  94335. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  94336. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  94337. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  94338. ];
  94339. PanoramaToCubeMapTools.FACE_RIGHT = [
  94340. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  94341. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  94342. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  94343. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  94344. ];
  94345. PanoramaToCubeMapTools.FACE_LEFT = [
  94346. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  94347. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  94348. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  94349. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  94350. ];
  94351. PanoramaToCubeMapTools.FACE_DOWN = [
  94352. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  94353. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  94354. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  94355. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  94356. ];
  94357. PanoramaToCubeMapTools.FACE_UP = [
  94358. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  94359. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  94360. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  94361. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  94362. ];
  94363. return PanoramaToCubeMapTools;
  94364. }());
  94365. /***/ }),
  94366. /***/ "./Misc/andOrNotEvaluator.ts":
  94367. /*!***********************************!*\
  94368. !*** ./Misc/andOrNotEvaluator.ts ***!
  94369. \***********************************/
  94370. /*! exports provided: AndOrNotEvaluator */
  94371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94372. "use strict";
  94373. __webpack_require__.r(__webpack_exports__);
  94374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  94375. /**
  94376. * Class used to evalaute queries containing `and` and `or` operators
  94377. */
  94378. var AndOrNotEvaluator = /** @class */ (function () {
  94379. function AndOrNotEvaluator() {
  94380. }
  94381. /**
  94382. * Evaluate a query
  94383. * @param query defines the query to evaluate
  94384. * @param evaluateCallback defines the callback used to filter result
  94385. * @returns true if the query matches
  94386. */
  94387. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  94388. if (!query.match(/\([^\(\)]*\)/g)) {
  94389. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  94390. }
  94391. else {
  94392. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  94393. // remove parenthesis
  94394. r = r.slice(1, r.length - 1);
  94395. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  94396. });
  94397. }
  94398. if (query === "true") {
  94399. return true;
  94400. }
  94401. if (query === "false") {
  94402. return false;
  94403. }
  94404. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  94405. };
  94406. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  94407. evaluateCallback = evaluateCallback || (function (r) {
  94408. return r === "true" ? true : false;
  94409. });
  94410. var result;
  94411. var or = parenthesisContent.split("||");
  94412. for (var i in or) {
  94413. if (or.hasOwnProperty(i)) {
  94414. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  94415. var and = ori.split("&&");
  94416. if (and.length > 1) {
  94417. for (var j = 0; j < and.length; ++j) {
  94418. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  94419. if (andj !== "true" && andj !== "false") {
  94420. if (andj[0] === "!") {
  94421. result = !evaluateCallback(andj.substring(1));
  94422. }
  94423. else {
  94424. result = evaluateCallback(andj);
  94425. }
  94426. }
  94427. else {
  94428. result = andj === "true" ? true : false;
  94429. }
  94430. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  94431. ori = "false";
  94432. break;
  94433. }
  94434. }
  94435. }
  94436. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  94437. result = true;
  94438. break;
  94439. }
  94440. // result equals false (or undefined)
  94441. if (ori !== "true" && ori !== "false") {
  94442. if (ori[0] === "!") {
  94443. result = !evaluateCallback(ori.substring(1));
  94444. }
  94445. else {
  94446. result = evaluateCallback(ori);
  94447. }
  94448. }
  94449. else {
  94450. result = ori === "true" ? true : false;
  94451. }
  94452. }
  94453. }
  94454. // the whole parenthesis scope is replaced by 'true' or 'false'
  94455. return result ? "true" : "false";
  94456. };
  94457. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  94458. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  94459. // remove whitespaces
  94460. r = r.replace(/[\s]/g, function () { return ""; });
  94461. return r.length % 2 ? "!" : "";
  94462. });
  94463. booleanString = booleanString.trim();
  94464. if (booleanString === "!true") {
  94465. booleanString = "false";
  94466. }
  94467. else if (booleanString === "!false") {
  94468. booleanString = "true";
  94469. }
  94470. return booleanString;
  94471. };
  94472. return AndOrNotEvaluator;
  94473. }());
  94474. /***/ }),
  94475. /***/ "./Misc/arrayTools.ts":
  94476. /*!****************************!*\
  94477. !*** ./Misc/arrayTools.ts ***!
  94478. \****************************/
  94479. /*! exports provided: ArrayTools */
  94480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94481. "use strict";
  94482. __webpack_require__.r(__webpack_exports__);
  94483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  94484. /**
  94485. * Class containing a set of static utilities functions for arrays.
  94486. */
  94487. var ArrayTools = /** @class */ (function () {
  94488. function ArrayTools() {
  94489. }
  94490. /**
  94491. * Returns an array of the given size filled with element built from the given constructor and the paramters
  94492. * @param size the number of element to construct and put in the array
  94493. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  94494. * @returns a new array filled with new objects
  94495. */
  94496. ArrayTools.BuildArray = function (size, itemBuilder) {
  94497. var a = [];
  94498. for (var i = 0; i < size; ++i) {
  94499. a.push(itemBuilder());
  94500. }
  94501. return a;
  94502. };
  94503. return ArrayTools;
  94504. }());
  94505. /***/ }),
  94506. /***/ "./Misc/assetsManager.ts":
  94507. /*!*******************************!*\
  94508. !*** ./Misc/assetsManager.ts ***!
  94509. \*******************************/
  94510. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  94511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94512. "use strict";
  94513. __webpack_require__.r(__webpack_exports__);
  94514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  94515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  94516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  94517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  94518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  94519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  94520. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  94521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  94522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  94523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  94524. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  94525. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94526. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  94527. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94528. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94529. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  94530. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  94531. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  94532. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94533. /**
  94534. * Defines the list of states available for a task inside a AssetsManager
  94535. */
  94536. var AssetTaskState;
  94537. (function (AssetTaskState) {
  94538. /**
  94539. * Initialization
  94540. */
  94541. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  94542. /**
  94543. * Running
  94544. */
  94545. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  94546. /**
  94547. * Done
  94548. */
  94549. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  94550. /**
  94551. * Error
  94552. */
  94553. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  94554. })(AssetTaskState || (AssetTaskState = {}));
  94555. /**
  94556. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  94557. */
  94558. var AbstractAssetTask = /** @class */ (function () {
  94559. /**
  94560. * Creates a new AssetsManager
  94561. * @param name defines the name of the task
  94562. */
  94563. function AbstractAssetTask(
  94564. /**
  94565. * Task name
  94566. */ name) {
  94567. this.name = name;
  94568. this._isCompleted = false;
  94569. this._taskState = AssetTaskState.INIT;
  94570. }
  94571. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  94572. /**
  94573. * Get if the task is completed
  94574. */
  94575. get: function () {
  94576. return this._isCompleted;
  94577. },
  94578. enumerable: true,
  94579. configurable: true
  94580. });
  94581. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  94582. /**
  94583. * Gets the current state of the task
  94584. */
  94585. get: function () {
  94586. return this._taskState;
  94587. },
  94588. enumerable: true,
  94589. configurable: true
  94590. });
  94591. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  94592. /**
  94593. * Gets the current error object (if task is in error)
  94594. */
  94595. get: function () {
  94596. return this._errorObject;
  94597. },
  94598. enumerable: true,
  94599. configurable: true
  94600. });
  94601. /**
  94602. * Internal only
  94603. * @hidden
  94604. */
  94605. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  94606. if (this._errorObject) {
  94607. return;
  94608. }
  94609. this._errorObject = {
  94610. message: message,
  94611. exception: exception
  94612. };
  94613. };
  94614. /**
  94615. * Execute the current task
  94616. * @param scene defines the scene where you want your assets to be loaded
  94617. * @param onSuccess is a callback called when the task is successfully executed
  94618. * @param onError is a callback called if an error occurs
  94619. */
  94620. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  94621. var _this = this;
  94622. this._taskState = AssetTaskState.RUNNING;
  94623. this.runTask(scene, function () {
  94624. _this.onDoneCallback(onSuccess, onError);
  94625. }, function (msg, exception) {
  94626. _this.onErrorCallback(onError, msg, exception);
  94627. });
  94628. };
  94629. /**
  94630. * Execute the current task
  94631. * @param scene defines the scene where you want your assets to be loaded
  94632. * @param onSuccess is a callback called when the task is successfully executed
  94633. * @param onError is a callback called if an error occurs
  94634. */
  94635. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94636. throw new Error("runTask is not implemented");
  94637. };
  94638. /**
  94639. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  94640. * This can be used with failed tasks that have the reason for failure fixed.
  94641. */
  94642. AbstractAssetTask.prototype.reset = function () {
  94643. this._taskState = AssetTaskState.INIT;
  94644. };
  94645. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  94646. this._taskState = AssetTaskState.ERROR;
  94647. this._errorObject = {
  94648. message: message,
  94649. exception: exception
  94650. };
  94651. if (this.onError) {
  94652. this.onError(this, message, exception);
  94653. }
  94654. onError();
  94655. };
  94656. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  94657. try {
  94658. this._taskState = AssetTaskState.DONE;
  94659. this._isCompleted = true;
  94660. if (this.onSuccess) {
  94661. this.onSuccess(this);
  94662. }
  94663. onSuccess();
  94664. }
  94665. catch (e) {
  94666. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  94667. }
  94668. };
  94669. return AbstractAssetTask;
  94670. }());
  94671. /**
  94672. * Class used to share progress information about assets loading
  94673. */
  94674. var AssetsProgressEvent = /** @class */ (function () {
  94675. /**
  94676. * Creates a AssetsProgressEvent
  94677. * @param remainingCount defines the number of remaining tasks to process
  94678. * @param totalCount defines the total number of tasks
  94679. * @param task defines the task that was just processed
  94680. */
  94681. function AssetsProgressEvent(remainingCount, totalCount, task) {
  94682. this.remainingCount = remainingCount;
  94683. this.totalCount = totalCount;
  94684. this.task = task;
  94685. }
  94686. return AssetsProgressEvent;
  94687. }());
  94688. /**
  94689. * Define a task used by AssetsManager to load meshes
  94690. */
  94691. var MeshAssetTask = /** @class */ (function (_super) {
  94692. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  94693. /**
  94694. * Creates a new MeshAssetTask
  94695. * @param name defines the name of the task
  94696. * @param meshesNames defines the list of mesh's names you want to load
  94697. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  94698. * @param sceneFilename defines the filename of the scene to load from
  94699. */
  94700. function MeshAssetTask(
  94701. /**
  94702. * Defines the name of the task
  94703. */
  94704. name,
  94705. /**
  94706. * Defines the list of mesh's names you want to load
  94707. */
  94708. meshesNames,
  94709. /**
  94710. * Defines the root url to use as a base to load your meshes and associated resources
  94711. */
  94712. rootUrl,
  94713. /**
  94714. * Defines the filename of the scene to load from
  94715. */
  94716. sceneFilename) {
  94717. var _this = _super.call(this, name) || this;
  94718. _this.name = name;
  94719. _this.meshesNames = meshesNames;
  94720. _this.rootUrl = rootUrl;
  94721. _this.sceneFilename = sceneFilename;
  94722. return _this;
  94723. }
  94724. /**
  94725. * Execute the current task
  94726. * @param scene defines the scene where you want your assets to be loaded
  94727. * @param onSuccess is a callback called when the task is successfully executed
  94728. * @param onError is a callback called if an error occurs
  94729. */
  94730. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94731. var _this = this;
  94732. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  94733. _this.loadedMeshes = meshes;
  94734. _this.loadedParticleSystems = particleSystems;
  94735. _this.loadedSkeletons = skeletons;
  94736. _this.loadedAnimationGroups = animationGroups;
  94737. onSuccess();
  94738. }, null, function (scene, message, exception) {
  94739. onError(message, exception);
  94740. });
  94741. };
  94742. return MeshAssetTask;
  94743. }(AbstractAssetTask));
  94744. /**
  94745. * Define a task used by AssetsManager to load text content
  94746. */
  94747. var TextFileAssetTask = /** @class */ (function (_super) {
  94748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  94749. /**
  94750. * Creates a new TextFileAssetTask object
  94751. * @param name defines the name of the task
  94752. * @param url defines the location of the file to load
  94753. */
  94754. function TextFileAssetTask(
  94755. /**
  94756. * Defines the name of the task
  94757. */
  94758. name,
  94759. /**
  94760. * Defines the location of the file to load
  94761. */
  94762. url) {
  94763. var _this = _super.call(this, name) || this;
  94764. _this.name = name;
  94765. _this.url = url;
  94766. return _this;
  94767. }
  94768. /**
  94769. * Execute the current task
  94770. * @param scene defines the scene where you want your assets to be loaded
  94771. * @param onSuccess is a callback called when the task is successfully executed
  94772. * @param onError is a callback called if an error occurs
  94773. */
  94774. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94775. var _this = this;
  94776. scene._loadFile(this.url, function (data) {
  94777. _this.text = data;
  94778. onSuccess();
  94779. }, undefined, false, false, function (request, exception) {
  94780. if (request) {
  94781. onError(request.status + " " + request.statusText, exception);
  94782. }
  94783. });
  94784. };
  94785. return TextFileAssetTask;
  94786. }(AbstractAssetTask));
  94787. /**
  94788. * Define a task used by AssetsManager to load binary data
  94789. */
  94790. var BinaryFileAssetTask = /** @class */ (function (_super) {
  94791. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  94792. /**
  94793. * Creates a new BinaryFileAssetTask object
  94794. * @param name defines the name of the new task
  94795. * @param url defines the location of the file to load
  94796. */
  94797. function BinaryFileAssetTask(
  94798. /**
  94799. * Defines the name of the task
  94800. */
  94801. name,
  94802. /**
  94803. * Defines the location of the file to load
  94804. */
  94805. url) {
  94806. var _this = _super.call(this, name) || this;
  94807. _this.name = name;
  94808. _this.url = url;
  94809. return _this;
  94810. }
  94811. /**
  94812. * Execute the current task
  94813. * @param scene defines the scene where you want your assets to be loaded
  94814. * @param onSuccess is a callback called when the task is successfully executed
  94815. * @param onError is a callback called if an error occurs
  94816. */
  94817. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94818. var _this = this;
  94819. scene._loadFile(this.url, function (data) {
  94820. _this.data = data;
  94821. onSuccess();
  94822. }, undefined, true, true, function (request, exception) {
  94823. if (request) {
  94824. onError(request.status + " " + request.statusText, exception);
  94825. }
  94826. });
  94827. };
  94828. return BinaryFileAssetTask;
  94829. }(AbstractAssetTask));
  94830. /**
  94831. * Define a task used by AssetsManager to load images
  94832. */
  94833. var ImageAssetTask = /** @class */ (function (_super) {
  94834. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  94835. /**
  94836. * Creates a new ImageAssetTask
  94837. * @param name defines the name of the task
  94838. * @param url defines the location of the image to load
  94839. */
  94840. function ImageAssetTask(
  94841. /**
  94842. * Defines the name of the task
  94843. */
  94844. name,
  94845. /**
  94846. * Defines the location of the image to load
  94847. */
  94848. url) {
  94849. var _this = _super.call(this, name) || this;
  94850. _this.name = name;
  94851. _this.url = url;
  94852. return _this;
  94853. }
  94854. /**
  94855. * Execute the current task
  94856. * @param scene defines the scene where you want your assets to be loaded
  94857. * @param onSuccess is a callback called when the task is successfully executed
  94858. * @param onError is a callback called if an error occurs
  94859. */
  94860. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94861. var _this = this;
  94862. var img = new Image();
  94863. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  94864. img.onload = function () {
  94865. _this.image = img;
  94866. onSuccess();
  94867. };
  94868. img.onerror = function (err) {
  94869. onError("Error loading image", err);
  94870. };
  94871. img.src = this.url;
  94872. };
  94873. return ImageAssetTask;
  94874. }(AbstractAssetTask));
  94875. /**
  94876. * Define a task used by AssetsManager to load 2D textures
  94877. */
  94878. var TextureAssetTask = /** @class */ (function (_super) {
  94879. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  94880. /**
  94881. * Creates a new TextureAssetTask object
  94882. * @param name defines the name of the task
  94883. * @param url defines the location of the file to load
  94884. * @param noMipmap defines if mipmap should not be generated (default is false)
  94885. * @param invertY defines if texture must be inverted on Y axis (default is false)
  94886. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94887. */
  94888. function TextureAssetTask(
  94889. /**
  94890. * Defines the name of the task
  94891. */
  94892. name,
  94893. /**
  94894. * Defines the location of the file to load
  94895. */
  94896. url,
  94897. /**
  94898. * Defines if mipmap should not be generated (default is false)
  94899. */
  94900. noMipmap,
  94901. /**
  94902. * Defines if texture must be inverted on Y axis (default is false)
  94903. */
  94904. invertY,
  94905. /**
  94906. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94907. */
  94908. samplingMode) {
  94909. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  94910. var _this = _super.call(this, name) || this;
  94911. _this.name = name;
  94912. _this.url = url;
  94913. _this.noMipmap = noMipmap;
  94914. _this.invertY = invertY;
  94915. _this.samplingMode = samplingMode;
  94916. return _this;
  94917. }
  94918. /**
  94919. * Execute the current task
  94920. * @param scene defines the scene where you want your assets to be loaded
  94921. * @param onSuccess is a callback called when the task is successfully executed
  94922. * @param onError is a callback called if an error occurs
  94923. */
  94924. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94925. var onload = function () {
  94926. onSuccess();
  94927. };
  94928. var onerror = function (message, exception) {
  94929. onError(message, exception);
  94930. };
  94931. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  94932. };
  94933. return TextureAssetTask;
  94934. }(AbstractAssetTask));
  94935. /**
  94936. * Define a task used by AssetsManager to load cube textures
  94937. */
  94938. var CubeTextureAssetTask = /** @class */ (function (_super) {
  94939. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  94940. /**
  94941. * Creates a new CubeTextureAssetTask
  94942. * @param name defines the name of the task
  94943. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  94944. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  94945. * @param noMipmap defines if mipmaps should not be generated (default is false)
  94946. * @param files defines the explicit list of files (undefined by default)
  94947. */
  94948. function CubeTextureAssetTask(
  94949. /**
  94950. * Defines the name of the task
  94951. */
  94952. name,
  94953. /**
  94954. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  94955. */
  94956. url,
  94957. /**
  94958. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  94959. */
  94960. extensions,
  94961. /**
  94962. * Defines if mipmaps should not be generated (default is false)
  94963. */
  94964. noMipmap,
  94965. /**
  94966. * Defines the explicit list of files (undefined by default)
  94967. */
  94968. files) {
  94969. var _this = _super.call(this, name) || this;
  94970. _this.name = name;
  94971. _this.url = url;
  94972. _this.extensions = extensions;
  94973. _this.noMipmap = noMipmap;
  94974. _this.files = files;
  94975. return _this;
  94976. }
  94977. /**
  94978. * Execute the current task
  94979. * @param scene defines the scene where you want your assets to be loaded
  94980. * @param onSuccess is a callback called when the task is successfully executed
  94981. * @param onError is a callback called if an error occurs
  94982. */
  94983. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94984. var onload = function () {
  94985. onSuccess();
  94986. };
  94987. var onerror = function (message, exception) {
  94988. onError(message, exception);
  94989. };
  94990. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  94991. };
  94992. return CubeTextureAssetTask;
  94993. }(AbstractAssetTask));
  94994. /**
  94995. * Define a task used by AssetsManager to load HDR cube textures
  94996. */
  94997. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  94998. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  94999. /**
  95000. * Creates a new HDRCubeTextureAssetTask object
  95001. * @param name defines the name of the task
  95002. * @param url defines the location of the file to load
  95003. * @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.
  95004. * @param noMipmap defines if mipmaps should not be generated (default is false)
  95005. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  95006. * @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)
  95007. * @param reserved Internal use only
  95008. */
  95009. function HDRCubeTextureAssetTask(
  95010. /**
  95011. * Defines the name of the task
  95012. */
  95013. name,
  95014. /**
  95015. * Defines the location of the file to load
  95016. */
  95017. url,
  95018. /**
  95019. * Defines the desired size (the more it increases the longer the generation will be)
  95020. */
  95021. size,
  95022. /**
  95023. * Defines if mipmaps should not be generated (default is false)
  95024. */
  95025. noMipmap,
  95026. /**
  95027. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  95028. */
  95029. generateHarmonics,
  95030. /**
  95031. * 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)
  95032. */
  95033. gammaSpace,
  95034. /**
  95035. * Internal Use Only
  95036. */
  95037. reserved) {
  95038. if (noMipmap === void 0) { noMipmap = false; }
  95039. if (generateHarmonics === void 0) { generateHarmonics = true; }
  95040. if (gammaSpace === void 0) { gammaSpace = false; }
  95041. if (reserved === void 0) { reserved = false; }
  95042. var _this = _super.call(this, name) || this;
  95043. _this.name = name;
  95044. _this.url = url;
  95045. _this.size = size;
  95046. _this.noMipmap = noMipmap;
  95047. _this.generateHarmonics = generateHarmonics;
  95048. _this.gammaSpace = gammaSpace;
  95049. _this.reserved = reserved;
  95050. return _this;
  95051. }
  95052. /**
  95053. * Execute the current task
  95054. * @param scene defines the scene where you want your assets to be loaded
  95055. * @param onSuccess is a callback called when the task is successfully executed
  95056. * @param onError is a callback called if an error occurs
  95057. */
  95058. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  95059. var onload = function () {
  95060. onSuccess();
  95061. };
  95062. var onerror = function (message, exception) {
  95063. onError(message, exception);
  95064. };
  95065. 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);
  95066. };
  95067. return HDRCubeTextureAssetTask;
  95068. }(AbstractAssetTask));
  95069. /**
  95070. * This class can be used to easily import assets into a scene
  95071. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  95072. */
  95073. var AssetsManager = /** @class */ (function () {
  95074. /**
  95075. * Creates a new AssetsManager
  95076. * @param scene defines the scene to work on
  95077. */
  95078. function AssetsManager(scene) {
  95079. this._isLoading = false;
  95080. this._tasks = new Array();
  95081. this._waitingTasksCount = 0;
  95082. this._totalTasksCount = 0;
  95083. /**
  95084. * Observable called when all tasks are processed
  95085. */
  95086. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95087. /**
  95088. * Observable called when a task had an error
  95089. */
  95090. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95091. /**
  95092. * Observable called when all tasks were executed
  95093. */
  95094. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95095. /**
  95096. * Observable called when a task is done (whatever the result is)
  95097. */
  95098. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95099. /**
  95100. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  95101. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95102. */
  95103. this.useDefaultLoadingScreen = true;
  95104. this._scene = scene;
  95105. }
  95106. /**
  95107. * Add a MeshAssetTask to the list of active tasks
  95108. * @param taskName defines the name of the new task
  95109. * @param meshesNames defines the name of meshes to load
  95110. * @param rootUrl defines the root url to use to locate files
  95111. * @param sceneFilename defines the filename of the scene file
  95112. * @returns a new MeshAssetTask object
  95113. */
  95114. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  95115. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  95116. this._tasks.push(task);
  95117. return task;
  95118. };
  95119. /**
  95120. * Add a TextFileAssetTask to the list of active tasks
  95121. * @param taskName defines the name of the new task
  95122. * @param url defines the url of the file to load
  95123. * @returns a new TextFileAssetTask object
  95124. */
  95125. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  95126. var task = new TextFileAssetTask(taskName, url);
  95127. this._tasks.push(task);
  95128. return task;
  95129. };
  95130. /**
  95131. * Add a BinaryFileAssetTask to the list of active tasks
  95132. * @param taskName defines the name of the new task
  95133. * @param url defines the url of the file to load
  95134. * @returns a new BinaryFileAssetTask object
  95135. */
  95136. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  95137. var task = new BinaryFileAssetTask(taskName, url);
  95138. this._tasks.push(task);
  95139. return task;
  95140. };
  95141. /**
  95142. * Add a ImageAssetTask to the list of active tasks
  95143. * @param taskName defines the name of the new task
  95144. * @param url defines the url of the file to load
  95145. * @returns a new ImageAssetTask object
  95146. */
  95147. AssetsManager.prototype.addImageTask = function (taskName, url) {
  95148. var task = new ImageAssetTask(taskName, url);
  95149. this._tasks.push(task);
  95150. return task;
  95151. };
  95152. /**
  95153. * Add a TextureAssetTask to the list of active tasks
  95154. * @param taskName defines the name of the new task
  95155. * @param url defines the url of the file to load
  95156. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95157. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  95158. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  95159. * @returns a new TextureAssetTask object
  95160. */
  95161. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  95162. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  95163. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  95164. this._tasks.push(task);
  95165. return task;
  95166. };
  95167. /**
  95168. * Add a CubeTextureAssetTask to the list of active tasks
  95169. * @param taskName defines the name of the new task
  95170. * @param url defines the url of the file to load
  95171. * @param extensions defines the extension to use to load the cube map (can be null)
  95172. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95173. * @param files defines the list of files to load (can be null)
  95174. * @returns a new CubeTextureAssetTask object
  95175. */
  95176. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  95177. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  95178. this._tasks.push(task);
  95179. return task;
  95180. };
  95181. /**
  95182. *
  95183. * Add a HDRCubeTextureAssetTask to the list of active tasks
  95184. * @param taskName defines the name of the new task
  95185. * @param url defines the url of the file to load
  95186. * @param size defines the size you want for the cubemap (can be null)
  95187. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95188. * @param generateHarmonics defines if you want to automatically generate (true by default)
  95189. * @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)
  95190. * @param reserved Internal use only
  95191. * @returns a new HDRCubeTextureAssetTask object
  95192. */
  95193. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  95194. if (noMipmap === void 0) { noMipmap = false; }
  95195. if (generateHarmonics === void 0) { generateHarmonics = true; }
  95196. if (gammaSpace === void 0) { gammaSpace = false; }
  95197. if (reserved === void 0) { reserved = false; }
  95198. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  95199. this._tasks.push(task);
  95200. return task;
  95201. };
  95202. /**
  95203. * Remove a task from the assets manager.
  95204. * @param task the task to remove
  95205. */
  95206. AssetsManager.prototype.removeTask = function (task) {
  95207. var index = this._tasks.indexOf(task);
  95208. if (index > -1) {
  95209. this._tasks.splice(index, 1);
  95210. }
  95211. };
  95212. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  95213. this._waitingTasksCount--;
  95214. try {
  95215. if (this.onProgress) {
  95216. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  95217. }
  95218. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  95219. }
  95220. catch (e) {
  95221. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  95222. console.log(e);
  95223. }
  95224. if (this._waitingTasksCount === 0) {
  95225. try {
  95226. if (this.onFinish) {
  95227. this.onFinish(this._tasks);
  95228. }
  95229. // Let's remove successfull tasks
  95230. var currentTasks = this._tasks.slice();
  95231. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  95232. var task = currentTasks_1[_i];
  95233. if (task.taskState === AssetTaskState.DONE) {
  95234. var index = this._tasks.indexOf(task);
  95235. if (index > -1) {
  95236. this._tasks.splice(index, 1);
  95237. }
  95238. }
  95239. }
  95240. this.onTasksDoneObservable.notifyObservers(this._tasks);
  95241. }
  95242. catch (e) {
  95243. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  95244. console.log(e);
  95245. }
  95246. this._isLoading = false;
  95247. this._scene.getEngine().hideLoadingUI();
  95248. }
  95249. };
  95250. AssetsManager.prototype._runTask = function (task) {
  95251. var _this = this;
  95252. var done = function () {
  95253. try {
  95254. if (_this.onTaskSuccess) {
  95255. _this.onTaskSuccess(task);
  95256. }
  95257. _this.onTaskSuccessObservable.notifyObservers(task);
  95258. _this._decreaseWaitingTasksCount(task);
  95259. }
  95260. catch (e) {
  95261. error("Error executing task success callbacks", e);
  95262. }
  95263. };
  95264. var error = function (message, exception) {
  95265. task._setErrorObject(message, exception);
  95266. if (_this.onTaskError) {
  95267. _this.onTaskError(task);
  95268. }
  95269. _this.onTaskErrorObservable.notifyObservers(task);
  95270. _this._decreaseWaitingTasksCount(task);
  95271. };
  95272. task.run(this._scene, done, error);
  95273. };
  95274. /**
  95275. * Reset the AssetsManager and remove all tasks
  95276. * @return the current instance of the AssetsManager
  95277. */
  95278. AssetsManager.prototype.reset = function () {
  95279. this._isLoading = false;
  95280. this._tasks = new Array();
  95281. return this;
  95282. };
  95283. /**
  95284. * Start the loading process
  95285. * @return the current instance of the AssetsManager
  95286. */
  95287. AssetsManager.prototype.load = function () {
  95288. if (this._isLoading) {
  95289. return this;
  95290. }
  95291. this._isLoading = true;
  95292. this._waitingTasksCount = this._tasks.length;
  95293. this._totalTasksCount = this._tasks.length;
  95294. if (this._waitingTasksCount === 0) {
  95295. this._isLoading = false;
  95296. if (this.onFinish) {
  95297. this.onFinish(this._tasks);
  95298. }
  95299. this.onTasksDoneObservable.notifyObservers(this._tasks);
  95300. return this;
  95301. }
  95302. if (this.useDefaultLoadingScreen) {
  95303. this._scene.getEngine().displayLoadingUI();
  95304. }
  95305. for (var index = 0; index < this._tasks.length; index++) {
  95306. var task = this._tasks[index];
  95307. if (task.taskState === AssetTaskState.INIT) {
  95308. this._runTask(task);
  95309. }
  95310. }
  95311. return this;
  95312. };
  95313. /**
  95314. * Start the loading process as an async operation
  95315. * @return a promise returning the list of failed tasks
  95316. */
  95317. AssetsManager.prototype.loadAsync = function () {
  95318. var _this = this;
  95319. return new Promise(function (resolve, reject) {
  95320. _this.onTasksDoneObservable.addOnce(function (remainingTasks) {
  95321. if (remainingTasks && remainingTasks.length) {
  95322. reject(remainingTasks);
  95323. }
  95324. else {
  95325. resolve();
  95326. }
  95327. });
  95328. });
  95329. };
  95330. return AssetsManager;
  95331. }());
  95332. /***/ }),
  95333. /***/ "./Misc/dds.ts":
  95334. /*!*********************!*\
  95335. !*** ./Misc/dds.ts ***!
  95336. \*********************/
  95337. /*! exports provided: DDSTools */
  95338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95339. "use strict";
  95340. __webpack_require__.r(__webpack_exports__);
  95341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  95342. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  95343. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  95344. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95345. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  95346. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  95347. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95348. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  95349. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  95350. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  95351. // All values and structures referenced from:
  95352. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  95353. var DDS_MAGIC = 0x20534444;
  95354. var
  95355. //DDSD_CAPS = 0x1,
  95356. //DDSD_HEIGHT = 0x2,
  95357. //DDSD_WIDTH = 0x4,
  95358. //DDSD_PITCH = 0x8,
  95359. //DDSD_PIXELFORMAT = 0x1000,
  95360. DDSD_MIPMAPCOUNT = 0x20000;
  95361. //DDSD_LINEARSIZE = 0x80000,
  95362. //DDSD_DEPTH = 0x800000;
  95363. // var DDSCAPS_COMPLEX = 0x8,
  95364. // DDSCAPS_MIPMAP = 0x400000,
  95365. // DDSCAPS_TEXTURE = 0x1000;
  95366. var DDSCAPS2_CUBEMAP = 0x200;
  95367. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  95368. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  95369. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  95370. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  95371. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  95372. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  95373. // DDSCAPS2_VOLUME = 0x200000;
  95374. var
  95375. //DDPF_ALPHAPIXELS = 0x1,
  95376. //DDPF_ALPHA = 0x2,
  95377. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  95378. //DDPF_YUV = 0x200,
  95379. DDPF_LUMINANCE = 0x20000;
  95380. function FourCCToInt32(value) {
  95381. return value.charCodeAt(0) +
  95382. (value.charCodeAt(1) << 8) +
  95383. (value.charCodeAt(2) << 16) +
  95384. (value.charCodeAt(3) << 24);
  95385. }
  95386. function Int32ToFourCC(value) {
  95387. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  95388. }
  95389. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  95390. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  95391. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  95392. var FOURCC_DX10 = FourCCToInt32("DX10");
  95393. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  95394. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  95395. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  95396. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  95397. var headerLengthInt = 31; // The header length in 32 bit ints
  95398. // Offsets into the header array
  95399. var off_magic = 0;
  95400. var off_size = 1;
  95401. var off_flags = 2;
  95402. var off_height = 3;
  95403. var off_width = 4;
  95404. var off_mipmapCount = 7;
  95405. var off_pfFlags = 20;
  95406. var off_pfFourCC = 21;
  95407. var off_RGBbpp = 22;
  95408. var off_RMask = 23;
  95409. var off_GMask = 24;
  95410. var off_BMask = 25;
  95411. var off_AMask = 26;
  95412. // var off_caps1 = 27;
  95413. var off_caps2 = 28;
  95414. // var off_caps3 = 29;
  95415. // var off_caps4 = 30;
  95416. var off_dxgiFormat = 32;
  95417. /**
  95418. * Class used to provide DDS decompression tools
  95419. */
  95420. var DDSTools = /** @class */ (function () {
  95421. function DDSTools() {
  95422. }
  95423. /**
  95424. * Gets DDS information from an array buffer
  95425. * @param arrayBuffer defines the array buffer to read data from
  95426. * @returns the DDS information
  95427. */
  95428. DDSTools.GetDDSInfo = function (arrayBuffer) {
  95429. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  95430. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  95431. var mipmapCount = 1;
  95432. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  95433. mipmapCount = Math.max(1, header[off_mipmapCount]);
  95434. }
  95435. var fourCC = header[off_pfFourCC];
  95436. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  95437. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95438. switch (fourCC) {
  95439. case FOURCC_D3DFMT_R16G16B16A16F:
  95440. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95441. break;
  95442. case FOURCC_D3DFMT_R32G32B32A32F:
  95443. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  95444. break;
  95445. case FOURCC_DX10:
  95446. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  95447. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95448. break;
  95449. }
  95450. }
  95451. return {
  95452. width: header[off_width],
  95453. height: header[off_height],
  95454. mipmapCount: mipmapCount,
  95455. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  95456. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  95457. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  95458. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  95459. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  95460. dxgiFormat: dxgiFormat,
  95461. textureType: textureType
  95462. };
  95463. };
  95464. DDSTools._ToHalfFloat = function (value) {
  95465. if (!DDSTools._FloatView) {
  95466. DDSTools._FloatView = new Float32Array(1);
  95467. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  95468. }
  95469. DDSTools._FloatView[0] = value;
  95470. var x = DDSTools._Int32View[0];
  95471. var bits = (x >> 16) & 0x8000; /* Get the sign */
  95472. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  95473. var e = (x >> 23) & 0xff; /* Using int is faster here */
  95474. /* If zero, or denormal, or exponent underflows too much for a denormal
  95475. * half, return signed zero. */
  95476. if (e < 103) {
  95477. return bits;
  95478. }
  95479. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  95480. if (e > 142) {
  95481. bits |= 0x7c00;
  95482. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  95483. * not Inf, so make sure we set one mantissa bit too. */
  95484. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  95485. return bits;
  95486. }
  95487. /* If exponent underflows but not too much, return a denormal */
  95488. if (e < 113) {
  95489. m |= 0x0800;
  95490. /* Extra rounding may overflow and set mantissa to 0 and exponent
  95491. * to 1, which is OK. */
  95492. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  95493. return bits;
  95494. }
  95495. bits |= ((e - 112) << 10) | (m >> 1);
  95496. bits += m & 1;
  95497. return bits;
  95498. };
  95499. DDSTools._FromHalfFloat = function (value) {
  95500. var s = (value & 0x8000) >> 15;
  95501. var e = (value & 0x7C00) >> 10;
  95502. var f = value & 0x03FF;
  95503. if (e === 0) {
  95504. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  95505. }
  95506. else if (e == 0x1F) {
  95507. return f ? NaN : ((s ? -1 : 1) * Infinity);
  95508. }
  95509. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  95510. };
  95511. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95512. var destArray = new Float32Array(dataLength);
  95513. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  95514. var index = 0;
  95515. for (var y = 0; y < height; y++) {
  95516. for (var x = 0; x < width; x++) {
  95517. var srcPos = (x + y * width) * 4;
  95518. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  95519. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  95520. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  95521. if (DDSTools.StoreLODInAlphaChannel) {
  95522. destArray[index + 3] = lod;
  95523. }
  95524. else {
  95525. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  95526. }
  95527. index += 4;
  95528. }
  95529. }
  95530. return destArray;
  95531. };
  95532. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95533. if (DDSTools.StoreLODInAlphaChannel) {
  95534. var destArray = new Uint16Array(dataLength);
  95535. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  95536. var index = 0;
  95537. for (var y = 0; y < height; y++) {
  95538. for (var x = 0; x < width; x++) {
  95539. var srcPos = (x + y * width) * 4;
  95540. destArray[index] = srcData[srcPos];
  95541. destArray[index + 1] = srcData[srcPos + 1];
  95542. destArray[index + 2] = srcData[srcPos + 2];
  95543. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  95544. index += 4;
  95545. }
  95546. }
  95547. return destArray;
  95548. }
  95549. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  95550. };
  95551. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95552. if (DDSTools.StoreLODInAlphaChannel) {
  95553. var destArray = new Float32Array(dataLength);
  95554. var srcData = new Float32Array(arrayBuffer, dataOffset);
  95555. var index = 0;
  95556. for (var y = 0; y < height; y++) {
  95557. for (var x = 0; x < width; x++) {
  95558. var srcPos = (x + y * width) * 4;
  95559. destArray[index] = srcData[srcPos];
  95560. destArray[index + 1] = srcData[srcPos + 1];
  95561. destArray[index + 2] = srcData[srcPos + 2];
  95562. destArray[index + 3] = lod;
  95563. index += 4;
  95564. }
  95565. }
  95566. return destArray;
  95567. }
  95568. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  95569. };
  95570. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95571. var destArray = new Uint8Array(dataLength);
  95572. var srcData = new Float32Array(arrayBuffer, dataOffset);
  95573. var index = 0;
  95574. for (var y = 0; y < height; y++) {
  95575. for (var x = 0; x < width; x++) {
  95576. var srcPos = (x + y * width) * 4;
  95577. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  95578. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  95579. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  95580. if (DDSTools.StoreLODInAlphaChannel) {
  95581. destArray[index + 3] = lod;
  95582. }
  95583. else {
  95584. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  95585. }
  95586. index += 4;
  95587. }
  95588. }
  95589. return destArray;
  95590. };
  95591. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95592. var destArray = new Uint8Array(dataLength);
  95593. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  95594. var index = 0;
  95595. for (var y = 0; y < height; y++) {
  95596. for (var x = 0; x < width; x++) {
  95597. var srcPos = (x + y * width) * 4;
  95598. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  95599. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  95600. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  95601. if (DDSTools.StoreLODInAlphaChannel) {
  95602. destArray[index + 3] = lod;
  95603. }
  95604. else {
  95605. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  95606. }
  95607. index += 4;
  95608. }
  95609. }
  95610. return destArray;
  95611. };
  95612. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  95613. var byteArray = new Uint8Array(dataLength);
  95614. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  95615. var index = 0;
  95616. for (var y = 0; y < height; y++) {
  95617. for (var x = 0; x < width; x++) {
  95618. var srcPos = (x + y * width) * 4;
  95619. byteArray[index] = srcData[srcPos + rOffset];
  95620. byteArray[index + 1] = srcData[srcPos + gOffset];
  95621. byteArray[index + 2] = srcData[srcPos + bOffset];
  95622. byteArray[index + 3] = srcData[srcPos + aOffset];
  95623. index += 4;
  95624. }
  95625. }
  95626. return byteArray;
  95627. };
  95628. DDSTools._ExtractLongWordOrder = function (value) {
  95629. if (value === 0 || value === 255 || value === -16777216) {
  95630. return 0;
  95631. }
  95632. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  95633. };
  95634. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  95635. var byteArray = new Uint8Array(dataLength);
  95636. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  95637. var index = 0;
  95638. for (var y = 0; y < height; y++) {
  95639. for (var x = 0; x < width; x++) {
  95640. var srcPos = (x + y * width) * 3;
  95641. byteArray[index] = srcData[srcPos + rOffset];
  95642. byteArray[index + 1] = srcData[srcPos + gOffset];
  95643. byteArray[index + 2] = srcData[srcPos + bOffset];
  95644. index += 3;
  95645. }
  95646. }
  95647. return byteArray;
  95648. };
  95649. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  95650. var byteArray = new Uint8Array(dataLength);
  95651. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  95652. var index = 0;
  95653. for (var y = 0; y < height; y++) {
  95654. for (var x = 0; x < width; x++) {
  95655. var srcPos = (x + y * width);
  95656. byteArray[index] = srcData[srcPos];
  95657. index++;
  95658. }
  95659. }
  95660. return byteArray;
  95661. };
  95662. /**
  95663. * Uploads DDS Levels to a Babylon Texture
  95664. * @hidden
  95665. */
  95666. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  95667. if (lodIndex === void 0) { lodIndex = -1; }
  95668. var sphericalPolynomialFaces = null;
  95669. if (info.sphericalPolynomial) {
  95670. sphericalPolynomialFaces = new Array();
  95671. }
  95672. var ext = engine.getCaps().s3tc;
  95673. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  95674. var fourCC, width, height, dataLength = 0, dataOffset;
  95675. var byteArray, mipmapCount, mip;
  95676. var internalCompressedFormat = 0;
  95677. var blockBytes = 1;
  95678. if (header[off_magic] !== DDS_MAGIC) {
  95679. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  95680. return;
  95681. }
  95682. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  95683. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  95684. return;
  95685. }
  95686. if (info.isCompressed && !ext) {
  95687. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  95688. return;
  95689. }
  95690. var bpp = header[off_RGBbpp];
  95691. dataOffset = header[off_size] + 4;
  95692. var computeFormats = false;
  95693. if (info.isFourCC) {
  95694. fourCC = header[off_pfFourCC];
  95695. switch (fourCC) {
  95696. case FOURCC_DXT1:
  95697. blockBytes = 8;
  95698. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  95699. break;
  95700. case FOURCC_DXT3:
  95701. blockBytes = 16;
  95702. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  95703. break;
  95704. case FOURCC_DXT5:
  95705. blockBytes = 16;
  95706. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  95707. break;
  95708. case FOURCC_D3DFMT_R16G16B16A16F:
  95709. computeFormats = true;
  95710. break;
  95711. case FOURCC_D3DFMT_R32G32B32A32F:
  95712. computeFormats = true;
  95713. break;
  95714. case FOURCC_DX10:
  95715. // There is an additionnal header so dataOffset need to be changed
  95716. dataOffset += 5 * 4; // 5 uints
  95717. var supported = false;
  95718. switch (info.dxgiFormat) {
  95719. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  95720. computeFormats = true;
  95721. supported = true;
  95722. break;
  95723. case DXGI_FORMAT_B8G8R8X8_UNORM:
  95724. info.isRGB = true;
  95725. info.isFourCC = false;
  95726. bpp = 32;
  95727. supported = true;
  95728. break;
  95729. }
  95730. if (supported) {
  95731. break;
  95732. }
  95733. default:
  95734. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  95735. return;
  95736. }
  95737. }
  95738. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  95739. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  95740. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  95741. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  95742. if (computeFormats) {
  95743. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  95744. }
  95745. mipmapCount = 1;
  95746. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  95747. mipmapCount = Math.max(1, header[off_mipmapCount]);
  95748. }
  95749. for (var face = 0; face < faces; face++) {
  95750. width = header[off_width];
  95751. height = header[off_height];
  95752. for (mip = 0; mip < mipmapCount; ++mip) {
  95753. if (lodIndex === -1 || lodIndex === mip) {
  95754. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  95755. var i = (lodIndex === -1) ? mip : 0;
  95756. if (!info.isCompressed && info.isFourCC) {
  95757. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  95758. dataLength = width * height * 4;
  95759. var floatArray = null;
  95760. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  95761. if (bpp === 128) {
  95762. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95763. if (sphericalPolynomialFaces && i == 0) {
  95764. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  95765. }
  95766. }
  95767. else if (bpp === 64) {
  95768. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95769. if (sphericalPolynomialFaces && i == 0) {
  95770. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  95771. }
  95772. }
  95773. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95774. }
  95775. else {
  95776. if (bpp === 128) {
  95777. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  95778. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95779. if (sphericalPolynomialFaces && i == 0) {
  95780. sphericalPolynomialFaces.push(floatArray);
  95781. }
  95782. }
  95783. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  95784. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  95785. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95786. if (sphericalPolynomialFaces && i == 0) {
  95787. sphericalPolynomialFaces.push(floatArray);
  95788. }
  95789. }
  95790. else { // 64
  95791. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95792. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95793. if (sphericalPolynomialFaces && i == 0) {
  95794. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  95795. }
  95796. }
  95797. }
  95798. if (floatArray) {
  95799. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  95800. }
  95801. }
  95802. else if (info.isRGB) {
  95803. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95804. if (bpp === 24) {
  95805. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  95806. dataLength = width * height * 3;
  95807. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  95808. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  95809. }
  95810. else { // 32
  95811. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  95812. dataLength = width * height * 4;
  95813. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  95814. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  95815. }
  95816. }
  95817. else if (info.isLuminance) {
  95818. var unpackAlignment = engine._getUnpackAlignement();
  95819. var unpaddedRowSize = width;
  95820. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  95821. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  95822. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  95823. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  95824. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95825. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  95826. }
  95827. else {
  95828. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  95829. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  95830. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95831. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  95832. }
  95833. }
  95834. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  95835. width *= 0.5;
  95836. height *= 0.5;
  95837. width = Math.max(1.0, width);
  95838. height = Math.max(1.0, height);
  95839. }
  95840. if (currentFace !== undefined) {
  95841. // Loading a single face
  95842. break;
  95843. }
  95844. }
  95845. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  95846. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  95847. size: header[off_width],
  95848. right: sphericalPolynomialFaces[0],
  95849. left: sphericalPolynomialFaces[1],
  95850. up: sphericalPolynomialFaces[2],
  95851. down: sphericalPolynomialFaces[3],
  95852. front: sphericalPolynomialFaces[4],
  95853. back: sphericalPolynomialFaces[5],
  95854. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  95855. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  95856. gammaSpace: false,
  95857. });
  95858. }
  95859. else {
  95860. info.sphericalPolynomial = undefined;
  95861. }
  95862. };
  95863. /**
  95864. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  95865. */
  95866. DDSTools.StoreLODInAlphaChannel = false;
  95867. return DDSTools;
  95868. }());
  95869. /**
  95870. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  95871. * @param rootUrl defines the url where the file to load is located
  95872. * @param scene defines the current scene
  95873. * @param lodScale defines scale to apply to the mip map selection
  95874. * @param lodOffset defines offset to apply to the mip map selection
  95875. * @param onLoad defines an optional callback raised when the texture is loaded
  95876. * @param onError defines an optional callback raised if there is an issue to load the texture
  95877. * @param format defines the format of the data
  95878. * @param forcedExtension defines the extension to use to pick the right loader
  95879. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  95880. * @returns the cube texture as an InternalTexture
  95881. */
  95882. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  95883. var _this = this;
  95884. if (onLoad === void 0) { onLoad = null; }
  95885. if (onError === void 0) { onError = null; }
  95886. if (forcedExtension === void 0) { forcedExtension = null; }
  95887. if (createPolynomials === void 0) { createPolynomials = true; }
  95888. var callback = function (loadData) {
  95889. if (!loadData) {
  95890. if (onLoad) {
  95891. onLoad(null);
  95892. }
  95893. return;
  95894. }
  95895. var texture = loadData.texture;
  95896. if (!createPolynomials) {
  95897. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  95898. }
  95899. else if (loadData.info.sphericalPolynomial) {
  95900. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  95901. }
  95902. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  95903. if (_this.getCaps().textureLOD) {
  95904. // Do not add extra process if texture lod is supported.
  95905. if (onLoad) {
  95906. onLoad(texture);
  95907. }
  95908. return;
  95909. }
  95910. var mipSlices = 3;
  95911. var gl = _this._gl;
  95912. var width = loadData.width;
  95913. if (!width) {
  95914. return;
  95915. }
  95916. var textures = [];
  95917. for (var i = 0; i < mipSlices; i++) {
  95918. //compute LOD from even spacing in smoothness (matching shader calculation)
  95919. var smoothness = i / (mipSlices - 1);
  95920. var roughness = 1 - smoothness;
  95921. var minLODIndex = lodOffset; // roughness = 0
  95922. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  95923. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  95924. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  95925. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  95926. glTextureFromLod.type = texture.type;
  95927. glTextureFromLod.format = texture.format;
  95928. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  95929. glTextureFromLod.height = glTextureFromLod.width;
  95930. glTextureFromLod.isCube = true;
  95931. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  95932. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  95933. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  95934. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  95935. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  95936. if (loadData.isDDS) {
  95937. var info = loadData.info;
  95938. var data = loadData.data;
  95939. _this._unpackFlipY(info.isCompressed);
  95940. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  95941. }
  95942. else {
  95943. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  95944. }
  95945. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  95946. // Wrap in a base texture for easy binding.
  95947. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  95948. lodTexture.isCube = true;
  95949. lodTexture._texture = glTextureFromLod;
  95950. glTextureFromLod.isReady = true;
  95951. textures.push(lodTexture);
  95952. }
  95953. texture._lodTextureHigh = textures[2];
  95954. texture._lodTextureMid = textures[1];
  95955. texture._lodTextureLow = textures[0];
  95956. if (onLoad) {
  95957. onLoad(texture);
  95958. }
  95959. };
  95960. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  95961. };
  95962. /***/ }),
  95963. /***/ "./Misc/decorators.ts":
  95964. /*!****************************!*\
  95965. !*** ./Misc/decorators.ts ***!
  95966. \****************************/
  95967. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper */
  95968. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95969. "use strict";
  95970. __webpack_require__.r(__webpack_exports__);
  95971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  95972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  95973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  95974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  95975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  95976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  95977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  95978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  95979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  95980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  95981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  95982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  95983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return serializeAsMatrix; });
  95984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  95985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  95986. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  95987. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95988. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  95989. var __decoratorInitialStore = {};
  95990. var __mergedStore = {};
  95991. var _copySource = function (creationFunction, source, instanciate) {
  95992. var destination = creationFunction();
  95993. // Tags
  95994. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  95995. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  95996. }
  95997. var classStore = getMergedStore(destination);
  95998. // Properties
  95999. for (var property in classStore) {
  96000. var propertyDescriptor = classStore[property];
  96001. var sourceProperty = source[property];
  96002. var propertyType = propertyDescriptor.type;
  96003. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  96004. switch (propertyType) {
  96005. case 0: // Value
  96006. case 6: // Mesh reference
  96007. case 11: // Camera reference
  96008. destination[property] = sourceProperty;
  96009. break;
  96010. case 1: // Texture
  96011. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  96012. break;
  96013. case 2: // Color3
  96014. case 3: // FresnelParameters
  96015. case 4: // Vector2
  96016. case 5: // Vector3
  96017. case 7: // Color Curves
  96018. case 10: // Quaternion
  96019. case 12: // Matrix
  96020. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  96021. break;
  96022. }
  96023. }
  96024. }
  96025. return destination;
  96026. };
  96027. function getDirectStore(target) {
  96028. var classKey = target.getClassName();
  96029. if (!__decoratorInitialStore[classKey]) {
  96030. __decoratorInitialStore[classKey] = {};
  96031. }
  96032. return __decoratorInitialStore[classKey];
  96033. }
  96034. /**
  96035. * Return the list of properties flagged as serializable
  96036. * @param target: host object
  96037. */
  96038. function getMergedStore(target) {
  96039. var classKey = target.getClassName();
  96040. if (__mergedStore[classKey]) {
  96041. return __mergedStore[classKey];
  96042. }
  96043. __mergedStore[classKey] = {};
  96044. var store = __mergedStore[classKey];
  96045. var currentTarget = target;
  96046. var currentKey = classKey;
  96047. while (currentKey) {
  96048. var initialStore = __decoratorInitialStore[currentKey];
  96049. for (var property in initialStore) {
  96050. store[property] = initialStore[property];
  96051. }
  96052. var parent_1 = void 0;
  96053. var done = false;
  96054. do {
  96055. parent_1 = Object.getPrototypeOf(currentTarget);
  96056. if (!parent_1.getClassName) {
  96057. done = true;
  96058. break;
  96059. }
  96060. if (parent_1.getClassName() !== currentKey) {
  96061. break;
  96062. }
  96063. currentTarget = parent_1;
  96064. } while (parent_1);
  96065. if (done) {
  96066. break;
  96067. }
  96068. currentKey = parent_1.getClassName();
  96069. currentTarget = parent_1;
  96070. }
  96071. return store;
  96072. }
  96073. function generateSerializableMember(type, sourceName) {
  96074. return function (target, propertyKey) {
  96075. var classStore = getDirectStore(target);
  96076. if (!classStore[propertyKey]) {
  96077. classStore[propertyKey] = { type: type, sourceName: sourceName };
  96078. }
  96079. };
  96080. }
  96081. function generateExpandMember(setCallback, targetKey) {
  96082. if (targetKey === void 0) { targetKey = null; }
  96083. return function (target, propertyKey) {
  96084. var key = targetKey || ("_" + propertyKey);
  96085. Object.defineProperty(target, propertyKey, {
  96086. get: function () {
  96087. return this[key];
  96088. },
  96089. set: function (value) {
  96090. if (this[key] === value) {
  96091. return;
  96092. }
  96093. this[key] = value;
  96094. target[setCallback].apply(this);
  96095. },
  96096. enumerable: true,
  96097. configurable: true
  96098. });
  96099. };
  96100. }
  96101. function expandToProperty(callback, targetKey) {
  96102. if (targetKey === void 0) { targetKey = null; }
  96103. return generateExpandMember(callback, targetKey);
  96104. }
  96105. function serialize(sourceName) {
  96106. return generateSerializableMember(0, sourceName); // value member
  96107. }
  96108. function serializeAsTexture(sourceName) {
  96109. return generateSerializableMember(1, sourceName); // texture member
  96110. }
  96111. function serializeAsColor3(sourceName) {
  96112. return generateSerializableMember(2, sourceName); // color3 member
  96113. }
  96114. function serializeAsFresnelParameters(sourceName) {
  96115. return generateSerializableMember(3, sourceName); // fresnel parameters member
  96116. }
  96117. function serializeAsVector2(sourceName) {
  96118. return generateSerializableMember(4, sourceName); // vector2 member
  96119. }
  96120. function serializeAsVector3(sourceName) {
  96121. return generateSerializableMember(5, sourceName); // vector3 member
  96122. }
  96123. function serializeAsMeshReference(sourceName) {
  96124. return generateSerializableMember(6, sourceName); // mesh reference member
  96125. }
  96126. function serializeAsColorCurves(sourceName) {
  96127. return generateSerializableMember(7, sourceName); // color curves
  96128. }
  96129. function serializeAsColor4(sourceName) {
  96130. return generateSerializableMember(8, sourceName); // color 4
  96131. }
  96132. function serializeAsImageProcessingConfiguration(sourceName) {
  96133. return generateSerializableMember(9, sourceName); // image processing
  96134. }
  96135. function serializeAsQuaternion(sourceName) {
  96136. return generateSerializableMember(10, sourceName); // quaternion member
  96137. }
  96138. function serializeAsMatrix(sourceName) {
  96139. return generateSerializableMember(12, sourceName); // matrix member
  96140. }
  96141. /**
  96142. * Decorator used to define property that can be serialized as reference to a camera
  96143. * @param sourceName defines the name of the property to decorate
  96144. */
  96145. function serializeAsCameraReference(sourceName) {
  96146. return generateSerializableMember(11, sourceName); // camera reference member
  96147. }
  96148. /**
  96149. * Class used to help serialization objects
  96150. */
  96151. var SerializationHelper = /** @class */ (function () {
  96152. function SerializationHelper() {
  96153. }
  96154. /**
  96155. * Appends the serialized animations from the source animations
  96156. * @param source Source containing the animations
  96157. * @param destination Target to store the animations
  96158. */
  96159. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  96160. if (source.animations) {
  96161. destination.animations = [];
  96162. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  96163. var animation = source.animations[animationIndex];
  96164. destination.animations.push(animation.serialize());
  96165. }
  96166. }
  96167. };
  96168. /**
  96169. * Static function used to serialized a specific entity
  96170. * @param entity defines the entity to serialize
  96171. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96172. * @returns a JSON compatible object representing the serialization of the entity
  96173. */
  96174. SerializationHelper.Serialize = function (entity, serializationObject) {
  96175. if (!serializationObject) {
  96176. serializationObject = {};
  96177. }
  96178. // Tags
  96179. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  96180. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  96181. }
  96182. var serializedProperties = getMergedStore(entity);
  96183. // Properties
  96184. for (var property in serializedProperties) {
  96185. var propertyDescriptor = serializedProperties[property];
  96186. var targetPropertyName = propertyDescriptor.sourceName || property;
  96187. var propertyType = propertyDescriptor.type;
  96188. var sourceProperty = entity[property];
  96189. if (sourceProperty !== undefined && sourceProperty !== null) {
  96190. switch (propertyType) {
  96191. case 0: // Value
  96192. serializationObject[targetPropertyName] = sourceProperty;
  96193. break;
  96194. case 1: // Texture
  96195. serializationObject[targetPropertyName] = sourceProperty.serialize();
  96196. break;
  96197. case 2: // Color3
  96198. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96199. break;
  96200. case 3: // FresnelParameters
  96201. serializationObject[targetPropertyName] = sourceProperty.serialize();
  96202. break;
  96203. case 4: // Vector2
  96204. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96205. break;
  96206. case 5: // Vector3
  96207. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96208. break;
  96209. case 6: // Mesh reference
  96210. serializationObject[targetPropertyName] = sourceProperty.id;
  96211. break;
  96212. case 7: // Color Curves
  96213. serializationObject[targetPropertyName] = sourceProperty.serialize();
  96214. break;
  96215. case 8: // Color 4
  96216. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96217. break;
  96218. case 9: // Image Processing
  96219. serializationObject[targetPropertyName] = sourceProperty.serialize();
  96220. break;
  96221. case 10: // Quaternion
  96222. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96223. break;
  96224. case 11: // Camera reference
  96225. serializationObject[targetPropertyName] = sourceProperty.id;
  96226. case 12: // Matrix
  96227. serializationObject[targetPropertyName] = sourceProperty.asArray();
  96228. break;
  96229. }
  96230. }
  96231. }
  96232. return serializationObject;
  96233. };
  96234. /**
  96235. * Creates a new entity from a serialization data object
  96236. * @param creationFunction defines a function used to instanciated the new entity
  96237. * @param source defines the source serialization data
  96238. * @param scene defines the hosting scene
  96239. * @param rootUrl defines the root url for resources
  96240. * @returns a new entity
  96241. */
  96242. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  96243. if (rootUrl === void 0) { rootUrl = null; }
  96244. var destination = creationFunction();
  96245. if (!rootUrl) {
  96246. rootUrl = "";
  96247. }
  96248. // Tags
  96249. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  96250. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  96251. }
  96252. var classStore = getMergedStore(destination);
  96253. // Properties
  96254. for (var property in classStore) {
  96255. var propertyDescriptor = classStore[property];
  96256. var sourceProperty = source[propertyDescriptor.sourceName || property];
  96257. var propertyType = propertyDescriptor.type;
  96258. if (sourceProperty !== undefined && sourceProperty !== null) {
  96259. var dest = destination;
  96260. switch (propertyType) {
  96261. case 0: // Value
  96262. dest[property] = sourceProperty;
  96263. break;
  96264. case 1: // Texture
  96265. if (scene) {
  96266. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  96267. }
  96268. break;
  96269. case 2: // Color3
  96270. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  96271. break;
  96272. case 3: // FresnelParameters
  96273. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  96274. break;
  96275. case 4: // Vector2
  96276. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  96277. break;
  96278. case 5: // Vector3
  96279. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  96280. break;
  96281. case 6: // Mesh reference
  96282. if (scene) {
  96283. dest[property] = scene.getLastMeshByID(sourceProperty);
  96284. }
  96285. break;
  96286. case 7: // Color Curves
  96287. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  96288. break;
  96289. case 8: // Color 4
  96290. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  96291. break;
  96292. case 9: // Image Processing
  96293. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  96294. break;
  96295. case 10: // Quaternion
  96296. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  96297. break;
  96298. case 11: // Camera reference
  96299. if (scene) {
  96300. dest[property] = scene.getCameraByID(sourceProperty);
  96301. }
  96302. case 12: // Matrix
  96303. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(sourceProperty);
  96304. break;
  96305. }
  96306. }
  96307. }
  96308. return destination;
  96309. };
  96310. /**
  96311. * Clones an object
  96312. * @param creationFunction defines the function used to instanciate the new object
  96313. * @param source defines the source object
  96314. * @returns the cloned object
  96315. */
  96316. SerializationHelper.Clone = function (creationFunction, source) {
  96317. return _copySource(creationFunction, source, false);
  96318. };
  96319. /**
  96320. * Instanciates a new object based on a source one (some data will be shared between both object)
  96321. * @param creationFunction defines the function used to instanciate the new object
  96322. * @param source defines the source object
  96323. * @returns the new object
  96324. */
  96325. SerializationHelper.Instanciate = function (creationFunction, source) {
  96326. return _copySource(creationFunction, source, true);
  96327. };
  96328. /** hidden */
  96329. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  96330. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  96331. };
  96332. /** hidden */
  96333. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  96334. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  96335. };
  96336. /** hidden */
  96337. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  96338. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  96339. };
  96340. /** hidden */
  96341. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  96342. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  96343. };
  96344. return SerializationHelper;
  96345. }());
  96346. /***/ }),
  96347. /***/ "./Misc/deepCopier.ts":
  96348. /*!****************************!*\
  96349. !*** ./Misc/deepCopier.ts ***!
  96350. \****************************/
  96351. /*! exports provided: DeepCopier */
  96352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96353. "use strict";
  96354. __webpack_require__.r(__webpack_exports__);
  96355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  96356. var cloneValue = function (source, destinationObject) {
  96357. if (!source) {
  96358. return null;
  96359. }
  96360. if (source.getClassName && source.getClassName() === "Mesh") {
  96361. return null;
  96362. }
  96363. if (source.getClassName && source.getClassName() === "SubMesh") {
  96364. return source.clone(destinationObject);
  96365. }
  96366. else if (source.clone) {
  96367. return source.clone();
  96368. }
  96369. return null;
  96370. };
  96371. /**
  96372. * Class containing a set of static utilities functions for deep copy.
  96373. */
  96374. var DeepCopier = /** @class */ (function () {
  96375. function DeepCopier() {
  96376. }
  96377. /**
  96378. * Tries to copy an object by duplicating every property
  96379. * @param source defines the source object
  96380. * @param destination defines the target object
  96381. * @param doNotCopyList defines a list of properties to avoid
  96382. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96383. */
  96384. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  96385. for (var prop in source) {
  96386. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  96387. continue;
  96388. }
  96389. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  96390. continue;
  96391. }
  96392. var sourceValue = source[prop];
  96393. var typeOfSourceValue = typeof sourceValue;
  96394. if (typeOfSourceValue === "function") {
  96395. continue;
  96396. }
  96397. try {
  96398. if (typeOfSourceValue === "object") {
  96399. if (sourceValue instanceof Array) {
  96400. destination[prop] = [];
  96401. if (sourceValue.length > 0) {
  96402. if (typeof sourceValue[0] == "object") {
  96403. for (var index = 0; index < sourceValue.length; index++) {
  96404. var clonedValue = cloneValue(sourceValue[index], destination);
  96405. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  96406. destination[prop].push(clonedValue);
  96407. }
  96408. }
  96409. }
  96410. else {
  96411. destination[prop] = sourceValue.slice(0);
  96412. }
  96413. }
  96414. }
  96415. else {
  96416. destination[prop] = cloneValue(sourceValue, destination);
  96417. }
  96418. }
  96419. else {
  96420. destination[prop] = sourceValue;
  96421. }
  96422. }
  96423. catch (e) {
  96424. // Just ignore error (it could be because of a read-only property)
  96425. }
  96426. }
  96427. };
  96428. return DeepCopier;
  96429. }());
  96430. /***/ }),
  96431. /***/ "./Misc/deferred.ts":
  96432. /*!**************************!*\
  96433. !*** ./Misc/deferred.ts ***!
  96434. \**************************/
  96435. /*! exports provided: Deferred */
  96436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96437. "use strict";
  96438. __webpack_require__.r(__webpack_exports__);
  96439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  96440. /**
  96441. * Wrapper class for promise with external resolve and reject.
  96442. */
  96443. var Deferred = /** @class */ (function () {
  96444. /**
  96445. * Constructor for this deferred object.
  96446. */
  96447. function Deferred() {
  96448. var _this = this;
  96449. this.promise = new Promise(function (resolve, reject) {
  96450. _this._resolve = resolve;
  96451. _this._reject = reject;
  96452. });
  96453. }
  96454. Object.defineProperty(Deferred.prototype, "resolve", {
  96455. /**
  96456. * The resolve method of the promise associated with this deferred object.
  96457. */
  96458. get: function () {
  96459. return this._resolve;
  96460. },
  96461. enumerable: true,
  96462. configurable: true
  96463. });
  96464. Object.defineProperty(Deferred.prototype, "reject", {
  96465. /**
  96466. * The reject method of the promise associated with this deferred object.
  96467. */
  96468. get: function () {
  96469. return this._reject;
  96470. },
  96471. enumerable: true,
  96472. configurable: true
  96473. });
  96474. return Deferred;
  96475. }());
  96476. /***/ }),
  96477. /***/ "./Misc/devTools.ts":
  96478. /*!**************************!*\
  96479. !*** ./Misc/devTools.ts ***!
  96480. \**************************/
  96481. /*! exports provided: _DevTools */
  96482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96483. "use strict";
  96484. __webpack_require__.r(__webpack_exports__);
  96485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  96486. /** @hidden */
  96487. var _DevTools = /** @class */ (function () {
  96488. function _DevTools() {
  96489. }
  96490. _DevTools.WarnImport = function (name) {
  96491. return name + " needs to be imported before as it contains a side-effect required by your code.";
  96492. };
  96493. return _DevTools;
  96494. }());
  96495. /***/ }),
  96496. /***/ "./Misc/domManagement.ts":
  96497. /*!*******************************!*\
  96498. !*** ./Misc/domManagement.ts ***!
  96499. \*******************************/
  96500. /*! exports provided: DomManagement */
  96501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96502. "use strict";
  96503. __webpack_require__.r(__webpack_exports__);
  96504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  96505. /**
  96506. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  96507. * Babylon.js
  96508. */
  96509. var DomManagement = /** @class */ (function () {
  96510. function DomManagement() {
  96511. }
  96512. /**
  96513. * Checks if the window object exists
  96514. * @returns true if the window object exists
  96515. */
  96516. DomManagement.IsWindowObjectExist = function () {
  96517. return (typeof window) !== "undefined";
  96518. };
  96519. /**
  96520. * Extracts text content from a DOM element hierarchy
  96521. * @param element defines the root element
  96522. * @returns a string
  96523. */
  96524. DomManagement.GetDOMTextContent = function (element) {
  96525. var result = "";
  96526. var child = element.firstChild;
  96527. while (child) {
  96528. if (child.nodeType === 3) {
  96529. result += child.textContent;
  96530. }
  96531. child = (child.nextSibling);
  96532. }
  96533. return result;
  96534. };
  96535. return DomManagement;
  96536. }());
  96537. /***/ }),
  96538. /***/ "./Misc/environmentTextureTools.ts":
  96539. /*!*****************************************!*\
  96540. !*** ./Misc/environmentTextureTools.ts ***!
  96541. \*****************************************/
  96542. /*! exports provided: EnvironmentTextureTools */
  96543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96544. "use strict";
  96545. __webpack_require__.r(__webpack_exports__);
  96546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  96547. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96548. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  96549. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  96550. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  96551. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  96552. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  96553. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96554. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  96555. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  96556. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96557. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  96558. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  96559. /**
  96560. * Sets of helpers addressing the serialization and deserialization of environment texture
  96561. * stored in a BabylonJS env file.
  96562. * Those files are usually stored as .env files.
  96563. */
  96564. var EnvironmentTextureTools = /** @class */ (function () {
  96565. function EnvironmentTextureTools() {
  96566. }
  96567. /**
  96568. * Gets the environment info from an env file.
  96569. * @param data The array buffer containing the .env bytes.
  96570. * @returns the environment file info (the json header) if successfully parsed.
  96571. */
  96572. EnvironmentTextureTools.GetEnvInfo = function (data) {
  96573. var dataView = new DataView(data);
  96574. var pos = 0;
  96575. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  96576. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  96577. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  96578. return null;
  96579. }
  96580. }
  96581. // Read json manifest - collect characters up to null terminator
  96582. var manifestString = '';
  96583. var charCode = 0x00;
  96584. while ((charCode = dataView.getUint8(pos++))) {
  96585. manifestString += String.fromCharCode(charCode);
  96586. }
  96587. var manifest = JSON.parse(manifestString);
  96588. if (manifest.specular) {
  96589. // Extend the header with the position of the payload.
  96590. manifest.specular.specularDataPosition = pos;
  96591. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  96592. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  96593. }
  96594. return manifest;
  96595. };
  96596. /**
  96597. * Creates an environment texture from a loaded cube texture.
  96598. * @param texture defines the cube texture to convert in env file
  96599. * @return a promise containing the environment data if succesfull.
  96600. */
  96601. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  96602. var _this = this;
  96603. var internalTexture = texture.getInternalTexture();
  96604. if (!internalTexture) {
  96605. return Promise.reject("The cube texture is invalid.");
  96606. }
  96607. if (!texture._prefiltered) {
  96608. return Promise.reject("The cube texture is invalid (not prefiltered).");
  96609. }
  96610. var engine = internalTexture.getEngine();
  96611. if (engine && engine.premultipliedAlpha) {
  96612. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  96613. }
  96614. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  96615. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  96616. }
  96617. var canvas = engine.getRenderingCanvas();
  96618. if (!canvas) {
  96619. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  96620. }
  96621. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  96622. if (!engine.getCaps().textureFloatRender) {
  96623. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96624. if (!engine.getCaps().textureHalfFloatRender) {
  96625. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  96626. }
  96627. }
  96628. var cubeWidth = internalTexture.width;
  96629. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  96630. var specularTextures = {};
  96631. var promises = [];
  96632. // Read and collect all mipmaps data from the cube.
  96633. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  96634. mipmapsCount = Math.round(mipmapsCount);
  96635. var _loop_1 = function (i) {
  96636. var faceWidth = Math.pow(2, mipmapsCount - i);
  96637. var _loop_2 = function (face) {
  96638. var data = texture.readPixels(face, i);
  96639. // Creates a temp texture with the face data.
  96640. 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);
  96641. // And rgbdEncode them.
  96642. var promise = new Promise(function (resolve, reject) {
  96643. 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);
  96644. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  96645. rgbdPostProcess.onApply = function (effect) {
  96646. effect._bindTexture("textureSampler", tempTexture);
  96647. };
  96648. // As the process needs to happen on the main canvas, keep track of the current size
  96649. var currentW = engine.getRenderWidth();
  96650. var currentH = engine.getRenderHeight();
  96651. // Set the desired size for the texture
  96652. engine.setSize(faceWidth, faceWidth);
  96653. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  96654. // Reading datas from WebGL
  96655. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  96656. var fileReader = new FileReader();
  96657. fileReader.onload = function (event) {
  96658. var arrayBuffer = event.target.result;
  96659. specularTextures[i * 6 + face] = arrayBuffer;
  96660. resolve();
  96661. };
  96662. fileReader.readAsArrayBuffer(blob);
  96663. });
  96664. // Reapply the previous canvas size
  96665. engine.setSize(currentW, currentH);
  96666. });
  96667. });
  96668. promises.push(promise);
  96669. };
  96670. // All faces of the cube.
  96671. for (var face = 0; face < 6; face++) {
  96672. _loop_2(face);
  96673. }
  96674. };
  96675. for (var i = 0; i <= mipmapsCount; i++) {
  96676. _loop_1(i);
  96677. }
  96678. // Once all the textures haves been collected as RGBD stored in PNGs
  96679. return Promise.all(promises).then(function () {
  96680. // We can delete the hosting scene keeping track of all the creation objects
  96681. hostingScene.dispose();
  96682. // Creates the json header for the env texture
  96683. var info = {
  96684. version: 1,
  96685. width: cubeWidth,
  96686. irradiance: _this._CreateEnvTextureIrradiance(texture),
  96687. specular: {
  96688. mipmaps: [],
  96689. lodGenerationScale: texture.lodGenerationScale
  96690. }
  96691. };
  96692. // Sets the specular image data information
  96693. var position = 0;
  96694. for (var i = 0; i <= mipmapsCount; i++) {
  96695. for (var face = 0; face < 6; face++) {
  96696. var byteLength = specularTextures[i * 6 + face].byteLength;
  96697. info.specular.mipmaps.push({
  96698. length: byteLength,
  96699. position: position
  96700. });
  96701. position += byteLength;
  96702. }
  96703. }
  96704. // Encode the JSON as an array buffer
  96705. var infoString = JSON.stringify(info);
  96706. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  96707. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  96708. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  96709. infoView[i] = infoString.charCodeAt(i);
  96710. }
  96711. // Ends up with a null terminator for easier parsing
  96712. infoView[infoString.length] = 0x00;
  96713. // Computes the final required size and creates the storage
  96714. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  96715. var finalBuffer = new ArrayBuffer(totalSize);
  96716. var finalBufferView = new Uint8Array(finalBuffer);
  96717. var dataView = new DataView(finalBuffer);
  96718. // Copy the magic bytes identifying the file in
  96719. var pos = 0;
  96720. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  96721. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  96722. }
  96723. // Add the json info
  96724. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  96725. pos += infoBuffer.byteLength;
  96726. // Finally inserts the texture data
  96727. for (var i = 0; i <= mipmapsCount; i++) {
  96728. for (var face = 0; face < 6; face++) {
  96729. var dataBuffer = specularTextures[i * 6 + face];
  96730. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  96731. pos += dataBuffer.byteLength;
  96732. }
  96733. }
  96734. // Voila
  96735. return finalBuffer;
  96736. });
  96737. };
  96738. /**
  96739. * Creates a JSON representation of the spherical data.
  96740. * @param texture defines the texture containing the polynomials
  96741. * @return the JSON representation of the spherical info
  96742. */
  96743. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  96744. var polynmials = texture.sphericalPolynomial;
  96745. if (polynmials == null) {
  96746. return null;
  96747. }
  96748. return {
  96749. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  96750. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  96751. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  96752. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  96753. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  96754. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  96755. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  96756. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  96757. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  96758. };
  96759. };
  96760. /**
  96761. * Uploads the texture info contained in the env file to the GPU.
  96762. * @param texture defines the internal texture to upload to
  96763. * @param arrayBuffer defines the buffer cotaining the data to load
  96764. * @param info defines the texture info retrieved through the GetEnvInfo method
  96765. * @returns a promise
  96766. */
  96767. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  96768. if (info.version !== 1) {
  96769. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  96770. }
  96771. var specularInfo = info.specular;
  96772. if (!specularInfo) {
  96773. // Nothing else parsed so far
  96774. return Promise.resolve();
  96775. }
  96776. // Double checks the enclosed info
  96777. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  96778. mipmapsCount = Math.round(mipmapsCount) + 1;
  96779. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  96780. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  96781. }
  96782. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  96783. var imageData = new Array(mipmapsCount);
  96784. for (var i = 0; i < mipmapsCount; i++) {
  96785. imageData[i] = new Array(6);
  96786. for (var face = 0; face < 6; face++) {
  96787. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  96788. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  96789. }
  96790. }
  96791. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  96792. };
  96793. /**
  96794. * Uploads the levels of image data to the GPU.
  96795. * @param texture defines the internal texture to upload to
  96796. * @param imageData defines the array buffer views of image data [mipmap][face]
  96797. * @returns a promise
  96798. */
  96799. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  96800. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  96801. throw new Error("Texture size must be a power of two");
  96802. }
  96803. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  96804. // Gets everything ready.
  96805. var engine = texture.getEngine();
  96806. var expandTexture = false;
  96807. var generateNonLODTextures = false;
  96808. var rgbdPostProcess = null;
  96809. var cubeRtt = null;
  96810. var lodTextures = null;
  96811. var caps = engine.getCaps();
  96812. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  96813. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96814. texture.generateMipMaps = true;
  96815. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  96816. // Add extra process if texture lod is not supported
  96817. if (!caps.textureLOD) {
  96818. expandTexture = false;
  96819. generateNonLODTextures = true;
  96820. lodTextures = {};
  96821. }
  96822. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  96823. else if (engine.webGLVersion < 2) {
  96824. expandTexture = false;
  96825. }
  96826. // If half float available we can uncompress the texture
  96827. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  96828. expandTexture = true;
  96829. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96830. }
  96831. // If full float available we can uncompress the texture
  96832. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  96833. expandTexture = true;
  96834. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  96835. }
  96836. // Expand the texture if possible
  96837. if (expandTexture) {
  96838. // Simply run through the decode PP
  96839. 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);
  96840. texture._isRGBD = false;
  96841. texture.invertY = false;
  96842. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  96843. generateDepthBuffer: false,
  96844. generateMipMaps: true,
  96845. generateStencilBuffer: false,
  96846. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  96847. type: texture.type,
  96848. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  96849. });
  96850. }
  96851. else {
  96852. texture._isRGBD = true;
  96853. texture.invertY = true;
  96854. // In case of missing support, applies the same patch than DDS files.
  96855. if (generateNonLODTextures) {
  96856. var mipSlices = 3;
  96857. var scale = texture._lodGenerationScale;
  96858. var offset = texture._lodGenerationOffset;
  96859. for (var i = 0; i < mipSlices; i++) {
  96860. //compute LOD from even spacing in smoothness (matching shader calculation)
  96861. var smoothness = i / (mipSlices - 1);
  96862. var roughness = 1 - smoothness;
  96863. var minLODIndex = offset; // roughness = 0
  96864. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  96865. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  96866. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  96867. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  96868. glTextureFromLod.isCube = true;
  96869. glTextureFromLod.invertY = true;
  96870. glTextureFromLod.generateMipMaps = false;
  96871. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  96872. // Wrap in a base texture for easy binding.
  96873. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  96874. lodTexture.isCube = true;
  96875. lodTexture._texture = glTextureFromLod;
  96876. lodTextures[mipmapIndex] = lodTexture;
  96877. switch (i) {
  96878. case 0:
  96879. texture._lodTextureLow = lodTexture;
  96880. break;
  96881. case 1:
  96882. texture._lodTextureMid = lodTexture;
  96883. break;
  96884. case 2:
  96885. texture._lodTextureHigh = lodTexture;
  96886. break;
  96887. }
  96888. }
  96889. }
  96890. }
  96891. var promises = [];
  96892. var _loop_3 = function (i) {
  96893. var _loop_4 = function (face) {
  96894. // Constructs an image element from image data
  96895. var bytes = imageData[i][face];
  96896. var blob = new Blob([bytes], { type: 'image/png' });
  96897. var url = URL.createObjectURL(blob);
  96898. var image = new Image();
  96899. image.src = url;
  96900. // Enqueue promise to upload to the texture.
  96901. var promise = new Promise(function (resolve, reject) {
  96902. image.onload = function () {
  96903. if (expandTexture) {
  96904. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  96905. reject(message);
  96906. }, image);
  96907. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  96908. // Uncompress the data to a RTT
  96909. rgbdPostProcess.onApply = function (effect) {
  96910. effect._bindTexture("textureSampler", tempTexture_1);
  96911. effect.setFloat2("scale", 1, 1);
  96912. };
  96913. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  96914. // Cleanup
  96915. engine.restoreDefaultFramebuffer();
  96916. tempTexture_1.dispose();
  96917. window.URL.revokeObjectURL(url);
  96918. resolve();
  96919. });
  96920. }
  96921. else {
  96922. engine._uploadImageToTexture(texture, image, face, i);
  96923. // Upload the face to the non lod texture support
  96924. if (generateNonLODTextures) {
  96925. var lodTexture = lodTextures[i];
  96926. if (lodTexture) {
  96927. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  96928. }
  96929. }
  96930. resolve();
  96931. }
  96932. };
  96933. image.onerror = function (error) {
  96934. reject(error);
  96935. };
  96936. });
  96937. promises.push(promise);
  96938. };
  96939. // All faces
  96940. for (var face = 0; face < 6; face++) {
  96941. _loop_4(face);
  96942. }
  96943. };
  96944. // All mipmaps up to provided number of images
  96945. for (var i = 0; i < imageData.length; i++) {
  96946. _loop_3(i);
  96947. }
  96948. // Fill remaining mipmaps with black textures.
  96949. if (imageData.length < mipmapsCount) {
  96950. var data = void 0;
  96951. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  96952. var dataLength = size * size * 4;
  96953. switch (texture.type) {
  96954. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  96955. data = new Uint8Array(dataLength);
  96956. break;
  96957. }
  96958. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  96959. data = new Uint16Array(dataLength);
  96960. break;
  96961. }
  96962. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  96963. data = new Float32Array(dataLength);
  96964. break;
  96965. }
  96966. }
  96967. for (var i = imageData.length; i < mipmapsCount; i++) {
  96968. for (var face = 0; face < 6; face++) {
  96969. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  96970. }
  96971. }
  96972. }
  96973. // Once all done, finishes the cleanup and return
  96974. return Promise.all(promises).then(function () {
  96975. // Release temp RTT.
  96976. if (cubeRtt) {
  96977. engine._releaseFramebufferObjects(cubeRtt);
  96978. cubeRtt._swapAndDie(texture);
  96979. }
  96980. // Release temp Post Process.
  96981. if (rgbdPostProcess) {
  96982. rgbdPostProcess.dispose();
  96983. }
  96984. // Flag internal texture as ready in case they are in use.
  96985. if (generateNonLODTextures) {
  96986. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  96987. texture._lodTextureHigh._texture.isReady = true;
  96988. }
  96989. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  96990. texture._lodTextureMid._texture.isReady = true;
  96991. }
  96992. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  96993. texture._lodTextureLow._texture.isReady = true;
  96994. }
  96995. }
  96996. });
  96997. };
  96998. /**
  96999. * Uploads spherical polynomials information to the texture.
  97000. * @param texture defines the texture we are trying to upload the information to
  97001. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  97002. */
  97003. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  97004. if (info.version !== 1) {
  97005. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  97006. }
  97007. var irradianceInfo = info.irradiance;
  97008. if (!irradianceInfo) {
  97009. return;
  97010. }
  97011. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  97012. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  97013. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  97014. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  97015. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  97016. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  97017. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  97018. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  97019. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  97020. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  97021. texture._sphericalPolynomial = sp;
  97022. };
  97023. /** @hidden */
  97024. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  97025. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  97026. internalTexture._bufferViewArrayArray = data;
  97027. internalTexture._lodGenerationScale = lodScale;
  97028. internalTexture._lodGenerationOffset = lodOffset;
  97029. internalTexture._sphericalPolynomial = sphericalPolynomial;
  97030. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  97031. internalTexture.isReady = true;
  97032. });
  97033. };
  97034. /**
  97035. * Magic number identifying the env file.
  97036. */
  97037. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  97038. return EnvironmentTextureTools;
  97039. }());
  97040. // References the dependencies.
  97041. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  97042. /***/ }),
  97043. /***/ "./Misc/filesInput.ts":
  97044. /*!****************************!*\
  97045. !*** ./Misc/filesInput.ts ***!
  97046. \****************************/
  97047. /*! exports provided: FilesInput */
  97048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97049. "use strict";
  97050. __webpack_require__.r(__webpack_exports__);
  97051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  97052. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  97053. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97054. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  97055. /**
  97056. * Class used to help managing file picking and drag'n'drop
  97057. */
  97058. var FilesInput = /** @class */ (function () {
  97059. /**
  97060. * Creates a new FilesInput
  97061. * @param engine defines the rendering engine
  97062. * @param scene defines the hosting scene
  97063. * @param sceneLoadedCallback callback called when scene is loaded
  97064. * @param progressCallback callback called to track progress
  97065. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  97066. * @param textureLoadingCallback callback called when a texture is loading
  97067. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  97068. * @param onReloadCallback callback called when a reload is requested
  97069. * @param errorCallback callback call if an error occurs
  97070. */
  97071. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  97072. /**
  97073. * Callback called when a file is processed
  97074. */
  97075. this.onProcessFileCallback = function () { return true; };
  97076. this._engine = engine;
  97077. this._currentScene = scene;
  97078. this._sceneLoadedCallback = sceneLoadedCallback;
  97079. this._progressCallback = progressCallback;
  97080. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  97081. this._textureLoadingCallback = textureLoadingCallback;
  97082. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  97083. this._onReloadCallback = onReloadCallback;
  97084. this._errorCallback = errorCallback;
  97085. }
  97086. Object.defineProperty(FilesInput, "FilesToLoad", {
  97087. /**
  97088. * List of files ready to be loaded
  97089. */
  97090. get: function () {
  97091. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  97092. },
  97093. enumerable: true,
  97094. configurable: true
  97095. });
  97096. /**
  97097. * Calls this function to listen to drag'n'drop events on a specific DOM element
  97098. * @param elementToMonitor defines the DOM element to track
  97099. */
  97100. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  97101. var _this = this;
  97102. if (elementToMonitor) {
  97103. this._elementToMonitor = elementToMonitor;
  97104. this._dragEnterHandler = function (e) { _this.drag(e); };
  97105. this._dragOverHandler = function (e) { _this.drag(e); };
  97106. this._dropHandler = function (e) { _this.drop(e); };
  97107. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  97108. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  97109. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  97110. }
  97111. };
  97112. /**
  97113. * Release all associated resources
  97114. */
  97115. FilesInput.prototype.dispose = function () {
  97116. if (!this._elementToMonitor) {
  97117. return;
  97118. }
  97119. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  97120. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  97121. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  97122. };
  97123. FilesInput.prototype.renderFunction = function () {
  97124. if (this._additionalRenderLoopLogicCallback) {
  97125. this._additionalRenderLoopLogicCallback();
  97126. }
  97127. if (this._currentScene) {
  97128. if (this._textureLoadingCallback) {
  97129. var remaining = this._currentScene.getWaitingItemsCount();
  97130. if (remaining > 0) {
  97131. this._textureLoadingCallback(remaining);
  97132. }
  97133. }
  97134. this._currentScene.render();
  97135. }
  97136. };
  97137. FilesInput.prototype.drag = function (e) {
  97138. e.stopPropagation();
  97139. e.preventDefault();
  97140. };
  97141. FilesInput.prototype.drop = function (eventDrop) {
  97142. eventDrop.stopPropagation();
  97143. eventDrop.preventDefault();
  97144. this.loadFiles(eventDrop);
  97145. };
  97146. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  97147. var _this = this;
  97148. var reader = folder.createReader();
  97149. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  97150. reader.readEntries(function (entries) {
  97151. remaining.count += entries.length;
  97152. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  97153. var entry = entries_1[_i];
  97154. if (entry.isFile) {
  97155. entry.file(function (file) {
  97156. file.correctName = relativePath + file.name;
  97157. files.push(file);
  97158. if (--remaining.count === 0) {
  97159. callback();
  97160. }
  97161. });
  97162. }
  97163. else if (entry.isDirectory) {
  97164. _this._traverseFolder(entry, files, remaining, callback);
  97165. }
  97166. }
  97167. if (--remaining.count) {
  97168. callback();
  97169. }
  97170. });
  97171. };
  97172. FilesInput.prototype._processFiles = function (files) {
  97173. for (var i = 0; i < files.length; i++) {
  97174. var name = files[i].correctName.toLowerCase();
  97175. var extension = name.split('.').pop();
  97176. if (!this.onProcessFileCallback(files[i], name, extension)) {
  97177. continue;
  97178. }
  97179. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  97180. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  97181. this._sceneFileToLoad = files[i];
  97182. }
  97183. FilesInput.FilesToLoad[name] = files[i];
  97184. }
  97185. };
  97186. /**
  97187. * Load files from a drop event
  97188. * @param event defines the drop event to use as source
  97189. */
  97190. FilesInput.prototype.loadFiles = function (event) {
  97191. var _this = this;
  97192. // Handling data transfer via drag'n'drop
  97193. if (event && event.dataTransfer && event.dataTransfer.files) {
  97194. this._filesToLoad = event.dataTransfer.files;
  97195. }
  97196. // Handling files from input files
  97197. if (event && event.target && event.target.files) {
  97198. this._filesToLoad = event.target.files;
  97199. }
  97200. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  97201. return;
  97202. }
  97203. if (this._startingProcessingFilesCallback) {
  97204. this._startingProcessingFilesCallback(this._filesToLoad);
  97205. }
  97206. if (this._filesToLoad && this._filesToLoad.length > 0) {
  97207. var files_1 = new Array();
  97208. var folders = [];
  97209. var items = event.dataTransfer ? event.dataTransfer.items : null;
  97210. for (var i = 0; i < this._filesToLoad.length; i++) {
  97211. var fileToLoad = this._filesToLoad[i];
  97212. var name_1 = fileToLoad.name.toLowerCase();
  97213. var entry = void 0;
  97214. fileToLoad.correctName = name_1;
  97215. if (items) {
  97216. var item = items[i];
  97217. if (item.getAsEntry) {
  97218. entry = item.getAsEntry();
  97219. }
  97220. else if (item.webkitGetAsEntry) {
  97221. entry = item.webkitGetAsEntry();
  97222. }
  97223. }
  97224. if (!entry) {
  97225. files_1.push(fileToLoad);
  97226. }
  97227. else {
  97228. if (entry.isDirectory) {
  97229. folders.push(entry);
  97230. }
  97231. else {
  97232. files_1.push(fileToLoad);
  97233. }
  97234. }
  97235. }
  97236. if (folders.length === 0) {
  97237. this._processFiles(files_1);
  97238. this._processReload();
  97239. }
  97240. else {
  97241. var remaining = { count: folders.length };
  97242. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  97243. var folder = folders_1[_i];
  97244. this._traverseFolder(folder, files_1, remaining, function () {
  97245. _this._processFiles(files_1);
  97246. if (remaining.count === 0) {
  97247. _this._processReload();
  97248. }
  97249. });
  97250. }
  97251. }
  97252. }
  97253. };
  97254. FilesInput.prototype._processReload = function () {
  97255. if (this._onReloadCallback) {
  97256. this._onReloadCallback(this._sceneFileToLoad);
  97257. }
  97258. else {
  97259. this.reload();
  97260. }
  97261. };
  97262. /**
  97263. * Reload the current scene from the loaded files
  97264. */
  97265. FilesInput.prototype.reload = function () {
  97266. var _this = this;
  97267. // If a scene file has been provided
  97268. if (this._sceneFileToLoad) {
  97269. if (this._currentScene) {
  97270. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  97271. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  97272. }
  97273. this._engine.stopRenderLoop();
  97274. }
  97275. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  97276. if (_this._progressCallback) {
  97277. _this._progressCallback(progress);
  97278. }
  97279. }).then(function (scene) {
  97280. if (_this._currentScene) {
  97281. _this._currentScene.dispose();
  97282. }
  97283. _this._currentScene = scene;
  97284. if (_this._sceneLoadedCallback) {
  97285. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  97286. }
  97287. // Wait for textures and shaders to be ready
  97288. _this._currentScene.executeWhenReady(function () {
  97289. _this._engine.runRenderLoop(function () {
  97290. _this.renderFunction();
  97291. });
  97292. });
  97293. }).catch(function (error) {
  97294. if (_this._errorCallback) {
  97295. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  97296. }
  97297. });
  97298. }
  97299. else {
  97300. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  97301. }
  97302. };
  97303. return FilesInput;
  97304. }());
  97305. /***/ }),
  97306. /***/ "./Misc/filesInputStore.ts":
  97307. /*!*********************************!*\
  97308. !*** ./Misc/filesInputStore.ts ***!
  97309. \*********************************/
  97310. /*! exports provided: FilesInputStore */
  97311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97312. "use strict";
  97313. __webpack_require__.r(__webpack_exports__);
  97314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  97315. /**
  97316. * Class used to help managing file picking and drag'n'drop
  97317. * File Storage
  97318. */
  97319. var FilesInputStore = /** @class */ (function () {
  97320. function FilesInputStore() {
  97321. }
  97322. /**
  97323. * List of files ready to be loaded
  97324. */
  97325. FilesInputStore.FilesToLoad = {};
  97326. return FilesInputStore;
  97327. }());
  97328. /***/ }),
  97329. /***/ "./Misc/iInspectable.ts":
  97330. /*!******************************!*\
  97331. !*** ./Misc/iInspectable.ts ***!
  97332. \******************************/
  97333. /*! exports provided: InspectableType */
  97334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97335. "use strict";
  97336. __webpack_require__.r(__webpack_exports__);
  97337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return InspectableType; });
  97338. /**
  97339. * Enum that determines the text-wrapping mode to use.
  97340. */
  97341. var InspectableType;
  97342. (function (InspectableType) {
  97343. /**
  97344. * Checkbox for booleans
  97345. */
  97346. InspectableType[InspectableType["Checkbox"] = 0] = "Checkbox";
  97347. /**
  97348. * Sliders for numbers
  97349. */
  97350. InspectableType[InspectableType["Slider"] = 1] = "Slider";
  97351. /**
  97352. * Vector3
  97353. */
  97354. InspectableType[InspectableType["Vector3"] = 2] = "Vector3";
  97355. /**
  97356. * Quaternions
  97357. */
  97358. InspectableType[InspectableType["Quaternion"] = 3] = "Quaternion";
  97359. /**
  97360. * Color3
  97361. */
  97362. InspectableType[InspectableType["Color3"] = 4] = "Color3";
  97363. })(InspectableType || (InspectableType = {}));
  97364. /***/ }),
  97365. /***/ "./Misc/index.ts":
  97366. /*!***********************!*\
  97367. !*** ./Misc/index.ts ***!
  97368. \***********************/
  97369. /*! 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, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, CubeMapToSphericalPolynomialTools, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, HDRTools, PanoramaToCubeMapTools */
  97370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97371. "use strict";
  97372. __webpack_require__.r(__webpack_exports__);
  97373. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  97374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  97375. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  97376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  97377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  97378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  97379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  97380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  97381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  97382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  97383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  97384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  97385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  97386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  97387. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  97388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  97389. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  97390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  97391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  97392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  97393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  97394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  97395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  97396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  97397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  97398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  97399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  97400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  97401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  97402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMatrix"]; });
  97403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  97404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  97405. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  97406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  97407. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  97408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  97409. /* harmony import */ var _meshExploder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshExploder */ "./Misc/meshExploder.ts");
  97410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _meshExploder__WEBPACK_IMPORTED_MODULE_6__["MeshExploder"]; });
  97411. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  97412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_7__["FilesInput"]; });
  97413. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  97414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["CubeMapToSphericalPolynomialTools"]; });
  97415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["HDRTools"]; });
  97416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["PanoramaToCubeMapTools"]; });
  97417. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  97418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__["KhronosTextureContainer"]; });
  97419. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  97420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["EventState"]; });
  97421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observer"]; });
  97422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["MultiObserver"]; });
  97423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observable"]; });
  97424. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  97425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["PerformanceMonitor"]; });
  97426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["RollingAverage"]; });
  97427. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  97428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_12__["PromisePolyfill"]; });
  97429. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  97430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimization"]; });
  97431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["TextureOptimization"]; });
  97432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["HardwareScalingOptimization"]; });
  97433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ShadowsOptimization"]; });
  97434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["PostProcessesOptimization"]; });
  97435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["LensFlaresOptimization"]; });
  97436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["CustomOptimization"]; });
  97437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ParticlesOptimization"]; });
  97438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["RenderTargetsOptimization"]; });
  97439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["MergeMeshesOptimization"]; });
  97440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizerOptions"]; });
  97441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizer"]; });
  97442. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  97443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__["SceneSerializer"]; });
  97444. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  97445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArray"]; });
  97446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArrayNoDuplicate"]; });
  97447. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  97448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_16__["StringDictionary"]; });
  97449. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  97450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_17__["Tags"]; });
  97451. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  97452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_18__["TextureTools"]; });
  97453. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  97454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_19__["TGATools"]; });
  97455. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["ColorGradient"]; });
  97457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Color3Gradient"]; });
  97458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["FactorGradient"]; });
  97459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["LoadFileError"]; });
  97460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["RetryStrategy"]; });
  97461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Tools"]; });
  97462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["PerfCounter"]; });
  97463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["className"]; });
  97464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["AsyncLoop"]; });
  97465. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  97466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_21__["VideoRecorder"]; });
  97467. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  97468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["JoystickAxis"]; });
  97469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["VirtualJoystick"]; });
  97470. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  97471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_23__["WorkerPool"]; });
  97472. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_24__["Logger"]; });
  97474. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  97475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_25__["_TypeStore"]; });
  97476. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  97477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_26__["FilesInputStore"]; });
  97478. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  97479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_27__["DeepCopier"]; });
  97480. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  97481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_28__["PivotTools"]; });
  97482. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  97483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_29__["PrecisionDate"]; });
  97484. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  97485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_30__["ScreenshotTools"]; });
  97486. /* empty/unused harmony star reexport *//* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  97487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _webRequest__WEBPACK_IMPORTED_MODULE_31__["WebRequest"]; });
  97488. /* harmony import */ var _iInspectable__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./iInspectable */ "./Misc/iInspectable.ts");
  97489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _iInspectable__WEBPACK_IMPORTED_MODULE_32__["InspectableType"]; });
  97490. /***/ }),
  97491. /***/ "./Misc/khronosTextureContainer.ts":
  97492. /*!*****************************************!*\
  97493. !*** ./Misc/khronosTextureContainer.ts ***!
  97494. \*****************************************/
  97495. /*! exports provided: KhronosTextureContainer */
  97496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97497. "use strict";
  97498. __webpack_require__.r(__webpack_exports__);
  97499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  97500. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97501. /**
  97502. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97503. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97504. */
  97505. var KhronosTextureContainer = /** @class */ (function () {
  97506. /**
  97507. * Creates a new KhronosTextureContainer
  97508. * @param arrayBuffer contents of the KTX container file
  97509. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  97510. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  97511. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  97512. */
  97513. function KhronosTextureContainer(
  97514. /** contents of the KTX container file */
  97515. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  97516. this.arrayBuffer = arrayBuffer;
  97517. /**
  97518. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  97519. */
  97520. this.isInvalid = false;
  97521. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  97522. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  97523. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  97524. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  97525. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  97526. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  97527. this.isInvalid = true;
  97528. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  97529. return;
  97530. }
  97531. // load the reset of the header in native 32 bit uint
  97532. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  97533. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  97534. var endianness = headerDataView.getUint32(0, true);
  97535. var littleEndian = endianness === 0x04030201;
  97536. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  97537. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  97538. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  97539. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  97540. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  97541. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  97542. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  97543. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  97544. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  97545. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  97546. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  97547. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  97548. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  97549. if (this.glType !== 0) {
  97550. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  97551. return;
  97552. }
  97553. else {
  97554. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  97555. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  97556. }
  97557. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  97558. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  97559. return;
  97560. }
  97561. if (this.numberOfArrayElements !== 0) {
  97562. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  97563. return;
  97564. }
  97565. if (this.numberOfFaces !== facesExpected) {
  97566. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  97567. return;
  97568. }
  97569. // we now have a completely validated file, so could use existence of loadType as success
  97570. // would need to make this more elaborate & adjust checks above to support more than one load type
  97571. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  97572. }
  97573. /**
  97574. * Uploads KTX content to a Babylon Texture.
  97575. * It is assumed that the texture has already been created & is currently bound
  97576. * @hidden
  97577. */
  97578. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  97579. switch (this.loadType) {
  97580. case KhronosTextureContainer.COMPRESSED_2D:
  97581. this._upload2DCompressedLevels(texture, loadMipmaps);
  97582. break;
  97583. case KhronosTextureContainer.TEX_2D:
  97584. case KhronosTextureContainer.COMPRESSED_3D:
  97585. case KhronosTextureContainer.TEX_3D:
  97586. }
  97587. };
  97588. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  97589. // initialize width & height for level 1
  97590. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  97591. var width = this.pixelWidth;
  97592. var height = this.pixelHeight;
  97593. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  97594. for (var level = 0; level < mipmapCount; level++) {
  97595. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  97596. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  97597. for (var face = 0; face < this.numberOfFaces; face++) {
  97598. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  97599. var engine = texture.getEngine();
  97600. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  97601. dataOffset += imageSize; // add size of the image for the next face/mipmap
  97602. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  97603. }
  97604. width = Math.max(1.0, width * 0.5);
  97605. height = Math.max(1.0, height * 0.5);
  97606. }
  97607. };
  97608. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  97609. // load types
  97610. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  97611. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  97612. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  97613. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  97614. return KhronosTextureContainer;
  97615. }());
  97616. /***/ }),
  97617. /***/ "./Misc/logger.ts":
  97618. /*!************************!*\
  97619. !*** ./Misc/logger.ts ***!
  97620. \************************/
  97621. /*! exports provided: Logger */
  97622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97623. "use strict";
  97624. __webpack_require__.r(__webpack_exports__);
  97625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  97626. /**
  97627. * Logger used througouht the application to allow configuration of
  97628. * the log level required for the messages.
  97629. */
  97630. var Logger = /** @class */ (function () {
  97631. function Logger() {
  97632. }
  97633. Logger._AddLogEntry = function (entry) {
  97634. Logger._LogCache = entry + Logger._LogCache;
  97635. if (Logger.OnNewCacheEntry) {
  97636. Logger.OnNewCacheEntry(entry);
  97637. }
  97638. };
  97639. Logger._FormatMessage = function (message) {
  97640. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  97641. var date = new Date();
  97642. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  97643. };
  97644. Logger._LogDisabled = function (message) {
  97645. // nothing to do
  97646. };
  97647. Logger._LogEnabled = function (message) {
  97648. var formattedMessage = Logger._FormatMessage(message);
  97649. console.log("BJS - " + formattedMessage);
  97650. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  97651. Logger._AddLogEntry(entry);
  97652. };
  97653. Logger._WarnDisabled = function (message) {
  97654. // nothing to do
  97655. };
  97656. Logger._WarnEnabled = function (message) {
  97657. var formattedMessage = Logger._FormatMessage(message);
  97658. console.warn("BJS - " + formattedMessage);
  97659. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  97660. Logger._AddLogEntry(entry);
  97661. };
  97662. Logger._ErrorDisabled = function (message) {
  97663. // nothing to do
  97664. };
  97665. Logger._ErrorEnabled = function (message) {
  97666. Logger.errorsCount++;
  97667. var formattedMessage = Logger._FormatMessage(message);
  97668. console.error("BJS - " + formattedMessage);
  97669. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  97670. Logger._AddLogEntry(entry);
  97671. };
  97672. Object.defineProperty(Logger, "LogCache", {
  97673. /**
  97674. * Gets current log cache (list of logs)
  97675. */
  97676. get: function () {
  97677. return Logger._LogCache;
  97678. },
  97679. enumerable: true,
  97680. configurable: true
  97681. });
  97682. /**
  97683. * Clears the log cache
  97684. */
  97685. Logger.ClearLogCache = function () {
  97686. Logger._LogCache = "";
  97687. Logger.errorsCount = 0;
  97688. };
  97689. Object.defineProperty(Logger, "LogLevels", {
  97690. /**
  97691. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97692. */
  97693. set: function (level) {
  97694. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  97695. Logger.Log = Logger._LogEnabled;
  97696. }
  97697. else {
  97698. Logger.Log = Logger._LogDisabled;
  97699. }
  97700. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  97701. Logger.Warn = Logger._WarnEnabled;
  97702. }
  97703. else {
  97704. Logger.Warn = Logger._WarnDisabled;
  97705. }
  97706. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  97707. Logger.Error = Logger._ErrorEnabled;
  97708. }
  97709. else {
  97710. Logger.Error = Logger._ErrorDisabled;
  97711. }
  97712. },
  97713. enumerable: true,
  97714. configurable: true
  97715. });
  97716. /**
  97717. * No log
  97718. */
  97719. Logger.NoneLogLevel = 0;
  97720. /**
  97721. * Only message logs
  97722. */
  97723. Logger.MessageLogLevel = 1;
  97724. /**
  97725. * Only warning logs
  97726. */
  97727. Logger.WarningLogLevel = 2;
  97728. /**
  97729. * Only error logs
  97730. */
  97731. Logger.ErrorLogLevel = 4;
  97732. /**
  97733. * All logs
  97734. */
  97735. Logger.AllLogLevel = 7;
  97736. Logger._LogCache = "";
  97737. /**
  97738. * Gets a value indicating the number of loading errors
  97739. * @ignorenaming
  97740. */
  97741. Logger.errorsCount = 0;
  97742. /**
  97743. * Log a message to the console
  97744. */
  97745. Logger.Log = Logger._LogEnabled;
  97746. /**
  97747. * Write a warning message to the console
  97748. */
  97749. Logger.Warn = Logger._WarnEnabled;
  97750. /**
  97751. * Write an error message to the console
  97752. */
  97753. Logger.Error = Logger._ErrorEnabled;
  97754. return Logger;
  97755. }());
  97756. /***/ }),
  97757. /***/ "./Misc/meshExploder.ts":
  97758. /*!******************************!*\
  97759. !*** ./Misc/meshExploder.ts ***!
  97760. \******************************/
  97761. /*! exports provided: MeshExploder */
  97762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97763. "use strict";
  97764. __webpack_require__.r(__webpack_exports__);
  97765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return MeshExploder; });
  97766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97767. /**
  97768. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  97769. */
  97770. var MeshExploder = /** @class */ (function () {
  97771. /**
  97772. * Explodes meshes from a center mesh.
  97773. * @param meshes The meshes to explode.
  97774. * @param centerMesh The mesh to be center of explosion.
  97775. */
  97776. function MeshExploder(meshes, centerMesh) {
  97777. this._meshesOrigins = [];
  97778. this._toCenterVectors = [];
  97779. this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  97780. this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  97781. this._centerPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  97782. this._meshes = meshes.slice();
  97783. if (centerMesh) {
  97784. this._centerMesh = centerMesh;
  97785. }
  97786. else {
  97787. this._setCenterMesh();
  97788. }
  97789. var centerMeshIndex = this._meshes.indexOf(this._centerMesh);
  97790. if (centerMeshIndex >= 0) {
  97791. this._meshes.splice(centerMeshIndex, 1);
  97792. }
  97793. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  97794. for (var index = 0; index < this._meshes.length; index++) {
  97795. if (this._meshes[index]) {
  97796. var mesh = this._meshes[index];
  97797. this._meshesOrigins[index] = mesh.getAbsolutePosition().clone();
  97798. this._toCenterVectors[index] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  97799. if (mesh._boundingInfo && this._centerMesh._boundingInfo) {
  97800. mesh._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld, this._toCenterVectors[index]);
  97801. }
  97802. }
  97803. }
  97804. }
  97805. MeshExploder.prototype._setCenterMesh = function () {
  97806. var averageCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  97807. var totalCenters = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  97808. var shortestToCenter = Number.MAX_VALUE;
  97809. for (var index = 0; index < this._meshes.length; index++) {
  97810. if (this._meshes[index]) {
  97811. var mesh = this._meshes[index];
  97812. var boundingInfo = mesh.getBoundingInfo();
  97813. if (boundingInfo) {
  97814. totalCenters.addInPlace(boundingInfo.boundingBox.centerWorld);
  97815. }
  97816. }
  97817. }
  97818. averageCenter = totalCenters.scale(1 / this._meshes.length);
  97819. for (var index = 0; index < this._meshes.length; index++) {
  97820. if (this._meshes[index]) {
  97821. var mesh = this._meshes[index];
  97822. var boundingInfo = mesh.getBoundingInfo();
  97823. if (boundingInfo) {
  97824. var distanceToCenter = boundingInfo.boundingBox.centerWorld.subtract(averageCenter).lengthSquared();
  97825. if (distanceToCenter < shortestToCenter) {
  97826. this._centerMesh = mesh;
  97827. shortestToCenter = distanceToCenter;
  97828. }
  97829. }
  97830. }
  97831. }
  97832. };
  97833. /**
  97834. * Get class name
  97835. * @returns "MeshExploder"
  97836. */
  97837. MeshExploder.prototype.getClassName = function () {
  97838. return "MeshExploder";
  97839. };
  97840. /**
  97841. * "Exploded meshes"
  97842. * @returns Array of meshes with the centerMesh at index 0.
  97843. */
  97844. MeshExploder.prototype.getMeshes = function () {
  97845. var meshArray = this._meshes.slice();
  97846. meshArray.unshift(this._centerMesh);
  97847. return meshArray;
  97848. };
  97849. /**
  97850. * Explodes meshes giving a specific direction
  97851. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  97852. */
  97853. MeshExploder.prototype.explode = function (direction) {
  97854. if (direction === void 0) { direction = 1.0; }
  97855. for (var index = 0; index < this._meshes.length; index++) {
  97856. if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
  97857. this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
  97858. this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);
  97859. this._meshes[index].setAbsolutePosition(this._newPosition);
  97860. }
  97861. }
  97862. this._centerMesh.setAbsolutePosition(this._centerPosition);
  97863. };
  97864. return MeshExploder;
  97865. }());
  97866. /***/ }),
  97867. /***/ "./Misc/observable.ts":
  97868. /*!****************************!*\
  97869. !*** ./Misc/observable.ts ***!
  97870. \****************************/
  97871. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  97872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97873. "use strict";
  97874. __webpack_require__.r(__webpack_exports__);
  97875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  97876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  97877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  97878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  97879. /**
  97880. * A class serves as a medium between the observable and its observers
  97881. */
  97882. var EventState = /** @class */ (function () {
  97883. /**
  97884. * Create a new EventState
  97885. * @param mask defines the mask associated with this state
  97886. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  97887. * @param target defines the original target of the state
  97888. * @param currentTarget defines the current target of the state
  97889. */
  97890. function EventState(mask, skipNextObservers, target, currentTarget) {
  97891. if (skipNextObservers === void 0) { skipNextObservers = false; }
  97892. this.initalize(mask, skipNextObservers, target, currentTarget);
  97893. }
  97894. /**
  97895. * Initialize the current event state
  97896. * @param mask defines the mask associated with this state
  97897. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  97898. * @param target defines the original target of the state
  97899. * @param currentTarget defines the current target of the state
  97900. * @returns the current event state
  97901. */
  97902. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  97903. if (skipNextObservers === void 0) { skipNextObservers = false; }
  97904. this.mask = mask;
  97905. this.skipNextObservers = skipNextObservers;
  97906. this.target = target;
  97907. this.currentTarget = currentTarget;
  97908. return this;
  97909. };
  97910. return EventState;
  97911. }());
  97912. /**
  97913. * Represent an Observer registered to a given Observable object.
  97914. */
  97915. var Observer = /** @class */ (function () {
  97916. /**
  97917. * Creates a new observer
  97918. * @param callback defines the callback to call when the observer is notified
  97919. * @param mask defines the mask of the observer (used to filter notifications)
  97920. * @param scope defines the current scope used to restore the JS context
  97921. */
  97922. function Observer(
  97923. /**
  97924. * Defines the callback to call when the observer is notified
  97925. */
  97926. callback,
  97927. /**
  97928. * Defines the mask of the observer (used to filter notifications)
  97929. */
  97930. mask,
  97931. /**
  97932. * Defines the current scope used to restore the JS context
  97933. */
  97934. scope) {
  97935. if (scope === void 0) { scope = null; }
  97936. this.callback = callback;
  97937. this.mask = mask;
  97938. this.scope = scope;
  97939. /** @hidden */
  97940. this._willBeUnregistered = false;
  97941. /**
  97942. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  97943. */
  97944. this.unregisterOnNextCall = false;
  97945. }
  97946. return Observer;
  97947. }());
  97948. /**
  97949. * Represent a list of observers registered to multiple Observables object.
  97950. */
  97951. var MultiObserver = /** @class */ (function () {
  97952. function MultiObserver() {
  97953. }
  97954. /**
  97955. * Release associated resources
  97956. */
  97957. MultiObserver.prototype.dispose = function () {
  97958. if (this._observers && this._observables) {
  97959. for (var index = 0; index < this._observers.length; index++) {
  97960. this._observables[index].remove(this._observers[index]);
  97961. }
  97962. }
  97963. this._observers = null;
  97964. this._observables = null;
  97965. };
  97966. /**
  97967. * Raise a callback when one of the observable will notify
  97968. * @param observables defines a list of observables to watch
  97969. * @param callback defines the callback to call on notification
  97970. * @param mask defines the mask used to filter notifications
  97971. * @param scope defines the current scope used to restore the JS context
  97972. * @returns the new MultiObserver
  97973. */
  97974. MultiObserver.Watch = function (observables, callback, mask, scope) {
  97975. if (mask === void 0) { mask = -1; }
  97976. if (scope === void 0) { scope = null; }
  97977. var result = new MultiObserver();
  97978. result._observers = new Array();
  97979. result._observables = observables;
  97980. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  97981. var observable = observables_1[_i];
  97982. var observer = observable.add(callback, mask, false, scope);
  97983. if (observer) {
  97984. result._observers.push(observer);
  97985. }
  97986. }
  97987. return result;
  97988. };
  97989. return MultiObserver;
  97990. }());
  97991. /**
  97992. * The Observable class is a simple implementation of the Observable pattern.
  97993. *
  97994. * 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.
  97995. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  97996. * 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).
  97997. * 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.
  97998. */
  97999. var Observable = /** @class */ (function () {
  98000. /**
  98001. * Creates a new observable
  98002. * @param onObserverAdded defines a callback to call when a new observer is added
  98003. */
  98004. function Observable(onObserverAdded) {
  98005. this._observers = new Array();
  98006. this._eventState = new EventState(0);
  98007. if (onObserverAdded) {
  98008. this._onObserverAdded = onObserverAdded;
  98009. }
  98010. }
  98011. /**
  98012. * Create a new Observer with the specified callback
  98013. * @param callback the callback that will be executed for that Observer
  98014. * @param mask the mask used to filter observers
  98015. * @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.
  98016. * @param scope optional scope for the callback to be called from
  98017. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  98018. * @returns the new observer created for the callback
  98019. */
  98020. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  98021. if (mask === void 0) { mask = -1; }
  98022. if (insertFirst === void 0) { insertFirst = false; }
  98023. if (scope === void 0) { scope = null; }
  98024. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  98025. if (!callback) {
  98026. return null;
  98027. }
  98028. var observer = new Observer(callback, mask, scope);
  98029. observer.unregisterOnNextCall = unregisterOnFirstCall;
  98030. if (insertFirst) {
  98031. this._observers.unshift(observer);
  98032. }
  98033. else {
  98034. this._observers.push(observer);
  98035. }
  98036. if (this._onObserverAdded) {
  98037. this._onObserverAdded(observer);
  98038. }
  98039. return observer;
  98040. };
  98041. /**
  98042. * Create a new Observer with the specified callback and unregisters after the next notification
  98043. * @param callback the callback that will be executed for that Observer
  98044. * @returns the new observer created for the callback
  98045. */
  98046. Observable.prototype.addOnce = function (callback) {
  98047. return this.add(callback, undefined, undefined, undefined, true);
  98048. };
  98049. /**
  98050. * Remove an Observer from the Observable object
  98051. * @param observer the instance of the Observer to remove
  98052. * @returns false if it doesn't belong to this Observable
  98053. */
  98054. Observable.prototype.remove = function (observer) {
  98055. if (!observer) {
  98056. return false;
  98057. }
  98058. var index = this._observers.indexOf(observer);
  98059. if (index !== -1) {
  98060. this._deferUnregister(observer);
  98061. return true;
  98062. }
  98063. return false;
  98064. };
  98065. /**
  98066. * Remove a callback from the Observable object
  98067. * @param callback the callback to remove
  98068. * @param scope optional scope. If used only the callbacks with this scope will be removed
  98069. * @returns false if it doesn't belong to this Observable
  98070. */
  98071. Observable.prototype.removeCallback = function (callback, scope) {
  98072. for (var index = 0; index < this._observers.length; index++) {
  98073. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  98074. this._deferUnregister(this._observers[index]);
  98075. return true;
  98076. }
  98077. }
  98078. return false;
  98079. };
  98080. Observable.prototype._deferUnregister = function (observer) {
  98081. var _this = this;
  98082. observer.unregisterOnNextCall = false;
  98083. observer._willBeUnregistered = true;
  98084. setTimeout(function () {
  98085. _this._remove(observer);
  98086. }, 0);
  98087. };
  98088. // This should only be called when not iterating over _observers to avoid callback skipping.
  98089. // Removes an observer from the _observer Array.
  98090. Observable.prototype._remove = function (observer) {
  98091. if (!observer) {
  98092. return false;
  98093. }
  98094. var index = this._observers.indexOf(observer);
  98095. if (index !== -1) {
  98096. this._observers.splice(index, 1);
  98097. return true;
  98098. }
  98099. return false;
  98100. };
  98101. /**
  98102. * Moves the observable to the top of the observer list making it get called first when notified
  98103. * @param observer the observer to move
  98104. */
  98105. Observable.prototype.makeObserverTopPriority = function (observer) {
  98106. this._remove(observer);
  98107. this._observers.unshift(observer);
  98108. };
  98109. /**
  98110. * Moves the observable to the bottom of the observer list making it get called last when notified
  98111. * @param observer the observer to move
  98112. */
  98113. Observable.prototype.makeObserverBottomPriority = function (observer) {
  98114. this._remove(observer);
  98115. this._observers.push(observer);
  98116. };
  98117. /**
  98118. * Notify all Observers by calling their respective callback with the given data
  98119. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  98120. * @param eventData defines the data to send to all observers
  98121. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  98122. * @param target defines the original target of the state
  98123. * @param currentTarget defines the current target of the state
  98124. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  98125. */
  98126. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  98127. if (mask === void 0) { mask = -1; }
  98128. if (!this._observers.length) {
  98129. return true;
  98130. }
  98131. var state = this._eventState;
  98132. state.mask = mask;
  98133. state.target = target;
  98134. state.currentTarget = currentTarget;
  98135. state.skipNextObservers = false;
  98136. state.lastReturnValue = eventData;
  98137. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  98138. var obs = _a[_i];
  98139. if (obs._willBeUnregistered) {
  98140. continue;
  98141. }
  98142. if (obs.mask & mask) {
  98143. if (obs.scope) {
  98144. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  98145. }
  98146. else {
  98147. state.lastReturnValue = obs.callback(eventData, state);
  98148. }
  98149. if (obs.unregisterOnNextCall) {
  98150. this._deferUnregister(obs);
  98151. }
  98152. }
  98153. if (state.skipNextObservers) {
  98154. return false;
  98155. }
  98156. }
  98157. return true;
  98158. };
  98159. /**
  98160. * Calling this will execute each callback, expecting it to be a promise or return a value.
  98161. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  98162. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  98163. * and it is crucial that all callbacks will be executed.
  98164. * The order of the callbacks is kept, callbacks are not executed parallel.
  98165. *
  98166. * @param eventData The data to be sent to each callback
  98167. * @param mask is used to filter observers defaults to -1
  98168. * @param target defines the callback target (see EventState)
  98169. * @param currentTarget defines he current object in the bubbling phase
  98170. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  98171. */
  98172. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  98173. var _this = this;
  98174. if (mask === void 0) { mask = -1; }
  98175. // create an empty promise
  98176. var p = Promise.resolve(eventData);
  98177. // no observers? return this promise.
  98178. if (!this._observers.length) {
  98179. return p;
  98180. }
  98181. var state = this._eventState;
  98182. state.mask = mask;
  98183. state.target = target;
  98184. state.currentTarget = currentTarget;
  98185. state.skipNextObservers = false;
  98186. // execute one callback after another (not using Promise.all, the order is important)
  98187. this._observers.forEach(function (obs) {
  98188. if (state.skipNextObservers) {
  98189. return;
  98190. }
  98191. if (obs._willBeUnregistered) {
  98192. return;
  98193. }
  98194. if (obs.mask & mask) {
  98195. if (obs.scope) {
  98196. p = p.then(function (lastReturnedValue) {
  98197. state.lastReturnValue = lastReturnedValue;
  98198. return obs.callback.apply(obs.scope, [eventData, state]);
  98199. });
  98200. }
  98201. else {
  98202. p = p.then(function (lastReturnedValue) {
  98203. state.lastReturnValue = lastReturnedValue;
  98204. return obs.callback(eventData, state);
  98205. });
  98206. }
  98207. if (obs.unregisterOnNextCall) {
  98208. _this._deferUnregister(obs);
  98209. }
  98210. }
  98211. });
  98212. // return the eventData
  98213. return p.then(function () { return eventData; });
  98214. };
  98215. /**
  98216. * Notify a specific observer
  98217. * @param observer defines the observer to notify
  98218. * @param eventData defines the data to be sent to each callback
  98219. * @param mask is used to filter observers defaults to -1
  98220. */
  98221. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  98222. if (mask === void 0) { mask = -1; }
  98223. var state = this._eventState;
  98224. state.mask = mask;
  98225. state.skipNextObservers = false;
  98226. observer.callback(eventData, state);
  98227. };
  98228. /**
  98229. * Gets a boolean indicating if the observable has at least one observer
  98230. * @returns true is the Observable has at least one Observer registered
  98231. */
  98232. Observable.prototype.hasObservers = function () {
  98233. return this._observers.length > 0;
  98234. };
  98235. /**
  98236. * Clear the list of observers
  98237. */
  98238. Observable.prototype.clear = function () {
  98239. this._observers = new Array();
  98240. this._onObserverAdded = null;
  98241. };
  98242. /**
  98243. * Clone the current observable
  98244. * @returns a new observable
  98245. */
  98246. Observable.prototype.clone = function () {
  98247. var result = new Observable();
  98248. result._observers = this._observers.slice(0);
  98249. return result;
  98250. };
  98251. /**
  98252. * Does this observable handles observer registered with a given mask
  98253. * @param mask defines the mask to be tested
  98254. * @return whether or not one observer registered with the given mask is handeled
  98255. **/
  98256. Observable.prototype.hasSpecificMask = function (mask) {
  98257. if (mask === void 0) { mask = -1; }
  98258. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  98259. var obs = _a[_i];
  98260. if (obs.mask & mask || obs.mask === mask) {
  98261. return true;
  98262. }
  98263. }
  98264. return false;
  98265. };
  98266. return Observable;
  98267. }());
  98268. /***/ }),
  98269. /***/ "./Misc/performanceMonitor.ts":
  98270. /*!************************************!*\
  98271. !*** ./Misc/performanceMonitor.ts ***!
  98272. \************************************/
  98273. /*! exports provided: PerformanceMonitor, RollingAverage */
  98274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98275. "use strict";
  98276. __webpack_require__.r(__webpack_exports__);
  98277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  98278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  98279. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  98280. /**
  98281. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98282. */
  98283. var PerformanceMonitor = /** @class */ (function () {
  98284. /**
  98285. * constructor
  98286. * @param frameSampleSize The number of samples required to saturate the sliding window
  98287. */
  98288. function PerformanceMonitor(frameSampleSize) {
  98289. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  98290. this._enabled = true;
  98291. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  98292. }
  98293. /**
  98294. * Samples current frame
  98295. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98296. */
  98297. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  98298. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  98299. if (!this._enabled) {
  98300. return;
  98301. }
  98302. if (this._lastFrameTimeMs != null) {
  98303. var dt = timeMs - this._lastFrameTimeMs;
  98304. this._rollingFrameTime.add(dt);
  98305. }
  98306. this._lastFrameTimeMs = timeMs;
  98307. };
  98308. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  98309. /**
  98310. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98311. */
  98312. get: function () {
  98313. return this._rollingFrameTime.average;
  98314. },
  98315. enumerable: true,
  98316. configurable: true
  98317. });
  98318. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  98319. /**
  98320. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98321. */
  98322. get: function () {
  98323. return this._rollingFrameTime.variance;
  98324. },
  98325. enumerable: true,
  98326. configurable: true
  98327. });
  98328. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  98329. /**
  98330. * Returns the frame time of the most recent frame
  98331. */
  98332. get: function () {
  98333. return this._rollingFrameTime.history(0);
  98334. },
  98335. enumerable: true,
  98336. configurable: true
  98337. });
  98338. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  98339. /**
  98340. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98341. */
  98342. get: function () {
  98343. return 1000.0 / this._rollingFrameTime.average;
  98344. },
  98345. enumerable: true,
  98346. configurable: true
  98347. });
  98348. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  98349. /**
  98350. * Returns the average framerate in frames per second using the most recent frame time
  98351. */
  98352. get: function () {
  98353. var history = this._rollingFrameTime.history(0);
  98354. if (history === 0) {
  98355. return 0;
  98356. }
  98357. return 1000.0 / history;
  98358. },
  98359. enumerable: true,
  98360. configurable: true
  98361. });
  98362. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  98363. /**
  98364. * Returns true if enough samples have been taken to completely fill the sliding window
  98365. */
  98366. get: function () {
  98367. return this._rollingFrameTime.isSaturated();
  98368. },
  98369. enumerable: true,
  98370. configurable: true
  98371. });
  98372. /**
  98373. * Enables contributions to the sliding window sample set
  98374. */
  98375. PerformanceMonitor.prototype.enable = function () {
  98376. this._enabled = true;
  98377. };
  98378. /**
  98379. * Disables contributions to the sliding window sample set
  98380. * Samples will not be interpolated over the disabled period
  98381. */
  98382. PerformanceMonitor.prototype.disable = function () {
  98383. this._enabled = false;
  98384. //clear last sample to avoid interpolating over the disabled period when next enabled
  98385. this._lastFrameTimeMs = null;
  98386. };
  98387. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  98388. /**
  98389. * Returns true if sampling is enabled
  98390. */
  98391. get: function () {
  98392. return this._enabled;
  98393. },
  98394. enumerable: true,
  98395. configurable: true
  98396. });
  98397. /**
  98398. * Resets performance monitor
  98399. */
  98400. PerformanceMonitor.prototype.reset = function () {
  98401. //clear last sample to avoid interpolating over the disabled period when next enabled
  98402. this._lastFrameTimeMs = null;
  98403. //wipe record
  98404. this._rollingFrameTime.reset();
  98405. };
  98406. return PerformanceMonitor;
  98407. }());
  98408. /**
  98409. * RollingAverage
  98410. *
  98411. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98412. */
  98413. var RollingAverage = /** @class */ (function () {
  98414. /**
  98415. * constructor
  98416. * @param length The number of samples required to saturate the sliding window
  98417. */
  98418. function RollingAverage(length) {
  98419. this._samples = new Array(length);
  98420. this.reset();
  98421. }
  98422. /**
  98423. * Adds a sample to the sample set
  98424. * @param v The sample value
  98425. */
  98426. RollingAverage.prototype.add = function (v) {
  98427. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  98428. var delta;
  98429. //we need to check if we've already wrapped round
  98430. if (this.isSaturated()) {
  98431. //remove bottom of stack from mean
  98432. var bottomValue = this._samples[this._pos];
  98433. delta = bottomValue - this.average;
  98434. this.average -= delta / (this._sampleCount - 1);
  98435. this._m2 -= delta * (bottomValue - this.average);
  98436. }
  98437. else {
  98438. this._sampleCount++;
  98439. }
  98440. //add new value to mean
  98441. delta = v - this.average;
  98442. this.average += delta / (this._sampleCount);
  98443. this._m2 += delta * (v - this.average);
  98444. //set the new variance
  98445. this.variance = this._m2 / (this._sampleCount - 1);
  98446. this._samples[this._pos] = v;
  98447. this._pos++;
  98448. this._pos %= this._samples.length; //positive wrap around
  98449. };
  98450. /**
  98451. * Returns previously added values or null if outside of history or outside the sliding window domain
  98452. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98453. * @return Value previously recorded with add() or null if outside of range
  98454. */
  98455. RollingAverage.prototype.history = function (i) {
  98456. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  98457. return 0;
  98458. }
  98459. var i0 = this._wrapPosition(this._pos - 1.0);
  98460. return this._samples[this._wrapPosition(i0 - i)];
  98461. };
  98462. /**
  98463. * Returns true if enough samples have been taken to completely fill the sliding window
  98464. * @return true if sample-set saturated
  98465. */
  98466. RollingAverage.prototype.isSaturated = function () {
  98467. return this._sampleCount >= this._samples.length;
  98468. };
  98469. /**
  98470. * Resets the rolling average (equivalent to 0 samples taken so far)
  98471. */
  98472. RollingAverage.prototype.reset = function () {
  98473. this.average = 0;
  98474. this.variance = 0;
  98475. this._sampleCount = 0;
  98476. this._pos = 0;
  98477. this._m2 = 0;
  98478. };
  98479. /**
  98480. * Wraps a value around the sample range boundaries
  98481. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98482. * @return Wrapped position in sample range
  98483. */
  98484. RollingAverage.prototype._wrapPosition = function (i) {
  98485. var max = this._samples.length;
  98486. return ((i % max) + max) % max;
  98487. };
  98488. return RollingAverage;
  98489. }());
  98490. /***/ }),
  98491. /***/ "./Misc/pivotTools.ts":
  98492. /*!****************************!*\
  98493. !*** ./Misc/pivotTools.ts ***!
  98494. \****************************/
  98495. /*! exports provided: PivotTools */
  98496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98497. "use strict";
  98498. __webpack_require__.r(__webpack_exports__);
  98499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  98500. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98501. /**
  98502. * Class containing a set of static utilities functions for managing Pivots
  98503. * @hidden
  98504. */
  98505. var PivotTools = /** @class */ (function () {
  98506. function PivotTools() {
  98507. }
  98508. /** @hidden */
  98509. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  98510. if (mesh && PivotTools._PivotCached === 0) {
  98511. // Save old pivot and set pivot to 0,0,0
  98512. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  98513. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  98514. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  98515. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  98516. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  98517. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  98518. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  98519. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  98520. }
  98521. }
  98522. PivotTools._PivotCached++;
  98523. };
  98524. /** @hidden */
  98525. PivotTools._RestorePivotPoint = function (mesh) {
  98526. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  98527. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  98528. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  98529. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  98530. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  98531. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  98532. }
  98533. this._PivotCached--;
  98534. };
  98535. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  98536. // store/remove pivot point should only be applied during their outermost calls
  98537. PivotTools._PivotCached = 0;
  98538. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  98539. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  98540. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  98541. return PivotTools;
  98542. }());
  98543. /***/ }),
  98544. /***/ "./Misc/precisionDate.ts":
  98545. /*!*******************************!*\
  98546. !*** ./Misc/precisionDate.ts ***!
  98547. \*******************************/
  98548. /*! exports provided: PrecisionDate */
  98549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98550. "use strict";
  98551. __webpack_require__.r(__webpack_exports__);
  98552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  98553. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  98554. /**
  98555. * Class containing a set of static utilities functions for precision date
  98556. */
  98557. var PrecisionDate = /** @class */ (function () {
  98558. function PrecisionDate() {
  98559. }
  98560. Object.defineProperty(PrecisionDate, "Now", {
  98561. /**
  98562. * Gets either window.performance.now() if supported or Date.now() else
  98563. */
  98564. get: function () {
  98565. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  98566. return window.performance.now();
  98567. }
  98568. return Date.now();
  98569. },
  98570. enumerable: true,
  98571. configurable: true
  98572. });
  98573. return PrecisionDate;
  98574. }());
  98575. /***/ }),
  98576. /***/ "./Misc/promise.ts":
  98577. /*!*************************!*\
  98578. !*** ./Misc/promise.ts ***!
  98579. \*************************/
  98580. /*! exports provided: PromisePolyfill */
  98581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98582. "use strict";
  98583. __webpack_require__.r(__webpack_exports__);
  98584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  98585. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98586. var PromiseStates;
  98587. (function (PromiseStates) {
  98588. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  98589. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  98590. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  98591. })(PromiseStates || (PromiseStates = {}));
  98592. var FulFillmentAgregator = /** @class */ (function () {
  98593. function FulFillmentAgregator() {
  98594. this.count = 0;
  98595. this.target = 0;
  98596. this.results = [];
  98597. }
  98598. return FulFillmentAgregator;
  98599. }());
  98600. var InternalPromise = /** @class */ (function () {
  98601. function InternalPromise(resolver) {
  98602. var _this = this;
  98603. this._state = PromiseStates.Pending;
  98604. this._children = new Array();
  98605. this._rejectWasConsumed = false;
  98606. if (!resolver) {
  98607. return;
  98608. }
  98609. try {
  98610. resolver(function (value) {
  98611. _this._resolve(value);
  98612. }, function (reason) {
  98613. _this._reject(reason);
  98614. });
  98615. }
  98616. catch (e) {
  98617. this._reject(e);
  98618. }
  98619. }
  98620. Object.defineProperty(InternalPromise.prototype, "_result", {
  98621. get: function () {
  98622. return this._resultValue;
  98623. },
  98624. set: function (value) {
  98625. this._resultValue = value;
  98626. if (this._parent && this._parent._result === undefined) {
  98627. this._parent._result = value;
  98628. }
  98629. },
  98630. enumerable: true,
  98631. configurable: true
  98632. });
  98633. InternalPromise.prototype.catch = function (onRejected) {
  98634. return this.then(undefined, onRejected);
  98635. };
  98636. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  98637. var _this = this;
  98638. var newPromise = new InternalPromise();
  98639. newPromise._onFulfilled = onFulfilled;
  98640. newPromise._onRejected = onRejected;
  98641. // Composition
  98642. this._children.push(newPromise);
  98643. newPromise._parent = this;
  98644. if (this._state !== PromiseStates.Pending) {
  98645. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  98646. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  98647. var returnedValue = newPromise._resolve(_this._result);
  98648. if (returnedValue !== undefined && returnedValue !== null) {
  98649. if (returnedValue._state !== undefined) {
  98650. var returnedPromise = returnedValue;
  98651. newPromise._children.push(returnedPromise);
  98652. returnedPromise._parent = newPromise;
  98653. newPromise = returnedPromise;
  98654. }
  98655. else {
  98656. newPromise._result = returnedValue;
  98657. }
  98658. }
  98659. }
  98660. else {
  98661. newPromise._reject(_this._reason);
  98662. }
  98663. });
  98664. }
  98665. return newPromise;
  98666. };
  98667. InternalPromise.prototype._moveChildren = function (children) {
  98668. var _this = this;
  98669. var _a;
  98670. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  98671. this._children.forEach(function (child) {
  98672. child._parent = _this;
  98673. });
  98674. if (this._state === PromiseStates.Fulfilled) {
  98675. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  98676. var child = _b[_i];
  98677. child._resolve(this._result);
  98678. }
  98679. }
  98680. else if (this._state === PromiseStates.Rejected) {
  98681. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  98682. var child = _d[_c];
  98683. child._reject(this._reason);
  98684. }
  98685. }
  98686. };
  98687. InternalPromise.prototype._resolve = function (value) {
  98688. try {
  98689. this._state = PromiseStates.Fulfilled;
  98690. var returnedValue = null;
  98691. if (this._onFulfilled) {
  98692. returnedValue = this._onFulfilled(value);
  98693. }
  98694. if (returnedValue !== undefined && returnedValue !== null) {
  98695. if (returnedValue._state !== undefined) {
  98696. // Transmit children
  98697. var returnedPromise = returnedValue;
  98698. returnedPromise._parent = this;
  98699. returnedPromise._moveChildren(this._children);
  98700. value = returnedPromise._result;
  98701. }
  98702. else {
  98703. value = returnedValue;
  98704. }
  98705. }
  98706. this._result = value;
  98707. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  98708. var child = _a[_i];
  98709. child._resolve(value);
  98710. }
  98711. this._children.length = 0;
  98712. delete this._onFulfilled;
  98713. delete this._onRejected;
  98714. }
  98715. catch (e) {
  98716. this._reject(e, true);
  98717. }
  98718. };
  98719. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  98720. if (onLocalThrow === void 0) { onLocalThrow = false; }
  98721. this._state = PromiseStates.Rejected;
  98722. this._reason = reason;
  98723. if (this._onRejected && !onLocalThrow) {
  98724. try {
  98725. this._onRejected(reason);
  98726. this._rejectWasConsumed = true;
  98727. }
  98728. catch (e) {
  98729. reason = e;
  98730. }
  98731. }
  98732. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  98733. var child = _a[_i];
  98734. if (this._rejectWasConsumed) {
  98735. child._resolve(null);
  98736. }
  98737. else {
  98738. child._reject(reason);
  98739. }
  98740. }
  98741. this._children.length = 0;
  98742. delete this._onFulfilled;
  98743. delete this._onRejected;
  98744. };
  98745. InternalPromise.resolve = function (value) {
  98746. var newPromise = new InternalPromise();
  98747. newPromise._resolve(value);
  98748. return newPromise;
  98749. };
  98750. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  98751. promise.then(function (value) {
  98752. agregator.results[index] = value;
  98753. agregator.count++;
  98754. if (agregator.count === agregator.target) {
  98755. agregator.rootPromise._resolve(agregator.results);
  98756. }
  98757. return null;
  98758. }, function (reason) {
  98759. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  98760. agregator.rootPromise._reject(reason);
  98761. }
  98762. });
  98763. };
  98764. InternalPromise.all = function (promises) {
  98765. var newPromise = new InternalPromise();
  98766. var agregator = new FulFillmentAgregator();
  98767. agregator.target = promises.length;
  98768. agregator.rootPromise = newPromise;
  98769. if (promises.length) {
  98770. for (var index = 0; index < promises.length; index++) {
  98771. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  98772. }
  98773. }
  98774. else {
  98775. newPromise._resolve([]);
  98776. }
  98777. return newPromise;
  98778. };
  98779. InternalPromise.race = function (promises) {
  98780. var newPromise = new InternalPromise();
  98781. if (promises.length) {
  98782. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  98783. var promise = promises_1[_i];
  98784. promise.then(function (value) {
  98785. if (newPromise) {
  98786. newPromise._resolve(value);
  98787. newPromise = null;
  98788. }
  98789. return null;
  98790. }, function (reason) {
  98791. if (newPromise) {
  98792. newPromise._reject(reason);
  98793. newPromise = null;
  98794. }
  98795. });
  98796. }
  98797. }
  98798. return newPromise;
  98799. };
  98800. return InternalPromise;
  98801. }());
  98802. /**
  98803. * Helper class that provides a small promise polyfill
  98804. */
  98805. var PromisePolyfill = /** @class */ (function () {
  98806. function PromisePolyfill() {
  98807. }
  98808. /**
  98809. * Static function used to check if the polyfill is required
  98810. * If this is the case then the function will inject the polyfill to window.Promise
  98811. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98812. */
  98813. PromisePolyfill.Apply = function (force) {
  98814. if (force === void 0) { force = false; }
  98815. if (force || typeof Promise === 'undefined') {
  98816. var root = window;
  98817. root.Promise = InternalPromise;
  98818. }
  98819. };
  98820. return PromisePolyfill;
  98821. }());
  98822. /***/ }),
  98823. /***/ "./Misc/sceneOptimizer.ts":
  98824. /*!********************************!*\
  98825. !*** ./Misc/sceneOptimizer.ts ***!
  98826. \********************************/
  98827. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  98828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98829. "use strict";
  98830. __webpack_require__.r(__webpack_exports__);
  98831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  98832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  98833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  98834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  98835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  98836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  98837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  98838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  98839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  98840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  98841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  98842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  98843. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98844. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  98845. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  98846. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98847. /**
  98848. * Defines the root class used to create scene optimization to use with SceneOptimizer
  98849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98850. */
  98851. var SceneOptimization = /** @class */ (function () {
  98852. /**
  98853. * Creates the SceneOptimization object
  98854. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  98855. * @param desc defines the description associated with the optimization
  98856. */
  98857. function SceneOptimization(
  98858. /**
  98859. * Defines the priority of this optimization (0 by default which means first in the list)
  98860. */
  98861. priority) {
  98862. if (priority === void 0) { priority = 0; }
  98863. this.priority = priority;
  98864. }
  98865. /**
  98866. * Gets a string describing the action executed by the current optimization
  98867. * @returns description string
  98868. */
  98869. SceneOptimization.prototype.getDescription = function () {
  98870. return "";
  98871. };
  98872. /**
  98873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98874. * @param scene defines the current scene where to apply this optimization
  98875. * @param optimizer defines the current optimizer
  98876. * @returns true if everything that can be done was applied
  98877. */
  98878. SceneOptimization.prototype.apply = function (scene, optimizer) {
  98879. return true;
  98880. };
  98881. return SceneOptimization;
  98882. }());
  98883. /**
  98884. * Defines an optimization used to reduce the size of render target textures
  98885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98886. */
  98887. var TextureOptimization = /** @class */ (function (_super) {
  98888. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  98889. /**
  98890. * Creates the TextureOptimization object
  98891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  98892. * @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
  98893. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  98894. */
  98895. function TextureOptimization(
  98896. /**
  98897. * Defines the priority of this optimization (0 by default which means first in the list)
  98898. */
  98899. priority,
  98900. /**
  98901. * 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
  98902. */
  98903. maximumSize,
  98904. /**
  98905. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  98906. */
  98907. step) {
  98908. if (priority === void 0) { priority = 0; }
  98909. if (maximumSize === void 0) { maximumSize = 1024; }
  98910. if (step === void 0) { step = 0.5; }
  98911. var _this = _super.call(this, priority) || this;
  98912. _this.priority = priority;
  98913. _this.maximumSize = maximumSize;
  98914. _this.step = step;
  98915. return _this;
  98916. }
  98917. /**
  98918. * Gets a string describing the action executed by the current optimization
  98919. * @returns description string
  98920. */
  98921. TextureOptimization.prototype.getDescription = function () {
  98922. return "Reducing render target texture size to " + this.maximumSize;
  98923. };
  98924. /**
  98925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98926. * @param scene defines the current scene where to apply this optimization
  98927. * @param optimizer defines the current optimizer
  98928. * @returns true if everything that can be done was applied
  98929. */
  98930. TextureOptimization.prototype.apply = function (scene, optimizer) {
  98931. var allDone = true;
  98932. for (var index = 0; index < scene.textures.length; index++) {
  98933. var texture = scene.textures[index];
  98934. if (!texture.canRescale || texture.getContext) {
  98935. continue;
  98936. }
  98937. var currentSize = texture.getSize();
  98938. var maxDimension = Math.max(currentSize.width, currentSize.height);
  98939. if (maxDimension > this.maximumSize) {
  98940. texture.scale(this.step);
  98941. allDone = false;
  98942. }
  98943. }
  98944. return allDone;
  98945. };
  98946. return TextureOptimization;
  98947. }(SceneOptimization));
  98948. /**
  98949. * Defines an optimization used to increase or decrease the rendering resolution
  98950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98951. */
  98952. var HardwareScalingOptimization = /** @class */ (function (_super) {
  98953. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  98954. /**
  98955. * Creates the HardwareScalingOptimization object
  98956. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  98957. * @param maximumScale defines the maximum scale to use (2 by default)
  98958. * @param step defines the step to use between two passes (0.5 by default)
  98959. */
  98960. function HardwareScalingOptimization(
  98961. /**
  98962. * Defines the priority of this optimization (0 by default which means first in the list)
  98963. */
  98964. priority,
  98965. /**
  98966. * Defines the maximum scale to use (2 by default)
  98967. */
  98968. maximumScale,
  98969. /**
  98970. * Defines the step to use between two passes (0.5 by default)
  98971. */
  98972. step) {
  98973. if (priority === void 0) { priority = 0; }
  98974. if (maximumScale === void 0) { maximumScale = 2; }
  98975. if (step === void 0) { step = 0.25; }
  98976. var _this = _super.call(this, priority) || this;
  98977. _this.priority = priority;
  98978. _this.maximumScale = maximumScale;
  98979. _this.step = step;
  98980. _this._currentScale = -1;
  98981. _this._directionOffset = 1;
  98982. return _this;
  98983. }
  98984. /**
  98985. * Gets a string describing the action executed by the current optimization
  98986. * @return description string
  98987. */
  98988. HardwareScalingOptimization.prototype.getDescription = function () {
  98989. return "Setting hardware scaling level to " + this._currentScale;
  98990. };
  98991. /**
  98992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98993. * @param scene defines the current scene where to apply this optimization
  98994. * @param optimizer defines the current optimizer
  98995. * @returns true if everything that can be done was applied
  98996. */
  98997. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  98998. if (this._currentScale === -1) {
  98999. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  99000. if (this._currentScale > this.maximumScale) {
  99001. this._directionOffset = -1;
  99002. }
  99003. }
  99004. this._currentScale += this._directionOffset * this.step;
  99005. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  99006. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  99007. };
  99008. return HardwareScalingOptimization;
  99009. }(SceneOptimization));
  99010. /**
  99011. * Defines an optimization used to remove shadows
  99012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99013. */
  99014. var ShadowsOptimization = /** @class */ (function (_super) {
  99015. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  99016. function ShadowsOptimization() {
  99017. return _super !== null && _super.apply(this, arguments) || this;
  99018. }
  99019. /**
  99020. * Gets a string describing the action executed by the current optimization
  99021. * @return description string
  99022. */
  99023. ShadowsOptimization.prototype.getDescription = function () {
  99024. return "Turning shadows on/off";
  99025. };
  99026. /**
  99027. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99028. * @param scene defines the current scene where to apply this optimization
  99029. * @param optimizer defines the current optimizer
  99030. * @returns true if everything that can be done was applied
  99031. */
  99032. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  99033. scene.shadowsEnabled = optimizer.isInImprovementMode;
  99034. return true;
  99035. };
  99036. return ShadowsOptimization;
  99037. }(SceneOptimization));
  99038. /**
  99039. * Defines an optimization used to turn post-processes off
  99040. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99041. */
  99042. var PostProcessesOptimization = /** @class */ (function (_super) {
  99043. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  99044. function PostProcessesOptimization() {
  99045. return _super !== null && _super.apply(this, arguments) || this;
  99046. }
  99047. /**
  99048. * Gets a string describing the action executed by the current optimization
  99049. * @return description string
  99050. */
  99051. PostProcessesOptimization.prototype.getDescription = function () {
  99052. return "Turning post-processes on/off";
  99053. };
  99054. /**
  99055. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99056. * @param scene defines the current scene where to apply this optimization
  99057. * @param optimizer defines the current optimizer
  99058. * @returns true if everything that can be done was applied
  99059. */
  99060. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  99061. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  99062. return true;
  99063. };
  99064. return PostProcessesOptimization;
  99065. }(SceneOptimization));
  99066. /**
  99067. * Defines an optimization used to turn lens flares off
  99068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99069. */
  99070. var LensFlaresOptimization = /** @class */ (function (_super) {
  99071. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  99072. function LensFlaresOptimization() {
  99073. return _super !== null && _super.apply(this, arguments) || this;
  99074. }
  99075. /**
  99076. * Gets a string describing the action executed by the current optimization
  99077. * @return description string
  99078. */
  99079. LensFlaresOptimization.prototype.getDescription = function () {
  99080. return "Turning lens flares on/off";
  99081. };
  99082. /**
  99083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99084. * @param scene defines the current scene where to apply this optimization
  99085. * @param optimizer defines the current optimizer
  99086. * @returns true if everything that can be done was applied
  99087. */
  99088. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  99089. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  99090. return true;
  99091. };
  99092. return LensFlaresOptimization;
  99093. }(SceneOptimization));
  99094. /**
  99095. * Defines an optimization based on user defined callback.
  99096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99097. */
  99098. var CustomOptimization = /** @class */ (function (_super) {
  99099. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  99100. function CustomOptimization() {
  99101. return _super !== null && _super.apply(this, arguments) || this;
  99102. }
  99103. /**
  99104. * Gets a string describing the action executed by the current optimization
  99105. * @returns description string
  99106. */
  99107. CustomOptimization.prototype.getDescription = function () {
  99108. if (this.onGetDescription) {
  99109. return this.onGetDescription();
  99110. }
  99111. return "Running user defined callback";
  99112. };
  99113. /**
  99114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99115. * @param scene defines the current scene where to apply this optimization
  99116. * @param optimizer defines the current optimizer
  99117. * @returns true if everything that can be done was applied
  99118. */
  99119. CustomOptimization.prototype.apply = function (scene, optimizer) {
  99120. if (this.onApply) {
  99121. return this.onApply(scene, optimizer);
  99122. }
  99123. return true;
  99124. };
  99125. return CustomOptimization;
  99126. }(SceneOptimization));
  99127. /**
  99128. * Defines an optimization used to turn particles off
  99129. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99130. */
  99131. var ParticlesOptimization = /** @class */ (function (_super) {
  99132. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  99133. function ParticlesOptimization() {
  99134. return _super !== null && _super.apply(this, arguments) || this;
  99135. }
  99136. /**
  99137. * Gets a string describing the action executed by the current optimization
  99138. * @return description string
  99139. */
  99140. ParticlesOptimization.prototype.getDescription = function () {
  99141. return "Turning particles on/off";
  99142. };
  99143. /**
  99144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99145. * @param scene defines the current scene where to apply this optimization
  99146. * @param optimizer defines the current optimizer
  99147. * @returns true if everything that can be done was applied
  99148. */
  99149. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  99150. scene.particlesEnabled = optimizer.isInImprovementMode;
  99151. return true;
  99152. };
  99153. return ParticlesOptimization;
  99154. }(SceneOptimization));
  99155. /**
  99156. * Defines an optimization used to turn render targets off
  99157. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99158. */
  99159. var RenderTargetsOptimization = /** @class */ (function (_super) {
  99160. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  99161. function RenderTargetsOptimization() {
  99162. return _super !== null && _super.apply(this, arguments) || this;
  99163. }
  99164. /**
  99165. * Gets a string describing the action executed by the current optimization
  99166. * @return description string
  99167. */
  99168. RenderTargetsOptimization.prototype.getDescription = function () {
  99169. return "Turning render targets off";
  99170. };
  99171. /**
  99172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99173. * @param scene defines the current scene where to apply this optimization
  99174. * @param optimizer defines the current optimizer
  99175. * @returns true if everything that can be done was applied
  99176. */
  99177. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  99178. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  99179. return true;
  99180. };
  99181. return RenderTargetsOptimization;
  99182. }(SceneOptimization));
  99183. /**
  99184. * Defines an optimization used to merge meshes with compatible materials
  99185. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99186. */
  99187. var MergeMeshesOptimization = /** @class */ (function (_super) {
  99188. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  99189. function MergeMeshesOptimization() {
  99190. var _this = _super !== null && _super.apply(this, arguments) || this;
  99191. _this._canBeMerged = function (abstractMesh) {
  99192. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  99193. return false;
  99194. }
  99195. var mesh = abstractMesh;
  99196. if (mesh.isDisposed()) {
  99197. return false;
  99198. }
  99199. if (!mesh.isVisible || !mesh.isEnabled()) {
  99200. return false;
  99201. }
  99202. if (mesh.instances.length > 0) {
  99203. return false;
  99204. }
  99205. if (mesh.skeleton || mesh.hasLODLevels) {
  99206. return false;
  99207. }
  99208. return true;
  99209. };
  99210. return _this;
  99211. }
  99212. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  99213. /**
  99214. * Gets or sets a boolean which defines if optimization octree has to be updated
  99215. */
  99216. get: function () {
  99217. return MergeMeshesOptimization._UpdateSelectionTree;
  99218. },
  99219. /**
  99220. * Gets or sets a boolean which defines if optimization octree has to be updated
  99221. */
  99222. set: function (value) {
  99223. MergeMeshesOptimization._UpdateSelectionTree = value;
  99224. },
  99225. enumerable: true,
  99226. configurable: true
  99227. });
  99228. /**
  99229. * Gets a string describing the action executed by the current optimization
  99230. * @return description string
  99231. */
  99232. MergeMeshesOptimization.prototype.getDescription = function () {
  99233. return "Merging similar meshes together";
  99234. };
  99235. /**
  99236. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99237. * @param scene defines the current scene where to apply this optimization
  99238. * @param optimizer defines the current optimizer
  99239. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  99240. * @returns true if everything that can be done was applied
  99241. */
  99242. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  99243. var globalPool = scene.meshes.slice(0);
  99244. var globalLength = globalPool.length;
  99245. for (var index = 0; index < globalLength; index++) {
  99246. var currentPool = new Array();
  99247. var current = globalPool[index];
  99248. // Checks
  99249. if (!this._canBeMerged(current)) {
  99250. continue;
  99251. }
  99252. currentPool.push(current);
  99253. // Find compatible meshes
  99254. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  99255. var otherMesh = globalPool[subIndex];
  99256. if (!this._canBeMerged(otherMesh)) {
  99257. continue;
  99258. }
  99259. if (otherMesh.material !== current.material) {
  99260. continue;
  99261. }
  99262. if (otherMesh.checkCollisions !== current.checkCollisions) {
  99263. continue;
  99264. }
  99265. currentPool.push(otherMesh);
  99266. globalLength--;
  99267. globalPool.splice(subIndex, 1);
  99268. subIndex--;
  99269. }
  99270. if (currentPool.length < 2) {
  99271. continue;
  99272. }
  99273. // Merge meshes
  99274. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  99275. }
  99276. // Call the octree system optimization if it is defined.
  99277. var sceneAsAny = scene;
  99278. if (sceneAsAny.createOrUpdateSelectionOctree) {
  99279. if (updateSelectionTree != undefined) {
  99280. if (updateSelectionTree) {
  99281. sceneAsAny.createOrUpdateSelectionOctree();
  99282. }
  99283. }
  99284. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  99285. sceneAsAny.createOrUpdateSelectionOctree();
  99286. }
  99287. }
  99288. return true;
  99289. };
  99290. MergeMeshesOptimization._UpdateSelectionTree = false;
  99291. return MergeMeshesOptimization;
  99292. }(SceneOptimization));
  99293. /**
  99294. * Defines a list of options used by SceneOptimizer
  99295. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99296. */
  99297. var SceneOptimizerOptions = /** @class */ (function () {
  99298. /**
  99299. * Creates a new list of options used by SceneOptimizer
  99300. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  99301. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  99302. */
  99303. function SceneOptimizerOptions(
  99304. /**
  99305. * Defines the target frame rate to reach (60 by default)
  99306. */
  99307. targetFrameRate,
  99308. /**
  99309. * Defines the interval between two checkes (2000ms by default)
  99310. */
  99311. trackerDuration) {
  99312. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  99313. if (trackerDuration === void 0) { trackerDuration = 2000; }
  99314. this.targetFrameRate = targetFrameRate;
  99315. this.trackerDuration = trackerDuration;
  99316. /**
  99317. * Gets the list of optimizations to apply
  99318. */
  99319. this.optimizations = new Array();
  99320. }
  99321. /**
  99322. * Add a new optimization
  99323. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  99324. * @returns the current SceneOptimizerOptions
  99325. */
  99326. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  99327. this.optimizations.push(optimization);
  99328. return this;
  99329. };
  99330. /**
  99331. * Add a new custom optimization
  99332. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  99333. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  99334. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  99335. * @returns the current SceneOptimizerOptions
  99336. */
  99337. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  99338. if (priority === void 0) { priority = 0; }
  99339. var optimization = new CustomOptimization(priority);
  99340. optimization.onApply = onApply;
  99341. optimization.onGetDescription = onGetDescription;
  99342. this.optimizations.push(optimization);
  99343. return this;
  99344. };
  99345. /**
  99346. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  99347. * @param targetFrameRate defines the target frame rate (60 by default)
  99348. * @returns a SceneOptimizerOptions object
  99349. */
  99350. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  99351. var result = new SceneOptimizerOptions(targetFrameRate);
  99352. var priority = 0;
  99353. result.addOptimization(new MergeMeshesOptimization(priority));
  99354. result.addOptimization(new ShadowsOptimization(priority));
  99355. result.addOptimization(new LensFlaresOptimization(priority));
  99356. // Next priority
  99357. priority++;
  99358. result.addOptimization(new PostProcessesOptimization(priority));
  99359. result.addOptimization(new ParticlesOptimization(priority));
  99360. // Next priority
  99361. priority++;
  99362. result.addOptimization(new TextureOptimization(priority, 1024));
  99363. return result;
  99364. };
  99365. /**
  99366. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  99367. * @param targetFrameRate defines the target frame rate (60 by default)
  99368. * @returns a SceneOptimizerOptions object
  99369. */
  99370. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  99371. var result = new SceneOptimizerOptions(targetFrameRate);
  99372. var priority = 0;
  99373. result.addOptimization(new MergeMeshesOptimization(priority));
  99374. result.addOptimization(new ShadowsOptimization(priority));
  99375. result.addOptimization(new LensFlaresOptimization(priority));
  99376. // Next priority
  99377. priority++;
  99378. result.addOptimization(new PostProcessesOptimization(priority));
  99379. result.addOptimization(new ParticlesOptimization(priority));
  99380. // Next priority
  99381. priority++;
  99382. result.addOptimization(new TextureOptimization(priority, 512));
  99383. // Next priority
  99384. priority++;
  99385. result.addOptimization(new RenderTargetsOptimization(priority));
  99386. // Next priority
  99387. priority++;
  99388. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  99389. return result;
  99390. };
  99391. /**
  99392. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  99393. * @param targetFrameRate defines the target frame rate (60 by default)
  99394. * @returns a SceneOptimizerOptions object
  99395. */
  99396. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  99397. var result = new SceneOptimizerOptions(targetFrameRate);
  99398. var priority = 0;
  99399. result.addOptimization(new MergeMeshesOptimization(priority));
  99400. result.addOptimization(new ShadowsOptimization(priority));
  99401. result.addOptimization(new LensFlaresOptimization(priority));
  99402. // Next priority
  99403. priority++;
  99404. result.addOptimization(new PostProcessesOptimization(priority));
  99405. result.addOptimization(new ParticlesOptimization(priority));
  99406. // Next priority
  99407. priority++;
  99408. result.addOptimization(new TextureOptimization(priority, 256));
  99409. // Next priority
  99410. priority++;
  99411. result.addOptimization(new RenderTargetsOptimization(priority));
  99412. // Next priority
  99413. priority++;
  99414. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  99415. return result;
  99416. };
  99417. return SceneOptimizerOptions;
  99418. }());
  99419. /**
  99420. * Class used to run optimizations in order to reach a target frame rate
  99421. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99422. */
  99423. var SceneOptimizer = /** @class */ (function () {
  99424. /**
  99425. * Creates a new SceneOptimizer
  99426. * @param scene defines the scene to work on
  99427. * @param options defines the options to use with the SceneOptimizer
  99428. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  99429. * @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)
  99430. */
  99431. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  99432. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  99433. if (improvementMode === void 0) { improvementMode = false; }
  99434. var _this = this;
  99435. this._isRunning = false;
  99436. this._currentPriorityLevel = 0;
  99437. this._targetFrameRate = 60;
  99438. this._trackerDuration = 2000;
  99439. this._currentFrameRate = 0;
  99440. this._improvementMode = false;
  99441. /**
  99442. * Defines an observable called when the optimizer reaches the target frame rate
  99443. */
  99444. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  99445. /**
  99446. * Defines an observable called when the optimizer enables an optimization
  99447. */
  99448. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  99449. /**
  99450. * Defines an observable called when the optimizer is not able to reach the target frame rate
  99451. */
  99452. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  99453. if (!options) {
  99454. this._options = new SceneOptimizerOptions();
  99455. }
  99456. else {
  99457. this._options = options;
  99458. }
  99459. if (this._options.targetFrameRate) {
  99460. this._targetFrameRate = this._options.targetFrameRate;
  99461. }
  99462. if (this._options.trackerDuration) {
  99463. this._trackerDuration = this._options.trackerDuration;
  99464. }
  99465. if (autoGeneratePriorities) {
  99466. var priority = 0;
  99467. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  99468. var optim = _a[_i];
  99469. optim.priority = priority++;
  99470. }
  99471. }
  99472. this._improvementMode = improvementMode;
  99473. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  99474. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  99475. _this._sceneDisposeObserver = null;
  99476. _this.dispose();
  99477. });
  99478. }
  99479. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  99480. /**
  99481. * Gets a boolean indicating if the optimizer is in improvement mode
  99482. */
  99483. get: function () {
  99484. return this._improvementMode;
  99485. },
  99486. enumerable: true,
  99487. configurable: true
  99488. });
  99489. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  99490. /**
  99491. * Gets the current priority level (0 at start)
  99492. */
  99493. get: function () {
  99494. return this._currentPriorityLevel;
  99495. },
  99496. enumerable: true,
  99497. configurable: true
  99498. });
  99499. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  99500. /**
  99501. * Gets the current frame rate checked by the SceneOptimizer
  99502. */
  99503. get: function () {
  99504. return this._currentFrameRate;
  99505. },
  99506. enumerable: true,
  99507. configurable: true
  99508. });
  99509. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  99510. /**
  99511. * Gets or sets the current target frame rate (60 by default)
  99512. */
  99513. get: function () {
  99514. return this._targetFrameRate;
  99515. },
  99516. /**
  99517. * Gets or sets the current target frame rate (60 by default)
  99518. */
  99519. set: function (value) {
  99520. this._targetFrameRate = value;
  99521. },
  99522. enumerable: true,
  99523. configurable: true
  99524. });
  99525. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  99526. /**
  99527. * Gets or sets the current interval between two checks (every 2000ms by default)
  99528. */
  99529. get: function () {
  99530. return this._trackerDuration;
  99531. },
  99532. /**
  99533. * Gets or sets the current interval between two checks (every 2000ms by default)
  99534. */
  99535. set: function (value) {
  99536. this._trackerDuration = value;
  99537. },
  99538. enumerable: true,
  99539. configurable: true
  99540. });
  99541. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  99542. /**
  99543. * Gets the list of active optimizations
  99544. */
  99545. get: function () {
  99546. return this._options.optimizations;
  99547. },
  99548. enumerable: true,
  99549. configurable: true
  99550. });
  99551. /**
  99552. * Stops the current optimizer
  99553. */
  99554. SceneOptimizer.prototype.stop = function () {
  99555. this._isRunning = false;
  99556. };
  99557. /**
  99558. * Reset the optimizer to initial step (current priority level = 0)
  99559. */
  99560. SceneOptimizer.prototype.reset = function () {
  99561. this._currentPriorityLevel = 0;
  99562. };
  99563. /**
  99564. * Start the optimizer. By default it will try to reach a specific framerate
  99565. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  99566. */
  99567. SceneOptimizer.prototype.start = function () {
  99568. var _this = this;
  99569. if (this._isRunning) {
  99570. return;
  99571. }
  99572. this._isRunning = true;
  99573. // Let's wait for the scene to be ready before running our check
  99574. this._scene.executeWhenReady(function () {
  99575. setTimeout(function () {
  99576. _this._checkCurrentState();
  99577. }, _this._trackerDuration);
  99578. });
  99579. };
  99580. SceneOptimizer.prototype._checkCurrentState = function () {
  99581. var _this = this;
  99582. if (!this._isRunning) {
  99583. return;
  99584. }
  99585. var scene = this._scene;
  99586. var options = this._options;
  99587. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  99588. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  99589. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  99590. this._isRunning = false;
  99591. this.onSuccessObservable.notifyObservers(this);
  99592. return;
  99593. }
  99594. // Apply current level of optimizations
  99595. var allDone = true;
  99596. var noOptimizationApplied = true;
  99597. for (var index = 0; index < options.optimizations.length; index++) {
  99598. var optimization = options.optimizations[index];
  99599. if (optimization.priority === this._currentPriorityLevel) {
  99600. noOptimizationApplied = false;
  99601. allDone = allDone && optimization.apply(scene, this);
  99602. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  99603. }
  99604. }
  99605. // If no optimization was applied, this is a failure :(
  99606. if (noOptimizationApplied) {
  99607. this._isRunning = false;
  99608. this.onFailureObservable.notifyObservers(this);
  99609. return;
  99610. }
  99611. // If all optimizations were done, move to next level
  99612. if (allDone) {
  99613. this._currentPriorityLevel++;
  99614. }
  99615. // Let's the system running for a specific amount of time before checking FPS
  99616. scene.executeWhenReady(function () {
  99617. setTimeout(function () {
  99618. _this._checkCurrentState();
  99619. }, _this._trackerDuration);
  99620. });
  99621. };
  99622. /**
  99623. * Release all resources
  99624. */
  99625. SceneOptimizer.prototype.dispose = function () {
  99626. this.stop();
  99627. this.onSuccessObservable.clear();
  99628. this.onFailureObservable.clear();
  99629. this.onNewOptimizationAppliedObservable.clear();
  99630. if (this._sceneDisposeObserver) {
  99631. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  99632. }
  99633. };
  99634. /**
  99635. * Helper function to create a SceneOptimizer with one single line of code
  99636. * @param scene defines the scene to work on
  99637. * @param options defines the options to use with the SceneOptimizer
  99638. * @param onSuccess defines a callback to call on success
  99639. * @param onFailure defines a callback to call on failure
  99640. * @returns the new SceneOptimizer object
  99641. */
  99642. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  99643. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  99644. if (onSuccess) {
  99645. optimizer.onSuccessObservable.add(function () {
  99646. onSuccess();
  99647. });
  99648. }
  99649. if (onFailure) {
  99650. optimizer.onFailureObservable.add(function () {
  99651. onFailure();
  99652. });
  99653. }
  99654. optimizer.start();
  99655. return optimizer;
  99656. };
  99657. return SceneOptimizer;
  99658. }());
  99659. /***/ }),
  99660. /***/ "./Misc/sceneSerializer.ts":
  99661. /*!*********************************!*\
  99662. !*** ./Misc/sceneSerializer.ts ***!
  99663. \*********************************/
  99664. /*! exports provided: SceneSerializer */
  99665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99666. "use strict";
  99667. __webpack_require__.r(__webpack_exports__);
  99668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  99669. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  99670. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  99671. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  99672. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  99673. var serializedGeometries = [];
  99674. var serializeGeometry = function (geometry, serializationGeometries) {
  99675. if (serializedGeometries[geometry.id]) {
  99676. return;
  99677. }
  99678. if (geometry.doNotSerialize) {
  99679. return;
  99680. }
  99681. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  99682. serializedGeometries[geometry.id] = true;
  99683. };
  99684. var serializeMesh = function (mesh, serializationScene) {
  99685. var serializationObject = {};
  99686. // Geometry
  99687. var geometry = mesh._geometry;
  99688. if (geometry) {
  99689. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  99690. // 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
  99691. serializeGeometry(geometry, serializationScene.geometries);
  99692. }
  99693. }
  99694. // Custom
  99695. if (mesh.serialize) {
  99696. mesh.serialize(serializationObject);
  99697. }
  99698. return serializationObject;
  99699. };
  99700. var finalizeSingleMesh = function (mesh, serializationObject) {
  99701. //only works if the mesh is already loaded
  99702. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  99703. //serialize material
  99704. if (mesh.material) {
  99705. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  99706. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  99707. serializationObject.materials = serializationObject.materials || [];
  99708. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  99709. serializationObject.multiMaterials.push(mesh.material.serialize());
  99710. var _loop_1 = function (submaterial) {
  99711. if (submaterial) {
  99712. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  99713. serializationObject.materials.push(submaterial.serialize());
  99714. }
  99715. }
  99716. };
  99717. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  99718. var submaterial = _a[_i];
  99719. _loop_1(submaterial);
  99720. }
  99721. }
  99722. }
  99723. else {
  99724. serializationObject.materials = serializationObject.materials || [];
  99725. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  99726. serializationObject.materials.push(mesh.material.serialize());
  99727. }
  99728. }
  99729. }
  99730. //serialize geometry
  99731. var geometry = mesh._geometry;
  99732. if (geometry) {
  99733. if (!serializationObject.geometries) {
  99734. serializationObject.geometries = {};
  99735. serializationObject.geometries.boxes = [];
  99736. serializationObject.geometries.spheres = [];
  99737. serializationObject.geometries.cylinders = [];
  99738. serializationObject.geometries.toruses = [];
  99739. serializationObject.geometries.grounds = [];
  99740. serializationObject.geometries.planes = [];
  99741. serializationObject.geometries.torusKnots = [];
  99742. serializationObject.geometries.vertexData = [];
  99743. }
  99744. serializeGeometry(geometry, serializationObject.geometries);
  99745. }
  99746. // Skeletons
  99747. if (mesh.skeleton) {
  99748. serializationObject.skeletons = serializationObject.skeletons || [];
  99749. serializationObject.skeletons.push(mesh.skeleton.serialize());
  99750. }
  99751. //serialize the actual mesh
  99752. serializationObject.meshes = serializationObject.meshes || [];
  99753. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  99754. }
  99755. };
  99756. /**
  99757. * Class used to serialize a scene into a string
  99758. */
  99759. var SceneSerializer = /** @class */ (function () {
  99760. function SceneSerializer() {
  99761. }
  99762. /**
  99763. * Clear cache used by a previous serialization
  99764. */
  99765. SceneSerializer.ClearCache = function () {
  99766. serializedGeometries = [];
  99767. };
  99768. /**
  99769. * Serialize a scene into a JSON compatible object
  99770. * @param scene defines the scene to serialize
  99771. * @returns a JSON compatible object
  99772. */
  99773. SceneSerializer.Serialize = function (scene) {
  99774. var serializationObject = {};
  99775. SceneSerializer.ClearCache();
  99776. // Scene
  99777. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  99778. serializationObject.autoClear = scene.autoClear;
  99779. serializationObject.clearColor = scene.clearColor.asArray();
  99780. serializationObject.ambientColor = scene.ambientColor.asArray();
  99781. serializationObject.gravity = scene.gravity.asArray();
  99782. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  99783. // Fog
  99784. if (scene.fogMode && scene.fogMode !== 0) {
  99785. serializationObject.fogMode = scene.fogMode;
  99786. serializationObject.fogColor = scene.fogColor.asArray();
  99787. serializationObject.fogStart = scene.fogStart;
  99788. serializationObject.fogEnd = scene.fogEnd;
  99789. serializationObject.fogDensity = scene.fogDensity;
  99790. }
  99791. //Physics
  99792. if (scene.isPhysicsEnabled()) {
  99793. var physicEngine = scene.getPhysicsEngine();
  99794. if (physicEngine) {
  99795. serializationObject.physicsEnabled = true;
  99796. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  99797. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  99798. }
  99799. }
  99800. // Metadata
  99801. if (scene.metadata) {
  99802. serializationObject.metadata = scene.metadata;
  99803. }
  99804. // Morph targets
  99805. serializationObject.morphTargetManagers = [];
  99806. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  99807. var abstractMesh = _a[_i];
  99808. var manager = abstractMesh.morphTargetManager;
  99809. if (manager) {
  99810. serializationObject.morphTargetManagers.push(manager.serialize());
  99811. }
  99812. }
  99813. // Lights
  99814. serializationObject.lights = [];
  99815. var index;
  99816. var light;
  99817. for (index = 0; index < scene.lights.length; index++) {
  99818. light = scene.lights[index];
  99819. if (!light.doNotSerialize) {
  99820. serializationObject.lights.push(light.serialize());
  99821. }
  99822. }
  99823. // Cameras
  99824. serializationObject.cameras = [];
  99825. for (index = 0; index < scene.cameras.length; index++) {
  99826. var camera = scene.cameras[index];
  99827. if (!camera.doNotSerialize) {
  99828. serializationObject.cameras.push(camera.serialize());
  99829. }
  99830. }
  99831. if (scene.activeCamera) {
  99832. serializationObject.activeCameraID = scene.activeCamera.id;
  99833. }
  99834. // Animations
  99835. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  99836. // Reflection probes
  99837. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  99838. serializationObject.reflectionProbes = [];
  99839. for (index = 0; index < scene.reflectionProbes.length; index++) {
  99840. var reflectionProbe = scene.reflectionProbes[index];
  99841. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  99842. }
  99843. }
  99844. // Materials
  99845. serializationObject.materials = [];
  99846. serializationObject.multiMaterials = [];
  99847. var material;
  99848. for (index = 0; index < scene.materials.length; index++) {
  99849. material = scene.materials[index];
  99850. if (!material.doNotSerialize) {
  99851. serializationObject.materials.push(material.serialize());
  99852. }
  99853. }
  99854. // MultiMaterials
  99855. serializationObject.multiMaterials = [];
  99856. for (index = 0; index < scene.multiMaterials.length; index++) {
  99857. var multiMaterial = scene.multiMaterials[index];
  99858. serializationObject.multiMaterials.push(multiMaterial.serialize());
  99859. }
  99860. // Environment texture
  99861. if (scene.environmentTexture) {
  99862. serializationObject.environmentTexture = scene.environmentTexture.name;
  99863. }
  99864. // Skeletons
  99865. serializationObject.skeletons = [];
  99866. for (index = 0; index < scene.skeletons.length; index++) {
  99867. var skeleton = scene.skeletons[index];
  99868. if (!skeleton.doNotSerialize) {
  99869. serializationObject.skeletons.push(skeleton.serialize());
  99870. }
  99871. }
  99872. // Transform nodes
  99873. serializationObject.transformNodes = [];
  99874. for (index = 0; index < scene.transformNodes.length; index++) {
  99875. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  99876. }
  99877. // Geometries
  99878. serializationObject.geometries = {};
  99879. serializationObject.geometries.boxes = [];
  99880. serializationObject.geometries.spheres = [];
  99881. serializationObject.geometries.cylinders = [];
  99882. serializationObject.geometries.toruses = [];
  99883. serializationObject.geometries.grounds = [];
  99884. serializationObject.geometries.planes = [];
  99885. serializationObject.geometries.torusKnots = [];
  99886. serializationObject.geometries.vertexData = [];
  99887. serializedGeometries = [];
  99888. var geometries = scene.getGeometries();
  99889. for (index = 0; index < geometries.length; index++) {
  99890. var geometry = geometries[index];
  99891. if (geometry.isReady()) {
  99892. serializeGeometry(geometry, serializationObject.geometries);
  99893. }
  99894. }
  99895. // Meshes
  99896. serializationObject.meshes = [];
  99897. for (index = 0; index < scene.meshes.length; index++) {
  99898. var abstractMesh = scene.meshes[index];
  99899. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  99900. var mesh = abstractMesh;
  99901. if (!mesh.doNotSerialize) {
  99902. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  99903. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  99904. }
  99905. }
  99906. }
  99907. }
  99908. // Particles Systems
  99909. serializationObject.particleSystems = [];
  99910. for (index = 0; index < scene.particleSystems.length; index++) {
  99911. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  99912. }
  99913. // Action Manager
  99914. if (scene.actionManager) {
  99915. serializationObject.actions = scene.actionManager.serialize("scene");
  99916. }
  99917. // Components
  99918. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  99919. var component = _c[_b];
  99920. component.serialize(serializationObject);
  99921. }
  99922. return serializationObject;
  99923. };
  99924. /**
  99925. * Serialize a mesh into a JSON compatible object
  99926. * @param toSerialize defines the mesh to serialize
  99927. * @param withParents defines if parents must be serialized as well
  99928. * @param withChildren defines if children must be serialized as well
  99929. * @returns a JSON compatible object
  99930. */
  99931. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  99932. if (withParents === void 0) { withParents = false; }
  99933. if (withChildren === void 0) { withChildren = false; }
  99934. var serializationObject = {};
  99935. SceneSerializer.ClearCache();
  99936. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  99937. if (withParents || withChildren) {
  99938. //deliberate for loop! not for each, appended should be processed as well.
  99939. for (var i = 0; i < toSerialize.length; ++i) {
  99940. if (withChildren) {
  99941. toSerialize[i].getDescendants().forEach(function (node) {
  99942. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  99943. toSerialize.push(node);
  99944. }
  99945. });
  99946. }
  99947. //make sure the array doesn't contain the object already
  99948. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  99949. toSerialize.push(toSerialize[i].parent);
  99950. }
  99951. }
  99952. }
  99953. toSerialize.forEach(function (mesh) {
  99954. finalizeSingleMesh(mesh, serializationObject);
  99955. });
  99956. return serializationObject;
  99957. };
  99958. return SceneSerializer;
  99959. }());
  99960. /***/ }),
  99961. /***/ "./Misc/screenshotTools.ts":
  99962. /*!*********************************!*\
  99963. !*** ./Misc/screenshotTools.ts ***!
  99964. \*********************************/
  99965. /*! exports provided: ScreenshotTools */
  99966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99967. "use strict";
  99968. __webpack_require__.r(__webpack_exports__);
  99969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  99970. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  99971. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  99972. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  99973. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  99974. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  99975. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99976. /**
  99977. * Class containing a set of static utilities functions for screenshots
  99978. */
  99979. var ScreenshotTools = /** @class */ (function () {
  99980. function ScreenshotTools() {
  99981. }
  99982. /**
  99983. * Captures a screenshot of the current rendering
  99984. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99985. * @param engine defines the rendering engine
  99986. * @param camera defines the source camera
  99987. * @param size This parameter can be set to a single number or to an object with the
  99988. * following (optional) properties: precision, width, height. If a single number is passed,
  99989. * it will be used for both width and height. If an object is passed, the screenshot size
  99990. * will be derived from the parameters. The precision property is a multiplier allowing
  99991. * rendering at a higher or lower resolution
  99992. * @param successCallback defines the callback receives a single parameter which contains the
  99993. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99994. * src parameter of an <img> to display it
  99995. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99996. * Check your browser for supported MIME types
  99997. */
  99998. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  99999. if (mimeType === void 0) { mimeType = "image/png"; }
  100000. var width;
  100001. var height;
  100002. // If a precision value is specified
  100003. if (size.precision) {
  100004. width = Math.round(engine.getRenderWidth() * size.precision);
  100005. height = Math.round(width / engine.getAspectRatio(camera));
  100006. }
  100007. else if (size.width && size.height) {
  100008. width = size.width;
  100009. height = size.height;
  100010. }
  100011. //If passing only width, computing height to keep display canvas ratio.
  100012. else if (size.width && !size.height) {
  100013. width = size.width;
  100014. height = Math.round(width / engine.getAspectRatio(camera));
  100015. }
  100016. //If passing only height, computing width to keep display canvas ratio.
  100017. else if (size.height && !size.width) {
  100018. height = size.height;
  100019. width = Math.round(height * engine.getAspectRatio(camera));
  100020. }
  100021. //Assuming here that "size" parameter is a number
  100022. else if (!isNaN(size)) {
  100023. height = size;
  100024. width = size;
  100025. }
  100026. else {
  100027. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  100028. return;
  100029. }
  100030. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  100031. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  100032. }
  100033. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  100034. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  100035. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  100036. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  100037. var newWidth = width;
  100038. var newHeight = newWidth / ratio;
  100039. if (newHeight > height) {
  100040. newHeight = height;
  100041. newWidth = newHeight * ratio;
  100042. }
  100043. var offsetX = Math.max(0, width - newWidth) / 2;
  100044. var offsetY = Math.max(0, height - newHeight) / 2;
  100045. var renderingCanvas = engine.getRenderingCanvas();
  100046. if (renderContext && renderingCanvas) {
  100047. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  100048. }
  100049. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  100050. };
  100051. /**
  100052. * Generates an image screenshot from the specified camera.
  100053. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100054. * @param engine The engine to use for rendering
  100055. * @param camera The camera to use for rendering
  100056. * @param size This parameter can be set to a single number or to an object with the
  100057. * following (optional) properties: precision, width, height. If a single number is passed,
  100058. * it will be used for both width and height. If an object is passed, the screenshot size
  100059. * will be derived from the parameters. The precision property is a multiplier allowing
  100060. * rendering at a higher or lower resolution
  100061. * @param successCallback The callback receives a single parameter which contains the
  100062. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100063. * src parameter of an <img> to display it
  100064. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100065. * Check your browser for supported MIME types
  100066. * @param samples Texture samples (default: 1)
  100067. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100068. * @param fileName A name for for the downloaded file.
  100069. */
  100070. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  100071. if (mimeType === void 0) { mimeType = "image/png"; }
  100072. if (samples === void 0) { samples = 1; }
  100073. if (antialiasing === void 0) { antialiasing = false; }
  100074. var width;
  100075. var height;
  100076. //If a precision value is specified
  100077. if (size.precision) {
  100078. width = Math.round(engine.getRenderWidth() * size.precision);
  100079. height = Math.round(width / engine.getAspectRatio(camera));
  100080. size = { width: width, height: height };
  100081. }
  100082. else if (size.width && size.height) {
  100083. width = size.width;
  100084. height = size.height;
  100085. }
  100086. //If passing only width, computing height to keep display canvas ratio.
  100087. else if (size.width && !size.height) {
  100088. width = size.width;
  100089. height = Math.round(width / engine.getAspectRatio(camera));
  100090. size = { width: width, height: height };
  100091. }
  100092. //If passing only height, computing width to keep display canvas ratio.
  100093. else if (size.height && !size.width) {
  100094. height = size.height;
  100095. width = Math.round(height * engine.getAspectRatio(camera));
  100096. size = { width: width, height: height };
  100097. }
  100098. //Assuming here that "size" parameter is a number
  100099. else if (!isNaN(size)) {
  100100. height = size;
  100101. width = size;
  100102. }
  100103. else {
  100104. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  100105. return;
  100106. }
  100107. var scene = camera.getScene();
  100108. var previousCamera = null;
  100109. if (scene.activeCamera !== camera) {
  100110. previousCamera = scene.activeCamera;
  100111. scene.activeCamera = camera;
  100112. }
  100113. var renderCanvas = engine.getRenderingCanvas();
  100114. if (!renderCanvas) {
  100115. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  100116. return;
  100117. }
  100118. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  100119. engine.setSize(width, height);
  100120. scene.render();
  100121. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  100122. 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);
  100123. texture.renderList = null;
  100124. texture.samples = samples;
  100125. if (antialiasing) {
  100126. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  100127. }
  100128. texture.onAfterRenderObservable.add(function () {
  100129. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  100130. });
  100131. scene.incrementRenderId();
  100132. scene.resetCachedMaterial();
  100133. texture.render(true);
  100134. texture.dispose();
  100135. if (previousCamera) {
  100136. scene.activeCamera = previousCamera;
  100137. }
  100138. engine.setSize(originalSize.width, originalSize.height);
  100139. camera.getProjectionMatrix(true); // Force cache refresh;
  100140. };
  100141. return ScreenshotTools;
  100142. }());
  100143. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  100144. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  100145. /***/ }),
  100146. /***/ "./Misc/smartArray.ts":
  100147. /*!****************************!*\
  100148. !*** ./Misc/smartArray.ts ***!
  100149. \****************************/
  100150. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  100151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100152. "use strict";
  100153. __webpack_require__.r(__webpack_exports__);
  100154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  100155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  100156. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100157. /**
  100158. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  100159. */
  100160. var SmartArray = /** @class */ (function () {
  100161. /**
  100162. * Instantiates a Smart Array.
  100163. * @param capacity defines the default capacity of the array.
  100164. */
  100165. function SmartArray(capacity) {
  100166. /**
  100167. * The active length of the array.
  100168. */
  100169. this.length = 0;
  100170. this.data = new Array(capacity);
  100171. this._id = SmartArray._GlobalId++;
  100172. }
  100173. /**
  100174. * Pushes a value at the end of the active data.
  100175. * @param value defines the object to push in the array.
  100176. */
  100177. SmartArray.prototype.push = function (value) {
  100178. this.data[this.length++] = value;
  100179. if (this.length > this.data.length) {
  100180. this.data.length *= 2;
  100181. }
  100182. };
  100183. /**
  100184. * Iterates over the active data and apply the lambda to them.
  100185. * @param func defines the action to apply on each value.
  100186. */
  100187. SmartArray.prototype.forEach = function (func) {
  100188. for (var index = 0; index < this.length; index++) {
  100189. func(this.data[index]);
  100190. }
  100191. };
  100192. /**
  100193. * Sorts the full sets of data.
  100194. * @param compareFn defines the comparison function to apply.
  100195. */
  100196. SmartArray.prototype.sort = function (compareFn) {
  100197. this.data.sort(compareFn);
  100198. };
  100199. /**
  100200. * Resets the active data to an empty array.
  100201. */
  100202. SmartArray.prototype.reset = function () {
  100203. this.length = 0;
  100204. };
  100205. /**
  100206. * Releases all the data from the array as well as the array.
  100207. */
  100208. SmartArray.prototype.dispose = function () {
  100209. this.reset();
  100210. if (this.data) {
  100211. this.data.length = 0;
  100212. this.data = [];
  100213. }
  100214. };
  100215. /**
  100216. * Concats the active data with a given array.
  100217. * @param array defines the data to concatenate with.
  100218. */
  100219. SmartArray.prototype.concat = function (array) {
  100220. if (array.length === 0) {
  100221. return;
  100222. }
  100223. if (this.length + array.length > this.data.length) {
  100224. this.data.length = (this.length + array.length) * 2;
  100225. }
  100226. for (var index = 0; index < array.length; index++) {
  100227. this.data[this.length++] = (array.data || array)[index];
  100228. }
  100229. };
  100230. /**
  100231. * Returns the position of a value in the active data.
  100232. * @param value defines the value to find the index for
  100233. * @returns the index if found in the active data otherwise -1
  100234. */
  100235. SmartArray.prototype.indexOf = function (value) {
  100236. var position = this.data.indexOf(value);
  100237. if (position >= this.length) {
  100238. return -1;
  100239. }
  100240. return position;
  100241. };
  100242. /**
  100243. * Returns whether an element is part of the active data.
  100244. * @param value defines the value to look for
  100245. * @returns true if found in the active data otherwise false
  100246. */
  100247. SmartArray.prototype.contains = function (value) {
  100248. return this.indexOf(value) !== -1;
  100249. };
  100250. // Statics
  100251. SmartArray._GlobalId = 0;
  100252. return SmartArray;
  100253. }());
  100254. /**
  100255. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  100256. * The data in this array can only be present once
  100257. */
  100258. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  100259. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  100260. function SmartArrayNoDuplicate() {
  100261. var _this = _super !== null && _super.apply(this, arguments) || this;
  100262. _this._duplicateId = 0;
  100263. return _this;
  100264. }
  100265. /**
  100266. * Pushes a value at the end of the active data.
  100267. * THIS DOES NOT PREVENT DUPPLICATE DATA
  100268. * @param value defines the object to push in the array.
  100269. */
  100270. SmartArrayNoDuplicate.prototype.push = function (value) {
  100271. _super.prototype.push.call(this, value);
  100272. if (!value.__smartArrayFlags) {
  100273. value.__smartArrayFlags = {};
  100274. }
  100275. value.__smartArrayFlags[this._id] = this._duplicateId;
  100276. };
  100277. /**
  100278. * Pushes a value at the end of the active data.
  100279. * If the data is already present, it won t be added again
  100280. * @param value defines the object to push in the array.
  100281. * @returns true if added false if it was already present
  100282. */
  100283. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  100284. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  100285. return false;
  100286. }
  100287. this.push(value);
  100288. return true;
  100289. };
  100290. /**
  100291. * Resets the active data to an empty array.
  100292. */
  100293. SmartArrayNoDuplicate.prototype.reset = function () {
  100294. _super.prototype.reset.call(this);
  100295. this._duplicateId++;
  100296. };
  100297. /**
  100298. * Concats the active data with a given array.
  100299. * This ensures no dupplicate will be present in the result.
  100300. * @param array defines the data to concatenate with.
  100301. */
  100302. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  100303. if (array.length === 0) {
  100304. return;
  100305. }
  100306. if (this.length + array.length > this.data.length) {
  100307. this.data.length = (this.length + array.length) * 2;
  100308. }
  100309. for (var index = 0; index < array.length; index++) {
  100310. var item = (array.data || array)[index];
  100311. this.pushNoDuplicate(item);
  100312. }
  100313. };
  100314. return SmartArrayNoDuplicate;
  100315. }(SmartArray));
  100316. /***/ }),
  100317. /***/ "./Misc/stringDictionary.ts":
  100318. /*!**********************************!*\
  100319. !*** ./Misc/stringDictionary.ts ***!
  100320. \**********************************/
  100321. /*! exports provided: StringDictionary */
  100322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100323. "use strict";
  100324. __webpack_require__.r(__webpack_exports__);
  100325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  100326. /**
  100327. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100328. * The underlying implementation relies on an associative array to ensure the best performances.
  100329. * The value can be anything including 'null' but except 'undefined'
  100330. */
  100331. var StringDictionary = /** @class */ (function () {
  100332. function StringDictionary() {
  100333. this._count = 0;
  100334. this._data = {};
  100335. }
  100336. /**
  100337. * This will clear this dictionary and copy the content from the 'source' one.
  100338. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100339. * @param source the dictionary to take the content from and copy to this dictionary
  100340. */
  100341. StringDictionary.prototype.copyFrom = function (source) {
  100342. var _this = this;
  100343. this.clear();
  100344. source.forEach(function (t, v) { return _this.add(t, v); });
  100345. };
  100346. /**
  100347. * Get a value based from its key
  100348. * @param key the given key to get the matching value from
  100349. * @return the value if found, otherwise undefined is returned
  100350. */
  100351. StringDictionary.prototype.get = function (key) {
  100352. var val = this._data[key];
  100353. if (val !== undefined) {
  100354. return val;
  100355. }
  100356. return undefined;
  100357. };
  100358. /**
  100359. * Get a value from its key or add it if it doesn't exist.
  100360. * This method will ensure you that a given key/data will be present in the dictionary.
  100361. * @param key the given key to get the matching value from
  100362. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100363. * The factory will only be invoked if there's no data for the given key.
  100364. * @return the value corresponding to the key.
  100365. */
  100366. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  100367. var val = this.get(key);
  100368. if (val !== undefined) {
  100369. return val;
  100370. }
  100371. val = factory(key);
  100372. if (val) {
  100373. this.add(key, val);
  100374. }
  100375. return val;
  100376. };
  100377. /**
  100378. * Get a value from its key if present in the dictionary otherwise add it
  100379. * @param key the key to get the value from
  100380. * @param val if there's no such key/value pair in the dictionary add it with this value
  100381. * @return the value corresponding to the key
  100382. */
  100383. StringDictionary.prototype.getOrAdd = function (key, val) {
  100384. var curVal = this.get(key);
  100385. if (curVal !== undefined) {
  100386. return curVal;
  100387. }
  100388. this.add(key, val);
  100389. return val;
  100390. };
  100391. /**
  100392. * Check if there's a given key in the dictionary
  100393. * @param key the key to check for
  100394. * @return true if the key is present, false otherwise
  100395. */
  100396. StringDictionary.prototype.contains = function (key) {
  100397. return this._data[key] !== undefined;
  100398. };
  100399. /**
  100400. * Add a new key and its corresponding value
  100401. * @param key the key to add
  100402. * @param value the value corresponding to the key
  100403. * @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
  100404. */
  100405. StringDictionary.prototype.add = function (key, value) {
  100406. if (this._data[key] !== undefined) {
  100407. return false;
  100408. }
  100409. this._data[key] = value;
  100410. ++this._count;
  100411. return true;
  100412. };
  100413. /**
  100414. * Update a specific value associated to a key
  100415. * @param key defines the key to use
  100416. * @param value defines the value to store
  100417. * @returns true if the value was updated (or false if the key was not found)
  100418. */
  100419. StringDictionary.prototype.set = function (key, value) {
  100420. if (this._data[key] === undefined) {
  100421. return false;
  100422. }
  100423. this._data[key] = value;
  100424. return true;
  100425. };
  100426. /**
  100427. * Get the element of the given key and remove it from the dictionary
  100428. * @param key defines the key to search
  100429. * @returns the value associated with the key or null if not found
  100430. */
  100431. StringDictionary.prototype.getAndRemove = function (key) {
  100432. var val = this.get(key);
  100433. if (val !== undefined) {
  100434. delete this._data[key];
  100435. --this._count;
  100436. return val;
  100437. }
  100438. return null;
  100439. };
  100440. /**
  100441. * Remove a key/value from the dictionary.
  100442. * @param key the key to remove
  100443. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100444. */
  100445. StringDictionary.prototype.remove = function (key) {
  100446. if (this.contains(key)) {
  100447. delete this._data[key];
  100448. --this._count;
  100449. return true;
  100450. }
  100451. return false;
  100452. };
  100453. /**
  100454. * Clear the whole content of the dictionary
  100455. */
  100456. StringDictionary.prototype.clear = function () {
  100457. this._data = {};
  100458. this._count = 0;
  100459. };
  100460. Object.defineProperty(StringDictionary.prototype, "count", {
  100461. /**
  100462. * Gets the current count
  100463. */
  100464. get: function () {
  100465. return this._count;
  100466. },
  100467. enumerable: true,
  100468. configurable: true
  100469. });
  100470. /**
  100471. * Execute a callback on each key/val of the dictionary.
  100472. * Note that you can remove any element in this dictionary in the callback implementation
  100473. * @param callback the callback to execute on a given key/value pair
  100474. */
  100475. StringDictionary.prototype.forEach = function (callback) {
  100476. for (var cur in this._data) {
  100477. var val = this._data[cur];
  100478. callback(cur, val);
  100479. }
  100480. };
  100481. /**
  100482. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100483. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100484. * Note that you can remove any element in this dictionary in the callback implementation
  100485. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100486. * @returns the first item
  100487. */
  100488. StringDictionary.prototype.first = function (callback) {
  100489. for (var cur in this._data) {
  100490. var val = this._data[cur];
  100491. var res = callback(cur, val);
  100492. if (res) {
  100493. return res;
  100494. }
  100495. }
  100496. return null;
  100497. };
  100498. return StringDictionary;
  100499. }());
  100500. /***/ }),
  100501. /***/ "./Misc/tags.ts":
  100502. /*!**********************!*\
  100503. !*** ./Misc/tags.ts ***!
  100504. \**********************/
  100505. /*! exports provided: Tags */
  100506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100507. "use strict";
  100508. __webpack_require__.r(__webpack_exports__);
  100509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  100510. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100511. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  100512. /**
  100513. * Class used to store custom tags
  100514. */
  100515. var Tags = /** @class */ (function () {
  100516. function Tags() {
  100517. }
  100518. /**
  100519. * Adds support for tags on the given object
  100520. * @param obj defines the object to use
  100521. */
  100522. Tags.EnableFor = function (obj) {
  100523. obj._tags = obj._tags || {};
  100524. obj.hasTags = function () {
  100525. return Tags.HasTags(obj);
  100526. };
  100527. obj.addTags = function (tagsString) {
  100528. return Tags.AddTagsTo(obj, tagsString);
  100529. };
  100530. obj.removeTags = function (tagsString) {
  100531. return Tags.RemoveTagsFrom(obj, tagsString);
  100532. };
  100533. obj.matchesTagsQuery = function (tagsQuery) {
  100534. return Tags.MatchesQuery(obj, tagsQuery);
  100535. };
  100536. };
  100537. /**
  100538. * Removes tags support
  100539. * @param obj defines the object to use
  100540. */
  100541. Tags.DisableFor = function (obj) {
  100542. delete obj._tags;
  100543. delete obj.hasTags;
  100544. delete obj.addTags;
  100545. delete obj.removeTags;
  100546. delete obj.matchesTagsQuery;
  100547. };
  100548. /**
  100549. * Gets a boolean indicating if the given object has tags
  100550. * @param obj defines the object to use
  100551. * @returns a boolean
  100552. */
  100553. Tags.HasTags = function (obj) {
  100554. if (!obj._tags) {
  100555. return false;
  100556. }
  100557. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  100558. };
  100559. /**
  100560. * Gets the tags available on a given object
  100561. * @param obj defines the object to use
  100562. * @param asString defines if the tags must be returned as a string instead of an array of strings
  100563. * @returns the tags
  100564. */
  100565. Tags.GetTags = function (obj, asString) {
  100566. if (asString === void 0) { asString = true; }
  100567. if (!obj._tags) {
  100568. return null;
  100569. }
  100570. if (asString) {
  100571. var tagsArray = [];
  100572. for (var tag in obj._tags) {
  100573. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  100574. tagsArray.push(tag);
  100575. }
  100576. }
  100577. return tagsArray.join(" ");
  100578. }
  100579. else {
  100580. return obj._tags;
  100581. }
  100582. };
  100583. /**
  100584. * Adds tags to an object
  100585. * @param obj defines the object to use
  100586. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  100587. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  100588. */
  100589. Tags.AddTagsTo = function (obj, tagsString) {
  100590. if (!tagsString) {
  100591. return;
  100592. }
  100593. if (typeof tagsString !== "string") {
  100594. return;
  100595. }
  100596. var tags = tagsString.split(" ");
  100597. tags.forEach(function (tag, index, array) {
  100598. Tags._AddTagTo(obj, tag);
  100599. });
  100600. };
  100601. /**
  100602. * @hidden
  100603. */
  100604. Tags._AddTagTo = function (obj, tag) {
  100605. tag = tag.trim();
  100606. if (tag === "" || tag === "true" || tag === "false") {
  100607. return;
  100608. }
  100609. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  100610. return;
  100611. }
  100612. Tags.EnableFor(obj);
  100613. obj._tags[tag] = true;
  100614. };
  100615. /**
  100616. * Removes specific tags from a specific object
  100617. * @param obj defines the object to use
  100618. * @param tagsString defines the tags to remove
  100619. */
  100620. Tags.RemoveTagsFrom = function (obj, tagsString) {
  100621. if (!Tags.HasTags(obj)) {
  100622. return;
  100623. }
  100624. var tags = tagsString.split(" ");
  100625. for (var t in tags) {
  100626. Tags._RemoveTagFrom(obj, tags[t]);
  100627. }
  100628. };
  100629. /**
  100630. * @hidden
  100631. */
  100632. Tags._RemoveTagFrom = function (obj, tag) {
  100633. delete obj._tags[tag];
  100634. };
  100635. /**
  100636. * Defines if tags hosted on an object match a given query
  100637. * @param obj defines the object to use
  100638. * @param tagsQuery defines the tag query
  100639. * @returns a boolean
  100640. */
  100641. Tags.MatchesQuery = function (obj, tagsQuery) {
  100642. if (tagsQuery === undefined) {
  100643. return true;
  100644. }
  100645. if (tagsQuery === "") {
  100646. return Tags.HasTags(obj);
  100647. }
  100648. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  100649. };
  100650. return Tags;
  100651. }());
  100652. /***/ }),
  100653. /***/ "./Misc/textureTools.ts":
  100654. /*!******************************!*\
  100655. !*** ./Misc/textureTools.ts ***!
  100656. \******************************/
  100657. /*! exports provided: TextureTools */
  100658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100659. "use strict";
  100660. __webpack_require__.r(__webpack_exports__);
  100661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  100662. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  100663. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  100664. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  100665. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  100666. /**
  100667. * Class used to host texture specific utilities
  100668. */
  100669. var TextureTools = /** @class */ (function () {
  100670. function TextureTools() {
  100671. }
  100672. /**
  100673. * Uses the GPU to create a copy texture rescaled at a given size
  100674. * @param texture Texture to copy from
  100675. * @param width defines the desired width
  100676. * @param height defines the desired height
  100677. * @param useBilinearMode defines if bilinear mode has to be used
  100678. * @return the generated texture
  100679. */
  100680. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  100681. if (useBilinearMode === void 0) { useBilinearMode = true; }
  100682. var scene = texture.getScene();
  100683. var engine = scene.getEngine();
  100684. 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);
  100685. rtt.wrapU = texture.wrapU;
  100686. rtt.wrapV = texture.wrapV;
  100687. rtt.uOffset = texture.uOffset;
  100688. rtt.vOffset = texture.vOffset;
  100689. rtt.uScale = texture.uScale;
  100690. rtt.vScale = texture.vScale;
  100691. rtt.uAng = texture.uAng;
  100692. rtt.vAng = texture.vAng;
  100693. rtt.wAng = texture.wAng;
  100694. rtt.coordinatesIndex = texture.coordinatesIndex;
  100695. rtt.level = texture.level;
  100696. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  100697. rtt._texture.isReady = false;
  100698. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  100699. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  100700. 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);
  100701. passPostProcess.getEffect().executeWhenCompiled(function () {
  100702. passPostProcess.onApply = function (effect) {
  100703. effect.setTexture("textureSampler", texture);
  100704. };
  100705. var internalTexture = rtt.getInternalTexture();
  100706. if (internalTexture) {
  100707. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  100708. engine.unBindFramebuffer(internalTexture);
  100709. rtt.disposeFramebufferObjects();
  100710. passPostProcess.dispose();
  100711. internalTexture.isReady = true;
  100712. }
  100713. });
  100714. return rtt;
  100715. };
  100716. /**
  100717. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100718. * @param scene defines the hosting scene
  100719. * @returns the environment BRDF texture
  100720. */
  100721. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  100722. if (!scene._environmentBRDFTexture) {
  100723. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, true, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  100724. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  100725. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  100726. scene._environmentBRDFTexture = texture;
  100727. }
  100728. return scene._environmentBRDFTexture;
  100729. };
  100730. TextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAEZ3SURBVHhe7b1rm2TLrpW3q/fmfLG52MY3jME2GJuLb2CwDXzx//9H5zyczZCGpFAoLjPmzKzuXqvrfVSaQ0OKyKzKmJVZvfaBj//kL//wh//whz//B8lZdPqvJf6sWeLPXqrI+c/IxXTHWl427dENrAKMk2rudBK2NjlzwVzKO1keyPUkg7sm2PvgcACMAhx2wX7gchVYafBgDJxPAne+2dX5sOsan/i4HM0DZfj6YQawZFxVzKnuhaRFS6CYlqu84nBVMcvkpgtWAvmBAFOx0uTEvKXBqkU9bYGxtSqBl3YD5FZQTV/TQcez9WMszcsNk0rREW4YuRVBVNtWvWnlqAchsneqYI5gucqLQNKvlKdRWrfKMWLgljiPB0t+7rCPQPkDT/0UhI8rHvVTkGbqnNtHFDouuo8u0UrRDUSA4iCQBqeKqalC1qoYW5ZL+TS3ByoZXJpgWoK9D54JcLcLPluDwxa4WdaPQB28S0bcrE3WeVUW/M0dcCzCPbvkyCRTUpTqNAFGMwl7JqW1KZ/m9mZVggMlirkqQ7w9Pm/nnzWGdwD8Yl6/CbQ/fF3Ib7gwkV00P5nm906JNsAAxUG4acNeLvVCyHIVlkfxpixXajAOgE1ZTLAS55Pk8Rj4nhpsyvNJMJQf/+lftqMf535+A2Ax7wHX5iQtOUzXJrysRzwHhnEtJkOf7ui0YS2rvhJynfldnpqHGeQbYGi1DB6U4EUB7nbBrQFwuRYcLgfPJkEp8R5wcQPQxLn02L0JZIFXfWYy7NQOfoQNgGRaFBMp6eyfCFmbytJ9Y+Z10gIPSvB2Ad5lgpUGL46Bx5Ogd/wGwFmc/uKnhojgyVYReXoPdCYjt66imwG57J3uEGd9KTS35cz78jCDwbQHAkNLmJbgmQ9CgNfHwH4S3NXg9RZ4oexuADv3ceizZmBxfhPw3DkM+kmXkNbMj0DKpUUxvfzce+DFDLyU62C2DKZdsB8DtwS42wV7E9zV4PUWeKGUGwAHsZ17iuTIMeU9gJXIGu34MuOldRFOZzJyK8x12AxIZnVc1+FLwexCrqns8tQsGRwMiBzMlsG0BHsfPBPgXSa4q8FhCzybJOuB2Q2AYzpqrIFm4IXUTN05jKTrPZBi05IAmBmcean64T3AjOV9aeLFDHrT7M0MeNEHIcBbuuB8AKw0eDAGPqesN0DWckDdFF+zLGZJgexidBh2LpMT0Z3vWSDlUutFiTQz54K5L2W5ii5PzZLBnQF7ILCeEVbicgCMAtztgmcDYKXBgzHwSgkWA3YDyHH3sx7CTBXi8wQjq2glsgt5acNxf3nKNy3g2maSU8ukpSrmSuTsQq6DeS+DgwGRqTSGMWPvg1sCvMsEdzV4vQX2JTgb6G+AENMbAAugERR4FZOmaAc6TA2bnMXyHmDoE20zWraIMkScrWwWwVxK5liecylLBvdbkliC3AXTErxdgL0JzgfASoMHY+CNJZgNTG4A0UUga7QTr6Id6yS6A+3+5JTHktLlM+sDKZfdzEyL7B0TzCvfsz0fL29kcNwye9oFl+JkEtztgmcDYKXB6y1wqwSXDv9LsJzF1bmPG0NDTgY1BV5Fai/FSdqCk9npY9Pis0TIjGuLXIZW0Q0XwVxK5lS2HZhLGRncaoFUSpp2QRGXA2AjwAMTnA+ArMGDMfB5JRicj7/5l+24x4ef7lOQd+0ca24lNXISdqDD91j5wFqrkAmfUZ39qlXIsIrWYl75OWN5Lg8zuG+aMfjGuwQ47ILzAbDS4PUWeKUEV878BmjnPnyeWmgXkeWoscxORLSKP8SkC/qyzeRW6F7IsIrWYt6Xntty5lyC0i0ZbMretAcC30GAByZYafDiEnA+Cc63IlunuwHyua9mBA6WZmpkO5QsXbeTmmPqA9fzVXkg6ew33Qs7W7nFXMoxq2jLLzO4NMFsxh4F9P5DAe52wd4EKw1eHAOvlODuAHBHbgA5l+UGoEMzujziKF1IpuPCHA0xe4dhw7PoWmBW2nEZ/KmwDekw78shy3XdnWdwsxRZuuBFAd5lgpUGr7fAG0tw7CxvgIlGYI3m5T2QzHrQVz6fikftIvKAaplRkc1OhEbqy9K9bLXH2mRwaYJtaQ8EFgPCagaMAhx2wX4VyBpcriWHLXCrBHcHwMypN0DW7QagifU8xCgpwolbIkLLyWnWWPmMduZyhKPCdlDdidFE6suWp+aQ5bru1gwelCA/EDgR4PEYuNSrAXC5lnxeCe4OgMH5+Jt/tT735R7QLFtontwDSUdMTYQdSgQIrdFaiNxNWqrBbLoIpJnZ8tRMWa6rLrg0wd7XLKn44ESAu13wGRoctsCtEtwdAKMDknlwA3hpJ95zd7JV2MENU6M7zSlWvgTS4Ixa5GAuBdLMPM9t+SaDkxIsfHsUsBgQRvNBF3yGBp9XgktnHADrVe0GyEffboYww8cyaM+tZHAgR4zNwnyQzAjpllaULrqZlWDGcC5znpqzbA8HFgOWwbQEB76k1QAYBZjq80nwigaHLXCrBJ/nAPwN8Lf+avK7P4TouBnoY6OU5UywZIz3gMbUREx8fVqM1k1m0ypkRsXYasKzbejlgyzXVReclOBqwL4pcCLAAxO8S4PPK8G7HDCYww2gQs5xnPvwNeS1gUBWYUcqHJ7IVDZzEUi5bIE0OKOwmeR0gjmVMk+dzPMsadGyDKYl2PvAhT1JcEuAvQnepcFhC9wqwd0B8misuwHkQA9CdNwMOK+aqSnaMXWzHlwNWwiKn8tpN5uhk7AdktMJ5lS2PVeZAsy6cs0O6AeMaQlWoi8llQEQAjwwwbs02JT7SfD6ALhcRbam3ADtd3x5ExiELIsTX8qI0fFY+ngivSPhpq3ysmlmFXWmCOZUyrzrGxmoWC4H0xLcHcD1YEbYm2A6AC7nweES8EoJPs8BUxPwb4Drc0/NwF484tQa0nVtDvLUROgDl1i21LGulxOBNPVD5IwNc7nJYNGStGgJRax8sBUmNzNgb4LLAXC5lhyuAqUEdwfAMwccm3YDyJnGeQ2hOoTk8LELXhgKL5uTop3aFFMTVF+sFmJEGboIpIU/KZEG5yKD3pTromVMu+BYSAoHLMaM/SQ40WBTnk+CfQne5YCnZn8DIMZ3g+xjsWc7bSzzyR6dPuox9WgnMoc7tUvN7KLNMO9LpMGZZLAwRQ5my2BagjvCniQIAR6Y4ESD83I/Ce4OgBMHHI6B7fJ2A8iZRp7eDB75HjDtpTgsU4wOYmICFa3lTi6tq7oJZhcyo8JyKZlTafMgmcsMetPszQyYliAE2HTLo5BxDOxNsNLgsAVeKcG7HHBugoX/8bfjX4Gm576/B/INgGj3gJvj4R4dRD3KEUh9WXRdSMHsQq6ptFzKlOW67hprU54SmXVrCW4JoFrSuitMTXCiwWEL7EtwdwCcOOBFEwz+/AZomsIHpMQWCGgV3T0QB3RqgtFkpNZkuNd1gILZhVxTabmUKcuVGswGWgZDKXLdbRmMAmy6LuQ6dsHeBCsNHoyBUoK7A+DEAYdj4KkvN0D+NR/3QDjNDI3FCBVyHMPR6E72wmGID7KpZZvXctRSZTNnF3JN5SSn0p4JSKZlcGniuu3eE2DWbf39EnCiwWELvFKS0TxxwLkJ7vp2A+BYlzcBxOoewCuhWYJl0ox2gqcOWJvUmxaydFWE02UXck3lPss1O6AfMNalpGkX7H1yYFq1nwQnGhy2wL4EdwfIZ5hg5YOhZTfA5E0g3RXZlC1QIjOy9jCHwyCbfSDlMoYRUrnOPvXJPdBmmEs5ZLlSg9wCuSwmUGEPB7ZjwkaArdkeBbyiwWELlBLcHQCjA85NcGsYHLR2N0DT+a8CrMRZcSGxuQdWDnBtfnJC24s9+BRdlyJnFW3mLE/mwUkJ8JQ0G0WMPlgNk5m2Z0he0WBTlhbYrwXPHHBuklXrrq/4DaCnfLwHQnQaO+LFdjEtxelLUB0GUtInfgg7Ddkfcps5yzYPcgtMS9D7F8vBRoC9CXibkfVMY6XBKyV45oDDMXDXB5sWGLoff+ev/GTv3wSyxi48WK6bsy4ZzQSh+aJGmbRUrpufhB247A9ZrviatWoGMR8ZFLH1JW0HjNUM2WpJqwGwam3GwK0SjA54PAamJrjrg02L+EC6ATTGv4brDYCVzDzNrq3sY3IPIBUHgZR0EdIazBAiR3/Icl13x8xrZ4JpOXPacyYnYqVnplynwyBrcNgau+DuAHk8Ru764FlLkRvATnYc8V5MNDZljiNeyhTmgEszyuyrbucpmZZjYc6l1CzXmV8zUNEelBSx8oEKSVczwijAgbanR1YaHLbIfmCcB5ebkKkJbg2DTQvc79YbIOvlPYCNGFl7XDtIg0MhvusmVNuSMHsh1zDH7EKupUVGk8MqWgbTEgzCvhdwIsBUZxP0M62ariWHLXJ3AIwOODfBygfPWmDfBT5gN4Ac5Tjfg6gaiyNKyUM8dcDeVF39JDYtZLmGuc6yieuLjGtfVhElmM2YnLWMUYATDbQ072rMKC2wGSbPHDA1wV0fbFpg3wXbgckNkHU1sRc1REQp4xAzQHFGU8vQ5oeZxKaFLNcwF1muqy4YTEnZBHeEPGEyCnBugtmMXWct45USnDhgaoJbw2DTAq90yTDz8Z+lP4L3576ZKHGSXIh2IV2QHY96dmn2Jbt2aJKzazG7kGtpDVmu2QH9QMuA8ypaBicClOVgMWZMTZA1SKX9TIJXSvDMAVMT3PXBpgX2XXIyo8xvANPYZTTp8yy6trKP6iD1JYWZXlKIqeKoxexCrqVFUtk2mWbQlzYPpmNgFMB1Ww7OlggnGvBbDoZux74EowMej5GVDzYtsO+CywGyHpMboJ3sLLBmMLFRvQc4lksPe9WvTDGiDI00OF0rlaWLLFdqEN0+t00ig7UpqXcEitEHSdtjgf3k1ARZg6HsjKvhjlKS0TwcA1OTPGuRywFwMhP4cL0BRKNHEQ6F+vkGQNgxZXAtAqjougikvqQQ03XzkXLZi24JBbMK64LS7bOkRUsYSpNlAGwEUC1pMIWpCU408NKupQsW840TB5ybYOWDTQvsu+ByIDibtBugnWwe4t7BXk3HALKGHdNBdw7ITiqp65gLkdlhVtEtGbJcV13gpVwXrZaBCkm9I2wESGazFwONlQbrUmTpgv1ycOKQqX9rONh3weUAOJnJzOY//vPyNwCG8s3gTjM5gMzIWqMrwcZRHSEGdS9WvqS+LFmuow960+zeNIbSZBkAowCDlrQdMFYarEuRpQv2y8HogKkJbg2DTYu8PhCcTyb6GwBb5LOOwEvuursZIFLYwlwCL+dOLl13YxSam8+cSmmlsmS5UoPZAOn2B9vShkEIMJrTLuR0AFz6YNNS2uZkGJg44EWTPGsF75opXC2RG8AOt57g8bhHq2rkFLsSqS8p7NXq/c6kQOrL627KvE5aIM8MpjErJYUD+q4w7QLVZmxnjKzBQdl5ZYCM5uEYWflg0wL7bnA4Rm4NF3Tt+gZAe695WD2ybg4fJsreETmYUmWTOXwvTWi2Vm/mzGtngr5szzYyKCJKyNUM2ZpynQ6DrMFhi6jT2eMMeNEkz1rkcoAcjhVurrIbIJ/s/e/+ZmrYMLULCaRcFkcKCTtGK5PZhVwHk3nTIt2eYFbaDJh1hV5IGltgbyrtscCJBvsSuNM64wx40Qxe6YLLgcLd+ZHZDpMbIOvuZgiTArkc+lUJshOlijqjYhxjlutgMltrnW1PkFsgz7gQki8Mom5IpjqbQEvzpvNgtqRj65gcZ8C5CVY+2XfB5QA5HBt5vND5+C/ij2CcoSLyXZFM02hp2Amelkh9iWyOaoo2M5p0UpbrvrXOkrIJhtLkdAz0QlI4YKqzCVIp32NmupzsS9A7Vo1jYGqCu37w+kDh7vzI8Q5yA8hB54FeicFENq3RnXKWYFGKE6WL0ZFrdlKW6741zbj2ZRVlDPT+VIRM6lTnqi/Wq0ApwejQm/lzE6x8sGkF75qZ8njhFX4D4AH0oI83QNel4AByil2JlDSFOK4pRkdMiiG34SHLddXF1UXxi5C0HRBcyDVMcEfbNbfArRIsnNEW5q7yrBWczAS3hqe8vkPcANgrftNvBHK7MeBDpMhl0yAc11KGTsJWJQdZrmGm3DYcslxHH6ioXTATJrczRgyDps40q965V4KFM9ozK/FKN3M+Se7Ov0L/WB9/l38DwE2HeyI0S+DFdlM0hEfWUmL7KFWX891OcAikXLqQa5TAddthyHKlBsPApAsGYfuDk2H7ck404bMNysC+BKMD3KzN6XCw75KTGXI+ueL1Ha64uAGQRYegGfcDMnzNTYNcJqd0RWbHhcjsaG6TfV75yLxOWqB0wUyczDRiHvR+I2uQSpNlAKyXGKMDkln70/lg3wWXA1Oerbrk5W3lBmgHOp3s/blvJkAJ7ZG1lDpggeRi4yCLqcKyimp6nvjgqiXXwXk2I6g2Y/Ab65ZUZRg8c0Aya386H+y7weHYyOOFn4PdAHhacaab0NxEmmlaQwZSWAmmpYulg9SX0RWfZZ/NB6vWdCC6pMwAFZIWLSPp+YZk0wL8OWRmM5XRIb3fVaslweVAcD654S2bPOXgBtiYyB5Zg2UphZYqJg4zT0MqTSAlHZnXYjLL1dp9C6iYDJBkmlx0G6onw2AY63CndcYZsF5Y6f2uWi3JnMwEt4bv8nmbf8jmH/9l/htAM7Q4IfrWRHsghZaSwk0pXcvVReekElmuqWQ2s2RcR9OzjWQTJNENgBDAte1PtpNgPkxKCXpHqnEGnJtg8JuxWjJyPhk8WPJDkRsgn+l64metpjmJbajhu7AytUS6oCMyO0h9iSyOipzlOvq4jua0BQZhAyAE6E2r9pNgOkxKCQanPZPC1L8z3LzVqpHzyRWv7/CZ2A2AZ8kzvf+VP78HoF00DbIfpYqJwwynL+UaZcpyzQ5QMRkGuQVmXbsOppDMZk8HQNLtEUkpwcIZ7Zm1MMHCb/Zq4Yq788945VHweeYR9QaYHvdwum6Y1BFIqRQtlgaSi7mjWa692TZJWa7ZASq6YZBKSdMuiIF2UYZJuU4HwKCbkVuglCSZy4WZVWu9xDqbPTc8W/Vz8/Ffrf4GCKdvdWNhloPO0p2spXRRnZTbbp5HR8aSNlTYMMhdtlwIMxEyqapPZrprboFSksEUYzpJHrVaZ7P8hBeX/0D69wq5AexMI1b3wOgUE0DT9xB71DGpojl9KSnplYMs1+wAFTYMhq7JMgBU1C4YtKRsgvV8GRzqmQPGhZld76Jrzf0OD3j7hoc8/fBD9AbAU/eDzgwnjnvTyYwxMTV3GmQ/ShV08iRzG/BcHcxECdyfmpZSKbjodgYhADckvd9YzYDZkuUwGB0wLszM3cR2oDUv93mdw4d47RC/wsd/jY9AeJar3/R0XJjZd22AgRSavlgaSC6s68IcpKSb05typQYbEyyGiT0WGEXukly6luvBGKkbkgOzjkyXZC4HYuRg8vfA9u5qNwB+HJujP74J5K5pEJqB5MJaLui0VZ7zPhRyDVNzc8DGBPRVtAxUSOodI7rtomQNYnMwtDq07LwyEAy+Gav5kYPJNnK+7U/O438Fwg2An8Kto29nuh8D5muIMdM2Fs5QIss1TM07B2RTRcug+OCkBaJL+lYgsptbls0uA8HCtx/RCceTNni+8w/k7R+Q0oZ2A9ix7s/05uiHkC61hmmw1pK2JbJczx2QTRWGC3kI4pNGLAFlRhGZSmEoO2M7LFUZIFOTaGvTbxwNGW32zqrP5TMP+oqP/2b8COSi3gA6Zod1cw9g171WMS9TvucAF3bWVz7YtMCgm5FbIJUiSxfM5uvUuCrj3f3UVXtOt+jRDke8/VhPefoocgPgmy+/48ejHwOi1ZncA0Ad87WsWgXzvpSUHYAZzdTM1swmri7CoZB00gJZo+rL0hXimZDZQNDkOBYMrfnsZocr3rzh9zno4JUHGtbaDVCP/uw3/SiQm8aVmqbUXoZGctFK6lJ6njguIvPambi6CIdCUjggdZs9G7BrbpEyANYzQXt6I+vW7iEecb1NTHy385158UEPln/8t/mfQe8LZNMappHClEJLFaIppiVS0lOH1zxQTaBCUu8Ii2Fij0WyBrEwqHW/nIwOGLcic7dh/auxc96305t4fOKfLfzQGwA/Bv7il9fvRKgO0UwKMGi5uuhamuUaTi6BijJvqTd59YsJSb0jxDBoyrSkbAIv7Vq6pMyA6RgYJ8FqeMB+FO/j3fud8fr7yYMdZku6G2AukOOU5+Me90DWSGH2GllKFZJCl1KzXLMzDFjKJq592cbapQkbJkmvfIFPLFNrQbyZP5pmTIdHfOxw/JD37nbBK+f+TSe+8PH3Vh+B8GLvbwbVMSwa+6kWc6bl6kJamqklJT12zVERWVIq5eoiHAiT4QDVkgbTrtkHqTRZBoibtTkdBvHcNgwT10tu8vYNO77nob81r8NyA8jLMD3WlzcDIt8DYSKFGVqUhEgvs64lU3Q185pNSamUq4twIEJm01MyQfZBboHSJbUWzJu1jOlWmXVvt+o+793NeHzuP//QZ7obQARy3AzprhgHolXvAexKIaqadFoLKWlpJS2JGuQBFZElpVKuLoStCdHsPFDmQena14K8bWFoTCY3OzsHIzd4z24/4aG/mvz47/gRCC9YHOv+rLM7+k33XWBmEjLgorVY9lomk5ZEDfKAisiSzF06dg0TnPjtklBntItVByYLjNZZzxSOB494abef7dzfuT3kBsB3L4ds/cmnlM0pXReisXuYoSlmZddCoga5TKbJ5EtKA5bCAWG2ixK7gdU86QrBjMEPpLPuNvJzOObBkhVPtvo+5/7OaT4lTdoNIC9APs1+D0h+dg8gDcIGVDDLdaYlJS3XvoQwmXxJacBTMkEsBMm3/UnWrHpHcGfsGJcD5HBsxoMlG27s9tlH/8H+J0tmMx9/f/wIhJyOdSlFlHsAkd80kAG1C7m6mPgsQ4OhJde+hDB54oCm0gMB13bdtEDuKp0xdMHMuzO5RZbkZY+P5uGjP9v/7qrD+XeMyQ2Ab10OxOrj/lBOnc7ExjSRNO/8tZbrtoQwuXEgkw5frtkHsRaUFozBiZmxU5CByyFlPrVdu2vePHkXz/HuOQ7OF55MHu52OaYDdgMgeHzlZU5lOKf3QBaA2oVcR19z07i6yWz2tAQnDmTSgpbjGKiTwJ3WGWY2LbKwK5f7jBwNnh2a660OD19wPn92Xq+5uc/Hf+8fgeIdoJThTO4B5P62aRrJhZkqRFNoXmlLuaWCuSvB6ECmbrumASEWkjzZLokyH6g7byUmA7M1l/uM3F6yOCUX+xweQXI+fPPIznk6IzcAvm85Luko29k9vAcQadJMkIQkdrWUq5fdjIuuBWIJYanCCAe4asuB6nEGdGMk70a87vxh4bhTQ3u7gcThWHB3XlicmOVWJycsOBx+emo7Xhv4+AfxRzByuQf63+7mr+6BJJpGciGm5uaznGowlCJLqSIoa+2aBqBz1Y21iyFV75D2KCNl/4F9Nzgcy9xesjgWy31ODit449jlzDsG5AbANy0vKnJ/uCW/eA8ACM16aWbzNTeNq5skl5LchwgZyoaJajOS382QvBXJa0newa7OpjVwOUAOx4K786vDMd/n5LyCk7G3zLxvwG4AhByL4888HB79TiNlIRcJkV7ONa5uknmpNB1d+1JUWBXmzAFS9Q6YmiA/h8K8k1yT2xdpvf2S20sWT2Cyz+V5At9tZj9ws/vxD+OPYBzBO7/vy6rsmAYQmvVyYVrykle/dGNydSGMw/blxADR4sQhRz5xa9JK7LvB9Vj/ch5u21iclck++1MFLgfA65vsBx4tlxsA37GcJ0T5hyAX1/fAIJpG0mwmRTanGnBYBXNX5kkQXaCqDINuHuQlTp1xlr59TVjYxr4bHI4J+uremCezM1E3eXSwKi9u8mnLP/6H/Ecw4uk9kHUTeIQsNO9MRZYTFbk0GZP2pUQXqCqlXZsrWJXMJqeTgdbVTGxa5HIAnMxk/nx5UAqL+e5xXzx8YD/wqcuvNpcbAN8uj6zk9CmIedU9EkiazVEhKUzNc63Cri4mLfsy2iSIYaJFc1ztZhJizhoTz63pPpk2sH6dLjcpyPzlkQoWk92DvnbCfuTyg+7H/9i/A5Tf9My1HP5W7gR2nTpIdLQMM+tqqrCri0nLvow2qZSyLQ9GJ/YrW9m1Uh8ise4Iy27/yu03Kdjw/rUPFmPdIx4cox2Pl3/ezsC7cgPg2+XRtHxyD9wSSJrF0XytVViy2jcB/Uy75tI1KCWYO8RV3zfMHHrTYbJpgX1X+DiY6bH5ywME1jPtQd9xzuZsuvuF4E1rP/6n8g6APP5jaF9e+p3Ag2ShObSMFQ3yMK+hywxRZWVMdpdagibLTGJcBcYxsvJBe9oZfxk2CwObuXxplbbhyfxi5nSTTfeTFoL3PajcAPheeV4tz94BmEex8k2ALDQXHd2qXcjVBWiamxBVpyXIax1z+sY4Bqrp9XQYrHxi3e0r1+1weT7y/OXwYuB0h033t7DQbgCEHKzIdz4FlVIENp46SJqLjq5pFZas9mFlpdtyUsoyLP18Eco8GcfAbnLGpgW67uJVrDtsX+w2vD8TYD1gm+x32HQ/Y+HjPcGs+/GPxncA5kd/CSDlsgkkzUXLlY4LM1VYstpXKSvdljtdV/r5UodBmScz74ZJNi0w6fYv2OVAphveHwuwGLBN9ss33e/ZAo+6dgMg5IUv+fweAIsxEdqVpLno6JoOYYVPKivd1ipdS5r50k2CMgwGQxhNcWaj0+VA/PWLtFqVl8xnFnu24f3JILMZ22G/fNP9ni3wqPvxj1fvAJrLfxczkwLXXM4EEsumkTRPHJBNF3KNgbUGXau7xFXhoyRK11PH6ICpCe76fHmWXbAfmL263fD+cIDNDvu1m+6q9fYNyaOFH//z+K9AfX5WgrkjF63ohPCWpV7I1QXotH0ZtRXwQROtVFW64MQB5ya5aF29xpvl49pueL8zmA2cPKUlq9bbNySPFsoNgO9Szs063y6x8crRR20OEq3UkmRF8rNZtH0ZJvWSbGE+6bTSVRkAowOqqT/u6SRY+aR1F6+ZDBy/0tMntmTWtR2OH7Hje7bAo4Uf/+TmO8DUbAKp+GK5o9ocpOyokGRFE20gmxyP4e7S5kFeAvrqogtOHHBq6isxHQ667uyVs4HVi5r81RNYMnQvHgu8vQVW3WeryKIrNwC+SzkH67wvm4n9iq9OHUCKll5zS66DaJMgaRExbFdTrQw9TirLcjGPH2V1xhnnwp+9KpMl/Vg3sHrV3b/crWNoteVXDzThWQt8xz0//pe3vAMg5ZJC3ORHSaFXE1Z4N0SMgYU24fV8PvvKcpWyL8loNif9rKdrQfX7l2e+arXt6oVX/3KryuaZbB9ozhuXkHcvlBsA32U7pn0+amGbXGoWj4KOzlC0UjPpzKkAKy1Vu5z44JUSjA6Ym4sf/XSYr9O8RVYD00fZ/NG8eFZCanXLV0vOtqo82A08eywyG/j4X9fvAFOztrDHYIo3K8XReXMUE2wthKdkKrEJaLLM2FXIM54at0rQHP/JjjOk89PLsJoHF//L/unJXiyZb7XZv2+tnnzH8W6NB0vI44VgGJAbAN8iD2g7pgdZBDbIZTLnZcxT6LUKLcaWp2Qqor0+9RObFtgMk7kz/JTHMWH7b5rWWr+iyztk+ujT4fXmuVWf5AtbVVatzRLwSpekmY9/evBH8JhFYPXWjNIcXLMvtQq29sIvoU0okwGl06nIPlgtAaUEnaM/x4sZsBgj4i9es7ZkNmDd6drePJ/s8FZ95qslB1tNeLAb2HfB8cDHP7v6I3jMJnBdm7V0QVOEZktXwq5h6sU7QqdTsZyxq5A12JdgOZB+6PNVs1dlupx0m9xcK4zP52qsw/3uaZCrJRMetDZLyH7gcjn40BsA32I7nVfZBK5jqzdbKcp91RRW7oV9CaHdaGMgyaT56M6JBvPSf6ClCybO7Kffxvput3zTAscLDTdXD91YL6/Pgdzah7y9RfYDV8s//vmdd4BWYmlpIaVSjChVU3TDcmHl5UyAZtqXrSJL07mrwY1Sf8RlAJjTvwDjQjCu3bVA2nO6YYeadZ/1ZOXlf0fq2CwBDzYMnu788S/0BpATNstTE6k41VRtJa6qQ9AUodnSKPRiAtJVnVHGMTAdACcaWOk/u3nXKcOkm9FWWWWsDtl2Cand/gkY033WkwVZOB0GKx88a4HPWEhmA3ID4FtsR/Mk4zo40wEpozUTVorBr17oxQSkq7EF2phdhU6nosn+8GUNli39UW6GpwPC4qyLuXj99v/aM32IKaf/GDob2zw94Xu2wCtd0A98/G/3/whGCm0C10FLGZNJWJfCcyfsqxdKN6OEA5ppV+G5Hg7rvEw/0DIAxmM3riLiz168lS+oPz7ovX0OzNVz7th0V63HG4JXusAHPv737UegScYi11OT2kpci8nJvrTEUuFaEfa1aCkmyphdhanOJn4cl/PC1S0xDgBx+tejzSR/ahJrLV7Uw/8gsNvkymzPjaweEaxaD5aQxwvB5QBGcAPg+7Nj2ufRFIFFpVUcXFWHEJkEZ1qp2VIIZF4GH8wd54EJsgZS+o9v0gJnXdAGzk1wNZw5uQdWmzfWm3RryWoYvL0FXumC9cDH/3H3IxCuG8e1lFL0JsW0VORKR1Lv68WNJEJl065NZD018TOa+0o+YaVVFoKu1IWXS1ZjQWvNXkvpznzDW93+q/np/neGjbe3XuySYebj/0w3QIhdxqKNo9pKXLPZl8X0yhaK8Iv5mqMEVehl2VXihexMuwpNb471qpV+uHVgfG3GewAsTFD9fsPWHR+ITDcB0/nBlIXbnedsWuAzFpLLAeAzcgPg+7Oj2eepCVaOlFL0Y8lZlpo9eddLG1DmA0mA0dx3gWj/iUyGtZV9kJeArjs7x2UejA6YmnTqnutHX3HvF/l0/1s7kE0LPF4IXh/AyP/lN4CcqpOM68YJLSo5Q9nMlC2xVEwMzsono9l1/ecyXQJEr2bSz7S11MyToJy2MkzMHCd7h8yPr5vl0YVhfrWzcGvz7fCcx939QvLCzMe/XPwNMDUlY9HGCY1rcqzcmJ5F2BeTZdANKN0At3W6Gf3mO8dpuv+13en0s1vNAykXk6Sb75+SMI6l3UDZv7C/Pchq58Zik+55kls7BJ/XJSczII19/KurfwatJq4rR1Snaytla/XZuuzTl2QZFB9MBpzR7IT/FCZLVjeDLula/U88lpOyEOS1426bhWTlA2kNppH8zQ7GzF9ufmeTjs3A5VrwrhlM4QbA92fH1HMpu4xrMcVqLa0XrT63gZQ9zUqlE2kAUEQJSgs/lOooovXnVU0w+v1PdjWWH8uY/Sqd/OZe/8YdNwxaa9wQuLnZoaP3DzefsGmBV7qZk8nFzMf/vf0bYGqCzpG694uTs3ebqV8TU2ldhaKU4HIATIbTD6Xrut8tH4fVyTNwurJfRSYOvnoz75+Z3i1Be+hxjKxvrTneqqvW+y/ZtMC+Cy4HgsNJH/v418PfAKWctLAut3AtfnGGLGmRQ3hlonVTBisx+kC0fudjd3ozYLguB/0OZQaUYyrdcfPFwwXjGJncA0DN8jTGtWC+HKx8ML1twKOtrrmcOdmEHEx+/Jur/w4wMbEuOa3EtQzQ8dxaJZcBL6mBNw0RPglWIl7scQCI1oHaPTBBPeWpzEtAKUHbZ9hWGM315o2z3+7L5cGsJatuLhEeLClcjh3uEwzzH//P7I/gUtYWZDal7v3iTLN+5dyZuPJinS6DaQmOBvSnEA4YzXBAmxzfEMrMbAnIq8omwuzsTn5Vz7bKSGtcBZI5PvSccedgtQSc7TbhcgCczJDzScz+v/0NECLniYkUZWhRySm+GEM3sn1NhkUMGRQx99PZWg2YcMb3jbwJWP2yX82D+naBrysHzM3ByTP2uOMMULM8MWM6D9yfrFotIZvufiF510ywHpYbAN+fHDXNIS5KXHvdmaI8hy/V0BXbuiG6lmbQWkrX9QM3745ielekn5GYWnZjPmBmPwD2p3xSgpsO2dwDtoSMY8pkOVn5myVk0328sHA5eb5VoEs+/r/FvwLtS9BMKZrZHJabbF9tXq6DA6yVMjgt9fssPpi3egfEa2/megDMZ/YlOHaI+ckxhnceYRhbLg9WS8idhR37LrgcIIdj4GDy498ON4CI9P8tgHzzpcuM6zhD8zLrV8vZwVUvWYsYMpiUw2/3Uo4DoJ7y0dFy7ILpQC37JcJwWMcBUGYmZr/KWmUr4uZ0zzmrJWSzEOy74PWB4HwS9MMf/278Z1D9/xhGRPi45pJdcb0MjWuUm4yrXjon6+gqucwZ8Ny0MmUgYnri8TVbWIfLTPrZxTyIgbwclDNdS3xtB8DogInpTn70srkx3HiN6bwyPtXKvks+e4fM8eTHvy//DJp/92cBWXyxmu7MPksrspuWszPTnpYZTMrh0Fs59fWH1fm9U1f5D7eZ6cedB8BkflGCE4fkbTPTG6ZMrvZsTB8us1kL9l1yOXOySXBrGKT5b9BjgOJ8/Fly5+tPpZpe5lyCJr4u9Yd8tXKagZW4RLgpqGPd8FnSd6M6WmrDSV1raYgXWgrFHYOtddmCqF7OLEyze9OYmqD4iExpMTKlhSiULiNTWoyRMpBjSpnJkehvAD3lOUArU7fzvWSemjm30BdsEu5zHl88B82JHC2tc8tMXwVYWliSS/jVsdQ5Qu5SaylE6U57ULItyzMU9k6Y4Jm58RlB8SMKpYsolC5ipAww9pRhxB4fm78DjGFLyh3ibwLFN7MPmpL10jn61fm4+Ils2Q9iy8p8QMmmlcgs85g7NkF6p62SwoOkh5Aquu5EaYaXxqrcOCCb4U9NcGlmH5QWIlNaOQqlixgpA4gVZSzHijIW4dgNAFaiBD4Pmih+NvsZ5giWlv1MWNZL18WFOft9lotG1xpNllp3pTqkrXIzHKPX3XLqsaQzK28sJ6OZnTDBiZ/Jfm4VnzFSBiIypRUxUgYiNpTJiD14Cf7/+C/B+uevCM0bAVophZZFRMY1Ccn6Zc5QWh6ds4xvqZr6U8glNTDTf0zN3ztpQ7D6C9gG+uH86EIp+93I6NQ9SXncYNyQl3FbMvPbnqtVhfeOBXfng/XC049AOfDzaKX+bMwPM0UxWeIrtISWDJr44m9HydlfZZ+3EllLLhdSaV48RF967TqcrIGXZnhprEtJqTTcMc/LqdO4NF/xQWkhCqUbMVIGGBvKJGNDmSyx5skNIKH3ACgOgz5zMUvZsl7YYrCUrPVF5iS/GJa6AYFl1KtSHRNpoDlWe7BKZdMcTqWh2sYIdZRg49wysw9O/NICpYsolG6OFWUsYkUZizihLNGwG+BbZ3rgTEeUVh+Lzc1nLiZe+FxK1lqyOhEsrzMufi4ls9SaZR44LA3qqcMql1mDUoLiRHnLAecmyH5urXxyq4tYUcZyrChjEXvKcIkZ63eAcujH2yDK5IMicsncTD1wrYysdeRSLrNc03LVgpYhpRU9bR2W3HbqGOwm7UUq1ZGUSuOWE2Z2wgQrH6x8kFt3u6AMROwpw4w9ZTjiHF/iN8DqcPcRn/5jhxCr6Aa0zia+cmnmkCNYTjLPpZ9O8+kkbWUMa0su29LWEu+a45qPGyWJBxXNr+QIMyevEqIMB4wOCHPjn7eAmvJX+LrbxYoyVmJDmYzYUCZX4dR3APkstDj9Frkbmn8Ka9n9iZxCBqaln57OTKVkrW1ymjnGHD6dXutFUV1bLENrGZrDJuikrhZCW05WpTv14UDvmN2bxqWZfbBpgVe6pMwwLinzEZeUecRN5AaY/wGwif0d4gGK2JValNxKufqkC8vDKvOR6Wy1XKLkcm1MS4usWYIYTs6uBMWJMhxw35SnkXHfovBKF5QBxJ4yHHFCWcJ4QL/D8DfA2eHOv/ubmWPml0ePMkQumUuJL7zAPGqWo4WcfLNA6ORL4qRr+iKpp2VszqQ6HJYt6KVSkpfiE3ca4WxNu/amEWbxQW7d7YLLgUwZRlxS5nMcUlaN0fMt//qfaxzls7sCrEQLvPbJD1FKCmaeIcthUuSWWvSrSc2Oai8spPIlRi5VcCtqi7EEqrtHAaty44BLc+Vnsl9aYN8FlwNBmURsKJMR55SFETdZ/ysQIh996nwnuLYP/TnnUAewHEUpTegZ4jHKvmSa7A6m1LqkM9XeaL0oqtkyn7u5pqS2MUi2ksOyBSklcKd5LOkHLIsJ7vogty67iA2Hk2WMcU5ZGPGMskn+CJT//M26xso/D32Bo7RnpQVbIsKnCF9rmlZmM8p+0pyiY3LQFkhJj6Xpseyd5aqNAy7NE58ctsZupkwiVhyOZcqSHK9QtkIM2A2QP/xIpFM++VwU3YObBMyFFsgmcsuFZA5kX5X4LPWLZilbJlp2AgyaVWwopP2FXFJECbysjzuYtkk4IJxLE6x8kFulu2llyhhiw/kkKMOMFym7RRyg/wrUn+N6M0yjHP3hTgDFuRd6Pnhc6OArO61EFm9SivKQ0k2VC63CXTWpQS5VS6mV+b3TgmQnTHBm2nXwjeyXFti0SB5gOPV/WgfKJGLPreGRsnwaj8FHoHLcpUyn2UqGm11kfzXjoY94JfQw7Rx1WQIrvV6WblJLSFG1yaTpW+maMpdClIPDhzbctAimJrjrg9wau+RygOQxxp4yjDikrIp4I2VnBN8BLP5cf/fXmyHdBqX1StgT0wK5OXrpHHW7lvamJR2RoRmKmUWrcLdpSa4Fai/Lzq0bDrg0/ckIvd+x8sGmRfLAagYcjoEyyTikrEK8hbJniRntbwA7/Ysjbt3eZJRPUOMAKA6imXo6i4kvmuaoO2mpZktrK0XSp+ZXDNMctciJtgKklvmpZcPhhWO16WqCcIoPNi2waYHcnQ4ED8b2k4WyEPGMsskY95GPQO1weyxPP8to5bM+nPtpgFbqabgw1WWLFxGqpUXJNlvqs2Vr2S2lOiaowV5z/yiZqLU07jjx3Az3Jy2QuhaFfTcoY4gVh2NBmY+4S1ke8XbG/xJs98P69FucHfdl8AVOjuhi6oVaxKBFqlavzbMOX3teqraSw6GlsK42TNhCL1X1mtfeaeXGISsf5NZlF7EizUz+78sKafiCPMl4RtkE8UbKziVwvEPL0R+OtX3uTzF/N2DOYhV6pKqJSCa+ogwtJC1ClYzJVxKc4YAoF6qjjK61aNJImr4XpqOyltflgQR3shdm7/Z+aYF9l5QZxoYyidhzPrki78C4RVl7GVfYR6DuWOshnt8P3pWY/tG8CT1zECBM0cW/1DpPRKhugl8cplDfRCpzV5I7Wii9tuVeMkoZcBjRPHeSpax8kFtjl5zMBGUYsUX+DfTOfEdZGHGXF5df4e8A6azL0e+dZjL8DrFyH3p0JIrPyL5edhoZFzdNF+HaBL90uUj6Q8lakm8iOTtEW+oqpQQnDghz45cWKQOIge7/gL3EhjIZcc7jhSPv2ueA7l+BulOewj4IFQciZVmYZqb71IiD6NrK0Hr4QjPJcaTWbhZZm+ByCs64L5FKMwn16ASxGynLAcvsADeLHf6EaK0GgjKJWFHGGLcoaxkPKDtEfAblITyGfwXqzzQOevsgBOG+OR5Hxz2Hnpgo8ZV9e7ZxUGJYvrylvRCd7k1ZwKTaOpxJJaOZ7lgo1vWydIXRAXuz+GDTInkgYkUZQ1xS5sd4QNmB8RbKnqtYkP4VSD/T57CboY/uftAsk32MThd6wpqOMglczFEBosuaXcIxVT4v7c5U1wVnpJ6XrCX52tjBSKVcWarjdmc2piYIf2yB3J0OBGUSsacMM16nbIh4L+/buf0R3E6tn2wrNbqZ1KqrsuPROX7aQjPwZdpF50itDk02Zi1tMzUtxCQk26mVy+haTbI5+hmfaXY4zVLCdL/r00/dOXlsP0mO5yf/KyBSdpjG65QNS7yP/r8D9Cfbgp+CGDHp3ezQLE4XeiwQMuZahGrQmVJLWDlzdM3QWmhBh02yndZaKOzGTCP5sZXAsZmTPcH9OfsuiIFbYxG3KGsZ76VsHvG96N4BWsRZ7w89yzbQj8G3MoWZelzCxJfpLKSRJr2lXzuHRWuphdaopaJQ34RqM1iyID5j2VyFkwxLndOx8kG0pl1wOQDyzGZsz1s2yZQNx/j+9I/bvwMg8olP2m4MRB7ou8VEmKnnpkWUMwGag+xCLltH3eaQom2AX1ylWMvrVrrTyhyZqQlWPti0yH4gupuZKWVhjgeUHUr8QMoziSBezt4B+Ndw/pu4HHqWmiddDS4UreesRZQrwWLmS0uf+uiImR2w0CKSb8GqlPxKjhGmR3sgRaroFsIfW2Q/sO9OSUvs/4WfV0i7Wfw8PHpiwztACRzuOO5+0O2uiCPeR+fzXIb2Eo/azNxKvqBF8aXDQkW0zMHVTS26JdA0m4bUUqKU6tAuZtD5OQorn0T3cuCEGD5fMqXsw/ixlCdT4hH6DqB/5lrwBFNEGaFOedwIzjRHT96o7fTrEexaU589oKL5LqIlVzhmiWMD0S1aLzGfuwbLZMqVSzzPYSvHlMPuaiDIk5fDI2W5xvX/Zu4V+se6EZ/A4j+EbSLeELTMN4kNMPTwZW1j9KMbZfbXpVyAitKSLnFTGzS0q1pKas5I7cGkuu1GOFBMEH6OPfuxfTeIscvJkbz2wfK7lIdD/EzYR6A4xBL+619ayBpiprMeweU19GwhZAZ/Z3DSz2V0dyXyqnQhFxAidYsZGkLKwFvmeRnY2t40Z/TD8G5bnsNHGkN3zuHYlFfW3iI/EOPnZvYfwhB6+pe/3f3XfxMeMV9X8dSOInIpNcsFsEy+iXDc5LCEO2YClq5ZWqWlOGY0x8q4JLMjWquBkfP5w7FCrHqwdqTstonfFuX/KD6f3ey34I2xDpnRk2RBHU6U2U8mn1NkmiJlQhzLIDsu6lZAu7aJl7zy0iYBu9kBbhY7fDZqF6QBeZQSe84nM89WTclbvb7bd6M87cvAoZWPNzy++iFHjjh/r9NX08LHbHmIHHpQOh3OptSMr9GUfCy0kO9KUN0MV3Kl1tLQHVzaxcZ6aMYwaJLzETPEzjOrOMD+pwr9quX/fuGEfqufjvz0VnGf9hGIO8QpZ46dJaYnPpYg/ON+aBwUG6OIXEo8kdxixIAKgcVegFiu2pUg+7gGVibHyuSYHHxw3QLRjXgL93eb3xuxT9rqpbvodfJTyvE5+Eeg+AWfHhERZo1xPg5r0jaTb4bIpVwMaCFPtPhNRCuZukDDYavRlyJ1PjwTajY3CH9sgX33MW/ZNm/yyj63KA+6j++L/CuQHVM+gfRRh1l+8cfv/sWbAI9d1RSeZbfeiUDdTM+qvMxdtojVSYCkbW1p6T4Gu61WfCwwOfiNaE27I3n+MB7zlk1ukR/xuz3oI7qPQN2hh6PZBtKv/F3EpyAe1iGvfMkReF7ZVKGu5qFlYqYbdNvVlGlF5ltbMDn4jU2rEJOH86/wPR+LfP9HfBN6A/Cg+xEXncowl+8D+cwlYTcDzZR394BmXEoJpAxfHS1UgJUGXtqVF3fs4g658MHQmhNjl5Mr8g4RI5cDn8H3f8RPoL0DMHC4850gZz2/D4wRv/KTIwtT5kx2NhmI1lK/WilddczUKrrqtgFBS3pi28Ww3dxpnd7vUF8W7tnssCFW5ZhSZhDvY/cX8Kc96A/E/gjmoZfTr4fYDn28CYRwbT+EdLxMa7a7IjnIsgpaQ1qzACI045KXy0WTOGpqIabgZhvw0l3OKdrN5LG+I8gwY4PPlJ0v8FUSn8nzf9j5Xs/wR9H/DZBFPuiI/mMPJ1v4iUe2k6e53gN9OckuQJT61Qa8YFKHJsgaTEvuGbg5YjvPWsDs7cyEmL+16nv+0+TTZ/gboHxrGjiTfoh54pE1OEBtAz5jwUOPMZ5Fz2yFI2MQjGF4kvsSl/D5PVgrvh9eR1+Uo2W1vWgONf3sFmJgM5O5O38X3/zh/4TTl1v81infSykH7B0AXcl+vlm2464i9pFI58lmNKLF2yPOZdwSYcZdgYYIPBfNzRGriTamWkq9+kVJvgSXxCSJtldG74/I0xgGclWXzuZfIjYskSmtk/iNUr6LiEwpZ9Q/ghFYJWI49DHQRf8rfywpLEdks28BmlOBS9ZS8spLUEoymFLRVD83TevDxcCK1ozh7fwpebe3bPhb5xN+Gn4D6L/2QMRHoKY5oDMmeMoxwPOnuZhy9LMYb4ZVVoGvpRg0lV29bNAZTOxQzWC6ZEUMH85vyFu9vtt9fvD/CGLKJ/9A9F+B4mSn4z43EXryKMRMWVobEaXmEiCyBMsipG1dHe00w6/JLORVCXE4P/am3BreEPvc2epnPKmvk38UEZ9M9xEIDyfH3d8NwpTgP4zOgucJOW6DLKKVy0lOJb4g5BqCX+yqtsmiCSfVbEGnTJIYciYzDnYow0+ITfp98rH+fR7xIP8EIn4E7SOQhT4TmpNDrye7CT1PVvLADUKyO11OPpCspWXOuKBpwn3qIAY66BSTpNa034jJi7ktb9nk+5CfaolnlE0QPw12A+ApUUjwNuCbAHMJPf08iKJZuqaILoXkEmrikssi2JWrTqqhuK9SvxjtmlUP/dSaTgl8FG0vZ/ZwuW/yo9i9meRnGLGhTCKmnMz8HHQfgeQc59MfwdIPOsMcPak4KKElU3uYo2McnmQV+IKQq7i9I6mVKvVLx9xzp9UOh0Z/gA99Mjknlj/e4fPIz43xOmVDxm8HvQHi0POg96ffvik/Z3LQmXmmQ+uA5KJjrZYRsER4tyuldlOk674UR0siq1JtFS/JL1gnxtaTO15c/knkZ8X4YuBbPfT83M+bITRbEXqsEThzonnK1acTGkIyzShzxsVLfFmpjpRhUo8lpJaswzRHx5o5kNfeJtY+W/6A/IgncZPf+Z/dC9JHoP4ffxD4GZrWI15FBCZVWNYudJjycrhjQSf8KFXgkgWQrJOkleq43ZkZehY6wxiZeU7bYr72DaSHmMQXn0D9G8B+9+sPvPMRetYlx0HXwGngQc9ZhLaaw9JNBAqWWYDm6FOMUjS/WMTVd/NqBgfmvTkyG6vuLMzs1uXNGS/wa/7+fp1vf8QXD70GXgU5uH4bSOhRbponO3QKnEJpTcUqu5CLOyIkySWXHDOtOQZUNpqGYpwTS26tOiHv/PbNv3jE8h2ghh7lpj1w/iKjZUKdXeiknAE9ClbqmaAWkwOpZLc4Utq1Ceu2+godvrfkEu6W44ufD78BeO716OOVMrNEOtxZWPYBlPJyc0YFyy5HoMSzcAFHayb1+9JiSnR9YDVoDPMvkXdjfPFbYPYOEDnCT3NXpsDLLdnDzEUIEDwnNNVpJgfoeylOlDmzxdr9oJQctugZjEa06gz3YfysfP1tsEdvAP3dj8/99q9A5fRHxIlPJU4etQjvytnV8zrPKrSQZxCOVuab1i6LcBr9ZFAc24FxzHw2bzWf+BS+wyH+Ze8TewfAq0kxOf1xsvuIJThh5pyEzmdhSO1+KolfrSW+TmZKKTVjbA3sBmKfy11mfP0C/slJ/yFMA6+ynfsx0ukvwaPM42slDsw0F9FrQVUrk4+x5iY6T2dksme2bo1uYvE5vHJjfN1Ub8Q/AvGIU+cyH/RS6jkrDiJMOdYROEvMeMw4VVY7MWm1IFqtMClyFjjT6tRyRoeIr8tbfPHLMPlXoEmk813CzjcDhycJLCymFkzeCs2BBM3ilhlfb9Ul3aAuHB/iO/P16/zH4v8hzM5DOvQIPeJ/RPxBchx6BM5NLhk8sl1gT8+48CGiJdAq6ECmjnBVckPWyQIf2p/AxfAn8HXcfzaGd4DyJjCc8oh2khg+LAcrsguQHdbWzZEHFPoELdZ0cp5iLV1i8cUvznAY0t8As6Mv7w9+4vkmgFMYTo44u5EBzRD2oFkTWaDRE/PTbqHrx5KrVV/cJv9sc/zMTJ+klvavQNP/AnDjYw/mQ+fAzi6ErPUJdN2EtNpFiBmKKDt0HhsG87Ernq36XaE/yXlM+Qk/210+Z4AzbOeeocPi8Pe9ioi4H+zUanQllnvWzZvAF1vEWlHTiQjlJNkhvu5c5n81Xjp+8f+DfI5D8MCMn4T734L/DaBLuncAP/TlfaAEDp+s5fmOcAc0Rx+PLRZhGqw7S8hG04vhL3bEDy3HA36ec//y9yI3gP2Pn/W/gsmHfn74SR+B/vhNBbMHTzaFZOzjB70IYJmul0Q89wvFtjF9xCkL+5fEf1ZdvEIc+h977t/4HSn6NwD/V0Dx6x8HevgDAIFjx8wwjadRsj4tyeqI1i/zWXqOmlevmhByIzEYjdzajP203Dtj/OGUeJ184u89ofdRvinEu/GPQHH6GX7oy22AQxxCNJ6Sa3l6kSn0AaChTGsWaLpfMFNnYmI6+csRP5Mca+6d23zc7618B+WbYnw+/kewPhxPPw49z7188vnm90D6/IODy2yBtS7w1Z65mnpNWduajBAGe72bqzLPspi/E/BdlXgvP+rEl2+K8YOQj0D2P4Tmm4Cfcvvcjxg++jPL0y5ZhZB0yzLkukc67I69X4T49nO8l3LcEZ9N+XYifib8HcA/AvHXv70DxLn3ewDHlDkL+Y70u5LvLpz0zcKJgYyUbM26wcr/rRLfco63U8464vMo30vEbwG5Afhs5fRr5omX04+8+OQjq/Sgs7TvV76EVmqX8Noyu1oG6nXsy0OerXoP/JZyLHjpiOaDzng75bvI8VvG/hUoPv+0d4D+I5Acep51PbVdpgiNXe3CJFCwhUnJ6oAQgfYtVqxamyWfTjzpHJ9BOeuIN1Kef8TvFH0H8M8/dtwZPP1+7plF6Bi1UH46WtILW0SxPp/Pfaj4dnJ8BuWgM16kPO0Svxjf+Bcw74H49S/R3wa8B7qjjx9XOusSXmZkWK3ig3DG1s8Fv4Ucn0E55YzHlCec44uEfwTir3+NOPq4DT6+yQmmb+dbf4Ki/biLYZcOzpi2q4lhduKM7Fed7HANdhnjvZQjHvGA8jxzfHEGjrr/+uc7gB/98uvfjrv+ZE3reiqWFj5/wtnUBc83sWec4r2UI864RXl6Jb54GfsIxHcAnH4GTz9+/bfTz8CPnRlLw+FOoCsa4c2ajX03cz7ZgWUl3kg55YxDyrPK8cUn0z4CydFf/e7nQdeXxF6XEErMjIwmnenwhrvzsqDEWyhHPGJPeSYlvvhx6DsAf/3z84//F4DuNsDL5Cc+bgPCox/YTIog6xUnM3Pi8SJepJzviA3lCeR4gf1jfvEi9hGIpz9//pFzz8Ar6CeeZ71pqnZ9wpO1fOgcr5DPd8SK8rg5vvgNIjfA/A+A/vSzBJKydrIe2XcvkYfL8Zhyyhkj5eFyfPH7wm6AdvT565/3AF5xfcnjuMtVfZaRz7lcKya+StylHPGITHmIHF/8Mnz7+Gu5Af4Uv/7jww9OQr4H+OWnf8qqtVli6M4tblGOOCOje8p3UeKLL+wdgJ9//uhvAv3pZ8ZFk0GRM8n6AoxGnFMOOiLIG+b4CchP84ufim9/+Gv5C/hP+fSnEDTngzQeqk23lVA5LsmnPAKUfSJ+Dfgz+OJdfMNPlB9+5Aboj76cK+j7p6vNc/HVFtLMp5zBBp9Mji++eB/yDiC//v8ov/75v/yxQ784beFRTEZ0YeyTaWU56whdxbCHRnzx+eBn/ysjfwPEDVD+/B1ZnsnLU5vPOiKGI7744kcgH4HsDwAefXh+HFl61QQQHe3cCPJxB3l4Ov/FFz8C/N7/w5/+JDeA/NZnDEe0c1iUCZCPO4ixcfKLL34avuEXP94B4vQvmZ7mfOinA1988XPzTf75H38A+OmPA9xOcjnW01/zX3zx2+TbX/xJ//1HP/l05MM9Hvovvvhd8O0v/kL/DtAzzYMtbwVUce7D+eKL3xdyA7Rf//noQ36d+y9+73z7G38jnf78OeeLL34Bvv0Rn38A3wS+zv0Xvxjf+I8/X3zxa6K//7/ugS9+Tf7wh/8IWJPIB1GI308AAAAASUVORK5CYII=";
  100731. return TextureTools;
  100732. }());
  100733. /***/ }),
  100734. /***/ "./Misc/tga.ts":
  100735. /*!*********************!*\
  100736. !*** ./Misc/tga.ts ***!
  100737. \*********************/
  100738. /*! exports provided: TGATools */
  100739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100740. "use strict";
  100741. __webpack_require__.r(__webpack_exports__);
  100742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  100743. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100744. /**
  100745. * Based on jsTGALoader - Javascript loader for TGA file
  100746. * By Vincent Thibault
  100747. * @see http://blog.robrowser.com/javascript-tga-loader.html
  100748. */
  100749. var TGATools = /** @class */ (function () {
  100750. function TGATools() {
  100751. }
  100752. /**
  100753. * Gets the header of a TGA file
  100754. * @param data defines the TGA data
  100755. * @returns the header
  100756. */
  100757. TGATools.GetTGAHeader = function (data) {
  100758. var offset = 0;
  100759. var header = {
  100760. id_length: data[offset++],
  100761. colormap_type: data[offset++],
  100762. image_type: data[offset++],
  100763. colormap_index: data[offset++] | data[offset++] << 8,
  100764. colormap_length: data[offset++] | data[offset++] << 8,
  100765. colormap_size: data[offset++],
  100766. origin: [
  100767. data[offset++] | data[offset++] << 8,
  100768. data[offset++] | data[offset++] << 8
  100769. ],
  100770. width: data[offset++] | data[offset++] << 8,
  100771. height: data[offset++] | data[offset++] << 8,
  100772. pixel_size: data[offset++],
  100773. flags: data[offset++]
  100774. };
  100775. return header;
  100776. };
  100777. /**
  100778. * Uploads TGA content to a Babylon Texture
  100779. * @hidden
  100780. */
  100781. TGATools.UploadContent = function (texture, data) {
  100782. // Not enough data to contain header ?
  100783. if (data.length < 19) {
  100784. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  100785. return;
  100786. }
  100787. // Read Header
  100788. var offset = 18;
  100789. var header = TGATools.GetTGAHeader(data);
  100790. // Assume it's a valid Targa file.
  100791. if (header.id_length + offset > data.length) {
  100792. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  100793. return;
  100794. }
  100795. // Skip not needed data
  100796. offset += header.id_length;
  100797. var use_rle = false;
  100798. var use_pal = false;
  100799. var use_grey = false;
  100800. // Get some informations.
  100801. switch (header.image_type) {
  100802. case TGATools._TYPE_RLE_INDEXED:
  100803. use_rle = true;
  100804. case TGATools._TYPE_INDEXED:
  100805. use_pal = true;
  100806. break;
  100807. case TGATools._TYPE_RLE_RGB:
  100808. use_rle = true;
  100809. case TGATools._TYPE_RGB:
  100810. // use_rgb = true;
  100811. break;
  100812. case TGATools._TYPE_RLE_GREY:
  100813. use_rle = true;
  100814. case TGATools._TYPE_GREY:
  100815. use_grey = true;
  100816. break;
  100817. }
  100818. var pixel_data;
  100819. // var numAlphaBits = header.flags & 0xf;
  100820. var pixel_size = header.pixel_size >> 3;
  100821. var pixel_total = header.width * header.height * pixel_size;
  100822. // Read palettes
  100823. var palettes;
  100824. if (use_pal) {
  100825. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  100826. }
  100827. // Read LRE
  100828. if (use_rle) {
  100829. pixel_data = new Uint8Array(pixel_total);
  100830. var c, count, i;
  100831. var localOffset = 0;
  100832. var pixels = new Uint8Array(pixel_size);
  100833. while (offset < pixel_total && localOffset < pixel_total) {
  100834. c = data[offset++];
  100835. count = (c & 0x7f) + 1;
  100836. // RLE pixels
  100837. if (c & 0x80) {
  100838. // Bind pixel tmp array
  100839. for (i = 0; i < pixel_size; ++i) {
  100840. pixels[i] = data[offset++];
  100841. }
  100842. // Copy pixel array
  100843. for (i = 0; i < count; ++i) {
  100844. pixel_data.set(pixels, localOffset + i * pixel_size);
  100845. }
  100846. localOffset += pixel_size * count;
  100847. }
  100848. // Raw pixels
  100849. else {
  100850. count *= pixel_size;
  100851. for (i = 0; i < count; ++i) {
  100852. pixel_data[localOffset + i] = data[offset++];
  100853. }
  100854. localOffset += count;
  100855. }
  100856. }
  100857. }
  100858. // RAW Pixels
  100859. else {
  100860. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  100861. }
  100862. // Load to texture
  100863. var x_start, y_start, x_step, y_step, y_end, x_end;
  100864. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  100865. default:
  100866. case TGATools._ORIGIN_UL:
  100867. x_start = 0;
  100868. x_step = 1;
  100869. x_end = header.width;
  100870. y_start = 0;
  100871. y_step = 1;
  100872. y_end = header.height;
  100873. break;
  100874. case TGATools._ORIGIN_BL:
  100875. x_start = 0;
  100876. x_step = 1;
  100877. x_end = header.width;
  100878. y_start = header.height - 1;
  100879. y_step = -1;
  100880. y_end = -1;
  100881. break;
  100882. case TGATools._ORIGIN_UR:
  100883. x_start = header.width - 1;
  100884. x_step = -1;
  100885. x_end = -1;
  100886. y_start = 0;
  100887. y_step = 1;
  100888. y_end = header.height;
  100889. break;
  100890. case TGATools._ORIGIN_BR:
  100891. x_start = header.width - 1;
  100892. x_step = -1;
  100893. x_end = -1;
  100894. y_start = header.height - 1;
  100895. y_step = -1;
  100896. y_end = -1;
  100897. break;
  100898. }
  100899. // Load the specify method
  100900. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  100901. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  100902. var engine = texture.getEngine();
  100903. engine._uploadDataToTextureDirectly(texture, imageData);
  100904. };
  100905. /** @hidden */
  100906. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100907. var image = pixel_data, colormap = palettes;
  100908. var width = header.width, height = header.height;
  100909. var color, i = 0, x, y;
  100910. var imageData = new Uint8Array(width * height * 4);
  100911. for (y = y_start; y !== y_end; y += y_step) {
  100912. for (x = x_start; x !== x_end; x += x_step, i++) {
  100913. color = image[i];
  100914. imageData[(x + width * y) * 4 + 3] = 255;
  100915. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  100916. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  100917. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  100918. }
  100919. }
  100920. return imageData;
  100921. };
  100922. /** @hidden */
  100923. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100924. var image = pixel_data;
  100925. var width = header.width, height = header.height;
  100926. var color, i = 0, x, y;
  100927. var imageData = new Uint8Array(width * height * 4);
  100928. for (y = y_start; y !== y_end; y += y_step) {
  100929. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  100930. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  100931. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  100932. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  100933. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  100934. imageData[(x + width * y) * 4 + 0] = r;
  100935. imageData[(x + width * y) * 4 + 1] = g;
  100936. imageData[(x + width * y) * 4 + 2] = b;
  100937. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  100938. }
  100939. }
  100940. return imageData;
  100941. };
  100942. /** @hidden */
  100943. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100944. var image = pixel_data;
  100945. var width = header.width, height = header.height;
  100946. var i = 0, x, y;
  100947. var imageData = new Uint8Array(width * height * 4);
  100948. for (y = y_start; y !== y_end; y += y_step) {
  100949. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  100950. imageData[(x + width * y) * 4 + 3] = 255;
  100951. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  100952. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  100953. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  100954. }
  100955. }
  100956. return imageData;
  100957. };
  100958. /** @hidden */
  100959. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100960. var image = pixel_data;
  100961. var width = header.width, height = header.height;
  100962. var i = 0, x, y;
  100963. var imageData = new Uint8Array(width * height * 4);
  100964. for (y = y_start; y !== y_end; y += y_step) {
  100965. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  100966. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  100967. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  100968. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  100969. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  100970. }
  100971. }
  100972. return imageData;
  100973. };
  100974. /** @hidden */
  100975. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100976. var image = pixel_data;
  100977. var width = header.width, height = header.height;
  100978. var color, i = 0, x, y;
  100979. var imageData = new Uint8Array(width * height * 4);
  100980. for (y = y_start; y !== y_end; y += y_step) {
  100981. for (x = x_start; x !== x_end; x += x_step, i++) {
  100982. color = image[i];
  100983. imageData[(x + width * y) * 4 + 0] = color;
  100984. imageData[(x + width * y) * 4 + 1] = color;
  100985. imageData[(x + width * y) * 4 + 2] = color;
  100986. imageData[(x + width * y) * 4 + 3] = 255;
  100987. }
  100988. }
  100989. return imageData;
  100990. };
  100991. /** @hidden */
  100992. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100993. var image = pixel_data;
  100994. var width = header.width, height = header.height;
  100995. var i = 0, x, y;
  100996. var imageData = new Uint8Array(width * height * 4);
  100997. for (y = y_start; y !== y_end; y += y_step) {
  100998. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  100999. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  101000. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  101001. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  101002. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  101003. }
  101004. }
  101005. return imageData;
  101006. };
  101007. //private static _TYPE_NO_DATA = 0;
  101008. TGATools._TYPE_INDEXED = 1;
  101009. TGATools._TYPE_RGB = 2;
  101010. TGATools._TYPE_GREY = 3;
  101011. TGATools._TYPE_RLE_INDEXED = 9;
  101012. TGATools._TYPE_RLE_RGB = 10;
  101013. TGATools._TYPE_RLE_GREY = 11;
  101014. TGATools._ORIGIN_MASK = 0x30;
  101015. TGATools._ORIGIN_SHIFT = 0x04;
  101016. TGATools._ORIGIN_BL = 0x00;
  101017. TGATools._ORIGIN_BR = 0x01;
  101018. TGATools._ORIGIN_UL = 0x02;
  101019. TGATools._ORIGIN_UR = 0x03;
  101020. return TGATools;
  101021. }());
  101022. /***/ }),
  101023. /***/ "./Misc/tools.ts":
  101024. /*!***********************!*\
  101025. !*** ./Misc/tools.ts ***!
  101026. \***********************/
  101027. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  101028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101029. "use strict";
  101030. __webpack_require__.r(__webpack_exports__);
  101031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  101032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  101033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  101034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  101035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  101036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  101037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  101038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  101039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  101040. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101041. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  101042. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101043. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  101044. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  101045. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101046. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  101047. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  101048. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  101049. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  101050. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  101051. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  101052. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  101053. /** Class used to store color4 gradient */
  101054. var ColorGradient = /** @class */ (function () {
  101055. function ColorGradient() {
  101056. }
  101057. /**
  101058. * Will get a color picked randomly between color1 and color2.
  101059. * If color2 is undefined then color1 will be used
  101060. * @param result defines the target Color4 to store the result in
  101061. */
  101062. ColorGradient.prototype.getColorToRef = function (result) {
  101063. if (!this.color2) {
  101064. result.copyFrom(this.color1);
  101065. return;
  101066. }
  101067. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  101068. };
  101069. return ColorGradient;
  101070. }());
  101071. /** Class used to store color 3 gradient */
  101072. var Color3Gradient = /** @class */ (function () {
  101073. function Color3Gradient() {
  101074. }
  101075. return Color3Gradient;
  101076. }());
  101077. /** Class used to store factor gradient */
  101078. var FactorGradient = /** @class */ (function () {
  101079. function FactorGradient() {
  101080. }
  101081. /**
  101082. * Will get a number picked randomly between factor1 and factor2.
  101083. * If factor2 is undefined then factor1 will be used
  101084. * @returns the picked number
  101085. */
  101086. FactorGradient.prototype.getFactor = function () {
  101087. if (this.factor2 === undefined) {
  101088. return this.factor1;
  101089. }
  101090. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  101091. };
  101092. return FactorGradient;
  101093. }());
  101094. /**
  101095. * @ignore
  101096. * Application error to support additional information when loading a file
  101097. */
  101098. var LoadFileError = /** @class */ (function (_super) {
  101099. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  101100. /**
  101101. * Creates a new LoadFileError
  101102. * @param message defines the message of the error
  101103. * @param request defines the optional web request
  101104. */
  101105. function LoadFileError(message,
  101106. /** defines the optional web request */
  101107. request) {
  101108. var _this = _super.call(this, message) || this;
  101109. _this.request = request;
  101110. _this.name = "LoadFileError";
  101111. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  101112. return _this;
  101113. }
  101114. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  101115. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  101116. // Polyfill for Object.setPrototypeOf if necessary.
  101117. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  101118. return LoadFileError;
  101119. }(Error));
  101120. /**
  101121. * Class used to define a retry strategy when error happens while loading assets
  101122. */
  101123. var RetryStrategy = /** @class */ (function () {
  101124. function RetryStrategy() {
  101125. }
  101126. /**
  101127. * Function used to defines an exponential back off strategy
  101128. * @param maxRetries defines the maximum number of retries (3 by default)
  101129. * @param baseInterval defines the interval between retries
  101130. * @returns the strategy function to use
  101131. */
  101132. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  101133. if (maxRetries === void 0) { maxRetries = 3; }
  101134. if (baseInterval === void 0) { baseInterval = 500; }
  101135. return function (url, request, retryIndex) {
  101136. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  101137. return -1;
  101138. }
  101139. return Math.pow(2, retryIndex) * baseInterval;
  101140. };
  101141. };
  101142. return RetryStrategy;
  101143. }());
  101144. /**
  101145. * Class containing a set of static utilities functions
  101146. */
  101147. var Tools = /** @class */ (function () {
  101148. function Tools() {
  101149. }
  101150. /**
  101151. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  101152. * @param u defines the coordinate on X axis
  101153. * @param v defines the coordinate on Y axis
  101154. * @param width defines the width of the source data
  101155. * @param height defines the height of the source data
  101156. * @param pixels defines the source byte array
  101157. * @param color defines the output color
  101158. */
  101159. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  101160. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  101161. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  101162. var position = (wrappedU + wrappedV * width) * 4;
  101163. color.r = pixels[position] / 255;
  101164. color.g = pixels[position + 1] / 255;
  101165. color.b = pixels[position + 2] / 255;
  101166. color.a = pixels[position + 3] / 255;
  101167. };
  101168. /**
  101169. * Interpolates between a and b via alpha
  101170. * @param a The lower value (returned when alpha = 0)
  101171. * @param b The upper value (returned when alpha = 1)
  101172. * @param alpha The interpolation-factor
  101173. * @return The mixed value
  101174. */
  101175. Tools.Mix = function (a, b, alpha) {
  101176. return a * (1 - alpha) + b * alpha;
  101177. };
  101178. /**
  101179. * Tries to instantiate a new object from a given class name
  101180. * @param className defines the class name to instantiate
  101181. * @returns the new object or null if the system was not able to do the instantiation
  101182. */
  101183. Tools.Instantiate = function (className) {
  101184. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  101185. return Tools.RegisteredExternalClasses[className];
  101186. }
  101187. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  101188. if (internalClass) {
  101189. return internalClass;
  101190. }
  101191. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  101192. var arr = className.split(".");
  101193. var fn = (window || this);
  101194. for (var i = 0, len = arr.length; i < len; i++) {
  101195. fn = fn[arr[i]];
  101196. }
  101197. if (typeof fn !== "function") {
  101198. return null;
  101199. }
  101200. return fn;
  101201. };
  101202. /**
  101203. * Provides a slice function that will work even on IE
  101204. * @param data defines the array to slice
  101205. * @param start defines the start of the data (optional)
  101206. * @param end defines the end of the data (optional)
  101207. * @returns the new sliced array
  101208. */
  101209. Tools.Slice = function (data, start, end) {
  101210. if (data.slice) {
  101211. return data.slice(start, end);
  101212. }
  101213. return Array.prototype.slice.call(data, start, end);
  101214. };
  101215. /**
  101216. * Polyfill for setImmediate
  101217. * @param action defines the action to execute after the current execution block
  101218. */
  101219. Tools.SetImmediate = function (action) {
  101220. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  101221. window.setImmediate(action);
  101222. }
  101223. else {
  101224. setTimeout(action, 1);
  101225. }
  101226. };
  101227. /**
  101228. * Function indicating if a number is an exponent of 2
  101229. * @param value defines the value to test
  101230. * @returns true if the value is an exponent of 2
  101231. */
  101232. Tools.IsExponentOfTwo = function (value) {
  101233. var count = 1;
  101234. do {
  101235. count *= 2;
  101236. } while (count < value);
  101237. return count === value;
  101238. };
  101239. /**
  101240. * Returns the nearest 32-bit single precision float representation of a Number
  101241. * @param value A Number. If the parameter is of a different type, it will get converted
  101242. * to a number or to NaN if it cannot be converted
  101243. * @returns number
  101244. */
  101245. Tools.FloatRound = function (value) {
  101246. if (Math.fround) {
  101247. return Math.fround(value);
  101248. }
  101249. return (Tools._tmpFloatArray[0] = value);
  101250. };
  101251. /**
  101252. * Find the next highest power of two.
  101253. * @param x Number to start search from.
  101254. * @return Next highest power of two.
  101255. */
  101256. Tools.CeilingPOT = function (x) {
  101257. x--;
  101258. x |= x >> 1;
  101259. x |= x >> 2;
  101260. x |= x >> 4;
  101261. x |= x >> 8;
  101262. x |= x >> 16;
  101263. x++;
  101264. return x;
  101265. };
  101266. /**
  101267. * Find the next lowest power of two.
  101268. * @param x Number to start search from.
  101269. * @return Next lowest power of two.
  101270. */
  101271. Tools.FloorPOT = function (x) {
  101272. x = x | (x >> 1);
  101273. x = x | (x >> 2);
  101274. x = x | (x >> 4);
  101275. x = x | (x >> 8);
  101276. x = x | (x >> 16);
  101277. return x - (x >> 1);
  101278. };
  101279. /**
  101280. * Find the nearest power of two.
  101281. * @param x Number to start search from.
  101282. * @return Next nearest power of two.
  101283. */
  101284. Tools.NearestPOT = function (x) {
  101285. var c = Tools.CeilingPOT(x);
  101286. var f = Tools.FloorPOT(x);
  101287. return (c - x) > (x - f) ? f : c;
  101288. };
  101289. /**
  101290. * Get the closest exponent of two
  101291. * @param value defines the value to approximate
  101292. * @param max defines the maximum value to return
  101293. * @param mode defines how to define the closest value
  101294. * @returns closest exponent of two of the given value
  101295. */
  101296. Tools.GetExponentOfTwo = function (value, max, mode) {
  101297. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  101298. var pot;
  101299. switch (mode) {
  101300. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  101301. pot = Tools.FloorPOT(value);
  101302. break;
  101303. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  101304. pot = Tools.NearestPOT(value);
  101305. break;
  101306. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  101307. default:
  101308. pot = Tools.CeilingPOT(value);
  101309. break;
  101310. }
  101311. return Math.min(pot, max);
  101312. };
  101313. /**
  101314. * Extracts the filename from a path
  101315. * @param path defines the path to use
  101316. * @returns the filename
  101317. */
  101318. Tools.GetFilename = function (path) {
  101319. var index = path.lastIndexOf("/");
  101320. if (index < 0) {
  101321. return path;
  101322. }
  101323. return path.substring(index + 1);
  101324. };
  101325. /**
  101326. * Extracts the "folder" part of a path (everything before the filename).
  101327. * @param uri The URI to extract the info from
  101328. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  101329. * @returns The "folder" part of the path
  101330. */
  101331. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  101332. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  101333. var index = uri.lastIndexOf("/");
  101334. if (index < 0) {
  101335. if (returnUnchangedIfNoSlash) {
  101336. return uri;
  101337. }
  101338. return "";
  101339. }
  101340. return uri.substring(0, index + 1);
  101341. };
  101342. /**
  101343. * Convert an angle in radians to degrees
  101344. * @param angle defines the angle to convert
  101345. * @returns the angle in degrees
  101346. */
  101347. Tools.ToDegrees = function (angle) {
  101348. return angle * 180 / Math.PI;
  101349. };
  101350. /**
  101351. * Convert an angle in degrees to radians
  101352. * @param angle defines the angle to convert
  101353. * @returns the angle in radians
  101354. */
  101355. Tools.ToRadians = function (angle) {
  101356. return angle * Math.PI / 180;
  101357. };
  101358. /**
  101359. * Encode a buffer to a base64 string
  101360. * @param buffer defines the buffer to encode
  101361. * @returns the encoded string
  101362. */
  101363. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  101364. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  101365. var output = "";
  101366. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  101367. var i = 0;
  101368. var bytes = new Uint8Array(buffer);
  101369. while (i < bytes.length) {
  101370. chr1 = bytes[i++];
  101371. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  101372. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  101373. enc1 = chr1 >> 2;
  101374. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  101375. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  101376. enc4 = chr3 & 63;
  101377. if (isNaN(chr2)) {
  101378. enc3 = enc4 = 64;
  101379. }
  101380. else if (isNaN(chr3)) {
  101381. enc4 = 64;
  101382. }
  101383. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  101384. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  101385. }
  101386. return "data:image/png;base64," + output;
  101387. };
  101388. /**
  101389. * Extracts minimum and maximum values from a list of indexed positions
  101390. * @param positions defines the positions to use
  101391. * @param indices defines the indices to the positions
  101392. * @param indexStart defines the start index
  101393. * @param indexCount defines the end index
  101394. * @param bias defines bias value to add to the result
  101395. * @return minimum and maximum values
  101396. */
  101397. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  101398. if (bias === void 0) { bias = null; }
  101399. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  101400. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  101401. for (var index = indexStart; index < indexStart + indexCount; index++) {
  101402. var offset = indices[index] * 3;
  101403. var x = positions[offset];
  101404. var y = positions[offset + 1];
  101405. var z = positions[offset + 2];
  101406. minimum.minimizeInPlaceFromFloats(x, y, z);
  101407. maximum.maximizeInPlaceFromFloats(x, y, z);
  101408. }
  101409. if (bias) {
  101410. minimum.x -= minimum.x * bias.x + bias.y;
  101411. minimum.y -= minimum.y * bias.x + bias.y;
  101412. minimum.z -= minimum.z * bias.x + bias.y;
  101413. maximum.x += maximum.x * bias.x + bias.y;
  101414. maximum.y += maximum.y * bias.x + bias.y;
  101415. maximum.z += maximum.z * bias.x + bias.y;
  101416. }
  101417. return {
  101418. minimum: minimum,
  101419. maximum: maximum
  101420. };
  101421. };
  101422. /**
  101423. * Extracts minimum and maximum values from a list of positions
  101424. * @param positions defines the positions to use
  101425. * @param start defines the start index in the positions array
  101426. * @param count defines the number of positions to handle
  101427. * @param bias defines bias value to add to the result
  101428. * @param stride defines the stride size to use (distance between two positions in the positions array)
  101429. * @return minimum and maximum values
  101430. */
  101431. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  101432. if (bias === void 0) { bias = null; }
  101433. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  101434. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  101435. if (!stride) {
  101436. stride = 3;
  101437. }
  101438. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  101439. var x = positions[offset];
  101440. var y = positions[offset + 1];
  101441. var z = positions[offset + 2];
  101442. minimum.minimizeInPlaceFromFloats(x, y, z);
  101443. maximum.maximizeInPlaceFromFloats(x, y, z);
  101444. }
  101445. if (bias) {
  101446. minimum.x -= minimum.x * bias.x + bias.y;
  101447. minimum.y -= minimum.y * bias.x + bias.y;
  101448. minimum.z -= minimum.z * bias.x + bias.y;
  101449. maximum.x += maximum.x * bias.x + bias.y;
  101450. maximum.y += maximum.y * bias.x + bias.y;
  101451. maximum.z += maximum.z * bias.x + bias.y;
  101452. }
  101453. return {
  101454. minimum: minimum,
  101455. maximum: maximum
  101456. };
  101457. };
  101458. /**
  101459. * Returns an array if obj is not an array
  101460. * @param obj defines the object to evaluate as an array
  101461. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  101462. * @returns either obj directly if obj is an array or a new array containing obj
  101463. */
  101464. Tools.MakeArray = function (obj, allowsNullUndefined) {
  101465. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  101466. return null;
  101467. }
  101468. return Array.isArray(obj) ? obj : [obj];
  101469. };
  101470. /**
  101471. * Gets the pointer prefix to use
  101472. * @returns "pointer" if touch is enabled. Else returns "mouse"
  101473. */
  101474. Tools.GetPointerPrefix = function () {
  101475. var eventPrefix = "pointer";
  101476. // Check if pointer events are supported
  101477. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  101478. eventPrefix = "mouse";
  101479. }
  101480. return eventPrefix;
  101481. };
  101482. /**
  101483. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  101484. * @param func - the function to be called
  101485. * @param requester - the object that will request the next frame. Falls back to window.
  101486. * @returns frame number
  101487. */
  101488. Tools.QueueNewFrame = function (func, requester) {
  101489. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  101490. return setTimeout(func, 16);
  101491. }
  101492. if (!requester) {
  101493. requester = window;
  101494. }
  101495. if (requester.requestAnimationFrame) {
  101496. return requester.requestAnimationFrame(func);
  101497. }
  101498. else if (requester.msRequestAnimationFrame) {
  101499. return requester.msRequestAnimationFrame(func);
  101500. }
  101501. else if (requester.webkitRequestAnimationFrame) {
  101502. return requester.webkitRequestAnimationFrame(func);
  101503. }
  101504. else if (requester.mozRequestAnimationFrame) {
  101505. return requester.mozRequestAnimationFrame(func);
  101506. }
  101507. else if (requester.oRequestAnimationFrame) {
  101508. return requester.oRequestAnimationFrame(func);
  101509. }
  101510. else {
  101511. return window.setTimeout(func, 16);
  101512. }
  101513. };
  101514. /**
  101515. * Ask the browser to promote the current element to fullscreen rendering mode
  101516. * @param element defines the DOM element to promote
  101517. */
  101518. Tools.RequestFullscreen = function (element) {
  101519. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  101520. if (!requestFunction) {
  101521. return;
  101522. }
  101523. requestFunction.call(element);
  101524. };
  101525. /**
  101526. * Asks the browser to exit fullscreen mode
  101527. */
  101528. Tools.ExitFullscreen = function () {
  101529. var anyDoc = document;
  101530. if (document.exitFullscreen) {
  101531. document.exitFullscreen();
  101532. }
  101533. else if (anyDoc.mozCancelFullScreen) {
  101534. anyDoc.mozCancelFullScreen();
  101535. }
  101536. else if (anyDoc.webkitCancelFullScreen) {
  101537. anyDoc.webkitCancelFullScreen();
  101538. }
  101539. else if (anyDoc.msCancelFullScreen) {
  101540. anyDoc.msCancelFullScreen();
  101541. }
  101542. };
  101543. /**
  101544. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  101545. * @param url define the url we are trying
  101546. * @param element define the dom element where to configure the cors policy
  101547. */
  101548. Tools.SetCorsBehavior = function (url, element) {
  101549. if (url && url.indexOf("data:") === 0) {
  101550. return;
  101551. }
  101552. if (Tools.CorsBehavior) {
  101553. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  101554. element.crossOrigin = Tools.CorsBehavior;
  101555. }
  101556. else {
  101557. var result = Tools.CorsBehavior(url);
  101558. if (result) {
  101559. element.crossOrigin = result;
  101560. }
  101561. }
  101562. }
  101563. };
  101564. // External files
  101565. /**
  101566. * Removes unwanted characters from an url
  101567. * @param url defines the url to clean
  101568. * @returns the cleaned url
  101569. */
  101570. Tools.CleanUrl = function (url) {
  101571. url = url.replace(/#/mg, "%23");
  101572. return url;
  101573. };
  101574. /**
  101575. * Loads an image as an HTMLImageElement.
  101576. * @param input url string, ArrayBuffer, or Blob to load
  101577. * @param onLoad callback called when the image successfully loads
  101578. * @param onError callback called when the image fails to load
  101579. * @param offlineProvider offline provider for caching
  101580. * @returns the HTMLImageElement of the loaded image
  101581. */
  101582. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  101583. var url;
  101584. var usingObjectURL = false;
  101585. if (input instanceof ArrayBuffer) {
  101586. url = URL.createObjectURL(new Blob([input]));
  101587. usingObjectURL = true;
  101588. }
  101589. else if (input instanceof Blob) {
  101590. url = URL.createObjectURL(input);
  101591. usingObjectURL = true;
  101592. }
  101593. else {
  101594. url = Tools.CleanUrl(input);
  101595. url = Tools.PreprocessUrl(input);
  101596. }
  101597. var img = new Image();
  101598. Tools.SetCorsBehavior(url, img);
  101599. var loadHandler = function () {
  101600. img.removeEventListener("load", loadHandler);
  101601. img.removeEventListener("error", errorHandler);
  101602. onLoad(img);
  101603. // Must revoke the URL after calling onLoad to avoid security exceptions in
  101604. // certain scenarios (e.g. when hosted in vscode).
  101605. if (usingObjectURL && img.src) {
  101606. URL.revokeObjectURL(img.src);
  101607. }
  101608. };
  101609. var errorHandler = function (err) {
  101610. img.removeEventListener("load", loadHandler);
  101611. img.removeEventListener("error", errorHandler);
  101612. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  101613. if (onError) {
  101614. onError("Error while trying to load image: " + input, err);
  101615. }
  101616. if (usingObjectURL && img.src) {
  101617. URL.revokeObjectURL(img.src);
  101618. }
  101619. };
  101620. img.addEventListener("load", loadHandler);
  101621. img.addEventListener("error", errorHandler);
  101622. var noOfflineSupport = function () {
  101623. img.src = url;
  101624. };
  101625. var loadFromOfflineSupport = function () {
  101626. if (offlineProvider) {
  101627. offlineProvider.loadImage(url, img);
  101628. }
  101629. };
  101630. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  101631. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  101632. }
  101633. else {
  101634. if (url.indexOf("file:") !== -1) {
  101635. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  101636. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  101637. try {
  101638. var blobURL;
  101639. try {
  101640. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  101641. }
  101642. catch (ex) {
  101643. // Chrome doesn't support oneTimeOnly parameter
  101644. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  101645. }
  101646. img.src = blobURL;
  101647. usingObjectURL = true;
  101648. }
  101649. catch (e) {
  101650. img.src = "";
  101651. }
  101652. return img;
  101653. }
  101654. }
  101655. noOfflineSupport();
  101656. }
  101657. return img;
  101658. };
  101659. /**
  101660. * Loads a file
  101661. * @param url url string, ArrayBuffer, or Blob to load
  101662. * @param onSuccess callback called when the file successfully loads
  101663. * @param onProgress callback called while file is loading (if the server supports this mode)
  101664. * @param offlineProvider defines the offline provider for caching
  101665. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  101666. * @param onError callback called when the file fails to load
  101667. * @returns a file request object
  101668. */
  101669. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  101670. url = Tools.CleanUrl(url);
  101671. url = Tools.PreprocessUrl(url);
  101672. // If file and file input are set
  101673. if (url.indexOf("file:") !== -1) {
  101674. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  101675. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  101676. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  101677. }
  101678. }
  101679. var loadUrl = Tools.BaseUrl + url;
  101680. var aborted = false;
  101681. var fileRequest = {
  101682. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  101683. abort: function () { return aborted = true; },
  101684. };
  101685. var requestFile = function () {
  101686. var request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  101687. var retryHandle = null;
  101688. fileRequest.abort = function () {
  101689. aborted = true;
  101690. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  101691. request.abort();
  101692. }
  101693. if (retryHandle !== null) {
  101694. clearTimeout(retryHandle);
  101695. retryHandle = null;
  101696. }
  101697. };
  101698. var retryLoop = function (retryIndex) {
  101699. request.open('GET', loadUrl);
  101700. if (useArrayBuffer) {
  101701. request.responseType = "arraybuffer";
  101702. }
  101703. if (onProgress) {
  101704. request.addEventListener("progress", onProgress);
  101705. }
  101706. var onLoadEnd = function () {
  101707. request.removeEventListener("loadend", onLoadEnd);
  101708. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  101709. fileRequest.onCompleteObservable.clear();
  101710. };
  101711. request.addEventListener("loadend", onLoadEnd);
  101712. var onReadyStateChange = function () {
  101713. if (aborted) {
  101714. return;
  101715. }
  101716. // In case of undefined state in some browsers.
  101717. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  101718. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  101719. request.removeEventListener("readystatechange", onReadyStateChange);
  101720. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  101721. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  101722. return;
  101723. }
  101724. var retryStrategy = Tools.DefaultRetryStrategy;
  101725. if (retryStrategy) {
  101726. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  101727. if (waitTime !== -1) {
  101728. // Prevent the request from completing for retry.
  101729. request.removeEventListener("loadend", onLoadEnd);
  101730. request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  101731. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  101732. return;
  101733. }
  101734. }
  101735. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  101736. if (onError) {
  101737. onError(request, e);
  101738. }
  101739. else {
  101740. throw e;
  101741. }
  101742. }
  101743. };
  101744. request.addEventListener("readystatechange", onReadyStateChange);
  101745. request.send();
  101746. };
  101747. retryLoop(0);
  101748. };
  101749. // Caching all files
  101750. if (offlineProvider && offlineProvider.enableSceneOffline) {
  101751. var noOfflineSupport_1 = function (request) {
  101752. if (request && request.status > 400) {
  101753. if (onError) {
  101754. onError(request);
  101755. }
  101756. }
  101757. else {
  101758. if (!aborted) {
  101759. requestFile();
  101760. }
  101761. }
  101762. };
  101763. var loadFromOfflineSupport = function () {
  101764. // TODO: database needs to support aborting and should return a IFileRequest
  101765. if (aborted) {
  101766. return;
  101767. }
  101768. if (offlineProvider) {
  101769. offlineProvider.loadFile(url, function (data) {
  101770. if (!aborted) {
  101771. onSuccess(data);
  101772. }
  101773. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  101774. }, onProgress ? function (event) {
  101775. if (!aborted) {
  101776. onProgress(event);
  101777. }
  101778. } : undefined, noOfflineSupport_1, useArrayBuffer);
  101779. }
  101780. };
  101781. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  101782. }
  101783. else {
  101784. requestFile();
  101785. }
  101786. return fileRequest;
  101787. };
  101788. /**
  101789. * Load a script (identified by an url). When the url returns, the
  101790. * content of this file is added into a new script element, attached to the DOM (body element)
  101791. * @param scriptUrl defines the url of the script to laod
  101792. * @param onSuccess defines the callback called when the script is loaded
  101793. * @param onError defines the callback to call if an error occurs
  101794. */
  101795. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  101796. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  101797. return;
  101798. }
  101799. var head = document.getElementsByTagName('head')[0];
  101800. var script = document.createElement('script');
  101801. script.type = 'text/javascript';
  101802. script.src = scriptUrl;
  101803. script.onload = function () {
  101804. if (onSuccess) {
  101805. onSuccess();
  101806. }
  101807. };
  101808. script.onerror = function (e) {
  101809. if (onError) {
  101810. onError("Unable to load script '" + scriptUrl + "'", e);
  101811. }
  101812. };
  101813. head.appendChild(script);
  101814. };
  101815. /**
  101816. * Loads a file from a blob
  101817. * @param fileToLoad defines the blob to use
  101818. * @param callback defines the callback to call when data is loaded
  101819. * @param progressCallback defines the callback to call during loading process
  101820. * @returns a file request object
  101821. */
  101822. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  101823. var reader = new FileReader();
  101824. var request = {
  101825. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  101826. abort: function () { return reader.abort(); },
  101827. };
  101828. reader.onloadend = function (e) {
  101829. request.onCompleteObservable.notifyObservers(request);
  101830. };
  101831. reader.onload = function (e) {
  101832. //target doesn't have result from ts 1.3
  101833. callback(e.target['result']);
  101834. };
  101835. reader.onprogress = progressCallback;
  101836. reader.readAsDataURL(fileToLoad);
  101837. return request;
  101838. };
  101839. /**
  101840. * Loads a file
  101841. * @param fileToLoad defines the file to load
  101842. * @param callback defines the callback to call when data is loaded
  101843. * @param progressCallBack defines the callback to call during loading process
  101844. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  101845. * @returns a file request object
  101846. */
  101847. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  101848. var reader = new FileReader();
  101849. var request = {
  101850. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  101851. abort: function () { return reader.abort(); },
  101852. };
  101853. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  101854. reader.onerror = function (e) {
  101855. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  101856. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  101857. };
  101858. reader.onload = function (e) {
  101859. //target doesn't have result from ts 1.3
  101860. callback(e.target['result']);
  101861. };
  101862. if (progressCallBack) {
  101863. reader.onprogress = progressCallBack;
  101864. }
  101865. if (!useArrayBuffer) {
  101866. // Asynchronous read
  101867. reader.readAsText(fileToLoad);
  101868. }
  101869. else {
  101870. reader.readAsArrayBuffer(fileToLoad);
  101871. }
  101872. return request;
  101873. };
  101874. /**
  101875. * Creates a data url from a given string content
  101876. * @param content defines the content to convert
  101877. * @returns the new data url link
  101878. */
  101879. Tools.FileAsURL = function (content) {
  101880. var fileBlob = new Blob([content]);
  101881. var url = window.URL || window.webkitURL;
  101882. var link = url.createObjectURL(fileBlob);
  101883. return link;
  101884. };
  101885. /**
  101886. * Format the given number to a specific decimal format
  101887. * @param value defines the number to format
  101888. * @param decimals defines the number of decimals to use
  101889. * @returns the formatted string
  101890. */
  101891. Tools.Format = function (value, decimals) {
  101892. if (decimals === void 0) { decimals = 2; }
  101893. return value.toFixed(decimals);
  101894. };
  101895. /**
  101896. * Checks if a given vector is inside a specific range
  101897. * @param v defines the vector to test
  101898. * @param min defines the minimum range
  101899. * @param max defines the maximum range
  101900. */
  101901. Tools.CheckExtends = function (v, min, max) {
  101902. min.minimizeInPlace(v);
  101903. max.maximizeInPlace(v);
  101904. };
  101905. /**
  101906. * Tries to copy an object by duplicating every property
  101907. * @param source defines the source object
  101908. * @param destination defines the target object
  101909. * @param doNotCopyList defines a list of properties to avoid
  101910. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  101911. */
  101912. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  101913. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  101914. };
  101915. /**
  101916. * Gets a boolean indicating if the given object has no own property
  101917. * @param obj defines the object to test
  101918. * @returns true if object has no own property
  101919. */
  101920. Tools.IsEmpty = function (obj) {
  101921. for (var i in obj) {
  101922. if (obj.hasOwnProperty(i)) {
  101923. return false;
  101924. }
  101925. }
  101926. return true;
  101927. };
  101928. /**
  101929. * Function used to register events at window level
  101930. * @param events defines the events to register
  101931. */
  101932. Tools.RegisterTopRootEvents = function (events) {
  101933. for (var index = 0; index < events.length; index++) {
  101934. var event = events[index];
  101935. window.addEventListener(event.name, event.handler, false);
  101936. try {
  101937. if (window.parent) {
  101938. window.parent.addEventListener(event.name, event.handler, false);
  101939. }
  101940. }
  101941. catch (e) {
  101942. // Silently fails...
  101943. }
  101944. }
  101945. };
  101946. /**
  101947. * Function used to unregister events from window level
  101948. * @param events defines the events to unregister
  101949. */
  101950. Tools.UnregisterTopRootEvents = function (events) {
  101951. for (var index = 0; index < events.length; index++) {
  101952. var event = events[index];
  101953. window.removeEventListener(event.name, event.handler);
  101954. try {
  101955. if (window.parent) {
  101956. window.parent.removeEventListener(event.name, event.handler);
  101957. }
  101958. }
  101959. catch (e) {
  101960. // Silently fails...
  101961. }
  101962. }
  101963. };
  101964. /**
  101965. * Dumps the current bound framebuffer
  101966. * @param width defines the rendering width
  101967. * @param height defines the rendering height
  101968. * @param engine defines the hosting engine
  101969. * @param successCallback defines the callback triggered once the data are available
  101970. * @param mimeType defines the mime type of the result
  101971. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  101972. */
  101973. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  101974. if (mimeType === void 0) { mimeType = "image/png"; }
  101975. // Read the contents of the framebuffer
  101976. var numberOfChannelsByLine = width * 4;
  101977. var halfHeight = height / 2;
  101978. //Reading datas from WebGL
  101979. var data = engine.readPixels(0, 0, width, height);
  101980. //To flip image on Y axis.
  101981. for (var i = 0; i < halfHeight; i++) {
  101982. for (var j = 0; j < numberOfChannelsByLine; j++) {
  101983. var currentCell = j + i * numberOfChannelsByLine;
  101984. var targetLine = height - i - 1;
  101985. var targetCell = j + targetLine * numberOfChannelsByLine;
  101986. var temp = data[currentCell];
  101987. data[currentCell] = data[targetCell];
  101988. data[targetCell] = temp;
  101989. }
  101990. }
  101991. // Create a 2D canvas to store the result
  101992. if (!Tools._ScreenshotCanvas) {
  101993. Tools._ScreenshotCanvas = document.createElement('canvas');
  101994. }
  101995. Tools._ScreenshotCanvas.width = width;
  101996. Tools._ScreenshotCanvas.height = height;
  101997. var context = Tools._ScreenshotCanvas.getContext('2d');
  101998. if (context) {
  101999. // Copy the pixels to a 2D canvas
  102000. var imageData = context.createImageData(width, height);
  102001. var castData = (imageData.data);
  102002. castData.set(data);
  102003. context.putImageData(imageData, 0, 0);
  102004. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  102005. }
  102006. };
  102007. /**
  102008. * Converts the canvas data to blob.
  102009. * This acts as a polyfill for browsers not supporting the to blob function.
  102010. * @param canvas Defines the canvas to extract the data from
  102011. * @param successCallback Defines the callback triggered once the data are available
  102012. * @param mimeType Defines the mime type of the result
  102013. */
  102014. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  102015. if (mimeType === void 0) { mimeType = "image/png"; }
  102016. // We need HTMLCanvasElement.toBlob for HD screenshots
  102017. if (!canvas.toBlob) {
  102018. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  102019. canvas.toBlob = function (callback, type, quality) {
  102020. var _this = this;
  102021. setTimeout(function () {
  102022. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  102023. for (var i = 0; i < len; i++) {
  102024. arr[i] = binStr.charCodeAt(i);
  102025. }
  102026. callback(new Blob([arr]));
  102027. });
  102028. };
  102029. }
  102030. canvas.toBlob(function (blob) {
  102031. successCallback(blob);
  102032. }, mimeType);
  102033. };
  102034. /**
  102035. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102036. * @param successCallback defines the callback triggered once the data are available
  102037. * @param mimeType defines the mime type of the result
  102038. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102039. */
  102040. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  102041. if (mimeType === void 0) { mimeType = "image/png"; }
  102042. if (successCallback) {
  102043. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  102044. successCallback(base64Image);
  102045. }
  102046. else {
  102047. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  102048. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  102049. if (("download" in document.createElement("a"))) {
  102050. if (!fileName) {
  102051. var date = new Date();
  102052. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  102053. fileName = "screenshot_" + stringDate + ".png";
  102054. }
  102055. Tools.Download(blob, fileName);
  102056. }
  102057. else {
  102058. var url = URL.createObjectURL(blob);
  102059. var newWindow = window.open("");
  102060. if (!newWindow) {
  102061. return;
  102062. }
  102063. var img = newWindow.document.createElement("img");
  102064. img.onload = function () {
  102065. // no longer need to read the blob so it's revoked
  102066. URL.revokeObjectURL(url);
  102067. };
  102068. img.src = url;
  102069. newWindow.document.body.appendChild(img);
  102070. }
  102071. }, mimeType);
  102072. }
  102073. };
  102074. /**
  102075. * Downloads a blob in the browser
  102076. * @param blob defines the blob to download
  102077. * @param fileName defines the name of the downloaded file
  102078. */
  102079. Tools.Download = function (blob, fileName) {
  102080. if (navigator && navigator.msSaveBlob) {
  102081. navigator.msSaveBlob(blob, fileName);
  102082. return;
  102083. }
  102084. var url = window.URL.createObjectURL(blob);
  102085. var a = document.createElement("a");
  102086. document.body.appendChild(a);
  102087. a.style.display = "none";
  102088. a.href = url;
  102089. a.download = fileName;
  102090. a.addEventListener("click", function () {
  102091. if (a.parentElement) {
  102092. a.parentElement.removeChild(a);
  102093. }
  102094. });
  102095. a.click();
  102096. window.URL.revokeObjectURL(url);
  102097. };
  102098. /**
  102099. * Captures a screenshot of the current rendering
  102100. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102101. * @param engine defines the rendering engine
  102102. * @param camera defines the source camera
  102103. * @param size This parameter can be set to a single number or to an object with the
  102104. * following (optional) properties: precision, width, height. If a single number is passed,
  102105. * it will be used for both width and height. If an object is passed, the screenshot size
  102106. * will be derived from the parameters. The precision property is a multiplier allowing
  102107. * rendering at a higher or lower resolution
  102108. * @param successCallback defines the callback receives a single parameter which contains the
  102109. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102110. * src parameter of an <img> to display it
  102111. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102112. * Check your browser for supported MIME types
  102113. */
  102114. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  102115. if (mimeType === void 0) { mimeType = "image/png"; }
  102116. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  102117. };
  102118. /**
  102119. * Generates an image screenshot from the specified camera.
  102120. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102121. * @param engine The engine to use for rendering
  102122. * @param camera The camera to use for rendering
  102123. * @param size This parameter can be set to a single number or to an object with the
  102124. * following (optional) properties: precision, width, height. If a single number is passed,
  102125. * it will be used for both width and height. If an object is passed, the screenshot size
  102126. * will be derived from the parameters. The precision property is a multiplier allowing
  102127. * rendering at a higher or lower resolution
  102128. * @param successCallback The callback receives a single parameter which contains the
  102129. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102130. * src parameter of an <img> to display it
  102131. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102132. * Check your browser for supported MIME types
  102133. * @param samples Texture samples (default: 1)
  102134. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102135. * @param fileName A name for for the downloaded file.
  102136. */
  102137. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  102138. if (mimeType === void 0) { mimeType = "image/png"; }
  102139. if (samples === void 0) { samples = 1; }
  102140. if (antialiasing === void 0) { antialiasing = false; }
  102141. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  102142. };
  102143. /**
  102144. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102145. * Be aware Math.random() could cause collisions, but:
  102146. * "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"
  102147. * @returns a pseudo random id
  102148. */
  102149. Tools.RandomId = function () {
  102150. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  102151. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  102152. return v.toString(16);
  102153. });
  102154. };
  102155. /**
  102156. * Test if the given uri is a base64 string
  102157. * @param uri The uri to test
  102158. * @return True if the uri is a base64 string or false otherwise
  102159. */
  102160. Tools.IsBase64 = function (uri) {
  102161. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  102162. };
  102163. /**
  102164. * Decode the given base64 uri.
  102165. * @param uri The uri to decode
  102166. * @return The decoded base64 data.
  102167. */
  102168. Tools.DecodeBase64 = function (uri) {
  102169. var decodedString = atob(uri.split(",")[1]);
  102170. var bufferLength = decodedString.length;
  102171. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  102172. for (var i = 0; i < bufferLength; i++) {
  102173. bufferView[i] = decodedString.charCodeAt(i);
  102174. }
  102175. return bufferView.buffer;
  102176. };
  102177. Object.defineProperty(Tools, "errorsCount", {
  102178. /**
  102179. * Gets a value indicating the number of loading errors
  102180. * @ignorenaming
  102181. */
  102182. get: function () {
  102183. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  102184. },
  102185. enumerable: true,
  102186. configurable: true
  102187. });
  102188. /**
  102189. * Log a message to the console
  102190. * @param message defines the message to log
  102191. */
  102192. Tools.Log = function (message) {
  102193. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  102194. };
  102195. /**
  102196. * Write a warning message to the console
  102197. * @param message defines the message to log
  102198. */
  102199. Tools.Warn = function (message) {
  102200. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  102201. };
  102202. /**
  102203. * Write an error message to the console
  102204. * @param message defines the message to log
  102205. */
  102206. Tools.Error = function (message) {
  102207. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  102208. };
  102209. Object.defineProperty(Tools, "LogCache", {
  102210. /**
  102211. * Gets current log cache (list of logs)
  102212. */
  102213. get: function () {
  102214. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  102215. },
  102216. enumerable: true,
  102217. configurable: true
  102218. });
  102219. /**
  102220. * Clears the log cache
  102221. */
  102222. Tools.ClearLogCache = function () {
  102223. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  102224. };
  102225. Object.defineProperty(Tools, "LogLevels", {
  102226. /**
  102227. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  102228. */
  102229. set: function (level) {
  102230. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  102231. },
  102232. enumerable: true,
  102233. configurable: true
  102234. });
  102235. /**
  102236. * Checks if the loaded document was accessed via `file:`-Protocol.
  102237. * @returns boolean
  102238. */
  102239. Tools.IsFileURL = function () {
  102240. return location.protocol === "file:";
  102241. };
  102242. Object.defineProperty(Tools, "PerformanceLogLevel", {
  102243. /**
  102244. * Sets the current performance log level
  102245. */
  102246. set: function (level) {
  102247. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  102248. Tools.StartPerformanceCounter = Tools._StartUserMark;
  102249. Tools.EndPerformanceCounter = Tools._EndUserMark;
  102250. return;
  102251. }
  102252. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  102253. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  102254. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  102255. return;
  102256. }
  102257. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  102258. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  102259. },
  102260. enumerable: true,
  102261. configurable: true
  102262. });
  102263. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  102264. };
  102265. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  102266. };
  102267. Tools._StartUserMark = function (counterName, condition) {
  102268. if (condition === void 0) { condition = true; }
  102269. if (!Tools._performance) {
  102270. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  102271. return;
  102272. }
  102273. Tools._performance = window.performance;
  102274. }
  102275. if (!condition || !Tools._performance.mark) {
  102276. return;
  102277. }
  102278. Tools._performance.mark(counterName + "-Begin");
  102279. };
  102280. Tools._EndUserMark = function (counterName, condition) {
  102281. if (condition === void 0) { condition = true; }
  102282. if (!condition || !Tools._performance.mark) {
  102283. return;
  102284. }
  102285. Tools._performance.mark(counterName + "-End");
  102286. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  102287. };
  102288. Tools._StartPerformanceConsole = function (counterName, condition) {
  102289. if (condition === void 0) { condition = true; }
  102290. if (!condition) {
  102291. return;
  102292. }
  102293. Tools._StartUserMark(counterName, condition);
  102294. if (console.time) {
  102295. console.time(counterName);
  102296. }
  102297. };
  102298. Tools._EndPerformanceConsole = function (counterName, condition) {
  102299. if (condition === void 0) { condition = true; }
  102300. if (!condition) {
  102301. return;
  102302. }
  102303. Tools._EndUserMark(counterName, condition);
  102304. if (console.time) {
  102305. console.timeEnd(counterName);
  102306. }
  102307. };
  102308. Object.defineProperty(Tools, "Now", {
  102309. /**
  102310. * Gets either window.performance.now() if supported or Date.now() else
  102311. */
  102312. get: function () {
  102313. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  102314. },
  102315. enumerable: true,
  102316. configurable: true
  102317. });
  102318. /**
  102319. * This method will return the name of the class used to create the instance of the given object.
  102320. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  102321. * @param object the object to get the class name from
  102322. * @param isType defines if the object is actually a type
  102323. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  102324. */
  102325. Tools.GetClassName = function (object, isType) {
  102326. if (isType === void 0) { isType = false; }
  102327. var name = null;
  102328. if (!isType && object.getClassName) {
  102329. name = object.getClassName();
  102330. }
  102331. else {
  102332. if (object instanceof Object) {
  102333. var classObj = isType ? object : Object.getPrototypeOf(object);
  102334. name = classObj.constructor["__bjsclassName__"];
  102335. }
  102336. if (!name) {
  102337. name = typeof object;
  102338. }
  102339. }
  102340. return name;
  102341. };
  102342. /**
  102343. * Gets the first element of an array satisfying a given predicate
  102344. * @param array defines the array to browse
  102345. * @param predicate defines the predicate to use
  102346. * @returns null if not found or the element
  102347. */
  102348. Tools.First = function (array, predicate) {
  102349. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  102350. var el = array_1[_i];
  102351. if (predicate(el)) {
  102352. return el;
  102353. }
  102354. }
  102355. return null;
  102356. };
  102357. /**
  102358. * This method will return the name of the full name of the class, including its owning module (if any).
  102359. * 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).
  102360. * @param object the object to get the class name from
  102361. * @param isType defines if the object is actually a type
  102362. * @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.
  102363. * @ignorenaming
  102364. */
  102365. Tools.getFullClassName = function (object, isType) {
  102366. if (isType === void 0) { isType = false; }
  102367. var className = null;
  102368. var moduleName = null;
  102369. if (!isType && object.getClassName) {
  102370. className = object.getClassName();
  102371. }
  102372. else {
  102373. if (object instanceof Object) {
  102374. var classObj = isType ? object : Object.getPrototypeOf(object);
  102375. className = classObj.constructor["__bjsclassName__"];
  102376. moduleName = classObj.constructor["__bjsmoduleName__"];
  102377. }
  102378. if (!className) {
  102379. className = typeof object;
  102380. }
  102381. }
  102382. if (!className) {
  102383. return null;
  102384. }
  102385. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  102386. };
  102387. /**
  102388. * Returns a promise that resolves after the given amount of time.
  102389. * @param delay Number of milliseconds to delay
  102390. * @returns Promise that resolves after the given amount of time
  102391. */
  102392. Tools.DelayAsync = function (delay) {
  102393. return new Promise(function (resolve) {
  102394. setTimeout(function () {
  102395. resolve();
  102396. }, delay);
  102397. });
  102398. };
  102399. /**
  102400. * Gets the current gradient from an array of IValueGradient
  102401. * @param ratio defines the current ratio to get
  102402. * @param gradients defines the array of IValueGradient
  102403. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  102404. */
  102405. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  102406. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  102407. var currentGradient = gradients[gradientIndex];
  102408. var nextGradient = gradients[gradientIndex + 1];
  102409. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  102410. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  102411. updateFunc(currentGradient, nextGradient, scale);
  102412. return;
  102413. }
  102414. }
  102415. // Use last index if over
  102416. var lastIndex = gradients.length - 1;
  102417. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  102418. };
  102419. /**
  102420. * Gets or sets the base URL to use to load assets
  102421. */
  102422. Tools.BaseUrl = "";
  102423. /**
  102424. * Enable/Disable Custom HTTP Request Headers globally.
  102425. * default = false
  102426. * @see CustomRequestHeaders
  102427. */
  102428. Tools.UseCustomRequestHeaders = false;
  102429. /**
  102430. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102431. * i.e. when loading files, where the server/service expects an Authorization header
  102432. */
  102433. Tools.CustomRequestHeaders = _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"].CustomRequestHeaders;
  102434. /**
  102435. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102436. */
  102437. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  102438. /**
  102439. * Default behaviour for cors in the application.
  102440. * It can be a string if the expected behavior is identical in the entire app.
  102441. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102442. */
  102443. Tools.CorsBehavior = "anonymous";
  102444. /**
  102445. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102446. * @ignorenaming
  102447. */
  102448. Tools.UseFallbackTexture = true;
  102449. /**
  102450. * Use this object to register external classes like custom textures or material
  102451. * to allow the laoders to instantiate them
  102452. */
  102453. Tools.RegisteredExternalClasses = {};
  102454. /**
  102455. * Texture content used if a texture cannot loaded
  102456. * @ignorenaming
  102457. */
  102458. 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";
  102459. Tools._tmpFloatArray = new Float32Array(1);
  102460. /**
  102461. * Extracts text content from a DOM element hierarchy
  102462. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102463. */
  102464. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  102465. /**
  102466. * Gets or sets a function used to pre-process url before using them to load assets
  102467. */
  102468. Tools.PreprocessUrl = function (url) {
  102469. return url;
  102470. };
  102471. // Logs
  102472. /**
  102473. * No log
  102474. */
  102475. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  102476. /**
  102477. * Only message logs
  102478. */
  102479. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  102480. /**
  102481. * Only warning logs
  102482. */
  102483. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  102484. /**
  102485. * Only error logs
  102486. */
  102487. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  102488. /**
  102489. * All logs
  102490. */
  102491. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  102492. /**
  102493. * Checks if the window object exists
  102494. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  102495. */
  102496. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  102497. // Performances
  102498. /**
  102499. * No performance log
  102500. */
  102501. Tools.PerformanceNoneLogLevel = 0;
  102502. /**
  102503. * Use user marks to log performance
  102504. */
  102505. Tools.PerformanceUserMarkLogLevel = 1;
  102506. /**
  102507. * Log performance to the console
  102508. */
  102509. Tools.PerformanceConsoleLogLevel = 2;
  102510. /**
  102511. * Starts a performance counter
  102512. */
  102513. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  102514. /**
  102515. * Ends a specific performance coutner
  102516. */
  102517. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  102518. return Tools;
  102519. }());
  102520. /**
  102521. * This class is used to track a performance counter which is number based.
  102522. * The user has access to many properties which give statistics of different nature.
  102523. *
  102524. * The implementer can track two kinds of Performance Counter: time and count.
  102525. * 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.
  102526. * 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.
  102527. */
  102528. var PerfCounter = /** @class */ (function () {
  102529. /**
  102530. * Creates a new counter
  102531. */
  102532. function PerfCounter() {
  102533. this._startMonitoringTime = 0;
  102534. this._min = 0;
  102535. this._max = 0;
  102536. this._average = 0;
  102537. this._lastSecAverage = 0;
  102538. this._current = 0;
  102539. this._totalValueCount = 0;
  102540. this._totalAccumulated = 0;
  102541. this._lastSecAccumulated = 0;
  102542. this._lastSecTime = 0;
  102543. this._lastSecValueCount = 0;
  102544. }
  102545. Object.defineProperty(PerfCounter.prototype, "min", {
  102546. /**
  102547. * Returns the smallest value ever
  102548. */
  102549. get: function () {
  102550. return this._min;
  102551. },
  102552. enumerable: true,
  102553. configurable: true
  102554. });
  102555. Object.defineProperty(PerfCounter.prototype, "max", {
  102556. /**
  102557. * Returns the biggest value ever
  102558. */
  102559. get: function () {
  102560. return this._max;
  102561. },
  102562. enumerable: true,
  102563. configurable: true
  102564. });
  102565. Object.defineProperty(PerfCounter.prototype, "average", {
  102566. /**
  102567. * Returns the average value since the performance counter is running
  102568. */
  102569. get: function () {
  102570. return this._average;
  102571. },
  102572. enumerable: true,
  102573. configurable: true
  102574. });
  102575. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  102576. /**
  102577. * Returns the average value of the last second the counter was monitored
  102578. */
  102579. get: function () {
  102580. return this._lastSecAverage;
  102581. },
  102582. enumerable: true,
  102583. configurable: true
  102584. });
  102585. Object.defineProperty(PerfCounter.prototype, "current", {
  102586. /**
  102587. * Returns the current value
  102588. */
  102589. get: function () {
  102590. return this._current;
  102591. },
  102592. enumerable: true,
  102593. configurable: true
  102594. });
  102595. Object.defineProperty(PerfCounter.prototype, "total", {
  102596. /**
  102597. * Gets the accumulated total
  102598. */
  102599. get: function () {
  102600. return this._totalAccumulated;
  102601. },
  102602. enumerable: true,
  102603. configurable: true
  102604. });
  102605. Object.defineProperty(PerfCounter.prototype, "count", {
  102606. /**
  102607. * Gets the total value count
  102608. */
  102609. get: function () {
  102610. return this._totalValueCount;
  102611. },
  102612. enumerable: true,
  102613. configurable: true
  102614. });
  102615. /**
  102616. * Call this method to start monitoring a new frame.
  102617. * 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.
  102618. */
  102619. PerfCounter.prototype.fetchNewFrame = function () {
  102620. this._totalValueCount++;
  102621. this._current = 0;
  102622. this._lastSecValueCount++;
  102623. };
  102624. /**
  102625. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  102626. * @param newCount the count value to add to the monitored count
  102627. * @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.
  102628. */
  102629. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  102630. if (!PerfCounter.Enabled) {
  102631. return;
  102632. }
  102633. this._current += newCount;
  102634. if (fetchResult) {
  102635. this._fetchResult();
  102636. }
  102637. };
  102638. /**
  102639. * Start monitoring this performance counter
  102640. */
  102641. PerfCounter.prototype.beginMonitoring = function () {
  102642. if (!PerfCounter.Enabled) {
  102643. return;
  102644. }
  102645. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  102646. };
  102647. /**
  102648. * Compute the time lapsed since the previous beginMonitoring() call.
  102649. * @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
  102650. */
  102651. PerfCounter.prototype.endMonitoring = function (newFrame) {
  102652. if (newFrame === void 0) { newFrame = true; }
  102653. if (!PerfCounter.Enabled) {
  102654. return;
  102655. }
  102656. if (newFrame) {
  102657. this.fetchNewFrame();
  102658. }
  102659. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  102660. this._current = currentTime - this._startMonitoringTime;
  102661. if (newFrame) {
  102662. this._fetchResult();
  102663. }
  102664. };
  102665. PerfCounter.prototype._fetchResult = function () {
  102666. this._totalAccumulated += this._current;
  102667. this._lastSecAccumulated += this._current;
  102668. // Min/Max update
  102669. this._min = Math.min(this._min, this._current);
  102670. this._max = Math.max(this._max, this._current);
  102671. this._average = this._totalAccumulated / this._totalValueCount;
  102672. // Reset last sec?
  102673. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  102674. if ((now - this._lastSecTime) > 1000) {
  102675. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  102676. this._lastSecTime = now;
  102677. this._lastSecAccumulated = 0;
  102678. this._lastSecValueCount = 0;
  102679. }
  102680. };
  102681. /**
  102682. * Gets or sets a global boolean to turn on and off all the counters
  102683. */
  102684. PerfCounter.Enabled = true;
  102685. return PerfCounter;
  102686. }());
  102687. /**
  102688. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  102689. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  102690. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  102691. * @param name The name of the class, case should be preserved
  102692. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  102693. */
  102694. function className(name, module) {
  102695. return function (target) {
  102696. target["__bjsclassName__"] = name;
  102697. target["__bjsmoduleName__"] = (module != null) ? module : null;
  102698. };
  102699. }
  102700. /**
  102701. * An implementation of a loop for asynchronous functions.
  102702. */
  102703. var AsyncLoop = /** @class */ (function () {
  102704. /**
  102705. * Constructor.
  102706. * @param iterations the number of iterations.
  102707. * @param func the function to run each iteration
  102708. * @param successCallback the callback that will be called upon succesful execution
  102709. * @param offset starting offset.
  102710. */
  102711. function AsyncLoop(
  102712. /**
  102713. * Defines the number of iterations for the loop
  102714. */
  102715. iterations, func, successCallback, offset) {
  102716. if (offset === void 0) { offset = 0; }
  102717. this.iterations = iterations;
  102718. this.index = offset - 1;
  102719. this._done = false;
  102720. this._fn = func;
  102721. this._successCallback = successCallback;
  102722. }
  102723. /**
  102724. * Execute the next iteration. Must be called after the last iteration was finished.
  102725. */
  102726. AsyncLoop.prototype.executeNext = function () {
  102727. if (!this._done) {
  102728. if (this.index + 1 < this.iterations) {
  102729. ++this.index;
  102730. this._fn(this);
  102731. }
  102732. else {
  102733. this.breakLoop();
  102734. }
  102735. }
  102736. };
  102737. /**
  102738. * Break the loop and run the success callback.
  102739. */
  102740. AsyncLoop.prototype.breakLoop = function () {
  102741. this._done = true;
  102742. this._successCallback();
  102743. };
  102744. /**
  102745. * Create and run an async loop.
  102746. * @param iterations the number of iterations.
  102747. * @param fn the function to run each iteration
  102748. * @param successCallback the callback that will be called upon succesful execution
  102749. * @param offset starting offset.
  102750. * @returns the created async loop object
  102751. */
  102752. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  102753. if (offset === void 0) { offset = 0; }
  102754. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  102755. loop.executeNext();
  102756. return loop;
  102757. };
  102758. /**
  102759. * A for-loop that will run a given number of iterations synchronous and the rest async.
  102760. * @param iterations total number of iterations
  102761. * @param syncedIterations number of synchronous iterations in each async iteration.
  102762. * @param fn the function to call each iteration.
  102763. * @param callback a success call back that will be called when iterating stops.
  102764. * @param breakFunction a break condition (optional)
  102765. * @param timeout timeout settings for the setTimeout function. default - 0.
  102766. * @returns the created async loop object
  102767. */
  102768. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  102769. if (timeout === void 0) { timeout = 0; }
  102770. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  102771. if (breakFunction && breakFunction()) {
  102772. loop.breakLoop();
  102773. }
  102774. else {
  102775. setTimeout(function () {
  102776. for (var i = 0; i < syncedIterations; ++i) {
  102777. var iteration = (loop.index * syncedIterations) + i;
  102778. if (iteration >= iterations) {
  102779. break;
  102780. }
  102781. fn(iteration);
  102782. if (breakFunction && breakFunction()) {
  102783. loop.breakLoop();
  102784. break;
  102785. }
  102786. }
  102787. loop.executeNext();
  102788. }, timeout);
  102789. }
  102790. }, callback);
  102791. };
  102792. return AsyncLoop;
  102793. }());
  102794. /***/ }),
  102795. /***/ "./Misc/typeStore.ts":
  102796. /*!***************************!*\
  102797. !*** ./Misc/typeStore.ts ***!
  102798. \***************************/
  102799. /*! exports provided: _TypeStore */
  102800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102801. "use strict";
  102802. __webpack_require__.r(__webpack_exports__);
  102803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  102804. /** @hidden */
  102805. var _TypeStore = /** @class */ (function () {
  102806. function _TypeStore() {
  102807. }
  102808. /** @hidden */
  102809. _TypeStore.GetClass = function (fqdn) {
  102810. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  102811. return this.RegisteredTypes[fqdn];
  102812. }
  102813. return null;
  102814. };
  102815. /** @hidden */
  102816. _TypeStore.RegisteredTypes = {};
  102817. return _TypeStore;
  102818. }());
  102819. /***/ }),
  102820. /***/ "./Misc/videoRecorder.ts":
  102821. /*!*******************************!*\
  102822. !*** ./Misc/videoRecorder.ts ***!
  102823. \*******************************/
  102824. /*! exports provided: VideoRecorder */
  102825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102826. "use strict";
  102827. __webpack_require__.r(__webpack_exports__);
  102828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  102829. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102830. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  102831. /**
  102832. * This can helps recording videos from BabylonJS.
  102833. * This is based on the available WebRTC functionalities of the browser.
  102834. *
  102835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  102836. */
  102837. var VideoRecorder = /** @class */ (function () {
  102838. /**
  102839. * Create a new VideoCapture object which can help converting what you see in Babylon to
  102840. * a video file.
  102841. * @param engine Defines the BabylonJS Engine you wish to record
  102842. * @param options Defines options that can be used to customized the capture
  102843. */
  102844. function VideoRecorder(engine, options) {
  102845. if (options === void 0) { options = null; }
  102846. if (!VideoRecorder.IsSupported(engine)) {
  102847. throw "Your browser does not support recording so far.";
  102848. }
  102849. var canvas = engine.getRenderingCanvas();
  102850. if (!canvas) {
  102851. throw "The babylon engine must have a canvas to be recorded";
  102852. }
  102853. this._canvas = canvas;
  102854. this._canvas.isRecording = false;
  102855. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  102856. var stream = this._canvas.captureStream(this._options.fps);
  102857. if (this._options.audioTracks) {
  102858. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  102859. var track = _a[_i];
  102860. stream.addTrack(track);
  102861. }
  102862. }
  102863. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  102864. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  102865. this._mediaRecorder.onerror = this._handleError.bind(this);
  102866. this._mediaRecorder.onstop = this._handleStop.bind(this);
  102867. }
  102868. /**
  102869. * Returns wehther or not the VideoRecorder is available in your browser.
  102870. * @param engine Defines the Babylon Engine to check the support for
  102871. * @returns true if supported otherwise false
  102872. */
  102873. VideoRecorder.IsSupported = function (engine) {
  102874. var canvas = engine.getRenderingCanvas();
  102875. return (!!canvas && typeof canvas.captureStream === "function");
  102876. };
  102877. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  102878. /**
  102879. * True wether a recording is already in progress.
  102880. */
  102881. get: function () {
  102882. return !!this._canvas && this._canvas.isRecording;
  102883. },
  102884. enumerable: true,
  102885. configurable: true
  102886. });
  102887. /**
  102888. * Stops the current recording before the default capture timeout passed in the startRecording
  102889. * functions.
  102890. */
  102891. VideoRecorder.prototype.stopRecording = function () {
  102892. if (!this._canvas || !this._mediaRecorder) {
  102893. return;
  102894. }
  102895. if (!this.isRecording) {
  102896. return;
  102897. }
  102898. this._canvas.isRecording = false;
  102899. this._mediaRecorder.stop();
  102900. };
  102901. /**
  102902. * Starts recording the canvas for a max duration specified in parameters.
  102903. * @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.
  102904. * @param maxDuration Defines the maximum recording time in seconds.
  102905. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  102906. * @return a promise callback at the end of the recording with the video data in Blob.
  102907. */
  102908. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  102909. var _this = this;
  102910. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  102911. if (maxDuration === void 0) { maxDuration = 7; }
  102912. if (!this._canvas || !this._mediaRecorder) {
  102913. throw "Recorder has already been disposed";
  102914. }
  102915. if (this.isRecording) {
  102916. throw "Recording already in progress";
  102917. }
  102918. if (maxDuration > 0) {
  102919. setTimeout(function () {
  102920. _this.stopRecording();
  102921. }, maxDuration * 1000);
  102922. }
  102923. this._fileName = fileName;
  102924. this._recordedChunks = [];
  102925. this._resolve = null;
  102926. this._reject = null;
  102927. this._canvas.isRecording = true;
  102928. this._mediaRecorder.start(this._options.recordChunckSize);
  102929. return new Promise(function (resolve, reject) {
  102930. _this._resolve = resolve;
  102931. _this._reject = reject;
  102932. });
  102933. };
  102934. /**
  102935. * Releases internal resources used during the recording.
  102936. */
  102937. VideoRecorder.prototype.dispose = function () {
  102938. this._canvas = null;
  102939. this._mediaRecorder = null;
  102940. this._recordedChunks = [];
  102941. this._fileName = null;
  102942. this._resolve = null;
  102943. this._reject = null;
  102944. };
  102945. VideoRecorder.prototype._handleDataAvailable = function (event) {
  102946. if (event.data.size > 0) {
  102947. this._recordedChunks.push(event.data);
  102948. }
  102949. };
  102950. VideoRecorder.prototype._handleError = function (event) {
  102951. this.stopRecording();
  102952. if (this._reject) {
  102953. this._reject(event.error);
  102954. }
  102955. else {
  102956. throw new event.error();
  102957. }
  102958. };
  102959. VideoRecorder.prototype._handleStop = function () {
  102960. this.stopRecording();
  102961. var superBuffer = new Blob(this._recordedChunks);
  102962. if (this._resolve) {
  102963. this._resolve(superBuffer);
  102964. }
  102965. window.URL.createObjectURL(superBuffer);
  102966. if (this._fileName) {
  102967. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  102968. }
  102969. };
  102970. VideoRecorder._defaultOptions = {
  102971. mimeType: "video/webm",
  102972. fps: 25,
  102973. recordChunckSize: 3000
  102974. };
  102975. return VideoRecorder;
  102976. }());
  102977. /***/ }),
  102978. /***/ "./Misc/virtualJoystick.ts":
  102979. /*!*********************************!*\
  102980. !*** ./Misc/virtualJoystick.ts ***!
  102981. \*********************************/
  102982. /*! exports provided: JoystickAxis, VirtualJoystick */
  102983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102984. "use strict";
  102985. __webpack_require__.r(__webpack_exports__);
  102986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  102987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  102988. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102989. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  102990. // Mainly based on these 2 articles :
  102991. // 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
  102992. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  102993. /**
  102994. * Defines the potential axis of a Joystick
  102995. */
  102996. var JoystickAxis;
  102997. (function (JoystickAxis) {
  102998. /** X axis */
  102999. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  103000. /** Y axis */
  103001. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  103002. /** Z axis */
  103003. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  103004. })(JoystickAxis || (JoystickAxis = {}));
  103005. /**
  103006. * Class used to define virtual joystick (used in touch mode)
  103007. */
  103008. var VirtualJoystick = /** @class */ (function () {
  103009. /**
  103010. * Creates a new virtual joystick
  103011. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103012. */
  103013. function VirtualJoystick(leftJoystick) {
  103014. var _this = this;
  103015. if (leftJoystick) {
  103016. this._leftJoystick = true;
  103017. }
  103018. else {
  103019. this._leftJoystick = false;
  103020. }
  103021. VirtualJoystick._globalJoystickIndex++;
  103022. // By default left & right arrow keys are moving the X
  103023. // and up & down keys are moving the Y
  103024. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  103025. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  103026. this.reverseLeftRight = false;
  103027. this.reverseUpDown = false;
  103028. // collections of pointers
  103029. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  103030. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103031. this._joystickSensibility = 25;
  103032. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  103033. this._onResize = function (evt) {
  103034. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  103035. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  103036. if (VirtualJoystick.Canvas) {
  103037. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  103038. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  103039. }
  103040. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  103041. };
  103042. // injecting a canvas element on top of the canvas 3D game
  103043. if (!VirtualJoystick.Canvas) {
  103044. window.addEventListener("resize", this._onResize, false);
  103045. VirtualJoystick.Canvas = document.createElement("canvas");
  103046. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  103047. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  103048. VirtualJoystick.Canvas.width = window.innerWidth;
  103049. VirtualJoystick.Canvas.height = window.innerHeight;
  103050. VirtualJoystick.Canvas.style.width = "100%";
  103051. VirtualJoystick.Canvas.style.height = "100%";
  103052. VirtualJoystick.Canvas.style.position = "absolute";
  103053. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  103054. VirtualJoystick.Canvas.style.top = "0px";
  103055. VirtualJoystick.Canvas.style.left = "0px";
  103056. VirtualJoystick.Canvas.style.zIndex = "5";
  103057. VirtualJoystick.Canvas.style.msTouchAction = "none";
  103058. // Support for jQuery PEP polyfill
  103059. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  103060. var context = VirtualJoystick.Canvas.getContext('2d');
  103061. if (!context) {
  103062. throw new Error("Unable to create canvas for virtual joystick");
  103063. }
  103064. VirtualJoystick.vjCanvasContext = context;
  103065. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  103066. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  103067. document.body.appendChild(VirtualJoystick.Canvas);
  103068. }
  103069. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  103070. this.pressed = false;
  103071. // default joystick color
  103072. this._joystickColor = "cyan";
  103073. this._joystickPointerID = -1;
  103074. // current joystick position
  103075. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103076. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103077. // origin joystick position
  103078. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103079. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103080. this._onPointerDownHandlerRef = function (evt) {
  103081. _this._onPointerDown(evt);
  103082. };
  103083. this._onPointerMoveHandlerRef = function (evt) {
  103084. _this._onPointerMove(evt);
  103085. };
  103086. this._onPointerUpHandlerRef = function (evt) {
  103087. _this._onPointerUp(evt);
  103088. };
  103089. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  103090. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  103091. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  103092. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  103093. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  103094. evt.preventDefault(); // Disables system menu
  103095. }, false);
  103096. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  103097. }
  103098. /**
  103099. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103100. * @param newJoystickSensibility defines the new sensibility
  103101. */
  103102. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  103103. this._joystickSensibility = newJoystickSensibility;
  103104. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  103105. };
  103106. VirtualJoystick.prototype._onPointerDown = function (e) {
  103107. var positionOnScreenCondition;
  103108. e.preventDefault();
  103109. if (this._leftJoystick === true) {
  103110. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  103111. }
  103112. else {
  103113. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  103114. }
  103115. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  103116. // First contact will be dedicated to the virtual joystick
  103117. this._joystickPointerID = e.pointerId;
  103118. this._joystickPointerStartPos.x = e.clientX;
  103119. this._joystickPointerStartPos.y = e.clientY;
  103120. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  103121. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  103122. this._deltaJoystickVector.x = 0;
  103123. this._deltaJoystickVector.y = 0;
  103124. this.pressed = true;
  103125. this._touches.add(e.pointerId.toString(), e);
  103126. }
  103127. else {
  103128. // You can only trigger the action buttons with a joystick declared
  103129. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  103130. this._action();
  103131. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  103132. }
  103133. }
  103134. };
  103135. VirtualJoystick.prototype._onPointerMove = function (e) {
  103136. // If the current pointer is the one associated to the joystick (first touch contact)
  103137. if (this._joystickPointerID == e.pointerId) {
  103138. this._joystickPointerPos.x = e.clientX;
  103139. this._joystickPointerPos.y = e.clientY;
  103140. this._deltaJoystickVector = this._joystickPointerPos.clone();
  103141. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  103142. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  103143. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  103144. switch (this._axisTargetedByLeftAndRight) {
  103145. case JoystickAxis.X:
  103146. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  103147. break;
  103148. case JoystickAxis.Y:
  103149. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  103150. break;
  103151. case JoystickAxis.Z:
  103152. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  103153. break;
  103154. }
  103155. var directionUpDown = this.reverseUpDown ? 1 : -1;
  103156. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  103157. switch (this._axisTargetedByUpAndDown) {
  103158. case JoystickAxis.X:
  103159. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  103160. break;
  103161. case JoystickAxis.Y:
  103162. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  103163. break;
  103164. case JoystickAxis.Z:
  103165. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  103166. break;
  103167. }
  103168. }
  103169. else {
  103170. var data = this._touches.get(e.pointerId.toString());
  103171. if (data) {
  103172. data.x = e.clientX;
  103173. data.y = e.clientY;
  103174. }
  103175. }
  103176. };
  103177. VirtualJoystick.prototype._onPointerUp = function (e) {
  103178. if (this._joystickPointerID == e.pointerId) {
  103179. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  103180. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  103181. this._joystickPointerID = -1;
  103182. this.pressed = false;
  103183. }
  103184. else {
  103185. var touch = this._touches.get(e.pointerId.toString());
  103186. if (touch) {
  103187. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  103188. }
  103189. }
  103190. this._deltaJoystickVector.x = 0;
  103191. this._deltaJoystickVector.y = 0;
  103192. this._touches.remove(e.pointerId.toString());
  103193. };
  103194. /**
  103195. * Change the color of the virtual joystick
  103196. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103197. */
  103198. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  103199. this._joystickColor = newColor;
  103200. };
  103201. /**
  103202. * Defines a callback to call when the joystick is touched
  103203. * @param action defines the callback
  103204. */
  103205. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  103206. this._action = action;
  103207. };
  103208. /**
  103209. * Defines which axis you'd like to control for left & right
  103210. * @param axis defines the axis to use
  103211. */
  103212. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  103213. switch (axis) {
  103214. case JoystickAxis.X:
  103215. case JoystickAxis.Y:
  103216. case JoystickAxis.Z:
  103217. this._axisTargetedByLeftAndRight = axis;
  103218. break;
  103219. default:
  103220. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  103221. break;
  103222. }
  103223. };
  103224. /**
  103225. * Defines which axis you'd like to control for up & down
  103226. * @param axis defines the axis to use
  103227. */
  103228. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  103229. switch (axis) {
  103230. case JoystickAxis.X:
  103231. case JoystickAxis.Y:
  103232. case JoystickAxis.Z:
  103233. this._axisTargetedByUpAndDown = axis;
  103234. break;
  103235. default:
  103236. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  103237. break;
  103238. }
  103239. };
  103240. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  103241. var _this = this;
  103242. if (this.pressed) {
  103243. this._touches.forEach(function (key, touch) {
  103244. if (touch.pointerId === _this._joystickPointerID) {
  103245. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  103246. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  103247. VirtualJoystick.vjCanvasContext.beginPath();
  103248. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  103249. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  103250. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  103251. VirtualJoystick.vjCanvasContext.stroke();
  103252. VirtualJoystick.vjCanvasContext.closePath();
  103253. VirtualJoystick.vjCanvasContext.beginPath();
  103254. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  103255. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  103256. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  103257. VirtualJoystick.vjCanvasContext.stroke();
  103258. VirtualJoystick.vjCanvasContext.closePath();
  103259. VirtualJoystick.vjCanvasContext.beginPath();
  103260. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  103261. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  103262. VirtualJoystick.vjCanvasContext.stroke();
  103263. VirtualJoystick.vjCanvasContext.closePath();
  103264. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  103265. }
  103266. else {
  103267. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  103268. VirtualJoystick.vjCanvasContext.beginPath();
  103269. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  103270. VirtualJoystick.vjCanvasContext.beginPath();
  103271. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  103272. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  103273. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  103274. VirtualJoystick.vjCanvasContext.stroke();
  103275. VirtualJoystick.vjCanvasContext.closePath();
  103276. touch.prevX = touch.x;
  103277. touch.prevY = touch.y;
  103278. }
  103279. });
  103280. }
  103281. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  103282. };
  103283. /**
  103284. * Release internal HTML canvas
  103285. */
  103286. VirtualJoystick.prototype.releaseCanvas = function () {
  103287. if (VirtualJoystick.Canvas) {
  103288. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  103289. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  103290. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  103291. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  103292. window.removeEventListener("resize", this._onResize);
  103293. document.body.removeChild(VirtualJoystick.Canvas);
  103294. VirtualJoystick.Canvas = null;
  103295. }
  103296. };
  103297. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  103298. VirtualJoystick._globalJoystickIndex = 0;
  103299. return VirtualJoystick;
  103300. }());
  103301. /***/ }),
  103302. /***/ "./Misc/webRequest.ts":
  103303. /*!****************************!*\
  103304. !*** ./Misc/webRequest.ts ***!
  103305. \****************************/
  103306. /*! exports provided: WebRequest */
  103307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103308. "use strict";
  103309. __webpack_require__.r(__webpack_exports__);
  103310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return WebRequest; });
  103311. /**
  103312. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  103313. */
  103314. var WebRequest = /** @class */ (function () {
  103315. function WebRequest() {
  103316. this._xhr = new XMLHttpRequest();
  103317. }
  103318. WebRequest.prototype._injectCustomRequestHeaders = function () {
  103319. for (var key in WebRequest.CustomRequestHeaders) {
  103320. var val = WebRequest.CustomRequestHeaders[key];
  103321. if (val) {
  103322. this._xhr.setRequestHeader(key, val);
  103323. }
  103324. }
  103325. };
  103326. Object.defineProperty(WebRequest.prototype, "onprogress", {
  103327. /**
  103328. * Gets or sets a function to be called when loading progress changes
  103329. */
  103330. get: function () {
  103331. return this._xhr.onprogress;
  103332. },
  103333. set: function (value) {
  103334. this._xhr.onprogress = value;
  103335. },
  103336. enumerable: true,
  103337. configurable: true
  103338. });
  103339. Object.defineProperty(WebRequest.prototype, "readyState", {
  103340. /**
  103341. * Returns client's state
  103342. */
  103343. get: function () {
  103344. return this._xhr.readyState;
  103345. },
  103346. enumerable: true,
  103347. configurable: true
  103348. });
  103349. Object.defineProperty(WebRequest.prototype, "status", {
  103350. /**
  103351. * Returns client's status
  103352. */
  103353. get: function () {
  103354. return this._xhr.status;
  103355. },
  103356. enumerable: true,
  103357. configurable: true
  103358. });
  103359. Object.defineProperty(WebRequest.prototype, "statusText", {
  103360. /**
  103361. * Returns client's status as a text
  103362. */
  103363. get: function () {
  103364. return this._xhr.statusText;
  103365. },
  103366. enumerable: true,
  103367. configurable: true
  103368. });
  103369. Object.defineProperty(WebRequest.prototype, "response", {
  103370. /**
  103371. * Returns client's response
  103372. */
  103373. get: function () {
  103374. return this._xhr.response;
  103375. },
  103376. enumerable: true,
  103377. configurable: true
  103378. });
  103379. Object.defineProperty(WebRequest.prototype, "responseURL", {
  103380. /**
  103381. * Returns client's response url
  103382. */
  103383. get: function () {
  103384. return this._xhr.responseURL;
  103385. },
  103386. enumerable: true,
  103387. configurable: true
  103388. });
  103389. Object.defineProperty(WebRequest.prototype, "responseText", {
  103390. /**
  103391. * Returns client's response as text
  103392. */
  103393. get: function () {
  103394. return this._xhr.responseText;
  103395. },
  103396. enumerable: true,
  103397. configurable: true
  103398. });
  103399. Object.defineProperty(WebRequest.prototype, "responseType", {
  103400. /**
  103401. * Gets or sets the expected response type
  103402. */
  103403. get: function () {
  103404. return this._xhr.responseType;
  103405. },
  103406. set: function (value) {
  103407. this._xhr.responseType = value;
  103408. },
  103409. enumerable: true,
  103410. configurable: true
  103411. });
  103412. WebRequest.prototype.addEventListener = function (type, listener, options) {
  103413. this._xhr.addEventListener(type, listener, options);
  103414. };
  103415. WebRequest.prototype.removeEventListener = function (type, listener, options) {
  103416. this._xhr.removeEventListener(type, listener, options);
  103417. };
  103418. /**
  103419. * Cancels any network activity
  103420. */
  103421. WebRequest.prototype.abort = function () {
  103422. this._xhr.abort();
  103423. };
  103424. /**
  103425. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  103426. * @param body defines an optional request body
  103427. */
  103428. WebRequest.prototype.send = function (body) {
  103429. this._xhr.send(body);
  103430. };
  103431. /**
  103432. * Sets the request method, request URL
  103433. * @param method defines the method to use (GET, POST, etc..)
  103434. * @param url defines the url to connect with
  103435. */
  103436. WebRequest.prototype.open = function (method, url) {
  103437. if (WebRequest.CustomRequestHeaders) {
  103438. this._injectCustomRequestHeaders();
  103439. }
  103440. for (var _i = 0, _a = WebRequest.CustomRequestModifiers; _i < _a.length; _i++) {
  103441. var update = _a[_i];
  103442. update(this._xhr);
  103443. }
  103444. return this._xhr.open(method, url, true);
  103445. };
  103446. /**
  103447. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  103448. * i.e. when loading files, where the server/service expects an Authorization header
  103449. */
  103450. WebRequest.CustomRequestHeaders = {};
  103451. /**
  103452. * Add callback functions in this array to update all the requests before they get sent to the network
  103453. */
  103454. WebRequest.CustomRequestModifiers = new Array();
  103455. return WebRequest;
  103456. }());
  103457. /***/ }),
  103458. /***/ "./Misc/workerPool.ts":
  103459. /*!****************************!*\
  103460. !*** ./Misc/workerPool.ts ***!
  103461. \****************************/
  103462. /*! exports provided: WorkerPool */
  103463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103464. "use strict";
  103465. __webpack_require__.r(__webpack_exports__);
  103466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  103467. /**
  103468. * Helper class to push actions to a pool of workers.
  103469. */
  103470. var WorkerPool = /** @class */ (function () {
  103471. /**
  103472. * Constructor
  103473. * @param workers Array of workers to use for actions
  103474. */
  103475. function WorkerPool(workers) {
  103476. this._pendingActions = new Array();
  103477. this._workerInfos = workers.map(function (worker) { return ({
  103478. worker: worker,
  103479. active: false
  103480. }); });
  103481. }
  103482. /**
  103483. * Terminates all workers and clears any pending actions.
  103484. */
  103485. WorkerPool.prototype.dispose = function () {
  103486. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  103487. var workerInfo = _a[_i];
  103488. workerInfo.worker.terminate();
  103489. }
  103490. delete this._workerInfos;
  103491. delete this._pendingActions;
  103492. };
  103493. /**
  103494. * Pushes an action to the worker pool. If all the workers are active, the action will be
  103495. * pended until a worker has completed its action.
  103496. * @param action The action to perform. Call onComplete when the action is complete.
  103497. */
  103498. WorkerPool.prototype.push = function (action) {
  103499. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  103500. var workerInfo = _a[_i];
  103501. if (!workerInfo.active) {
  103502. this._execute(workerInfo, action);
  103503. return;
  103504. }
  103505. }
  103506. this._pendingActions.push(action);
  103507. };
  103508. WorkerPool.prototype._execute = function (workerInfo, action) {
  103509. var _this = this;
  103510. workerInfo.active = true;
  103511. action(workerInfo.worker, function () {
  103512. workerInfo.active = false;
  103513. var nextAction = _this._pendingActions.shift();
  103514. if (nextAction) {
  103515. _this._execute(workerInfo, nextAction);
  103516. }
  103517. });
  103518. };
  103519. return WorkerPool;
  103520. }());
  103521. /***/ }),
  103522. /***/ "./Morph/index.ts":
  103523. /*!************************!*\
  103524. !*** ./Morph/index.ts ***!
  103525. \************************/
  103526. /*! exports provided: MorphTarget, MorphTargetManager */
  103527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103528. "use strict";
  103529. __webpack_require__.r(__webpack_exports__);
  103530. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  103531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  103532. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  103533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  103534. /***/ }),
  103535. /***/ "./Morph/morphTarget.ts":
  103536. /*!******************************!*\
  103537. !*** ./Morph/morphTarget.ts ***!
  103538. \******************************/
  103539. /*! exports provided: MorphTarget */
  103540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103541. "use strict";
  103542. __webpack_require__.r(__webpack_exports__);
  103543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  103544. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103545. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  103546. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103547. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103548. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  103549. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  103550. /**
  103551. * Defines a target to use with MorphTargetManager
  103552. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103553. */
  103554. var MorphTarget = /** @class */ (function () {
  103555. /**
  103556. * Creates a new MorphTarget
  103557. * @param name defines the name of the target
  103558. * @param influence defines the influence to use
  103559. * @param scene defines the scene the morphtarget belongs to
  103560. */
  103561. function MorphTarget(
  103562. /** defines the name of the target */
  103563. name, influence, scene) {
  103564. if (influence === void 0) { influence = 0; }
  103565. if (scene === void 0) { scene = null; }
  103566. this.name = name;
  103567. /**
  103568. * Gets or sets the list of animations
  103569. */
  103570. this.animations = new Array();
  103571. this._positions = null;
  103572. this._normals = null;
  103573. this._tangents = null;
  103574. /**
  103575. * Observable raised when the influence changes
  103576. */
  103577. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  103578. /** @hidden */
  103579. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  103580. this._animationPropertiesOverride = null;
  103581. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  103582. this.influence = influence;
  103583. }
  103584. Object.defineProperty(MorphTarget.prototype, "influence", {
  103585. /**
  103586. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103587. */
  103588. get: function () {
  103589. return this._influence;
  103590. },
  103591. set: function (influence) {
  103592. if (this._influence === influence) {
  103593. return;
  103594. }
  103595. var previous = this._influence;
  103596. this._influence = influence;
  103597. if (this.onInfluenceChanged.hasObservers) {
  103598. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  103599. }
  103600. },
  103601. enumerable: true,
  103602. configurable: true
  103603. });
  103604. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  103605. /**
  103606. * Gets or sets the animation properties override
  103607. */
  103608. get: function () {
  103609. if (!this._animationPropertiesOverride && this._scene) {
  103610. return this._scene.animationPropertiesOverride;
  103611. }
  103612. return this._animationPropertiesOverride;
  103613. },
  103614. set: function (value) {
  103615. this._animationPropertiesOverride = value;
  103616. },
  103617. enumerable: true,
  103618. configurable: true
  103619. });
  103620. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  103621. /**
  103622. * Gets a boolean defining if the target contains position data
  103623. */
  103624. get: function () {
  103625. return !!this._positions;
  103626. },
  103627. enumerable: true,
  103628. configurable: true
  103629. });
  103630. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  103631. /**
  103632. * Gets a boolean defining if the target contains normal data
  103633. */
  103634. get: function () {
  103635. return !!this._normals;
  103636. },
  103637. enumerable: true,
  103638. configurable: true
  103639. });
  103640. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  103641. /**
  103642. * Gets a boolean defining if the target contains tangent data
  103643. */
  103644. get: function () {
  103645. return !!this._tangents;
  103646. },
  103647. enumerable: true,
  103648. configurable: true
  103649. });
  103650. /**
  103651. * Affects position data to this target
  103652. * @param data defines the position data to use
  103653. */
  103654. MorphTarget.prototype.setPositions = function (data) {
  103655. var hadPositions = this.hasPositions;
  103656. this._positions = data;
  103657. if (hadPositions !== this.hasPositions) {
  103658. this._onDataLayoutChanged.notifyObservers(undefined);
  103659. }
  103660. };
  103661. /**
  103662. * Gets the position data stored in this target
  103663. * @returns a FloatArray containing the position data (or null if not present)
  103664. */
  103665. MorphTarget.prototype.getPositions = function () {
  103666. return this._positions;
  103667. };
  103668. /**
  103669. * Affects normal data to this target
  103670. * @param data defines the normal data to use
  103671. */
  103672. MorphTarget.prototype.setNormals = function (data) {
  103673. var hadNormals = this.hasNormals;
  103674. this._normals = data;
  103675. if (hadNormals !== this.hasNormals) {
  103676. this._onDataLayoutChanged.notifyObservers(undefined);
  103677. }
  103678. };
  103679. /**
  103680. * Gets the normal data stored in this target
  103681. * @returns a FloatArray containing the normal data (or null if not present)
  103682. */
  103683. MorphTarget.prototype.getNormals = function () {
  103684. return this._normals;
  103685. };
  103686. /**
  103687. * Affects tangent data to this target
  103688. * @param data defines the tangent data to use
  103689. */
  103690. MorphTarget.prototype.setTangents = function (data) {
  103691. var hadTangents = this.hasTangents;
  103692. this._tangents = data;
  103693. if (hadTangents !== this.hasTangents) {
  103694. this._onDataLayoutChanged.notifyObservers(undefined);
  103695. }
  103696. };
  103697. /**
  103698. * Gets the tangent data stored in this target
  103699. * @returns a FloatArray containing the tangent data (or null if not present)
  103700. */
  103701. MorphTarget.prototype.getTangents = function () {
  103702. return this._tangents;
  103703. };
  103704. /**
  103705. * Serializes the current target into a Serialization object
  103706. * @returns the serialized object
  103707. */
  103708. MorphTarget.prototype.serialize = function () {
  103709. var serializationObject = {};
  103710. serializationObject.name = this.name;
  103711. serializationObject.influence = this.influence;
  103712. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  103713. if (this.id != null) {
  103714. serializationObject.id = this.id;
  103715. }
  103716. if (this.hasNormals) {
  103717. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  103718. }
  103719. if (this.hasTangents) {
  103720. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  103721. }
  103722. // Animations
  103723. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  103724. return serializationObject;
  103725. };
  103726. /**
  103727. * Returns the string "MorphTarget"
  103728. * @returns "MorphTarget"
  103729. */
  103730. MorphTarget.prototype.getClassName = function () {
  103731. return "MorphTarget";
  103732. };
  103733. // Statics
  103734. /**
  103735. * Creates a new target from serialized data
  103736. * @param serializationObject defines the serialized data to use
  103737. * @returns a new MorphTarget
  103738. */
  103739. MorphTarget.Parse = function (serializationObject) {
  103740. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  103741. result.setPositions(serializationObject.positions);
  103742. if (serializationObject.id != null) {
  103743. result.id = serializationObject.id;
  103744. }
  103745. if (serializationObject.normals) {
  103746. result.setNormals(serializationObject.normals);
  103747. }
  103748. if (serializationObject.tangents) {
  103749. result.setTangents(serializationObject.tangents);
  103750. }
  103751. // Animations
  103752. if (serializationObject.animations) {
  103753. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  103754. var parsedAnimation = serializationObject.animations[animationIndex];
  103755. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  103756. if (internalClass) {
  103757. result.animations.push(internalClass.Parse(parsedAnimation));
  103758. }
  103759. }
  103760. }
  103761. return result;
  103762. };
  103763. /**
  103764. * Creates a MorphTarget from mesh data
  103765. * @param mesh defines the source mesh
  103766. * @param name defines the name to use for the new target
  103767. * @param influence defines the influence to attach to the target
  103768. * @returns a new MorphTarget
  103769. */
  103770. MorphTarget.FromMesh = function (mesh, name, influence) {
  103771. if (!name) {
  103772. name = mesh.name;
  103773. }
  103774. var result = new MorphTarget(name, influence, mesh.getScene());
  103775. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  103776. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  103777. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  103778. }
  103779. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  103780. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  103781. }
  103782. return result;
  103783. };
  103784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  103785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  103786. ], MorphTarget.prototype, "id", void 0);
  103787. return MorphTarget;
  103788. }());
  103789. /***/ }),
  103790. /***/ "./Morph/morphTargetManager.ts":
  103791. /*!*************************************!*\
  103792. !*** ./Morph/morphTargetManager.ts ***!
  103793. \*************************************/
  103794. /*! exports provided: MorphTargetManager */
  103795. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103796. "use strict";
  103797. __webpack_require__.r(__webpack_exports__);
  103798. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  103799. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  103800. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  103801. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103802. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  103803. /**
  103804. * This class is used to deform meshes using morphing between different targets
  103805. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103806. */
  103807. var MorphTargetManager = /** @class */ (function () {
  103808. /**
  103809. * Creates a new MorphTargetManager
  103810. * @param scene defines the current scene
  103811. */
  103812. function MorphTargetManager(scene) {
  103813. if (scene === void 0) { scene = null; }
  103814. this._targets = new Array();
  103815. this._targetInfluenceChangedObservers = new Array();
  103816. this._targetDataLayoutChangedObservers = new Array();
  103817. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  103818. this._supportsNormals = false;
  103819. this._supportsTangents = false;
  103820. this._vertexCount = 0;
  103821. this._uniqueId = 0;
  103822. this._tempInfluences = new Array();
  103823. if (!scene) {
  103824. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  103825. }
  103826. this._scene = scene;
  103827. if (this._scene) {
  103828. this._scene.morphTargetManagers.push(this);
  103829. this._uniqueId = this._scene.getUniqueId();
  103830. }
  103831. }
  103832. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  103833. /**
  103834. * Gets the unique ID of this manager
  103835. */
  103836. get: function () {
  103837. return this._uniqueId;
  103838. },
  103839. enumerable: true,
  103840. configurable: true
  103841. });
  103842. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  103843. /**
  103844. * Gets the number of vertices handled by this manager
  103845. */
  103846. get: function () {
  103847. return this._vertexCount;
  103848. },
  103849. enumerable: true,
  103850. configurable: true
  103851. });
  103852. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  103853. /**
  103854. * Gets a boolean indicating if this manager supports morphing of normals
  103855. */
  103856. get: function () {
  103857. return this._supportsNormals;
  103858. },
  103859. enumerable: true,
  103860. configurable: true
  103861. });
  103862. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  103863. /**
  103864. * Gets a boolean indicating if this manager supports morphing of tangents
  103865. */
  103866. get: function () {
  103867. return this._supportsTangents;
  103868. },
  103869. enumerable: true,
  103870. configurable: true
  103871. });
  103872. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  103873. /**
  103874. * Gets the number of targets stored in this manager
  103875. */
  103876. get: function () {
  103877. return this._targets.length;
  103878. },
  103879. enumerable: true,
  103880. configurable: true
  103881. });
  103882. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  103883. /**
  103884. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103885. */
  103886. get: function () {
  103887. return this._activeTargets.length;
  103888. },
  103889. enumerable: true,
  103890. configurable: true
  103891. });
  103892. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  103893. /**
  103894. * Gets the list of influences (one per target)
  103895. */
  103896. get: function () {
  103897. return this._influences;
  103898. },
  103899. enumerable: true,
  103900. configurable: true
  103901. });
  103902. /**
  103903. * Gets the active target at specified index. An active target is a target with an influence > 0
  103904. * @param index defines the index to check
  103905. * @returns the requested target
  103906. */
  103907. MorphTargetManager.prototype.getActiveTarget = function (index) {
  103908. return this._activeTargets.data[index];
  103909. };
  103910. /**
  103911. * Gets the target at specified index
  103912. * @param index defines the index to check
  103913. * @returns the requested target
  103914. */
  103915. MorphTargetManager.prototype.getTarget = function (index) {
  103916. return this._targets[index];
  103917. };
  103918. /**
  103919. * Add a new target to this manager
  103920. * @param target defines the target to add
  103921. */
  103922. MorphTargetManager.prototype.addTarget = function (target) {
  103923. var _this = this;
  103924. this._targets.push(target);
  103925. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  103926. _this._syncActiveTargets(needUpdate);
  103927. }));
  103928. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  103929. _this._syncActiveTargets(true);
  103930. }));
  103931. this._syncActiveTargets(true);
  103932. };
  103933. /**
  103934. * Removes a target from the manager
  103935. * @param target defines the target to remove
  103936. */
  103937. MorphTargetManager.prototype.removeTarget = function (target) {
  103938. var index = this._targets.indexOf(target);
  103939. if (index >= 0) {
  103940. this._targets.splice(index, 1);
  103941. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  103942. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  103943. this._syncActiveTargets(true);
  103944. }
  103945. };
  103946. /**
  103947. * Serializes the current manager into a Serialization object
  103948. * @returns the serialized object
  103949. */
  103950. MorphTargetManager.prototype.serialize = function () {
  103951. var serializationObject = {};
  103952. serializationObject.id = this.uniqueId;
  103953. serializationObject.targets = [];
  103954. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  103955. var target = _a[_i];
  103956. serializationObject.targets.push(target.serialize());
  103957. }
  103958. return serializationObject;
  103959. };
  103960. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  103961. var influenceCount = 0;
  103962. this._activeTargets.reset();
  103963. this._supportsNormals = true;
  103964. this._supportsTangents = true;
  103965. this._vertexCount = 0;
  103966. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  103967. var target = _a[_i];
  103968. if (target.influence === 0) {
  103969. continue;
  103970. }
  103971. this._activeTargets.push(target);
  103972. this._tempInfluences[influenceCount++] = target.influence;
  103973. this._supportsNormals = this._supportsNormals && target.hasNormals;
  103974. this._supportsTangents = this._supportsTangents && target.hasTangents;
  103975. var positions = target.getPositions();
  103976. if (positions) {
  103977. var vertexCount = positions.length / 3;
  103978. if (this._vertexCount === 0) {
  103979. this._vertexCount = vertexCount;
  103980. }
  103981. else if (this._vertexCount !== vertexCount) {
  103982. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  103983. return;
  103984. }
  103985. }
  103986. }
  103987. if (!this._influences || this._influences.length !== influenceCount) {
  103988. this._influences = new Float32Array(influenceCount);
  103989. }
  103990. for (var index = 0; index < influenceCount; index++) {
  103991. this._influences[index] = this._tempInfluences[index];
  103992. }
  103993. if (needUpdate) {
  103994. this.synchronize();
  103995. }
  103996. };
  103997. /**
  103998. * Syncrhonize the targets with all the meshes using this morph target manager
  103999. */
  104000. MorphTargetManager.prototype.synchronize = function () {
  104001. if (!this._scene) {
  104002. return;
  104003. }
  104004. // Flag meshes as dirty to resync with the active targets
  104005. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  104006. var mesh = _a[_i];
  104007. if (mesh.morphTargetManager === this) {
  104008. mesh._syncGeometryWithMorphTargetManager();
  104009. }
  104010. }
  104011. };
  104012. // Statics
  104013. /**
  104014. * Creates a new MorphTargetManager from serialized data
  104015. * @param serializationObject defines the serialized data
  104016. * @param scene defines the hosting scene
  104017. * @returns the new MorphTargetManager
  104018. */
  104019. MorphTargetManager.Parse = function (serializationObject, scene) {
  104020. var result = new MorphTargetManager(scene);
  104021. result._uniqueId = serializationObject.id;
  104022. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  104023. var targetData = _a[_i];
  104024. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  104025. }
  104026. return result;
  104027. };
  104028. return MorphTargetManager;
  104029. }());
  104030. /***/ }),
  104031. /***/ "./Offline/database.ts":
  104032. /*!*****************************!*\
  104033. !*** ./Offline/database.ts ***!
  104034. \*****************************/
  104035. /*! exports provided: Database */
  104036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104037. "use strict";
  104038. __webpack_require__.r(__webpack_exports__);
  104039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  104040. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104041. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  104042. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  104043. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  104044. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/webRequest */ "./Misc/webRequest.ts");
  104045. // Sets the default offline provider to Babylon.js
  104046. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  104047. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  104048. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  104049. };
  104050. /**
  104051. * Class used to enable access to IndexedDB
  104052. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104053. */
  104054. var Database = /** @class */ (function () {
  104055. /**
  104056. * Creates a new Database
  104057. * @param urlToScene defines the url to load the scene
  104058. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104059. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104060. */
  104061. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  104062. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  104063. var _this = this;
  104064. // Handling various flavors of prefixed version of IndexedDB
  104065. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  104066. this._callbackManifestChecked = callbackManifestChecked;
  104067. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  104068. this._db = null;
  104069. this._enableSceneOffline = false;
  104070. this._enableTexturesOffline = false;
  104071. this._manifestVersionFound = 0;
  104072. this._mustUpdateRessources = false;
  104073. this._hasReachedQuota = false;
  104074. if (!Database.IDBStorageEnabled) {
  104075. this._callbackManifestChecked(true);
  104076. }
  104077. else {
  104078. if (disableManifestCheck) {
  104079. this._enableSceneOffline = true;
  104080. this._enableTexturesOffline = true;
  104081. this._manifestVersionFound = 1;
  104082. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  104083. _this._callbackManifestChecked(true);
  104084. });
  104085. }
  104086. else {
  104087. this._checkManifestFile();
  104088. }
  104089. }
  104090. }
  104091. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  104092. /**
  104093. * Gets a boolean indicating if scene must be saved in the database
  104094. */
  104095. get: function () {
  104096. return this._enableSceneOffline;
  104097. },
  104098. enumerable: true,
  104099. configurable: true
  104100. });
  104101. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  104102. /**
  104103. * Gets a boolean indicating if textures must be saved in the database
  104104. */
  104105. get: function () {
  104106. return this._enableTexturesOffline;
  104107. },
  104108. enumerable: true,
  104109. configurable: true
  104110. });
  104111. Database.prototype._checkManifestFile = function () {
  104112. var _this = this;
  104113. var noManifestFile = function () {
  104114. _this._enableSceneOffline = false;
  104115. _this._enableTexturesOffline = false;
  104116. _this._callbackManifestChecked(false);
  104117. };
  104118. var timeStampUsed = false;
  104119. var manifestURL = this._currentSceneUrl + ".manifest";
  104120. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  104121. if (navigator.onLine) {
  104122. // Adding a timestamp to by-pass browsers' cache
  104123. timeStampUsed = true;
  104124. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  104125. }
  104126. xhr.open("GET", manifestURL);
  104127. xhr.addEventListener("load", function () {
  104128. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  104129. try {
  104130. var manifestFile = JSON.parse(xhr.response);
  104131. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  104132. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  104133. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  104134. _this._manifestVersionFound = manifestFile.version;
  104135. }
  104136. if (_this._callbackManifestChecked) {
  104137. _this._callbackManifestChecked(true);
  104138. }
  104139. }
  104140. catch (ex) {
  104141. noManifestFile();
  104142. }
  104143. }
  104144. else {
  104145. noManifestFile();
  104146. }
  104147. }, false);
  104148. xhr.addEventListener("error", function () {
  104149. if (timeStampUsed) {
  104150. timeStampUsed = false;
  104151. // Let's retry without the timeStamp
  104152. // It could fail when coupled with HTML5 Offline API
  104153. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  104154. xhr.open("GET", retryManifestURL);
  104155. xhr.send();
  104156. }
  104157. else {
  104158. noManifestFile();
  104159. }
  104160. }, false);
  104161. try {
  104162. xhr.send();
  104163. }
  104164. catch (ex) {
  104165. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  104166. this._callbackManifestChecked(false);
  104167. }
  104168. };
  104169. /**
  104170. * Open the database and make it available
  104171. * @param successCallback defines the callback to call on success
  104172. * @param errorCallback defines the callback to call on error
  104173. */
  104174. Database.prototype.open = function (successCallback, errorCallback) {
  104175. var _this = this;
  104176. var handleError = function () {
  104177. _this._isSupported = false;
  104178. if (errorCallback) {
  104179. errorCallback();
  104180. }
  104181. };
  104182. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  104183. // Your browser doesn't support IndexedDB
  104184. this._isSupported = false;
  104185. if (errorCallback) {
  104186. errorCallback();
  104187. }
  104188. }
  104189. else {
  104190. // If the DB hasn't been opened or created yet
  104191. if (!this._db) {
  104192. this._hasReachedQuota = false;
  104193. this._isSupported = true;
  104194. var request = this._idbFactory.open("babylonjs", 1);
  104195. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  104196. request.onerror = function () {
  104197. handleError();
  104198. };
  104199. // executes when a version change transaction cannot complete due to other active transactions
  104200. request.onblocked = function () {
  104201. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  104202. handleError();
  104203. };
  104204. // DB has been opened successfully
  104205. request.onsuccess = function () {
  104206. _this._db = request.result;
  104207. successCallback();
  104208. };
  104209. // Initialization of the DB. Creating Scenes & Textures stores
  104210. request.onupgradeneeded = function (event) {
  104211. _this._db = (event.target).result;
  104212. if (_this._db) {
  104213. try {
  104214. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  104215. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  104216. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  104217. }
  104218. catch (ex) {
  104219. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  104220. handleError();
  104221. }
  104222. }
  104223. };
  104224. }
  104225. // DB has already been created and opened
  104226. else {
  104227. if (successCallback) {
  104228. successCallback();
  104229. }
  104230. }
  104231. }
  104232. };
  104233. /**
  104234. * Loads an image from the database
  104235. * @param url defines the url to load from
  104236. * @param image defines the target DOM image
  104237. */
  104238. Database.prototype.loadImage = function (url, image) {
  104239. var _this = this;
  104240. var completeURL = Database._ReturnFullUrlLocation(url);
  104241. var saveAndLoadImage = function () {
  104242. if (!_this._hasReachedQuota && _this._db !== null) {
  104243. // the texture is not yet in the DB, let's try to save it
  104244. _this._saveImageIntoDBAsync(completeURL, image);
  104245. }
  104246. // If the texture is not in the DB and we've reached the DB quota limit
  104247. // let's load it directly from the web
  104248. else {
  104249. image.src = url;
  104250. }
  104251. };
  104252. if (!this._mustUpdateRessources) {
  104253. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  104254. }
  104255. // First time we're download the images or update requested in the manifest file by a version change
  104256. else {
  104257. saveAndLoadImage();
  104258. }
  104259. };
  104260. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  104261. if (this._isSupported && this._db !== null) {
  104262. var texture;
  104263. var transaction = this._db.transaction(["textures"]);
  104264. transaction.onabort = function () {
  104265. image.src = url;
  104266. };
  104267. transaction.oncomplete = function () {
  104268. var blobTextureURL;
  104269. if (texture) {
  104270. var URL = window.URL || window.webkitURL;
  104271. blobTextureURL = URL.createObjectURL(texture.data);
  104272. image.onerror = function () {
  104273. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  104274. image.src = url;
  104275. };
  104276. image.src = blobTextureURL;
  104277. }
  104278. else {
  104279. notInDBCallback();
  104280. }
  104281. };
  104282. var getRequest = transaction.objectStore("textures").get(url);
  104283. getRequest.onsuccess = function (event) {
  104284. texture = (event.target).result;
  104285. };
  104286. getRequest.onerror = function () {
  104287. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  104288. image.src = url;
  104289. };
  104290. }
  104291. else {
  104292. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  104293. image.src = url;
  104294. }
  104295. };
  104296. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  104297. var _this = this;
  104298. if (this._isSupported) {
  104299. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  104300. var generateBlobUrl = function () {
  104301. var blobTextureURL;
  104302. if (blob) {
  104303. var URL = window.URL || window.webkitURL;
  104304. try {
  104305. blobTextureURL = URL.createObjectURL(blob);
  104306. }
  104307. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  104308. catch (ex) {
  104309. blobTextureURL = URL.createObjectURL(blob);
  104310. }
  104311. }
  104312. if (blobTextureURL) {
  104313. image.src = blobTextureURL;
  104314. }
  104315. };
  104316. if (Database.IsUASupportingBlobStorage) { // Create XHR
  104317. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"](), blob;
  104318. xhr.open("GET", url);
  104319. xhr.responseType = "blob";
  104320. xhr.addEventListener("load", function () {
  104321. if (xhr.status === 200 && _this._db) {
  104322. // Blob as response (XHR2)
  104323. blob = xhr.response;
  104324. var transaction = _this._db.transaction(["textures"], "readwrite");
  104325. // the transaction could abort because of a QuotaExceededError error
  104326. transaction.onabort = function (event) {
  104327. try {
  104328. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  104329. var srcElement = (event.srcElement || event.target);
  104330. var error = srcElement.error;
  104331. if (error && error.name === "QuotaExceededError") {
  104332. _this._hasReachedQuota = true;
  104333. }
  104334. }
  104335. catch (ex) { }
  104336. generateBlobUrl();
  104337. };
  104338. transaction.oncomplete = function () {
  104339. generateBlobUrl();
  104340. };
  104341. var newTexture = { textureUrl: url, data: blob };
  104342. try {
  104343. // Put the blob into the dabase
  104344. var addRequest = transaction.objectStore("textures").put(newTexture);
  104345. addRequest.onsuccess = function () {
  104346. };
  104347. addRequest.onerror = function () {
  104348. generateBlobUrl();
  104349. };
  104350. }
  104351. catch (ex) {
  104352. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  104353. if (ex.code === 25) {
  104354. Database.IsUASupportingBlobStorage = false;
  104355. _this._enableTexturesOffline = false;
  104356. }
  104357. image.src = url;
  104358. }
  104359. }
  104360. else {
  104361. image.src = url;
  104362. }
  104363. }, false);
  104364. xhr.addEventListener("error", function () {
  104365. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  104366. image.src = url;
  104367. }, false);
  104368. xhr.send();
  104369. }
  104370. else {
  104371. image.src = url;
  104372. }
  104373. }
  104374. else {
  104375. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  104376. image.src = url;
  104377. }
  104378. };
  104379. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  104380. var _this = this;
  104381. var updateVersion = function () {
  104382. // the version is not yet in the DB or we need to update it
  104383. _this._saveVersionIntoDBAsync(url, versionLoaded);
  104384. };
  104385. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  104386. };
  104387. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  104388. var _this = this;
  104389. if (this._isSupported && this._db) {
  104390. var version;
  104391. try {
  104392. var transaction = this._db.transaction(["versions"]);
  104393. transaction.oncomplete = function () {
  104394. if (version) {
  104395. // If the version in the JSON file is different from the version in DB
  104396. if (_this._manifestVersionFound !== version.data) {
  104397. _this._mustUpdateRessources = true;
  104398. updateInDBCallback();
  104399. }
  104400. else {
  104401. callback(version.data);
  104402. }
  104403. }
  104404. // version was not found in DB
  104405. else {
  104406. _this._mustUpdateRessources = true;
  104407. updateInDBCallback();
  104408. }
  104409. };
  104410. transaction.onabort = function () {
  104411. callback(-1);
  104412. };
  104413. var getRequest = transaction.objectStore("versions").get(url);
  104414. getRequest.onsuccess = function (event) {
  104415. version = (event.target).result;
  104416. };
  104417. getRequest.onerror = function () {
  104418. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  104419. callback(-1);
  104420. };
  104421. }
  104422. catch (ex) {
  104423. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  104424. callback(-1);
  104425. }
  104426. }
  104427. else {
  104428. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  104429. callback(-1);
  104430. }
  104431. };
  104432. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  104433. var _this = this;
  104434. if (this._isSupported && !this._hasReachedQuota && this._db) {
  104435. try {
  104436. // Open a transaction to the database
  104437. var transaction = this._db.transaction(["versions"], "readwrite");
  104438. // the transaction could abort because of a QuotaExceededError error
  104439. transaction.onabort = function (event) {
  104440. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  104441. var error = event.srcElement['error'];
  104442. if (error && error.name === "QuotaExceededError") {
  104443. _this._hasReachedQuota = true;
  104444. }
  104445. }
  104446. catch (ex) { }
  104447. callback(-1);
  104448. };
  104449. transaction.oncomplete = function () {
  104450. callback(_this._manifestVersionFound);
  104451. };
  104452. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  104453. // Put the scene into the database
  104454. var addRequest = transaction.objectStore("versions").put(newVersion);
  104455. addRequest.onsuccess = function () {
  104456. };
  104457. addRequest.onerror = function () {
  104458. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  104459. };
  104460. }
  104461. catch (ex) {
  104462. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  104463. callback(-1);
  104464. }
  104465. }
  104466. else {
  104467. callback(-1);
  104468. }
  104469. };
  104470. /**
  104471. * Loads a file from database
  104472. * @param url defines the URL to load from
  104473. * @param sceneLoaded defines a callback to call on success
  104474. * @param progressCallBack defines a callback to call when progress changed
  104475. * @param errorCallback defines a callback to call on error
  104476. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  104477. */
  104478. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  104479. var _this = this;
  104480. var completeUrl = Database._ReturnFullUrlLocation(url);
  104481. var saveAndLoadFile = function () {
  104482. // the scene is not yet in the DB, let's try to save it
  104483. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  104484. };
  104485. this._checkVersionFromDB(completeUrl, function (version) {
  104486. if (version !== -1) {
  104487. if (!_this._mustUpdateRessources) {
  104488. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  104489. }
  104490. else {
  104491. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  104492. }
  104493. }
  104494. else {
  104495. if (errorCallback) {
  104496. errorCallback();
  104497. }
  104498. }
  104499. });
  104500. };
  104501. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  104502. if (this._isSupported && this._db) {
  104503. var targetStore;
  104504. if (url.indexOf(".babylon") !== -1) {
  104505. targetStore = "scenes";
  104506. }
  104507. else {
  104508. targetStore = "textures";
  104509. }
  104510. var file;
  104511. var transaction = this._db.transaction([targetStore]);
  104512. transaction.oncomplete = function () {
  104513. if (file) {
  104514. callback(file.data);
  104515. }
  104516. // file was not found in DB
  104517. else {
  104518. notInDBCallback();
  104519. }
  104520. };
  104521. transaction.onabort = function () {
  104522. notInDBCallback();
  104523. };
  104524. var getRequest = transaction.objectStore(targetStore).get(url);
  104525. getRequest.onsuccess = function (event) {
  104526. file = (event.target).result;
  104527. };
  104528. getRequest.onerror = function () {
  104529. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  104530. notInDBCallback();
  104531. };
  104532. }
  104533. else {
  104534. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  104535. callback();
  104536. }
  104537. };
  104538. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  104539. var _this = this;
  104540. if (this._isSupported) {
  104541. var targetStore;
  104542. if (url.indexOf(".babylon") !== -1) {
  104543. targetStore = "scenes";
  104544. }
  104545. else {
  104546. targetStore = "textures";
  104547. }
  104548. // Create XHR
  104549. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  104550. var fileData;
  104551. xhr.open("GET", url + "?" + Date.now());
  104552. if (useArrayBuffer) {
  104553. xhr.responseType = "arraybuffer";
  104554. }
  104555. if (progressCallback) {
  104556. xhr.onprogress = progressCallback;
  104557. }
  104558. xhr.addEventListener("load", function () {
  104559. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  104560. // Blob as response (XHR2)
  104561. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  104562. if (!_this._hasReachedQuota && _this._db) {
  104563. // Open a transaction to the database
  104564. var transaction = _this._db.transaction([targetStore], "readwrite");
  104565. // the transaction could abort because of a QuotaExceededError error
  104566. transaction.onabort = function (event) {
  104567. try {
  104568. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  104569. var error = event.srcElement['error'];
  104570. if (error && error.name === "QuotaExceededError") {
  104571. _this._hasReachedQuota = true;
  104572. }
  104573. }
  104574. catch (ex) { }
  104575. callback(fileData);
  104576. };
  104577. transaction.oncomplete = function () {
  104578. callback(fileData);
  104579. };
  104580. var newFile;
  104581. if (targetStore === "scenes") {
  104582. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  104583. }
  104584. else {
  104585. newFile = { textureUrl: url, data: fileData };
  104586. }
  104587. try {
  104588. // Put the scene into the database
  104589. var addRequest = transaction.objectStore(targetStore).put(newFile);
  104590. addRequest.onsuccess = function () {
  104591. };
  104592. addRequest.onerror = function () {
  104593. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  104594. };
  104595. }
  104596. catch (ex) {
  104597. callback(fileData);
  104598. }
  104599. }
  104600. else {
  104601. callback(fileData);
  104602. }
  104603. }
  104604. else {
  104605. if (xhr.status >= 400 && errorCallback) {
  104606. errorCallback(xhr);
  104607. }
  104608. else {
  104609. callback();
  104610. }
  104611. }
  104612. }, false);
  104613. xhr.addEventListener("error", function () {
  104614. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  104615. callback();
  104616. }, false);
  104617. xhr.send();
  104618. }
  104619. else {
  104620. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  104621. callback();
  104622. }
  104623. };
  104624. /**
  104625. * Validates if xhr data is correct
  104626. * @param xhr defines the request to validate
  104627. * @param dataType defines the expected data type
  104628. * @returns true if data is correct
  104629. */
  104630. Database._ValidateXHRData = function (xhr, dataType) {
  104631. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  104632. if (dataType === void 0) { dataType = 7; }
  104633. try {
  104634. if (dataType & 1) {
  104635. if (xhr.responseText && xhr.responseText.length > 0) {
  104636. return true;
  104637. }
  104638. else if (dataType === 1) {
  104639. return false;
  104640. }
  104641. }
  104642. if (dataType & 2) {
  104643. // Check header width and height since there is no "TGA" magic number
  104644. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  104645. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  104646. return true;
  104647. }
  104648. else if (dataType === 2) {
  104649. return false;
  104650. }
  104651. }
  104652. if (dataType & 4) {
  104653. // Check for the "DDS" magic number
  104654. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  104655. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  104656. return true;
  104657. }
  104658. else {
  104659. return false;
  104660. }
  104661. }
  104662. }
  104663. catch (e) {
  104664. // Global protection
  104665. }
  104666. return false;
  104667. };
  104668. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  104669. Database.IsUASupportingBlobStorage = true;
  104670. /**
  104671. * Gets a boolean indicating if Database storate is enabled (off by default)
  104672. */
  104673. Database.IDBStorageEnabled = false;
  104674. Database._ParseURL = function (url) {
  104675. var a = document.createElement('a');
  104676. a.href = url;
  104677. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  104678. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  104679. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  104680. return absLocation;
  104681. };
  104682. Database._ReturnFullUrlLocation = function (url) {
  104683. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  104684. return (Database._ParseURL(window.location.href) + url);
  104685. }
  104686. else {
  104687. return url;
  104688. }
  104689. };
  104690. return Database;
  104691. }());
  104692. /***/ }),
  104693. /***/ "./Offline/index.ts":
  104694. /*!**************************!*\
  104695. !*** ./Offline/index.ts ***!
  104696. \**************************/
  104697. /*! exports provided: Database */
  104698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104699. "use strict";
  104700. __webpack_require__.r(__webpack_exports__);
  104701. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  104702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  104703. /***/ }),
  104704. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  104705. /*!******************************************************!*\
  104706. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  104707. \******************************************************/
  104708. /*! exports provided: BoxParticleEmitter */
  104709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104710. "use strict";
  104711. __webpack_require__.r(__webpack_exports__);
  104712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  104713. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104714. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  104715. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104716. /**
  104717. * Particle emitter emitting particles from the inside of a box.
  104718. * It emits the particles randomly between 2 given directions.
  104719. */
  104720. var BoxParticleEmitter = /** @class */ (function () {
  104721. /**
  104722. * Creates a new instance BoxParticleEmitter
  104723. */
  104724. function BoxParticleEmitter() {
  104725. /**
  104726. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  104727. */
  104728. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  104729. /**
  104730. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  104731. */
  104732. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  104733. /**
  104734. * 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.
  104735. */
  104736. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  104737. /**
  104738. * 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.
  104739. */
  104740. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  104741. }
  104742. /**
  104743. * Called by the particle System when the direction is computed for the created particle.
  104744. * @param worldMatrix is the world matrix of the particle system
  104745. * @param directionToUpdate is the direction vector to update with the result
  104746. * @param particle is the particle we are computed the direction for
  104747. */
  104748. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104749. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  104750. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  104751. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  104752. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  104753. };
  104754. /**
  104755. * Called by the particle System when the position is computed for the created particle.
  104756. * @param worldMatrix is the world matrix of the particle system
  104757. * @param positionToUpdate is the position vector to update with the result
  104758. * @param particle is the particle we are computed the position for
  104759. */
  104760. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104761. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  104762. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  104763. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  104764. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  104765. };
  104766. /**
  104767. * Clones the current emitter and returns a copy of it
  104768. * @returns the new emitter
  104769. */
  104770. BoxParticleEmitter.prototype.clone = function () {
  104771. var newOne = new BoxParticleEmitter();
  104772. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  104773. return newOne;
  104774. };
  104775. /**
  104776. * Called by the GPUParticleSystem to setup the update shader
  104777. * @param effect defines the update shader
  104778. */
  104779. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  104780. effect.setVector3("direction1", this.direction1);
  104781. effect.setVector3("direction2", this.direction2);
  104782. effect.setVector3("minEmitBox", this.minEmitBox);
  104783. effect.setVector3("maxEmitBox", this.maxEmitBox);
  104784. };
  104785. /**
  104786. * Returns a string to use to update the GPU particles update shader
  104787. * @returns a string containng the defines string
  104788. */
  104789. BoxParticleEmitter.prototype.getEffectDefines = function () {
  104790. return "#define BOXEMITTER";
  104791. };
  104792. /**
  104793. * Returns the string "BoxParticleEmitter"
  104794. * @returns a string containing the class name
  104795. */
  104796. BoxParticleEmitter.prototype.getClassName = function () {
  104797. return "BoxParticleEmitter";
  104798. };
  104799. /**
  104800. * Serializes the particle system to a JSON object.
  104801. * @returns the JSON object
  104802. */
  104803. BoxParticleEmitter.prototype.serialize = function () {
  104804. var serializationObject = {};
  104805. serializationObject.type = this.getClassName();
  104806. serializationObject.direction1 = this.direction1.asArray();
  104807. serializationObject.direction2 = this.direction2.asArray();
  104808. serializationObject.minEmitBox = this.minEmitBox.asArray();
  104809. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  104810. return serializationObject;
  104811. };
  104812. /**
  104813. * Parse properties from a JSON object
  104814. * @param serializationObject defines the JSON object
  104815. */
  104816. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  104817. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  104818. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  104819. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  104820. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  104821. };
  104822. return BoxParticleEmitter;
  104823. }());
  104824. /***/ }),
  104825. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  104826. /*!*******************************************************!*\
  104827. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  104828. \*******************************************************/
  104829. /*! exports provided: ConeParticleEmitter */
  104830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104831. "use strict";
  104832. __webpack_require__.r(__webpack_exports__);
  104833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  104834. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104835. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  104836. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104837. /**
  104838. * Particle emitter emitting particles from the inside of a cone.
  104839. * It emits the particles alongside the cone volume from the base to the particle.
  104840. * The emission direction might be randomized.
  104841. */
  104842. var ConeParticleEmitter = /** @class */ (function () {
  104843. /**
  104844. * Creates a new instance ConeParticleEmitter
  104845. * @param radius the radius of the emission cone (1 by default)
  104846. * @param angle the cone base angle (PI by default)
  104847. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  104848. */
  104849. function ConeParticleEmitter(radius, angle,
  104850. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  104851. directionRandomizer) {
  104852. if (radius === void 0) { radius = 1; }
  104853. if (angle === void 0) { angle = Math.PI; }
  104854. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  104855. this.directionRandomizer = directionRandomizer;
  104856. /**
  104857. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  104858. */
  104859. this.radiusRange = 1;
  104860. /**
  104861. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  104862. */
  104863. this.heightRange = 1;
  104864. /**
  104865. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  104866. */
  104867. this.emitFromSpawnPointOnly = false;
  104868. this.angle = angle;
  104869. this.radius = radius;
  104870. }
  104871. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  104872. /**
  104873. * Gets or sets the radius of the emission cone
  104874. */
  104875. get: function () {
  104876. return this._radius;
  104877. },
  104878. set: function (value) {
  104879. this._radius = value;
  104880. this._buildHeight();
  104881. },
  104882. enumerable: true,
  104883. configurable: true
  104884. });
  104885. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  104886. /**
  104887. * Gets or sets the angle of the emission cone
  104888. */
  104889. get: function () {
  104890. return this._angle;
  104891. },
  104892. set: function (value) {
  104893. this._angle = value;
  104894. this._buildHeight();
  104895. },
  104896. enumerable: true,
  104897. configurable: true
  104898. });
  104899. ConeParticleEmitter.prototype._buildHeight = function () {
  104900. if (this._angle !== 0) {
  104901. this._height = this._radius / Math.tan(this._angle / 2);
  104902. }
  104903. else {
  104904. this._height = 1;
  104905. }
  104906. };
  104907. /**
  104908. * Called by the particle System when the direction is computed for the created particle.
  104909. * @param worldMatrix is the world matrix of the particle system
  104910. * @param directionToUpdate is the direction vector to update with the result
  104911. * @param particle is the particle we are computed the direction for
  104912. */
  104913. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104914. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  104915. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  104916. }
  104917. else {
  104918. // measure the direction Vector from the emitter to the particle.
  104919. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  104920. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104921. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104922. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104923. direction.x += randX;
  104924. direction.y += randY;
  104925. direction.z += randZ;
  104926. direction.normalize();
  104927. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  104928. }
  104929. };
  104930. /**
  104931. * Called by the particle System when the position is computed for the created particle.
  104932. * @param worldMatrix is the world matrix of the particle system
  104933. * @param positionToUpdate is the position vector to update with the result
  104934. * @param particle is the particle we are computed the position for
  104935. */
  104936. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104937. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  104938. var h;
  104939. if (!this.emitFromSpawnPointOnly) {
  104940. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  104941. // Better distribution in a cone at normal angles.
  104942. h = 1 - h * h;
  104943. }
  104944. else {
  104945. h = 0.0001;
  104946. }
  104947. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  104948. radius = radius * h;
  104949. var randX = radius * Math.sin(s);
  104950. var randZ = radius * Math.cos(s);
  104951. var randY = h * this._height;
  104952. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  104953. };
  104954. /**
  104955. * Clones the current emitter and returns a copy of it
  104956. * @returns the new emitter
  104957. */
  104958. ConeParticleEmitter.prototype.clone = function () {
  104959. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  104960. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  104961. return newOne;
  104962. };
  104963. /**
  104964. * Called by the GPUParticleSystem to setup the update shader
  104965. * @param effect defines the update shader
  104966. */
  104967. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  104968. effect.setFloat2("radius", this._radius, this.radiusRange);
  104969. effect.setFloat("coneAngle", this._angle);
  104970. effect.setFloat2("height", this._height, this.heightRange);
  104971. effect.setFloat("directionRandomizer", this.directionRandomizer);
  104972. };
  104973. /**
  104974. * Returns a string to use to update the GPU particles update shader
  104975. * @returns a string containng the defines string
  104976. */
  104977. ConeParticleEmitter.prototype.getEffectDefines = function () {
  104978. var defines = "#define CONEEMITTER";
  104979. if (this.emitFromSpawnPointOnly) {
  104980. defines += "\n#define CONEEMITTERSPAWNPOINT";
  104981. }
  104982. return defines;
  104983. };
  104984. /**
  104985. * Returns the string "ConeParticleEmitter"
  104986. * @returns a string containing the class name
  104987. */
  104988. ConeParticleEmitter.prototype.getClassName = function () {
  104989. return "ConeParticleEmitter";
  104990. };
  104991. /**
  104992. * Serializes the particle system to a JSON object.
  104993. * @returns the JSON object
  104994. */
  104995. ConeParticleEmitter.prototype.serialize = function () {
  104996. var serializationObject = {};
  104997. serializationObject.type = this.getClassName();
  104998. serializationObject.radius = this._radius;
  104999. serializationObject.angle = this._angle;
  105000. serializationObject.directionRandomizer = this.directionRandomizer;
  105001. return serializationObject;
  105002. };
  105003. /**
  105004. * Parse properties from a JSON object
  105005. * @param serializationObject defines the JSON object
  105006. */
  105007. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  105008. this.radius = serializationObject.radius;
  105009. this.angle = serializationObject.angle;
  105010. this.directionRandomizer = serializationObject.directionRandomizer;
  105011. };
  105012. return ConeParticleEmitter;
  105013. }());
  105014. /***/ }),
  105015. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  105016. /*!***********************************************************!*\
  105017. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  105018. \***********************************************************/
  105019. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  105020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105021. "use strict";
  105022. __webpack_require__.r(__webpack_exports__);
  105023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  105024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  105025. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105026. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105027. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105028. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105029. /**
  105030. * Particle emitter emitting particles from the inside of a cylinder.
  105031. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  105032. */
  105033. var CylinderParticleEmitter = /** @class */ (function () {
  105034. /**
  105035. * Creates a new instance CylinderParticleEmitter
  105036. * @param radius the radius of the emission cylinder (1 by default)
  105037. * @param height the height of the emission cylinder (1 by default)
  105038. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105039. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  105040. */
  105041. function CylinderParticleEmitter(
  105042. /**
  105043. * The radius of the emission cylinder.
  105044. */
  105045. radius,
  105046. /**
  105047. * The height of the emission cylinder.
  105048. */
  105049. height,
  105050. /**
  105051. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  105052. */
  105053. radiusRange,
  105054. /**
  105055. * How much to randomize the particle direction [0-1].
  105056. */
  105057. directionRandomizer) {
  105058. if (radius === void 0) { radius = 1; }
  105059. if (height === void 0) { height = 1; }
  105060. if (radiusRange === void 0) { radiusRange = 1; }
  105061. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105062. this.radius = radius;
  105063. this.height = height;
  105064. this.radiusRange = radiusRange;
  105065. this.directionRandomizer = directionRandomizer;
  105066. }
  105067. /**
  105068. * Called by the particle System when the direction is computed for the created particle.
  105069. * @param worldMatrix is the world matrix of the particle system
  105070. * @param directionToUpdate is the direction vector to update with the result
  105071. * @param particle is the particle we are computed the direction for
  105072. */
  105073. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105074. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  105075. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  105076. var angle = Math.atan2(direction.x, direction.z);
  105077. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  105078. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  105079. direction.x = Math.sin(angle);
  105080. direction.z = Math.cos(angle);
  105081. direction.normalize();
  105082. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  105083. };
  105084. /**
  105085. * Called by the particle System when the position is computed for the created particle.
  105086. * @param worldMatrix is the world matrix of the particle system
  105087. * @param positionToUpdate is the position vector to update with the result
  105088. * @param particle is the particle we are computed the position for
  105089. */
  105090. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105091. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  105092. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  105093. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  105094. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  105095. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  105096. var xPos = positionRadius * Math.cos(angle);
  105097. var zPos = positionRadius * Math.sin(angle);
  105098. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  105099. };
  105100. /**
  105101. * Clones the current emitter and returns a copy of it
  105102. * @returns the new emitter
  105103. */
  105104. CylinderParticleEmitter.prototype.clone = function () {
  105105. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  105106. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  105107. return newOne;
  105108. };
  105109. /**
  105110. * Called by the GPUParticleSystem to setup the update shader
  105111. * @param effect defines the update shader
  105112. */
  105113. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  105114. effect.setFloat("radius", this.radius);
  105115. effect.setFloat("height", this.height);
  105116. effect.setFloat("radiusRange", this.radiusRange);
  105117. effect.setFloat("directionRandomizer", this.directionRandomizer);
  105118. };
  105119. /**
  105120. * Returns a string to use to update the GPU particles update shader
  105121. * @returns a string containng the defines string
  105122. */
  105123. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  105124. return "#define CYLINDEREMITTER";
  105125. };
  105126. /**
  105127. * Returns the string "CylinderParticleEmitter"
  105128. * @returns a string containing the class name
  105129. */
  105130. CylinderParticleEmitter.prototype.getClassName = function () {
  105131. return "CylinderParticleEmitter";
  105132. };
  105133. /**
  105134. * Serializes the particle system to a JSON object.
  105135. * @returns the JSON object
  105136. */
  105137. CylinderParticleEmitter.prototype.serialize = function () {
  105138. var serializationObject = {};
  105139. serializationObject.type = this.getClassName();
  105140. serializationObject.radius = this.radius;
  105141. serializationObject.height = this.height;
  105142. serializationObject.radiusRange = this.radiusRange;
  105143. serializationObject.directionRandomizer = this.directionRandomizer;
  105144. return serializationObject;
  105145. };
  105146. /**
  105147. * Parse properties from a JSON object
  105148. * @param serializationObject defines the JSON object
  105149. */
  105150. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  105151. this.radius = serializationObject.radius;
  105152. this.height = serializationObject.height;
  105153. this.radiusRange = serializationObject.radiusRange;
  105154. this.directionRandomizer = serializationObject.directionRandomizer;
  105155. };
  105156. return CylinderParticleEmitter;
  105157. }());
  105158. /**
  105159. * Particle emitter emitting particles from the inside of a cylinder.
  105160. * It emits the particles randomly between two vectors.
  105161. */
  105162. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  105163. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  105164. /**
  105165. * Creates a new instance CylinderDirectedParticleEmitter
  105166. * @param radius the radius of the emission cylinder (1 by default)
  105167. * @param height the height of the emission cylinder (1 by default)
  105168. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105169. * @param direction1 the min limit of the emission direction (up vector by default)
  105170. * @param direction2 the max limit of the emission direction (up vector by default)
  105171. */
  105172. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  105173. /**
  105174. * The min limit of the emission direction.
  105175. */
  105176. direction1,
  105177. /**
  105178. * The max limit of the emission direction.
  105179. */
  105180. direction2) {
  105181. if (radius === void 0) { radius = 1; }
  105182. if (height === void 0) { height = 1; }
  105183. if (radiusRange === void 0) { radiusRange = 1; }
  105184. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  105185. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  105186. var _this = _super.call(this, radius, height, radiusRange) || this;
  105187. _this.direction1 = direction1;
  105188. _this.direction2 = direction2;
  105189. return _this;
  105190. }
  105191. /**
  105192. * Called by the particle System when the direction is computed for the created particle.
  105193. * @param worldMatrix is the world matrix of the particle system
  105194. * @param directionToUpdate is the direction vector to update with the result
  105195. * @param particle is the particle we are computed the direction for
  105196. */
  105197. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105198. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  105199. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  105200. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  105201. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  105202. };
  105203. /**
  105204. * Clones the current emitter and returns a copy of it
  105205. * @returns the new emitter
  105206. */
  105207. CylinderDirectedParticleEmitter.prototype.clone = function () {
  105208. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  105209. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  105210. return newOne;
  105211. };
  105212. /**
  105213. * Called by the GPUParticleSystem to setup the update shader
  105214. * @param effect defines the update shader
  105215. */
  105216. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  105217. effect.setFloat("radius", this.radius);
  105218. effect.setFloat("height", this.height);
  105219. effect.setFloat("radiusRange", this.radiusRange);
  105220. effect.setVector3("direction1", this.direction1);
  105221. effect.setVector3("direction2", this.direction2);
  105222. };
  105223. /**
  105224. * Returns a string to use to update the GPU particles update shader
  105225. * @returns a string containng the defines string
  105226. */
  105227. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  105228. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  105229. };
  105230. /**
  105231. * Returns the string "CylinderDirectedParticleEmitter"
  105232. * @returns a string containing the class name
  105233. */
  105234. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  105235. return "CylinderDirectedParticleEmitter";
  105236. };
  105237. /**
  105238. * Serializes the particle system to a JSON object.
  105239. * @returns the JSON object
  105240. */
  105241. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  105242. var serializationObject = _super.prototype.serialize.call(this);
  105243. serializationObject.direction1 = this.direction1.asArray();
  105244. serializationObject.direction2 = this.direction2.asArray();
  105245. return serializationObject;
  105246. };
  105247. /**
  105248. * Parse properties from a JSON object
  105249. * @param serializationObject defines the JSON object
  105250. */
  105251. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  105252. _super.prototype.parse.call(this, serializationObject);
  105253. this.direction1.copyFrom(serializationObject.direction1);
  105254. this.direction2.copyFrom(serializationObject.direction2);
  105255. };
  105256. return CylinderDirectedParticleEmitter;
  105257. }(CylinderParticleEmitter));
  105258. /***/ }),
  105259. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  105260. /*!**************************************************************!*\
  105261. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  105262. \**************************************************************/
  105263. /*! exports provided: HemisphericParticleEmitter */
  105264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105265. "use strict";
  105266. __webpack_require__.r(__webpack_exports__);
  105267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  105268. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105269. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105270. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105271. /**
  105272. * Particle emitter emitting particles from the inside of a hemisphere.
  105273. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  105274. */
  105275. var HemisphericParticleEmitter = /** @class */ (function () {
  105276. /**
  105277. * Creates a new instance HemisphericParticleEmitter
  105278. * @param radius the radius of the emission hemisphere (1 by default)
  105279. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105280. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  105281. */
  105282. function HemisphericParticleEmitter(
  105283. /**
  105284. * The radius of the emission hemisphere.
  105285. */
  105286. radius,
  105287. /**
  105288. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  105289. */
  105290. radiusRange,
  105291. /**
  105292. * How much to randomize the particle direction [0-1].
  105293. */
  105294. directionRandomizer) {
  105295. if (radius === void 0) { radius = 1; }
  105296. if (radiusRange === void 0) { radiusRange = 1; }
  105297. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105298. this.radius = radius;
  105299. this.radiusRange = radiusRange;
  105300. this.directionRandomizer = directionRandomizer;
  105301. }
  105302. /**
  105303. * Called by the particle System when the direction is computed for the created particle.
  105304. * @param worldMatrix is the world matrix of the particle system
  105305. * @param directionToUpdate is the direction vector to update with the result
  105306. * @param particle is the particle we are computed the direction for
  105307. */
  105308. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105309. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  105310. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105311. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105312. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105313. direction.x += randX;
  105314. direction.y += randY;
  105315. direction.z += randZ;
  105316. direction.normalize();
  105317. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  105318. };
  105319. /**
  105320. * Called by the particle System when the position is computed for the created particle.
  105321. * @param worldMatrix is the world matrix of the particle system
  105322. * @param positionToUpdate is the position vector to update with the result
  105323. * @param particle is the particle we are computed the position for
  105324. */
  105325. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105326. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  105327. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  105328. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  105329. var theta = Math.acos(2 * v - 1);
  105330. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  105331. var randY = randRadius * Math.cos(theta);
  105332. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  105333. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  105334. };
  105335. /**
  105336. * Clones the current emitter and returns a copy of it
  105337. * @returns the new emitter
  105338. */
  105339. HemisphericParticleEmitter.prototype.clone = function () {
  105340. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  105341. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  105342. return newOne;
  105343. };
  105344. /**
  105345. * Called by the GPUParticleSystem to setup the update shader
  105346. * @param effect defines the update shader
  105347. */
  105348. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  105349. effect.setFloat("radius", this.radius);
  105350. effect.setFloat("radiusRange", this.radiusRange);
  105351. effect.setFloat("directionRandomizer", this.directionRandomizer);
  105352. };
  105353. /**
  105354. * Returns a string to use to update the GPU particles update shader
  105355. * @returns a string containng the defines string
  105356. */
  105357. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  105358. return "#define HEMISPHERICEMITTER";
  105359. };
  105360. /**
  105361. * Returns the string "HemisphericParticleEmitter"
  105362. * @returns a string containing the class name
  105363. */
  105364. HemisphericParticleEmitter.prototype.getClassName = function () {
  105365. return "HemisphericParticleEmitter";
  105366. };
  105367. /**
  105368. * Serializes the particle system to a JSON object.
  105369. * @returns the JSON object
  105370. */
  105371. HemisphericParticleEmitter.prototype.serialize = function () {
  105372. var serializationObject = {};
  105373. serializationObject.type = this.getClassName();
  105374. serializationObject.radius = this.radius;
  105375. serializationObject.radiusRange = this.radiusRange;
  105376. serializationObject.directionRandomizer = this.directionRandomizer;
  105377. return serializationObject;
  105378. };
  105379. /**
  105380. * Parse properties from a JSON object
  105381. * @param serializationObject defines the JSON object
  105382. */
  105383. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  105384. this.radius = serializationObject.radius;
  105385. this.radiusRange = serializationObject.radiusRange;
  105386. this.directionRandomizer = serializationObject.directionRandomizer;
  105387. };
  105388. return HemisphericParticleEmitter;
  105389. }());
  105390. /***/ }),
  105391. /***/ "./Particles/EmitterTypes/index.ts":
  105392. /*!*****************************************!*\
  105393. !*** ./Particles/EmitterTypes/index.ts ***!
  105394. \*****************************************/
  105395. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  105396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105397. "use strict";
  105398. __webpack_require__.r(__webpack_exports__);
  105399. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  105400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  105401. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  105402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  105403. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  105404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  105405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  105406. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  105407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  105408. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  105409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  105410. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  105411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  105412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  105413. /***/ }),
  105414. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  105415. /*!********************************************************!*\
  105416. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  105417. \********************************************************/
  105418. /*! exports provided: PointParticleEmitter */
  105419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105420. "use strict";
  105421. __webpack_require__.r(__webpack_exports__);
  105422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  105423. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105424. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105425. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105426. /**
  105427. * Particle emitter emitting particles from a point.
  105428. * It emits the particles randomly between 2 given directions.
  105429. */
  105430. var PointParticleEmitter = /** @class */ (function () {
  105431. /**
  105432. * Creates a new instance PointParticleEmitter
  105433. */
  105434. function PointParticleEmitter() {
  105435. /**
  105436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105437. */
  105438. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  105439. /**
  105440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105441. */
  105442. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  105443. }
  105444. /**
  105445. * Called by the particle System when the direction is computed for the created particle.
  105446. * @param worldMatrix is the world matrix of the particle system
  105447. * @param directionToUpdate is the direction vector to update with the result
  105448. * @param particle is the particle we are computed the direction for
  105449. */
  105450. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105451. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  105452. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  105453. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  105454. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  105455. };
  105456. /**
  105457. * Called by the particle System when the position is computed for the created particle.
  105458. * @param worldMatrix is the world matrix of the particle system
  105459. * @param positionToUpdate is the position vector to update with the result
  105460. * @param particle is the particle we are computed the position for
  105461. */
  105462. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105463. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  105464. };
  105465. /**
  105466. * Clones the current emitter and returns a copy of it
  105467. * @returns the new emitter
  105468. */
  105469. PointParticleEmitter.prototype.clone = function () {
  105470. var newOne = new PointParticleEmitter();
  105471. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  105472. return newOne;
  105473. };
  105474. /**
  105475. * Called by the GPUParticleSystem to setup the update shader
  105476. * @param effect defines the update shader
  105477. */
  105478. PointParticleEmitter.prototype.applyToShader = function (effect) {
  105479. effect.setVector3("direction1", this.direction1);
  105480. effect.setVector3("direction2", this.direction2);
  105481. };
  105482. /**
  105483. * Returns a string to use to update the GPU particles update shader
  105484. * @returns a string containng the defines string
  105485. */
  105486. PointParticleEmitter.prototype.getEffectDefines = function () {
  105487. return "#define POINTEMITTER";
  105488. };
  105489. /**
  105490. * Returns the string "PointParticleEmitter"
  105491. * @returns a string containing the class name
  105492. */
  105493. PointParticleEmitter.prototype.getClassName = function () {
  105494. return "PointParticleEmitter";
  105495. };
  105496. /**
  105497. * Serializes the particle system to a JSON object.
  105498. * @returns the JSON object
  105499. */
  105500. PointParticleEmitter.prototype.serialize = function () {
  105501. var serializationObject = {};
  105502. serializationObject.type = this.getClassName();
  105503. serializationObject.direction1 = this.direction1.asArray();
  105504. serializationObject.direction2 = this.direction2.asArray();
  105505. return serializationObject;
  105506. };
  105507. /**
  105508. * Parse properties from a JSON object
  105509. * @param serializationObject defines the JSON object
  105510. */
  105511. PointParticleEmitter.prototype.parse = function (serializationObject) {
  105512. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  105513. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  105514. };
  105515. return PointParticleEmitter;
  105516. }());
  105517. /***/ }),
  105518. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  105519. /*!*********************************************************!*\
  105520. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  105521. \*********************************************************/
  105522. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  105523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105524. "use strict";
  105525. __webpack_require__.r(__webpack_exports__);
  105526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  105527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  105528. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105529. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105530. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105531. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105532. /**
  105533. * Particle emitter emitting particles from the inside of a sphere.
  105534. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  105535. */
  105536. var SphereParticleEmitter = /** @class */ (function () {
  105537. /**
  105538. * Creates a new instance SphereParticleEmitter
  105539. * @param radius the radius of the emission sphere (1 by default)
  105540. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105541. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  105542. */
  105543. function SphereParticleEmitter(
  105544. /**
  105545. * The radius of the emission sphere.
  105546. */
  105547. radius,
  105548. /**
  105549. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  105550. */
  105551. radiusRange,
  105552. /**
  105553. * How much to randomize the particle direction [0-1].
  105554. */
  105555. directionRandomizer) {
  105556. if (radius === void 0) { radius = 1; }
  105557. if (radiusRange === void 0) { radiusRange = 1; }
  105558. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105559. this.radius = radius;
  105560. this.radiusRange = radiusRange;
  105561. this.directionRandomizer = directionRandomizer;
  105562. }
  105563. /**
  105564. * Called by the particle System when the direction is computed for the created particle.
  105565. * @param worldMatrix is the world matrix of the particle system
  105566. * @param directionToUpdate is the direction vector to update with the result
  105567. * @param particle is the particle we are computed the direction for
  105568. */
  105569. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105570. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  105571. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105572. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105573. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105574. direction.x += randX;
  105575. direction.y += randY;
  105576. direction.z += randZ;
  105577. direction.normalize();
  105578. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  105579. };
  105580. /**
  105581. * Called by the particle System when the position is computed for the created particle.
  105582. * @param worldMatrix is the world matrix of the particle system
  105583. * @param positionToUpdate is the position vector to update with the result
  105584. * @param particle is the particle we are computed the position for
  105585. */
  105586. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105587. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  105588. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  105589. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  105590. var theta = Math.acos(2 * v - 1);
  105591. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  105592. var randY = randRadius * Math.cos(theta);
  105593. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  105594. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  105595. };
  105596. /**
  105597. * Clones the current emitter and returns a copy of it
  105598. * @returns the new emitter
  105599. */
  105600. SphereParticleEmitter.prototype.clone = function () {
  105601. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  105602. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  105603. return newOne;
  105604. };
  105605. /**
  105606. * Called by the GPUParticleSystem to setup the update shader
  105607. * @param effect defines the update shader
  105608. */
  105609. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  105610. effect.setFloat("radius", this.radius);
  105611. effect.setFloat("radiusRange", this.radiusRange);
  105612. effect.setFloat("directionRandomizer", this.directionRandomizer);
  105613. };
  105614. /**
  105615. * Returns a string to use to update the GPU particles update shader
  105616. * @returns a string containng the defines string
  105617. */
  105618. SphereParticleEmitter.prototype.getEffectDefines = function () {
  105619. return "#define SPHEREEMITTER";
  105620. };
  105621. /**
  105622. * Returns the string "SphereParticleEmitter"
  105623. * @returns a string containing the class name
  105624. */
  105625. SphereParticleEmitter.prototype.getClassName = function () {
  105626. return "SphereParticleEmitter";
  105627. };
  105628. /**
  105629. * Serializes the particle system to a JSON object.
  105630. * @returns the JSON object
  105631. */
  105632. SphereParticleEmitter.prototype.serialize = function () {
  105633. var serializationObject = {};
  105634. serializationObject.type = this.getClassName();
  105635. serializationObject.radius = this.radius;
  105636. serializationObject.radiusRange = this.radiusRange;
  105637. serializationObject.directionRandomizer = this.directionRandomizer;
  105638. return serializationObject;
  105639. };
  105640. /**
  105641. * Parse properties from a JSON object
  105642. * @param serializationObject defines the JSON object
  105643. */
  105644. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  105645. this.radius = serializationObject.radius;
  105646. this.radiusRange = serializationObject.radiusRange;
  105647. this.directionRandomizer = serializationObject.directionRandomizer;
  105648. };
  105649. return SphereParticleEmitter;
  105650. }());
  105651. /**
  105652. * Particle emitter emitting particles from the inside of a sphere.
  105653. * It emits the particles randomly between two vectors.
  105654. */
  105655. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  105656. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  105657. /**
  105658. * Creates a new instance SphereDirectedParticleEmitter
  105659. * @param radius the radius of the emission sphere (1 by default)
  105660. * @param direction1 the min limit of the emission direction (up vector by default)
  105661. * @param direction2 the max limit of the emission direction (up vector by default)
  105662. */
  105663. function SphereDirectedParticleEmitter(radius,
  105664. /**
  105665. * The min limit of the emission direction.
  105666. */
  105667. direction1,
  105668. /**
  105669. * The max limit of the emission direction.
  105670. */
  105671. direction2) {
  105672. if (radius === void 0) { radius = 1; }
  105673. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  105674. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  105675. var _this = _super.call(this, radius) || this;
  105676. _this.direction1 = direction1;
  105677. _this.direction2 = direction2;
  105678. return _this;
  105679. }
  105680. /**
  105681. * Called by the particle System when the direction is computed for the created particle.
  105682. * @param worldMatrix is the world matrix of the particle system
  105683. * @param directionToUpdate is the direction vector to update with the result
  105684. * @param particle is the particle we are computed the direction for
  105685. */
  105686. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105687. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  105688. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  105689. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  105690. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  105691. };
  105692. /**
  105693. * Clones the current emitter and returns a copy of it
  105694. * @returns the new emitter
  105695. */
  105696. SphereDirectedParticleEmitter.prototype.clone = function () {
  105697. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  105698. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  105699. return newOne;
  105700. };
  105701. /**
  105702. * Called by the GPUParticleSystem to setup the update shader
  105703. * @param effect defines the update shader
  105704. */
  105705. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  105706. effect.setFloat("radius", this.radius);
  105707. effect.setFloat("radiusRange", this.radiusRange);
  105708. effect.setVector3("direction1", this.direction1);
  105709. effect.setVector3("direction2", this.direction2);
  105710. };
  105711. /**
  105712. * Returns a string to use to update the GPU particles update shader
  105713. * @returns a string containng the defines string
  105714. */
  105715. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  105716. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  105717. };
  105718. /**
  105719. * Returns the string "SphereDirectedParticleEmitter"
  105720. * @returns a string containing the class name
  105721. */
  105722. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  105723. return "SphereDirectedParticleEmitter";
  105724. };
  105725. /**
  105726. * Serializes the particle system to a JSON object.
  105727. * @returns the JSON object
  105728. */
  105729. SphereDirectedParticleEmitter.prototype.serialize = function () {
  105730. var serializationObject = _super.prototype.serialize.call(this);
  105731. serializationObject.direction1 = this.direction1.asArray();
  105732. serializationObject.direction2 = this.direction2.asArray();
  105733. return serializationObject;
  105734. };
  105735. /**
  105736. * Parse properties from a JSON object
  105737. * @param serializationObject defines the JSON object
  105738. */
  105739. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  105740. _super.prototype.parse.call(this, serializationObject);
  105741. this.direction1.copyFrom(serializationObject.direction1);
  105742. this.direction2.copyFrom(serializationObject.direction2);
  105743. };
  105744. return SphereDirectedParticleEmitter;
  105745. }(SphereParticleEmitter));
  105746. /***/ }),
  105747. /***/ "./Particles/baseParticleSystem.ts":
  105748. /*!*****************************************!*\
  105749. !*** ./Particles/baseParticleSystem.ts ***!
  105750. \*****************************************/
  105751. /*! exports provided: BaseParticleSystem */
  105752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105753. "use strict";
  105754. __webpack_require__.r(__webpack_exports__);
  105755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  105756. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105757. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  105758. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  105759. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105760. /**
  105761. * This represents the base class for particle system in Babylon.
  105762. * 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.
  105763. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  105764. * @example https://doc.babylonjs.com/babylon101/particles
  105765. */
  105766. var BaseParticleSystem = /** @class */ (function () {
  105767. /**
  105768. * Instantiates a particle system.
  105769. * 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.
  105770. * @param name The name of the particle system
  105771. */
  105772. function BaseParticleSystem(name) {
  105773. /**
  105774. * List of animations used by the particle system.
  105775. */
  105776. this.animations = [];
  105777. /**
  105778. * The rendering group used by the Particle system to chose when to render.
  105779. */
  105780. this.renderingGroupId = 0;
  105781. /**
  105782. * The emitter represents the Mesh or position we are attaching the particle system to.
  105783. */
  105784. this.emitter = null;
  105785. /**
  105786. * The maximum number of particles to emit per frame
  105787. */
  105788. this.emitRate = 10;
  105789. /**
  105790. * If you want to launch only a few particles at once, that can be done, as well.
  105791. */
  105792. this.manualEmitCount = -1;
  105793. /**
  105794. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  105795. */
  105796. this.updateSpeed = 0.01;
  105797. /**
  105798. * The amount of time the particle system is running (depends of the overall update speed).
  105799. */
  105800. this.targetStopDuration = 0;
  105801. /**
  105802. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  105803. */
  105804. this.disposeOnStop = false;
  105805. /**
  105806. * Minimum power of emitting particles.
  105807. */
  105808. this.minEmitPower = 1;
  105809. /**
  105810. * Maximum power of emitting particles.
  105811. */
  105812. this.maxEmitPower = 1;
  105813. /**
  105814. * Minimum life time of emitting particles.
  105815. */
  105816. this.minLifeTime = 1;
  105817. /**
  105818. * Maximum life time of emitting particles.
  105819. */
  105820. this.maxLifeTime = 1;
  105821. /**
  105822. * Minimum Size of emitting particles.
  105823. */
  105824. this.minSize = 1;
  105825. /**
  105826. * Maximum Size of emitting particles.
  105827. */
  105828. this.maxSize = 1;
  105829. /**
  105830. * Minimum scale of emitting particles on X axis.
  105831. */
  105832. this.minScaleX = 1;
  105833. /**
  105834. * Maximum scale of emitting particles on X axis.
  105835. */
  105836. this.maxScaleX = 1;
  105837. /**
  105838. * Minimum scale of emitting particles on Y axis.
  105839. */
  105840. this.minScaleY = 1;
  105841. /**
  105842. * Maximum scale of emitting particles on Y axis.
  105843. */
  105844. this.maxScaleY = 1;
  105845. /**
  105846. * Gets or sets the minimal initial rotation in radians.
  105847. */
  105848. this.minInitialRotation = 0;
  105849. /**
  105850. * Gets or sets the maximal initial rotation in radians.
  105851. */
  105852. this.maxInitialRotation = 0;
  105853. /**
  105854. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  105855. */
  105856. this.minAngularSpeed = 0;
  105857. /**
  105858. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  105859. */
  105860. this.maxAngularSpeed = 0;
  105861. /**
  105862. * The layer mask we are rendering the particles through.
  105863. */
  105864. this.layerMask = 0x0FFFFFFF;
  105865. /**
  105866. * This can help using your own shader to render the particle system.
  105867. * The according effect will be created
  105868. */
  105869. this.customShader = null;
  105870. /**
  105871. * By default particle system starts as soon as they are created. This prevents the
  105872. * automatic start to happen and let you decide when to start emitting particles.
  105873. */
  105874. this.preventAutoStart = false;
  105875. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  105876. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  105877. /**
  105878. * Callback triggered when the particle animation is ending.
  105879. */
  105880. this.onAnimationEnd = null;
  105881. /**
  105882. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  105883. */
  105884. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  105885. /**
  105886. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  105887. * to override the particles.
  105888. */
  105889. this.forceDepthWrite = false;
  105890. /** 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 */
  105891. this.preWarmCycles = 0;
  105892. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  105893. this.preWarmStepOffset = 1;
  105894. /**
  105895. * 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)
  105896. */
  105897. this.spriteCellChangeSpeed = 1;
  105898. /**
  105899. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  105900. */
  105901. this.startSpriteCellID = 0;
  105902. /**
  105903. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  105904. */
  105905. this.endSpriteCellID = 0;
  105906. /**
  105907. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  105908. */
  105909. this.spriteCellWidth = 0;
  105910. /**
  105911. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  105912. */
  105913. this.spriteCellHeight = 0;
  105914. /**
  105915. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  105916. */
  105917. this.spriteRandomStartCell = false;
  105918. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  105919. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  105920. /**
  105921. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  105922. */
  105923. this.beginAnimationOnStart = false;
  105924. /**
  105925. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  105926. */
  105927. this.beginAnimationFrom = 0;
  105928. /**
  105929. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  105930. */
  105931. this.beginAnimationTo = 60;
  105932. /**
  105933. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  105934. */
  105935. this.beginAnimationLoop = false;
  105936. /**
  105937. * Gets or sets a world offset applied to all particles
  105938. */
  105939. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  105940. /**
  105941. * You can use gravity if you want to give an orientation to your particles.
  105942. */
  105943. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105944. this._colorGradients = null;
  105945. this._sizeGradients = null;
  105946. this._lifeTimeGradients = null;
  105947. this._angularSpeedGradients = null;
  105948. this._velocityGradients = null;
  105949. this._limitVelocityGradients = null;
  105950. this._dragGradients = null;
  105951. this._emitRateGradients = null;
  105952. this._startSizeGradients = null;
  105953. this._rampGradients = null;
  105954. this._colorRemapGradients = null;
  105955. this._alphaRemapGradients = null;
  105956. /**
  105957. * Defines the delay in milliseconds before starting the system (0 by default)
  105958. */
  105959. this.startDelay = 0;
  105960. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  105961. this.limitVelocityDamping = 0.4;
  105962. /**
  105963. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  105964. */
  105965. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  105966. /**
  105967. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  105968. */
  105969. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  105970. /**
  105971. * Color the particle will have at the end of its lifetime
  105972. */
  105973. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  105974. /**
  105975. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  105976. */
  105977. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  105978. /** @hidden */
  105979. this._isSubEmitter = false;
  105980. /**
  105981. * Gets or sets the billboard mode to use when isBillboardBased = true.
  105982. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  105983. */
  105984. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  105985. this._isBillboardBased = true;
  105986. /**
  105987. * Local cache of defines for image processing.
  105988. */
  105989. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  105990. this.id = name;
  105991. this.name = name;
  105992. }
  105993. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  105994. /**
  105995. * Gets or sets a texture used to add random noise to particle positions
  105996. */
  105997. get: function () {
  105998. return this._noiseTexture;
  105999. },
  106000. set: function (value) {
  106001. if (this._noiseTexture === value) {
  106002. return;
  106003. }
  106004. this._noiseTexture = value;
  106005. this._reset();
  106006. },
  106007. enumerable: true,
  106008. configurable: true
  106009. });
  106010. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  106011. /**
  106012. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  106013. */
  106014. get: function () {
  106015. return this._isAnimationSheetEnabled;
  106016. },
  106017. set: function (value) {
  106018. if (this._isAnimationSheetEnabled == value) {
  106019. return;
  106020. }
  106021. this._isAnimationSheetEnabled = value;
  106022. this._reset();
  106023. },
  106024. enumerable: true,
  106025. configurable: true
  106026. });
  106027. /**
  106028. * Get hosting scene
  106029. * @returns the scene
  106030. */
  106031. BaseParticleSystem.prototype.getScene = function () {
  106032. return this._scene;
  106033. };
  106034. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  106035. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  106036. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  106037. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  106038. };
  106039. /**
  106040. * Gets the current list of drag gradients.
  106041. * You must use addDragGradient and removeDragGradient to udpate this list
  106042. * @returns the list of drag gradients
  106043. */
  106044. BaseParticleSystem.prototype.getDragGradients = function () {
  106045. return this._dragGradients;
  106046. };
  106047. /**
  106048. * Gets the current list of limit velocity gradients.
  106049. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  106050. * @returns the list of limit velocity gradients
  106051. */
  106052. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  106053. return this._limitVelocityGradients;
  106054. };
  106055. /**
  106056. * Gets the current list of color gradients.
  106057. * You must use addColorGradient and removeColorGradient to udpate this list
  106058. * @returns the list of color gradients
  106059. */
  106060. BaseParticleSystem.prototype.getColorGradients = function () {
  106061. return this._colorGradients;
  106062. };
  106063. /**
  106064. * Gets the current list of size gradients.
  106065. * You must use addSizeGradient and removeSizeGradient to udpate this list
  106066. * @returns the list of size gradients
  106067. */
  106068. BaseParticleSystem.prototype.getSizeGradients = function () {
  106069. return this._sizeGradients;
  106070. };
  106071. /**
  106072. * Gets the current list of color remap gradients.
  106073. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  106074. * @returns the list of color remap gradients
  106075. */
  106076. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  106077. return this._colorRemapGradients;
  106078. };
  106079. /**
  106080. * Gets the current list of alpha remap gradients.
  106081. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  106082. * @returns the list of alpha remap gradients
  106083. */
  106084. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  106085. return this._alphaRemapGradients;
  106086. };
  106087. /**
  106088. * Gets the current list of life time gradients.
  106089. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  106090. * @returns the list of life time gradients
  106091. */
  106092. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  106093. return this._lifeTimeGradients;
  106094. };
  106095. /**
  106096. * Gets the current list of angular speed gradients.
  106097. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  106098. * @returns the list of angular speed gradients
  106099. */
  106100. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  106101. return this._angularSpeedGradients;
  106102. };
  106103. /**
  106104. * Gets the current list of velocity gradients.
  106105. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  106106. * @returns the list of velocity gradients
  106107. */
  106108. BaseParticleSystem.prototype.getVelocityGradients = function () {
  106109. return this._velocityGradients;
  106110. };
  106111. /**
  106112. * Gets the current list of start size gradients.
  106113. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  106114. * @returns the list of start size gradients
  106115. */
  106116. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  106117. return this._startSizeGradients;
  106118. };
  106119. /**
  106120. * Gets the current list of emit rate gradients.
  106121. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  106122. * @returns the list of emit rate gradients
  106123. */
  106124. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  106125. return this._emitRateGradients;
  106126. };
  106127. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  106128. /**
  106129. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106130. * This only works when particleEmitterTyps is a BoxParticleEmitter
  106131. */
  106132. get: function () {
  106133. if (this.particleEmitterType.direction1) {
  106134. return this.particleEmitterType.direction1;
  106135. }
  106136. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106137. },
  106138. set: function (value) {
  106139. if (this.particleEmitterType.direction1) {
  106140. this.particleEmitterType.direction1 = value;
  106141. }
  106142. },
  106143. enumerable: true,
  106144. configurable: true
  106145. });
  106146. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  106147. /**
  106148. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106149. * This only works when particleEmitterTyps is a BoxParticleEmitter
  106150. */
  106151. get: function () {
  106152. if (this.particleEmitterType.direction2) {
  106153. return this.particleEmitterType.direction2;
  106154. }
  106155. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106156. },
  106157. set: function (value) {
  106158. if (this.particleEmitterType.direction2) {
  106159. this.particleEmitterType.direction2 = value;
  106160. }
  106161. },
  106162. enumerable: true,
  106163. configurable: true
  106164. });
  106165. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  106166. /**
  106167. * 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.
  106168. * This only works when particleEmitterTyps is a BoxParticleEmitter
  106169. */
  106170. get: function () {
  106171. if (this.particleEmitterType.minEmitBox) {
  106172. return this.particleEmitterType.minEmitBox;
  106173. }
  106174. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106175. },
  106176. set: function (value) {
  106177. if (this.particleEmitterType.minEmitBox) {
  106178. this.particleEmitterType.minEmitBox = value;
  106179. }
  106180. },
  106181. enumerable: true,
  106182. configurable: true
  106183. });
  106184. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  106185. /**
  106186. * 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.
  106187. * This only works when particleEmitterTyps is a BoxParticleEmitter
  106188. */
  106189. get: function () {
  106190. if (this.particleEmitterType.maxEmitBox) {
  106191. return this.particleEmitterType.maxEmitBox;
  106192. }
  106193. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106194. },
  106195. set: function (value) {
  106196. if (this.particleEmitterType.maxEmitBox) {
  106197. this.particleEmitterType.maxEmitBox = value;
  106198. }
  106199. },
  106200. enumerable: true,
  106201. configurable: true
  106202. });
  106203. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  106204. /**
  106205. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  106206. */
  106207. get: function () {
  106208. return this._isBillboardBased;
  106209. },
  106210. set: function (value) {
  106211. if (this._isBillboardBased === value) {
  106212. return;
  106213. }
  106214. this._isBillboardBased = value;
  106215. this._reset();
  106216. },
  106217. enumerable: true,
  106218. configurable: true
  106219. });
  106220. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  106221. /**
  106222. * Gets the image processing configuration used either in this material.
  106223. */
  106224. get: function () {
  106225. return this._imageProcessingConfiguration;
  106226. },
  106227. /**
  106228. * Sets the Default image processing configuration used either in the this material.
  106229. *
  106230. * If sets to null, the scene one is in use.
  106231. */
  106232. set: function (value) {
  106233. this._attachImageProcessingConfiguration(value);
  106234. },
  106235. enumerable: true,
  106236. configurable: true
  106237. });
  106238. /**
  106239. * Attaches a new image processing configuration to the Standard Material.
  106240. * @param configuration
  106241. */
  106242. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  106243. if (configuration === this._imageProcessingConfiguration) {
  106244. return;
  106245. }
  106246. // Pick the scene configuration if needed.
  106247. if (!configuration) {
  106248. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  106249. }
  106250. else {
  106251. this._imageProcessingConfiguration = configuration;
  106252. }
  106253. };
  106254. /** @hidden */
  106255. BaseParticleSystem.prototype._reset = function () {
  106256. };
  106257. /** @hidden */
  106258. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  106259. if (!gradients) {
  106260. return this;
  106261. }
  106262. var index = 0;
  106263. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  106264. var valueGradient = gradients_1[_i];
  106265. if (valueGradient.gradient === gradient) {
  106266. gradients.splice(index, 1);
  106267. break;
  106268. }
  106269. index++;
  106270. }
  106271. if (texture) {
  106272. texture.dispose();
  106273. }
  106274. return this;
  106275. };
  106276. /**
  106277. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  106278. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  106279. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  106280. * @returns the emitter
  106281. */
  106282. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  106283. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  106284. particleEmitter.direction1 = direction1;
  106285. particleEmitter.direction2 = direction2;
  106286. this.particleEmitterType = particleEmitter;
  106287. return particleEmitter;
  106288. };
  106289. /**
  106290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  106291. * @param radius The radius of the hemisphere to emit from
  106292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  106293. * @returns the emitter
  106294. */
  106295. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  106296. if (radius === void 0) { radius = 1; }
  106297. if (radiusRange === void 0) { radiusRange = 1; }
  106298. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  106299. this.particleEmitterType = particleEmitter;
  106300. return particleEmitter;
  106301. };
  106302. /**
  106303. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  106304. * @param radius The radius of the sphere to emit from
  106305. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  106306. * @returns the emitter
  106307. */
  106308. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  106309. if (radius === void 0) { radius = 1; }
  106310. if (radiusRange === void 0) { radiusRange = 1; }
  106311. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  106312. this.particleEmitterType = particleEmitter;
  106313. return particleEmitter;
  106314. };
  106315. /**
  106316. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  106317. * @param radius The radius of the sphere to emit from
  106318. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  106319. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  106320. * @returns the emitter
  106321. */
  106322. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  106323. if (radius === void 0) { radius = 1; }
  106324. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  106325. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  106326. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  106327. this.particleEmitterType = particleEmitter;
  106328. return particleEmitter;
  106329. };
  106330. /**
  106331. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  106332. * @param radius The radius of the emission cylinder
  106333. * @param height The height of the emission cylinder
  106334. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  106335. * @param directionRandomizer How much to randomize the particle direction [0-1]
  106336. * @returns the emitter
  106337. */
  106338. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  106339. if (radius === void 0) { radius = 1; }
  106340. if (height === void 0) { height = 1; }
  106341. if (radiusRange === void 0) { radiusRange = 1; }
  106342. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106343. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  106344. this.particleEmitterType = particleEmitter;
  106345. return particleEmitter;
  106346. };
  106347. /**
  106348. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  106349. * @param radius The radius of the cylinder to emit from
  106350. * @param height The height of the emission cylinder
  106351. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106352. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  106353. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  106354. * @returns the emitter
  106355. */
  106356. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  106357. if (radius === void 0) { radius = 1; }
  106358. if (height === void 0) { height = 1; }
  106359. if (radiusRange === void 0) { radiusRange = 1; }
  106360. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  106361. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  106362. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  106363. this.particleEmitterType = particleEmitter;
  106364. return particleEmitter;
  106365. };
  106366. /**
  106367. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  106368. * @param radius The radius of the cone to emit from
  106369. * @param angle The base angle of the cone
  106370. * @returns the emitter
  106371. */
  106372. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  106373. if (radius === void 0) { radius = 1; }
  106374. if (angle === void 0) { angle = Math.PI / 4; }
  106375. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  106376. this.particleEmitterType = particleEmitter;
  106377. return particleEmitter;
  106378. };
  106379. /**
  106380. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  106381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  106382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  106383. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  106384. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  106385. * @returns the emitter
  106386. */
  106387. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  106388. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  106389. this.particleEmitterType = particleEmitter;
  106390. this.direction1 = direction1;
  106391. this.direction2 = direction2;
  106392. this.minEmitBox = minEmitBox;
  106393. this.maxEmitBox = maxEmitBox;
  106394. return particleEmitter;
  106395. };
  106396. /**
  106397. * Source color is added to the destination color without alpha affecting the result
  106398. */
  106399. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  106400. /**
  106401. * Blend current color and particle color using particle’s alpha
  106402. */
  106403. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  106404. /**
  106405. * Add current color and particle color multiplied by particle’s alpha
  106406. */
  106407. BaseParticleSystem.BLENDMODE_ADD = 2;
  106408. /**
  106409. * Multiply current color with particle color
  106410. */
  106411. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  106412. /**
  106413. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  106414. */
  106415. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  106416. return BaseParticleSystem;
  106417. }());
  106418. /***/ }),
  106419. /***/ "./Particles/gpuParticleSystem.ts":
  106420. /*!****************************************!*\
  106421. !*** ./Particles/gpuParticleSystem.ts ***!
  106422. \****************************************/
  106423. /*! exports provided: GPUParticleSystem */
  106424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106425. "use strict";
  106426. __webpack_require__.r(__webpack_exports__);
  106427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  106428. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  106429. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  106430. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  106431. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106432. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106433. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  106434. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  106435. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  106436. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  106437. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  106438. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  106439. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  106440. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  106441. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  106442. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  106443. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106444. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106445. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106446. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  106447. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  106448. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  106449. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  106450. /**
  106451. * This represents a GPU particle system in Babylon
  106452. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106453. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106454. */
  106455. var GPUParticleSystem = /** @class */ (function (_super) {
  106456. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  106457. /**
  106458. * Instantiates a GPU particle system.
  106459. * 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.
  106460. * @param name The name of the particle system
  106461. * @param options The options used to create the system
  106462. * @param scene The scene the particle system belongs to
  106463. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106464. */
  106465. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  106466. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106467. var _this = _super.call(this, name) || this;
  106468. /**
  106469. * The layer mask we are rendering the particles through.
  106470. */
  106471. _this.layerMask = 0x0FFFFFFF;
  106472. _this._accumulatedCount = 0;
  106473. _this._targetIndex = 0;
  106474. _this._currentRenderId = -1;
  106475. _this._started = false;
  106476. _this._stopped = false;
  106477. _this._timeDelta = 0;
  106478. _this._actualFrame = 0;
  106479. _this._rawTextureWidth = 256;
  106480. /**
  106481. * An event triggered when the system is disposed.
  106482. */
  106483. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  106484. /**
  106485. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106486. * to override the particles.
  106487. */
  106488. _this.forceDepthWrite = false;
  106489. _this._preWarmDone = false;
  106490. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  106491. // Setup the default processing configuration to the scene.
  106492. _this._attachImageProcessingConfiguration(null);
  106493. _this._engine = _this._scene.getEngine();
  106494. if (!options.randomTextureSize) {
  106495. delete options.randomTextureSize;
  106496. }
  106497. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  106498. var optionsAsNumber = options;
  106499. if (isFinite(optionsAsNumber)) {
  106500. fullOptions.capacity = optionsAsNumber;
  106501. }
  106502. _this._capacity = fullOptions.capacity;
  106503. _this._activeCount = fullOptions.capacity;
  106504. _this._currentActiveCount = 0;
  106505. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  106506. _this._scene.particleSystems.push(_this);
  106507. _this._updateEffectOptions = {
  106508. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  106509. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  106510. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  106511. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  106512. uniformBuffersNames: [],
  106513. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  106514. defines: "",
  106515. fallbacks: null,
  106516. onCompiled: null,
  106517. onError: null,
  106518. indexParameters: null,
  106519. maxSimultaneousLights: 0,
  106520. transformFeedbackVaryings: []
  106521. };
  106522. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  106523. // Random data
  106524. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  106525. var d = [];
  106526. for (var i = 0; i < maxTextureSize; ++i) {
  106527. d.push(Math.random());
  106528. d.push(Math.random());
  106529. d.push(Math.random());
  106530. d.push(Math.random());
  106531. }
  106532. _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);
  106533. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  106534. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  106535. d = [];
  106536. for (var i = 0; i < maxTextureSize; ++i) {
  106537. d.push(Math.random());
  106538. d.push(Math.random());
  106539. d.push(Math.random());
  106540. d.push(Math.random());
  106541. }
  106542. _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);
  106543. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  106544. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  106545. _this._randomTextureSize = maxTextureSize;
  106546. return _this;
  106547. }
  106548. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  106549. /**
  106550. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106551. */
  106552. get: function () {
  106553. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  106554. return false;
  106555. }
  106556. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  106557. },
  106558. enumerable: true,
  106559. configurable: true
  106560. });
  106561. /**
  106562. * Gets the maximum number of particles active at the same time.
  106563. * @returns The max number of active particles.
  106564. */
  106565. GPUParticleSystem.prototype.getCapacity = function () {
  106566. return this._capacity;
  106567. };
  106568. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  106569. /**
  106570. * Gets or set the number of active particles
  106571. */
  106572. get: function () {
  106573. return this._activeCount;
  106574. },
  106575. set: function (value) {
  106576. this._activeCount = Math.min(value, this._capacity);
  106577. },
  106578. enumerable: true,
  106579. configurable: true
  106580. });
  106581. /**
  106582. * Is this system ready to be used/rendered
  106583. * @return true if the system is ready
  106584. */
  106585. GPUParticleSystem.prototype.isReady = function () {
  106586. if (!this._updateEffect) {
  106587. this._recreateUpdateEffect();
  106588. this._recreateRenderEffect();
  106589. return false;
  106590. }
  106591. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  106592. return false;
  106593. }
  106594. return true;
  106595. };
  106596. /**
  106597. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106598. * @returns True if it has been started, otherwise false.
  106599. */
  106600. GPUParticleSystem.prototype.isStarted = function () {
  106601. return this._started;
  106602. };
  106603. /**
  106604. * Starts the particle system and begins to emit
  106605. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106606. */
  106607. GPUParticleSystem.prototype.start = function (delay) {
  106608. var _this = this;
  106609. if (delay === void 0) { delay = this.startDelay; }
  106610. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  106611. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  106612. }
  106613. if (delay) {
  106614. setTimeout(function () {
  106615. _this.start(0);
  106616. }, delay);
  106617. return;
  106618. }
  106619. this._started = true;
  106620. this._stopped = false;
  106621. this._preWarmDone = false;
  106622. // Animations
  106623. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  106624. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  106625. }
  106626. };
  106627. /**
  106628. * Stops the particle system.
  106629. */
  106630. GPUParticleSystem.prototype.stop = function () {
  106631. this._stopped = true;
  106632. };
  106633. /**
  106634. * Remove all active particles
  106635. */
  106636. GPUParticleSystem.prototype.reset = function () {
  106637. this._releaseBuffers();
  106638. this._releaseVAOs();
  106639. this._currentActiveCount = 0;
  106640. this._targetIndex = 0;
  106641. };
  106642. /**
  106643. * Returns the string "GPUParticleSystem"
  106644. * @returns a string containing the class name
  106645. */
  106646. GPUParticleSystem.prototype.getClassName = function () {
  106647. return "GPUParticleSystem";
  106648. };
  106649. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  106650. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  106651. this._releaseBuffers();
  106652. return this;
  106653. };
  106654. /**
  106655. * Adds a new color gradient
  106656. * @param gradient defines the gradient to use (between 0 and 1)
  106657. * @param color1 defines the color to affect to the specified gradient
  106658. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106659. * @returns the current particle system
  106660. */
  106661. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  106662. if (!this._colorGradients) {
  106663. this._colorGradients = [];
  106664. }
  106665. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  106666. colorGradient.gradient = gradient;
  106667. colorGradient.color1 = color1;
  106668. this._colorGradients.push(colorGradient);
  106669. this._colorGradients.sort(function (a, b) {
  106670. if (a.gradient < b.gradient) {
  106671. return -1;
  106672. }
  106673. else if (a.gradient > b.gradient) {
  106674. return 1;
  106675. }
  106676. return 0;
  106677. });
  106678. if (this._colorGradientsTexture) {
  106679. this._colorGradientsTexture.dispose();
  106680. this._colorGradientsTexture = null;
  106681. }
  106682. this._releaseBuffers();
  106683. return this;
  106684. };
  106685. /**
  106686. * Remove a specific color gradient
  106687. * @param gradient defines the gradient to remove
  106688. * @returns the current particle system
  106689. */
  106690. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  106691. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  106692. this._colorGradientsTexture = null;
  106693. return this;
  106694. };
  106695. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  106696. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  106697. valueGradient.gradient = gradient;
  106698. valueGradient.factor1 = factor;
  106699. factorGradients.push(valueGradient);
  106700. factorGradients.sort(function (a, b) {
  106701. if (a.gradient < b.gradient) {
  106702. return -1;
  106703. }
  106704. else if (a.gradient > b.gradient) {
  106705. return 1;
  106706. }
  106707. return 0;
  106708. });
  106709. this._releaseBuffers();
  106710. };
  106711. /**
  106712. * Adds a new size gradient
  106713. * @param gradient defines the gradient to use (between 0 and 1)
  106714. * @param factor defines the size factor to affect to the specified gradient
  106715. * @returns the current particle system
  106716. */
  106717. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  106718. if (!this._sizeGradients) {
  106719. this._sizeGradients = [];
  106720. }
  106721. this._addFactorGradient(this._sizeGradients, gradient, factor);
  106722. if (this._sizeGradientsTexture) {
  106723. this._sizeGradientsTexture.dispose();
  106724. this._sizeGradientsTexture = null;
  106725. }
  106726. this._releaseBuffers();
  106727. return this;
  106728. };
  106729. /**
  106730. * Remove a specific size gradient
  106731. * @param gradient defines the gradient to remove
  106732. * @returns the current particle system
  106733. */
  106734. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  106735. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  106736. this._sizeGradientsTexture = null;
  106737. return this;
  106738. };
  106739. /**
  106740. * Adds a new angular speed gradient
  106741. * @param gradient defines the gradient to use (between 0 and 1)
  106742. * @param factor defines the angular speed to affect to the specified gradient
  106743. * @returns the current particle system
  106744. */
  106745. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  106746. if (!this._angularSpeedGradients) {
  106747. this._angularSpeedGradients = [];
  106748. }
  106749. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  106750. if (this._angularSpeedGradientsTexture) {
  106751. this._angularSpeedGradientsTexture.dispose();
  106752. this._angularSpeedGradientsTexture = null;
  106753. }
  106754. this._releaseBuffers();
  106755. return this;
  106756. };
  106757. /**
  106758. * Remove a specific angular speed gradient
  106759. * @param gradient defines the gradient to remove
  106760. * @returns the current particle system
  106761. */
  106762. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  106763. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  106764. this._angularSpeedGradientsTexture = null;
  106765. return this;
  106766. };
  106767. /**
  106768. * Adds a new velocity gradient
  106769. * @param gradient defines the gradient to use (between 0 and 1)
  106770. * @param factor defines the velocity to affect to the specified gradient
  106771. * @returns the current particle system
  106772. */
  106773. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  106774. if (!this._velocityGradients) {
  106775. this._velocityGradients = [];
  106776. }
  106777. this._addFactorGradient(this._velocityGradients, gradient, factor);
  106778. if (this._velocityGradientsTexture) {
  106779. this._velocityGradientsTexture.dispose();
  106780. this._velocityGradientsTexture = null;
  106781. }
  106782. this._releaseBuffers();
  106783. return this;
  106784. };
  106785. /**
  106786. * Remove a specific velocity gradient
  106787. * @param gradient defines the gradient to remove
  106788. * @returns the current particle system
  106789. */
  106790. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  106791. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  106792. this._velocityGradientsTexture = null;
  106793. return this;
  106794. };
  106795. /**
  106796. * Adds a new limit velocity gradient
  106797. * @param gradient defines the gradient to use (between 0 and 1)
  106798. * @param factor defines the limit velocity value to affect to the specified gradient
  106799. * @returns the current particle system
  106800. */
  106801. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  106802. if (!this._limitVelocityGradients) {
  106803. this._limitVelocityGradients = [];
  106804. }
  106805. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  106806. if (this._limitVelocityGradientsTexture) {
  106807. this._limitVelocityGradientsTexture.dispose();
  106808. this._limitVelocityGradientsTexture = null;
  106809. }
  106810. this._releaseBuffers();
  106811. return this;
  106812. };
  106813. /**
  106814. * Remove a specific limit velocity gradient
  106815. * @param gradient defines the gradient to remove
  106816. * @returns the current particle system
  106817. */
  106818. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  106819. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  106820. this._limitVelocityGradientsTexture = null;
  106821. return this;
  106822. };
  106823. /**
  106824. * Adds a new drag gradient
  106825. * @param gradient defines the gradient to use (between 0 and 1)
  106826. * @param factor defines the drag value to affect to the specified gradient
  106827. * @returns the current particle system
  106828. */
  106829. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  106830. if (!this._dragGradients) {
  106831. this._dragGradients = [];
  106832. }
  106833. this._addFactorGradient(this._dragGradients, gradient, factor);
  106834. if (this._dragGradientsTexture) {
  106835. this._dragGradientsTexture.dispose();
  106836. this._dragGradientsTexture = null;
  106837. }
  106838. this._releaseBuffers();
  106839. return this;
  106840. };
  106841. /**
  106842. * Remove a specific drag gradient
  106843. * @param gradient defines the gradient to remove
  106844. * @returns the current particle system
  106845. */
  106846. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  106847. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  106848. this._dragGradientsTexture = null;
  106849. return this;
  106850. };
  106851. /**
  106852. * Not supported by GPUParticleSystem
  106853. * @param gradient defines the gradient to use (between 0 and 1)
  106854. * @param factor defines the emit rate value to affect to the specified gradient
  106855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106856. * @returns the current particle system
  106857. */
  106858. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  106859. // Do nothing as emit rate is not supported by GPUParticleSystem
  106860. return this;
  106861. };
  106862. /**
  106863. * Not supported by GPUParticleSystem
  106864. * @param gradient defines the gradient to remove
  106865. * @returns the current particle system
  106866. */
  106867. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  106868. // Do nothing as emit rate is not supported by GPUParticleSystem
  106869. return this;
  106870. };
  106871. /**
  106872. * Not supported by GPUParticleSystem
  106873. * @param gradient defines the gradient to use (between 0 and 1)
  106874. * @param factor defines the start size value to affect to the specified gradient
  106875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106876. * @returns the current particle system
  106877. */
  106878. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  106879. // Do nothing as start size is not supported by GPUParticleSystem
  106880. return this;
  106881. };
  106882. /**
  106883. * Not supported by GPUParticleSystem
  106884. * @param gradient defines the gradient to remove
  106885. * @returns the current particle system
  106886. */
  106887. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  106888. // Do nothing as start size is not supported by GPUParticleSystem
  106889. return this;
  106890. };
  106891. /**
  106892. * Not supported by GPUParticleSystem
  106893. * @param gradient defines the gradient to use (between 0 and 1)
  106894. * @param min defines the color remap minimal range
  106895. * @param max defines the color remap maximal range
  106896. * @returns the current particle system
  106897. */
  106898. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  106899. // Do nothing as start size is not supported by GPUParticleSystem
  106900. return this;
  106901. };
  106902. /**
  106903. * Not supported by GPUParticleSystem
  106904. * @param gradient defines the gradient to remove
  106905. * @returns the current particle system
  106906. */
  106907. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  106908. // Do nothing as start size is not supported by GPUParticleSystem
  106909. return this;
  106910. };
  106911. /**
  106912. * Not supported by GPUParticleSystem
  106913. * @param gradient defines the gradient to use (between 0 and 1)
  106914. * @param min defines the alpha remap minimal range
  106915. * @param max defines the alpha remap maximal range
  106916. * @returns the current particle system
  106917. */
  106918. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  106919. // Do nothing as start size is not supported by GPUParticleSystem
  106920. return this;
  106921. };
  106922. /**
  106923. * Not supported by GPUParticleSystem
  106924. * @param gradient defines the gradient to remove
  106925. * @returns the current particle system
  106926. */
  106927. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  106928. // Do nothing as start size is not supported by GPUParticleSystem
  106929. return this;
  106930. };
  106931. /**
  106932. * Not supported by GPUParticleSystem
  106933. * @param gradient defines the gradient to use (between 0 and 1)
  106934. * @param color defines the color to affect to the specified gradient
  106935. * @returns the current particle system
  106936. */
  106937. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  106938. //Not supported by GPUParticleSystem
  106939. return this;
  106940. };
  106941. /**
  106942. * Not supported by GPUParticleSystem
  106943. * @param gradient defines the gradient to remove
  106944. * @returns the current particle system
  106945. */
  106946. GPUParticleSystem.prototype.removeRampGradient = function () {
  106947. //Not supported by GPUParticleSystem
  106948. return this;
  106949. };
  106950. /**
  106951. * Not supported by GPUParticleSystem
  106952. * @returns the list of ramp gradients
  106953. */
  106954. GPUParticleSystem.prototype.getRampGradients = function () {
  106955. return null;
  106956. };
  106957. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  106958. /**
  106959. * Not supported by GPUParticleSystem
  106960. * Gets or sets a boolean indicating that ramp gradients must be used
  106961. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106962. */
  106963. get: function () {
  106964. //Not supported by GPUParticleSystem
  106965. return false;
  106966. },
  106967. set: function (value) {
  106968. //Not supported by GPUParticleSystem
  106969. },
  106970. enumerable: true,
  106971. configurable: true
  106972. });
  106973. /**
  106974. * Not supported by GPUParticleSystem
  106975. * @param gradient defines the gradient to use (between 0 and 1)
  106976. * @param factor defines the life time factor to affect to the specified gradient
  106977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106978. * @returns the current particle system
  106979. */
  106980. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  106981. //Not supported by GPUParticleSystem
  106982. return this;
  106983. };
  106984. /**
  106985. * Not supported by GPUParticleSystem
  106986. * @param gradient defines the gradient to remove
  106987. * @returns the current particle system
  106988. */
  106989. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  106990. //Not supported by GPUParticleSystem
  106991. return this;
  106992. };
  106993. GPUParticleSystem.prototype._reset = function () {
  106994. this._releaseBuffers();
  106995. };
  106996. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  106997. var updateVertexBuffers = {};
  106998. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  106999. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  107000. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  107001. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  107002. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  107003. var offset = 12;
  107004. if (!this._colorGradientsTexture) {
  107005. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  107006. offset += 4;
  107007. }
  107008. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  107009. offset += 3;
  107010. if (!this._isBillboardBased) {
  107011. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  107012. offset += 3;
  107013. }
  107014. if (this._angularSpeedGradientsTexture) {
  107015. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  107016. offset += 1;
  107017. }
  107018. else {
  107019. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  107020. offset += 2;
  107021. }
  107022. if (this._isAnimationSheetEnabled) {
  107023. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  107024. offset += 1;
  107025. if (this.spriteRandomStartCell) {
  107026. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  107027. offset += 1;
  107028. }
  107029. }
  107030. if (this.noiseTexture) {
  107031. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  107032. offset += 3;
  107033. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  107034. offset += 3;
  107035. }
  107036. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  107037. this._engine.bindArrayBuffer(null);
  107038. return vao;
  107039. };
  107040. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  107041. var renderVertexBuffers = {};
  107042. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  107043. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  107044. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  107045. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  107046. var offset = 12;
  107047. if (!this._colorGradientsTexture) {
  107048. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  107049. offset += 4;
  107050. }
  107051. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  107052. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  107053. }
  107054. offset += 3; // Direction
  107055. if (!this._isBillboardBased) {
  107056. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  107057. offset += 3;
  107058. }
  107059. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  107060. if (this._angularSpeedGradientsTexture) {
  107061. offset++;
  107062. }
  107063. else {
  107064. offset += 2;
  107065. }
  107066. if (this._isAnimationSheetEnabled) {
  107067. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  107068. offset += 1;
  107069. if (this.spriteRandomStartCell) {
  107070. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  107071. offset += 1;
  107072. }
  107073. }
  107074. if (this.noiseTexture) {
  107075. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  107076. offset += 3;
  107077. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  107078. offset += 3;
  107079. }
  107080. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  107081. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  107082. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  107083. this._engine.bindArrayBuffer(null);
  107084. return vao;
  107085. };
  107086. GPUParticleSystem.prototype._initialize = function (force) {
  107087. if (force === void 0) { force = false; }
  107088. if (this._buffer0 && !force) {
  107089. return;
  107090. }
  107091. var engine = this._scene.getEngine();
  107092. var data = new Array();
  107093. this._attributesStrideSize = 21;
  107094. this._targetIndex = 0;
  107095. if (!this.isBillboardBased) {
  107096. this._attributesStrideSize += 3;
  107097. }
  107098. if (this._colorGradientsTexture) {
  107099. this._attributesStrideSize -= 4;
  107100. }
  107101. if (this._angularSpeedGradientsTexture) {
  107102. this._attributesStrideSize -= 1;
  107103. }
  107104. if (this._isAnimationSheetEnabled) {
  107105. this._attributesStrideSize += 1;
  107106. if (this.spriteRandomStartCell) {
  107107. this._attributesStrideSize += 1;
  107108. }
  107109. }
  107110. if (this.noiseTexture) {
  107111. this._attributesStrideSize += 6;
  107112. }
  107113. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  107114. // position
  107115. data.push(0.0);
  107116. data.push(0.0);
  107117. data.push(0.0);
  107118. // Age and life
  107119. data.push(0.0); // create the particle as a dead one to create a new one at start
  107120. data.push(0.0);
  107121. // Seed
  107122. data.push(Math.random());
  107123. data.push(Math.random());
  107124. data.push(Math.random());
  107125. data.push(Math.random());
  107126. // Size
  107127. data.push(0.0);
  107128. data.push(0.0);
  107129. data.push(0.0);
  107130. if (!this._colorGradientsTexture) {
  107131. // color
  107132. data.push(0.0);
  107133. data.push(0.0);
  107134. data.push(0.0);
  107135. data.push(0.0);
  107136. }
  107137. // direction
  107138. data.push(0.0);
  107139. data.push(0.0);
  107140. data.push(0.0);
  107141. if (!this.isBillboardBased) {
  107142. // initialDirection
  107143. data.push(0.0);
  107144. data.push(0.0);
  107145. data.push(0.0);
  107146. }
  107147. // angle
  107148. data.push(0.0);
  107149. if (!this._angularSpeedGradientsTexture) {
  107150. data.push(0.0);
  107151. }
  107152. if (this._isAnimationSheetEnabled) {
  107153. data.push(0.0);
  107154. if (this.spriteRandomStartCell) {
  107155. data.push(0.0);
  107156. }
  107157. }
  107158. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  107159. data.push(Math.random());
  107160. data.push(Math.random());
  107161. data.push(Math.random());
  107162. data.push(Math.random());
  107163. data.push(Math.random());
  107164. data.push(Math.random());
  107165. }
  107166. }
  107167. // Sprite data
  107168. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  107169. -0.5, 0.5, 0, 1,
  107170. -0.5, -0.5, 0, 0,
  107171. 0.5, -0.5, 1, 0]);
  107172. // Buffers
  107173. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  107174. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  107175. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  107176. // Update VAO
  107177. this._updateVAO = [];
  107178. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  107179. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  107180. // Render VAO
  107181. this._renderVAO = [];
  107182. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  107183. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  107184. // Links
  107185. this._sourceBuffer = this._buffer0;
  107186. this._targetBuffer = this._buffer1;
  107187. };
  107188. /** @hidden */
  107189. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  107190. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  107191. if (this._isBillboardBased) {
  107192. defines += "\n#define BILLBOARD";
  107193. }
  107194. if (this._colorGradientsTexture) {
  107195. defines += "\n#define COLORGRADIENTS";
  107196. }
  107197. if (this._sizeGradientsTexture) {
  107198. defines += "\n#define SIZEGRADIENTS";
  107199. }
  107200. if (this._angularSpeedGradientsTexture) {
  107201. defines += "\n#define ANGULARSPEEDGRADIENTS";
  107202. }
  107203. if (this._velocityGradientsTexture) {
  107204. defines += "\n#define VELOCITYGRADIENTS";
  107205. }
  107206. if (this._limitVelocityGradientsTexture) {
  107207. defines += "\n#define LIMITVELOCITYGRADIENTS";
  107208. }
  107209. if (this._dragGradientsTexture) {
  107210. defines += "\n#define DRAGGRADIENTS";
  107211. }
  107212. if (this.isAnimationSheetEnabled) {
  107213. defines += "\n#define ANIMATESHEET";
  107214. if (this.spriteRandomStartCell) {
  107215. defines += "\n#define ANIMATESHEETRANDOMSTART";
  107216. }
  107217. }
  107218. if (this.noiseTexture) {
  107219. defines += "\n#define NOISE";
  107220. }
  107221. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  107222. return;
  107223. }
  107224. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  107225. if (!this._colorGradientsTexture) {
  107226. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  107227. }
  107228. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  107229. if (!this._isBillboardBased) {
  107230. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  107231. }
  107232. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  107233. if (this.isAnimationSheetEnabled) {
  107234. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  107235. if (this.spriteRandomStartCell) {
  107236. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  107237. }
  107238. }
  107239. if (this.noiseTexture) {
  107240. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  107241. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  107242. }
  107243. this._updateEffectOptions.defines = defines;
  107244. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  107245. };
  107246. /** @hidden */
  107247. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  107248. var defines = "";
  107249. if (this._scene.clipPlane) {
  107250. defines = "\n#define CLIPPLANE";
  107251. }
  107252. if (this._scene.clipPlane2) {
  107253. defines = "\n#define CLIPPLANE2";
  107254. }
  107255. if (this._scene.clipPlane3) {
  107256. defines = "\n#define CLIPPLANE3";
  107257. }
  107258. if (this._scene.clipPlane4) {
  107259. defines = "\n#define CLIPPLANE4";
  107260. }
  107261. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  107262. defines = "\n#define BLENDMULTIPLYMODE";
  107263. }
  107264. if (this._isBillboardBased) {
  107265. defines += "\n#define BILLBOARD";
  107266. switch (this.billboardMode) {
  107267. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  107268. defines += "\n#define BILLBOARDY";
  107269. break;
  107270. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  107271. defines += "\n#define BILLBOARDSTRETCHED";
  107272. break;
  107273. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  107274. default:
  107275. break;
  107276. }
  107277. }
  107278. if (this._colorGradientsTexture) {
  107279. defines += "\n#define COLORGRADIENTS";
  107280. }
  107281. if (this.isAnimationSheetEnabled) {
  107282. defines += "\n#define ANIMATESHEET";
  107283. }
  107284. if (this._imageProcessingConfiguration) {
  107285. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  107286. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  107287. }
  107288. if (this._renderEffect && this._renderEffect.defines === defines) {
  107289. return;
  107290. }
  107291. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  107292. var samplers = ["textureSampler", "colorGradientSampler"];
  107293. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  107294. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  107295. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  107296. }
  107297. 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);
  107298. };
  107299. /**
  107300. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107301. * @param preWarm defines if we are in the pre-warmimg phase
  107302. */
  107303. GPUParticleSystem.prototype.animate = function (preWarm) {
  107304. if (preWarm === void 0) { preWarm = false; }
  107305. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  107306. this._actualFrame += this._timeDelta;
  107307. if (!this._stopped) {
  107308. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  107309. this.stop();
  107310. }
  107311. }
  107312. };
  107313. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  107314. var texture = this[textureName];
  107315. if (!factorGradients || !factorGradients.length || texture) {
  107316. return;
  107317. }
  107318. var data = new Float32Array(this._rawTextureWidth);
  107319. for (var x = 0; x < this._rawTextureWidth; x++) {
  107320. var ratio = x / this._rawTextureWidth;
  107321. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  107322. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  107323. });
  107324. }
  107325. 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);
  107326. };
  107327. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  107328. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  107329. };
  107330. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  107331. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  107332. };
  107333. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  107334. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  107335. };
  107336. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  107337. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  107338. };
  107339. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  107340. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  107341. };
  107342. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  107343. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  107344. return;
  107345. }
  107346. var data = new Uint8Array(this._rawTextureWidth * 4);
  107347. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  107348. for (var x = 0; x < this._rawTextureWidth; x++) {
  107349. var ratio = x / this._rawTextureWidth;
  107350. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  107351. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  107352. data[x * 4] = tmpColor.r * 255;
  107353. data[x * 4 + 1] = tmpColor.g * 255;
  107354. data[x * 4 + 2] = tmpColor.b * 255;
  107355. data[x * 4 + 3] = tmpColor.a * 255;
  107356. });
  107357. }
  107358. 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);
  107359. };
  107360. /**
  107361. * Renders the particle system in its current state
  107362. * @param preWarm defines if the system should only update the particles but not render them
  107363. * @returns the current number of particles
  107364. */
  107365. GPUParticleSystem.prototype.render = function (preWarm) {
  107366. if (preWarm === void 0) { preWarm = false; }
  107367. if (!this._started) {
  107368. return 0;
  107369. }
  107370. this._createColorGradientTexture();
  107371. this._createSizeGradientTexture();
  107372. this._createAngularSpeedGradientTexture();
  107373. this._createVelocityGradientTexture();
  107374. this._createLimitVelocityGradientTexture();
  107375. this._createDragGradientTexture();
  107376. this._recreateUpdateEffect();
  107377. this._recreateRenderEffect();
  107378. if (!this.isReady()) {
  107379. return 0;
  107380. }
  107381. if (!preWarm) {
  107382. if (!this._preWarmDone && this.preWarmCycles) {
  107383. for (var index = 0; index < this.preWarmCycles; index++) {
  107384. this.animate(true);
  107385. this.render(true);
  107386. }
  107387. this._preWarmDone = true;
  107388. }
  107389. if (this._currentRenderId === this._scene.getFrameId()) {
  107390. return 0;
  107391. }
  107392. this._currentRenderId = this._scene.getFrameId();
  107393. }
  107394. // Get everything ready to render
  107395. this._initialize();
  107396. this._accumulatedCount += this.emitRate * this._timeDelta;
  107397. if (this._accumulatedCount > 1) {
  107398. var intPart = this._accumulatedCount | 0;
  107399. this._accumulatedCount -= intPart;
  107400. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  107401. }
  107402. if (!this._currentActiveCount) {
  107403. return 0;
  107404. }
  107405. // Enable update effect
  107406. this._engine.enableEffect(this._updateEffect);
  107407. this._engine.setState(false);
  107408. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  107409. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  107410. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  107411. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  107412. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  107413. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  107414. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  107415. if (!this._colorGradientsTexture) {
  107416. this._updateEffect.setDirectColor4("color1", this.color1);
  107417. this._updateEffect.setDirectColor4("color2", this.color2);
  107418. }
  107419. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  107420. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  107421. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  107422. this._updateEffect.setVector3("gravity", this.gravity);
  107423. if (this._sizeGradientsTexture) {
  107424. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  107425. }
  107426. if (this._angularSpeedGradientsTexture) {
  107427. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  107428. }
  107429. if (this._velocityGradientsTexture) {
  107430. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  107431. }
  107432. if (this._limitVelocityGradientsTexture) {
  107433. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  107434. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  107435. }
  107436. if (this._dragGradientsTexture) {
  107437. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  107438. }
  107439. if (this.particleEmitterType) {
  107440. this.particleEmitterType.applyToShader(this._updateEffect);
  107441. }
  107442. if (this._isAnimationSheetEnabled) {
  107443. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  107444. }
  107445. if (this.noiseTexture) {
  107446. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  107447. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  107448. }
  107449. var emitterWM;
  107450. if (this.emitter.position) {
  107451. var emitterMesh = this.emitter;
  107452. emitterWM = emitterMesh.getWorldMatrix();
  107453. }
  107454. else {
  107455. var emitterPosition = this.emitter;
  107456. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  107457. }
  107458. this._updateEffect.setMatrix("emitterWM", emitterWM);
  107459. // Bind source VAO
  107460. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  107461. // Update
  107462. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  107463. this._engine.setRasterizerState(false);
  107464. this._engine.beginTransformFeedback(true);
  107465. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  107466. this._engine.endTransformFeedback();
  107467. this._engine.setRasterizerState(true);
  107468. this._engine.bindTransformFeedbackBuffer(null);
  107469. if (!preWarm) {
  107470. // Enable render effect
  107471. this._engine.enableEffect(this._renderEffect);
  107472. var viewMatrix = this._scene.getViewMatrix();
  107473. this._renderEffect.setMatrix("view", viewMatrix);
  107474. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  107475. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  107476. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  107477. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  107478. if (this._colorGradientsTexture) {
  107479. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  107480. }
  107481. else {
  107482. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  107483. }
  107484. if (this._isAnimationSheetEnabled && this.particleTexture) {
  107485. var baseSize = this.particleTexture.getBaseSize();
  107486. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  107487. }
  107488. if (this._isBillboardBased) {
  107489. var camera = this._scene.activeCamera;
  107490. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  107491. }
  107492. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  107493. var invView = viewMatrix.clone();
  107494. invView.invert();
  107495. this._renderEffect.setMatrix("invView", invView);
  107496. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  107497. }
  107498. // image processing
  107499. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  107500. this._imageProcessingConfiguration.bind(this._renderEffect);
  107501. }
  107502. // Draw order
  107503. switch (this.blendMode) {
  107504. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  107505. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  107506. break;
  107507. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  107508. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  107509. break;
  107510. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  107511. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  107512. break;
  107513. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  107514. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  107515. break;
  107516. }
  107517. if (this.forceDepthWrite) {
  107518. this._engine.setDepthWrite(true);
  107519. }
  107520. // Bind source VAO
  107521. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  107522. // Render
  107523. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  107524. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  107525. }
  107526. // Switch VAOs
  107527. this._targetIndex++;
  107528. if (this._targetIndex === 2) {
  107529. this._targetIndex = 0;
  107530. }
  107531. // Switch buffers
  107532. var tmpBuffer = this._sourceBuffer;
  107533. this._sourceBuffer = this._targetBuffer;
  107534. this._targetBuffer = tmpBuffer;
  107535. return this._currentActiveCount;
  107536. };
  107537. /**
  107538. * Rebuilds the particle system
  107539. */
  107540. GPUParticleSystem.prototype.rebuild = function () {
  107541. this._initialize(true);
  107542. };
  107543. GPUParticleSystem.prototype._releaseBuffers = function () {
  107544. if (this._buffer0) {
  107545. this._buffer0.dispose();
  107546. this._buffer0 = null;
  107547. }
  107548. if (this._buffer1) {
  107549. this._buffer1.dispose();
  107550. this._buffer1 = null;
  107551. }
  107552. if (this._spriteBuffer) {
  107553. this._spriteBuffer.dispose();
  107554. this._spriteBuffer = null;
  107555. }
  107556. };
  107557. GPUParticleSystem.prototype._releaseVAOs = function () {
  107558. if (!this._updateVAO) {
  107559. return;
  107560. }
  107561. for (var index = 0; index < this._updateVAO.length; index++) {
  107562. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  107563. }
  107564. this._updateVAO = [];
  107565. for (var index = 0; index < this._renderVAO.length; index++) {
  107566. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  107567. }
  107568. this._renderVAO = [];
  107569. };
  107570. /**
  107571. * Disposes the particle system and free the associated resources
  107572. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107573. */
  107574. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  107575. if (disposeTexture === void 0) { disposeTexture = true; }
  107576. var index = this._scene.particleSystems.indexOf(this);
  107577. if (index > -1) {
  107578. this._scene.particleSystems.splice(index, 1);
  107579. }
  107580. this._releaseBuffers();
  107581. this._releaseVAOs();
  107582. if (this._colorGradientsTexture) {
  107583. this._colorGradientsTexture.dispose();
  107584. this._colorGradientsTexture = null;
  107585. }
  107586. if (this._sizeGradientsTexture) {
  107587. this._sizeGradientsTexture.dispose();
  107588. this._sizeGradientsTexture = null;
  107589. }
  107590. if (this._angularSpeedGradientsTexture) {
  107591. this._angularSpeedGradientsTexture.dispose();
  107592. this._angularSpeedGradientsTexture = null;
  107593. }
  107594. if (this._velocityGradientsTexture) {
  107595. this._velocityGradientsTexture.dispose();
  107596. this._velocityGradientsTexture = null;
  107597. }
  107598. if (this._limitVelocityGradientsTexture) {
  107599. this._limitVelocityGradientsTexture.dispose();
  107600. this._limitVelocityGradientsTexture = null;
  107601. }
  107602. if (this._dragGradientsTexture) {
  107603. this._dragGradientsTexture.dispose();
  107604. this._dragGradientsTexture = null;
  107605. }
  107606. if (this._randomTexture) {
  107607. this._randomTexture.dispose();
  107608. this._randomTexture = null;
  107609. }
  107610. if (this._randomTexture2) {
  107611. this._randomTexture2.dispose();
  107612. this._randomTexture2 = null;
  107613. }
  107614. if (disposeTexture && this.particleTexture) {
  107615. this.particleTexture.dispose();
  107616. this.particleTexture = null;
  107617. }
  107618. if (disposeTexture && this.noiseTexture) {
  107619. this.noiseTexture.dispose();
  107620. this.noiseTexture = null;
  107621. }
  107622. // Callback
  107623. this.onDisposeObservable.notifyObservers(this);
  107624. this.onDisposeObservable.clear();
  107625. };
  107626. /**
  107627. * Clones the particle system.
  107628. * @param name The name of the cloned object
  107629. * @param newEmitter The new emitter to use
  107630. * @returns the cloned particle system
  107631. */
  107632. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  107633. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  107634. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  107635. if (newEmitter === undefined) {
  107636. newEmitter = this.emitter;
  107637. }
  107638. result.emitter = newEmitter;
  107639. if (this.particleTexture) {
  107640. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  107641. }
  107642. return result;
  107643. };
  107644. /**
  107645. * Serializes the particle system to a JSON object.
  107646. * @returns the JSON object
  107647. */
  107648. GPUParticleSystem.prototype.serialize = function () {
  107649. var serializationObject = {};
  107650. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  107651. serializationObject.activeParticleCount = this.activeParticleCount;
  107652. return serializationObject;
  107653. };
  107654. /**
  107655. * Parses a JSON object to create a GPU particle system.
  107656. * @param parsedParticleSystem The JSON object to parse
  107657. * @param scene The scene to create the particle system in
  107658. * @param rootUrl The root url to use to load external dependencies like texture
  107659. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107660. * @returns the parsed GPU particle system
  107661. */
  107662. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  107663. if (doNotStart === void 0) { doNotStart = false; }
  107664. var name = parsedParticleSystem.name;
  107665. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  107666. if (parsedParticleSystem.activeParticleCount) {
  107667. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  107668. }
  107669. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  107670. // Auto start
  107671. if (parsedParticleSystem.preventAutoStart) {
  107672. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  107673. }
  107674. if (!doNotStart && !particleSystem.preventAutoStart) {
  107675. particleSystem.start();
  107676. }
  107677. return particleSystem;
  107678. };
  107679. return GPUParticleSystem;
  107680. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  107681. /***/ }),
  107682. /***/ "./Particles/index.ts":
  107683. /*!****************************!*\
  107684. !*** ./Particles/index.ts ***!
  107685. \****************************/
  107686. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  107687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107688. "use strict";
  107689. __webpack_require__.r(__webpack_exports__);
  107690. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  107691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  107692. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  107693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  107694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  107695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  107696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  107697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  107698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  107699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  107700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  107701. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  107703. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  107704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  107705. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  107706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  107707. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  107709. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  107710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  107711. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  107712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  107713. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  107714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  107715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  107716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  107717. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  107718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  107719. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  107720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  107721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  107722. /***/ }),
  107723. /***/ "./Particles/particle.ts":
  107724. /*!*******************************!*\
  107725. !*** ./Particles/particle.ts ***!
  107726. \*******************************/
  107727. /*! exports provided: Particle */
  107728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107729. "use strict";
  107730. __webpack_require__.r(__webpack_exports__);
  107731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  107732. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107733. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107734. /**
  107735. * A particle represents one of the element emitted by a particle system.
  107736. * This is mainly define by its coordinates, direction, velocity and age.
  107737. */
  107738. var Particle = /** @class */ (function () {
  107739. /**
  107740. * Creates a new instance Particle
  107741. * @param particleSystem the particle system the particle belongs to
  107742. */
  107743. function Particle(
  107744. /**
  107745. * The particle system the particle belongs to.
  107746. */
  107747. particleSystem) {
  107748. this.particleSystem = particleSystem;
  107749. /**
  107750. * The world position of the particle in the scene.
  107751. */
  107752. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107753. /**
  107754. * The world direction of the particle in the scene.
  107755. */
  107756. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107757. /**
  107758. * The color of the particle.
  107759. */
  107760. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107761. /**
  107762. * The color change of the particle per step.
  107763. */
  107764. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107765. /**
  107766. * Defines how long will the life of the particle be.
  107767. */
  107768. this.lifeTime = 1.0;
  107769. /**
  107770. * The current age of the particle.
  107771. */
  107772. this.age = 0;
  107773. /**
  107774. * The current size of the particle.
  107775. */
  107776. this.size = 0;
  107777. /**
  107778. * The current scale of the particle.
  107779. */
  107780. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  107781. /**
  107782. * The current angle of the particle.
  107783. */
  107784. this.angle = 0;
  107785. /**
  107786. * Defines how fast is the angle changing.
  107787. */
  107788. this.angularSpeed = 0;
  107789. /**
  107790. * Defines the cell index used by the particle to be rendered from a sprite.
  107791. */
  107792. this.cellIndex = 0;
  107793. /** @hidden */
  107794. this._attachedSubEmitters = null;
  107795. /** @hidden */
  107796. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107797. /** @hidden */
  107798. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107799. /** @hidden */
  107800. this._currentSize1 = 0;
  107801. /** @hidden */
  107802. this._currentSize2 = 0;
  107803. /** @hidden */
  107804. this._currentAngularSpeed1 = 0;
  107805. /** @hidden */
  107806. this._currentAngularSpeed2 = 0;
  107807. /** @hidden */
  107808. this._currentVelocity1 = 0;
  107809. /** @hidden */
  107810. this._currentVelocity2 = 0;
  107811. /** @hidden */
  107812. this._currentLimitVelocity1 = 0;
  107813. /** @hidden */
  107814. this._currentLimitVelocity2 = 0;
  107815. /** @hidden */
  107816. this._currentDrag1 = 0;
  107817. /** @hidden */
  107818. this._currentDrag2 = 0;
  107819. this.id = Particle._Count++;
  107820. if (!this.particleSystem.isAnimationSheetEnabled) {
  107821. return;
  107822. }
  107823. this.updateCellInfoFromSystem();
  107824. }
  107825. Particle.prototype.updateCellInfoFromSystem = function () {
  107826. this.cellIndex = this.particleSystem.startSpriteCellID;
  107827. };
  107828. /**
  107829. * Defines how the sprite cell index is updated for the particle
  107830. */
  107831. Particle.prototype.updateCellIndex = function () {
  107832. var offsetAge = this.age;
  107833. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  107834. if (this.particleSystem.spriteRandomStartCell) {
  107835. if (this._randomCellOffset === undefined) {
  107836. this._randomCellOffset = Math.random() * this.lifeTime;
  107837. }
  107838. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  107839. changeSpeed = 1;
  107840. offsetAge = this._randomCellOffset;
  107841. }
  107842. else {
  107843. offsetAge += this._randomCellOffset;
  107844. }
  107845. }
  107846. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  107847. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  107848. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  107849. };
  107850. /** @hidden */
  107851. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  107852. if (subEmitter.particleSystem.emitter.position) {
  107853. var emitterMesh = subEmitter.particleSystem.emitter;
  107854. emitterMesh.position.copyFrom(this.position);
  107855. if (subEmitter.inheritDirection) {
  107856. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  107857. // Look at using Y as forward
  107858. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  107859. }
  107860. }
  107861. else {
  107862. var emitterPosition = subEmitter.particleSystem.emitter;
  107863. emitterPosition.copyFrom(this.position);
  107864. }
  107865. // Set inheritedVelocityOffset to be used when new particles are created
  107866. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  107867. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  107868. };
  107869. /** @hidden */
  107870. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  107871. var _this = this;
  107872. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  107873. this._attachedSubEmitters.forEach(function (subEmitter) {
  107874. _this._inheritParticleInfoToSubEmitter(subEmitter);
  107875. });
  107876. }
  107877. };
  107878. /** @hidden */
  107879. Particle.prototype._reset = function () {
  107880. this.age = 0;
  107881. this._currentColorGradient = null;
  107882. this._currentSizeGradient = null;
  107883. this._currentAngularSpeedGradient = null;
  107884. this._currentVelocityGradient = null;
  107885. this._currentLimitVelocityGradient = null;
  107886. this._currentDragGradient = null;
  107887. this.cellIndex = this.particleSystem.startSpriteCellID;
  107888. this._randomCellOffset = undefined;
  107889. };
  107890. /**
  107891. * Copy the properties of particle to another one.
  107892. * @param other the particle to copy the information to.
  107893. */
  107894. Particle.prototype.copyTo = function (other) {
  107895. other.position.copyFrom(this.position);
  107896. if (this._initialDirection) {
  107897. if (other._initialDirection) {
  107898. other._initialDirection.copyFrom(this._initialDirection);
  107899. }
  107900. else {
  107901. other._initialDirection = this._initialDirection.clone();
  107902. }
  107903. }
  107904. else {
  107905. other._initialDirection = null;
  107906. }
  107907. other.direction.copyFrom(this.direction);
  107908. other.color.copyFrom(this.color);
  107909. other.colorStep.copyFrom(this.colorStep);
  107910. other.lifeTime = this.lifeTime;
  107911. other.age = this.age;
  107912. other._randomCellOffset = this._randomCellOffset;
  107913. other.size = this.size;
  107914. other.scale.copyFrom(this.scale);
  107915. other.angle = this.angle;
  107916. other.angularSpeed = this.angularSpeed;
  107917. other.particleSystem = this.particleSystem;
  107918. other.cellIndex = this.cellIndex;
  107919. other.id = this.id;
  107920. other._attachedSubEmitters = this._attachedSubEmitters;
  107921. if (this._currentColorGradient) {
  107922. other._currentColorGradient = this._currentColorGradient;
  107923. other._currentColor1.copyFrom(this._currentColor1);
  107924. other._currentColor2.copyFrom(this._currentColor2);
  107925. }
  107926. if (this._currentSizeGradient) {
  107927. other._currentSizeGradient = this._currentSizeGradient;
  107928. other._currentSize1 = this._currentSize1;
  107929. other._currentSize2 = this._currentSize2;
  107930. }
  107931. if (this._currentAngularSpeedGradient) {
  107932. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  107933. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  107934. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  107935. }
  107936. if (this._currentVelocityGradient) {
  107937. other._currentVelocityGradient = this._currentVelocityGradient;
  107938. other._currentVelocity1 = this._currentVelocity1;
  107939. other._currentVelocity2 = this._currentVelocity2;
  107940. }
  107941. if (this._currentLimitVelocityGradient) {
  107942. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  107943. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  107944. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  107945. }
  107946. if (this._currentDragGradient) {
  107947. other._currentDragGradient = this._currentDragGradient;
  107948. other._currentDrag1 = this._currentDrag1;
  107949. other._currentDrag2 = this._currentDrag2;
  107950. }
  107951. if (this.particleSystem.isAnimationSheetEnabled) {
  107952. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  107953. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  107954. }
  107955. if (this.particleSystem.useRampGradients) {
  107956. other.remapData.copyFrom(this.remapData);
  107957. }
  107958. if (this._randomNoiseCoordinates1) {
  107959. if (other._randomNoiseCoordinates1) {
  107960. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  107961. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  107962. }
  107963. else {
  107964. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  107965. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  107966. }
  107967. }
  107968. };
  107969. Particle._Count = 0;
  107970. return Particle;
  107971. }());
  107972. /***/ }),
  107973. /***/ "./Particles/particleHelper.ts":
  107974. /*!*************************************!*\
  107975. !*** ./Particles/particleHelper.ts ***!
  107976. \*************************************/
  107977. /*! exports provided: ParticleHelper */
  107978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107979. "use strict";
  107980. __webpack_require__.r(__webpack_exports__);
  107981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  107982. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  107983. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107984. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  107985. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107986. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107987. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  107988. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107989. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107990. /**
  107991. * This class is made for on one-liner static method to help creating particle system set.
  107992. */
  107993. var ParticleHelper = /** @class */ (function () {
  107994. function ParticleHelper() {
  107995. }
  107996. /**
  107997. * Create a default particle system that you can tweak
  107998. * @param emitter defines the emitter to use
  107999. * @param capacity defines the system capacity (default is 500 particles)
  108000. * @param scene defines the hosting scene
  108001. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108002. * @returns the new Particle system
  108003. */
  108004. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  108005. if (capacity === void 0) { capacity = 500; }
  108006. if (useGPU === void 0) { useGPU = false; }
  108007. var system;
  108008. if (useGPU) {
  108009. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  108010. }
  108011. else {
  108012. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  108013. }
  108014. system.emitter = emitter;
  108015. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  108016. system.createConeEmitter(0.1, Math.PI / 4);
  108017. // Particle color
  108018. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  108019. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  108020. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  108021. // Particle Size
  108022. system.minSize = 0.1;
  108023. system.maxSize = 0.1;
  108024. // Emission speed
  108025. system.minEmitPower = 2;
  108026. system.maxEmitPower = 2;
  108027. // Update speed
  108028. system.updateSpeed = 1 / 60;
  108029. system.emitRate = 30;
  108030. return system;
  108031. };
  108032. /**
  108033. * This is the main static method (one-liner) of this helper to create different particle systems
  108034. * @param type This string represents the type to the particle system to create
  108035. * @param scene The scene where the particle system should live
  108036. * @param gpu If the system will use gpu
  108037. * @returns the ParticleSystemSet created
  108038. */
  108039. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  108040. if (gpu === void 0) { gpu = false; }
  108041. if (!scene) {
  108042. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  108043. }
  108044. var token = {};
  108045. scene._addPendingData(token);
  108046. return new Promise(function (resolve, reject) {
  108047. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  108048. scene._removePendingData(token);
  108049. return reject("Particle system with GPU is not supported.");
  108050. }
  108051. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  108052. scene._removePendingData(token);
  108053. var newData = JSON.parse(data.toString());
  108054. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  108055. }, undefined, undefined, undefined, function () {
  108056. scene._removePendingData(token);
  108057. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  108058. });
  108059. });
  108060. };
  108061. /**
  108062. * Static function used to export a particle system to a ParticleSystemSet variable.
  108063. * Please note that the emitter shape is not exported
  108064. * @param systems defines the particle systems to export
  108065. * @returns the created particle system set
  108066. */
  108067. ParticleHelper.ExportSet = function (systems) {
  108068. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  108069. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  108070. var system = systems_1[_i];
  108071. set.systems.push(system);
  108072. }
  108073. return set;
  108074. };
  108075. /**
  108076. * Gets or sets base Assets URL
  108077. */
  108078. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  108079. return ParticleHelper;
  108080. }());
  108081. /***/ }),
  108082. /***/ "./Particles/particleSystem.ts":
  108083. /*!*************************************!*\
  108084. !*** ./Particles/particleSystem.ts ***!
  108085. \*************************************/
  108086. /*! exports provided: ParticleSystem */
  108087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108088. "use strict";
  108089. __webpack_require__.r(__webpack_exports__);
  108090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  108091. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  108092. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  108093. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  108094. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108095. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108096. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  108097. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108098. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  108099. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  108100. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  108101. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108102. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  108103. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  108104. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108105. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  108106. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  108107. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  108108. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  108109. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108110. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  108111. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  108112. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  108113. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  108114. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  108115. /**
  108116. * This represents a particle system in Babylon.
  108117. * 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.
  108118. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  108119. * @example https://doc.babylonjs.com/babylon101/particles
  108120. */
  108121. var ParticleSystem = /** @class */ (function (_super) {
  108122. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  108123. /**
  108124. * Instantiates a particle system.
  108125. * 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.
  108126. * @param name The name of the particle system
  108127. * @param capacity The max number of particles alive at the same time
  108128. * @param scene The scene the particle system belongs to
  108129. * @param customEffect a custom effect used to change the way particles are rendered by default
  108130. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108131. * @param epsilon Offset used to render the particles
  108132. */
  108133. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  108134. if (customEffect === void 0) { customEffect = null; }
  108135. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  108136. if (epsilon === void 0) { epsilon = 0.01; }
  108137. var _this = _super.call(this, name) || this;
  108138. /**
  108139. * @hidden
  108140. */
  108141. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  108142. /**
  108143. * An event triggered when the system is disposed
  108144. */
  108145. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  108146. _this._particles = new Array();
  108147. _this._stockParticles = new Array();
  108148. _this._newPartsExcess = 0;
  108149. _this._vertexBuffers = {};
  108150. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  108151. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  108152. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  108153. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  108154. _this._currentRenderId = -1;
  108155. _this._useInstancing = false;
  108156. _this._started = false;
  108157. _this._stopped = false;
  108158. _this._actualFrame = 0;
  108159. /** @hidden */
  108160. _this._currentEmitRate1 = 0;
  108161. /** @hidden */
  108162. _this._currentEmitRate2 = 0;
  108163. /** @hidden */
  108164. _this._currentStartSize1 = 0;
  108165. /** @hidden */
  108166. _this._currentStartSize2 = 0;
  108167. _this._rawTextureWidth = 256;
  108168. _this._useRampGradients = false;
  108169. /**
  108170. * @hidden
  108171. * If the particle systems emitter should be disposed when the particle system is disposed
  108172. */
  108173. _this._disposeEmitterOnDispose = false;
  108174. // start of sub system methods
  108175. /**
  108176. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  108177. * Its lifetime will start back at 0.
  108178. */
  108179. _this.recycleParticle = function (particle) {
  108180. // move particle from activeParticle list to stock particles
  108181. var lastParticle = _this._particles.pop();
  108182. if (lastParticle !== particle) {
  108183. lastParticle.copyTo(particle);
  108184. }
  108185. _this._stockParticles.push(lastParticle);
  108186. };
  108187. _this._createParticle = function () {
  108188. var particle;
  108189. if (_this._stockParticles.length !== 0) {
  108190. particle = _this._stockParticles.pop();
  108191. particle._reset();
  108192. }
  108193. else {
  108194. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  108195. }
  108196. // Attach emitters
  108197. if (_this._subEmitters && _this._subEmitters.length > 0) {
  108198. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  108199. particle._attachedSubEmitters = [];
  108200. subEmitters.forEach(function (subEmitter) {
  108201. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  108202. var newEmitter = subEmitter.clone();
  108203. particle._attachedSubEmitters.push(newEmitter);
  108204. newEmitter.particleSystem.start();
  108205. }
  108206. });
  108207. }
  108208. return particle;
  108209. };
  108210. _this._emitFromParticle = function (particle) {
  108211. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  108212. return;
  108213. }
  108214. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  108215. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  108216. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  108217. var subSystem = subEmitter.clone();
  108218. particle._inheritParticleInfoToSubEmitter(subSystem);
  108219. subSystem.particleSystem._rootParticleSystem = _this;
  108220. _this.activeSubSystems.push(subSystem.particleSystem);
  108221. subSystem.particleSystem.start();
  108222. }
  108223. });
  108224. };
  108225. _this._capacity = capacity;
  108226. _this._epsilon = epsilon;
  108227. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  108228. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  108229. // Setup the default processing configuration to the scene.
  108230. _this._attachImageProcessingConfiguration(null);
  108231. _this._customEffect = customEffect;
  108232. _this._scene.particleSystems.push(_this);
  108233. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  108234. _this._createIndexBuffer();
  108235. _this._createVertexBuffers();
  108236. // Default emitter type
  108237. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  108238. // Update
  108239. _this.updateFunction = function (particles) {
  108240. var noiseTextureSize = null;
  108241. var noiseTextureData = null;
  108242. if (_this.noiseTexture) { // We need to get texture data back to CPU
  108243. noiseTextureSize = _this.noiseTexture.getSize();
  108244. noiseTextureData = (_this.noiseTexture.getContent());
  108245. }
  108246. var _loop_1 = function () {
  108247. particle = particles[index];
  108248. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  108249. var previousAge = particle.age;
  108250. particle.age += scaledUpdateSpeed;
  108251. // Evaluate step to death
  108252. if (particle.age > particle.lifeTime) {
  108253. var diff = particle.age - previousAge;
  108254. var oldDiff = particle.lifeTime - previousAge;
  108255. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  108256. particle.age = particle.lifeTime;
  108257. }
  108258. var ratio = particle.age / particle.lifeTime;
  108259. // Color
  108260. if (_this._colorGradients && _this._colorGradients.length > 0) {
  108261. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  108262. if (currentGradient !== particle._currentColorGradient) {
  108263. particle._currentColor1.copyFrom(particle._currentColor2);
  108264. nextGradient.getColorToRef(particle._currentColor2);
  108265. particle._currentColorGradient = currentGradient;
  108266. }
  108267. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  108268. });
  108269. }
  108270. else {
  108271. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  108272. particle.color.addInPlace(_this._scaledColorStep);
  108273. if (particle.color.a < 0) {
  108274. particle.color.a = 0;
  108275. }
  108276. }
  108277. // Angular speed
  108278. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  108279. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  108280. if (currentGradient !== particle._currentAngularSpeedGradient) {
  108281. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  108282. particle._currentAngularSpeed2 = nextGradient.getFactor();
  108283. particle._currentAngularSpeedGradient = currentGradient;
  108284. }
  108285. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  108286. });
  108287. }
  108288. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  108289. // Direction
  108290. var directionScale = scaledUpdateSpeed;
  108291. /// Velocity
  108292. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  108293. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  108294. if (currentGradient !== particle._currentVelocityGradient) {
  108295. particle._currentVelocity1 = particle._currentVelocity2;
  108296. particle._currentVelocity2 = nextGradient.getFactor();
  108297. particle._currentVelocityGradient = currentGradient;
  108298. }
  108299. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  108300. });
  108301. }
  108302. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  108303. /// Limit velocity
  108304. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  108305. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  108306. if (currentGradient !== particle._currentLimitVelocityGradient) {
  108307. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  108308. particle._currentLimitVelocity2 = nextGradient.getFactor();
  108309. particle._currentLimitVelocityGradient = currentGradient;
  108310. }
  108311. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  108312. var currentVelocity = particle.direction.length();
  108313. if (currentVelocity > limitVelocity) {
  108314. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  108315. }
  108316. });
  108317. }
  108318. /// Drag
  108319. if (_this._dragGradients && _this._dragGradients.length > 0) {
  108320. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  108321. if (currentGradient !== particle._currentDragGradient) {
  108322. particle._currentDrag1 = particle._currentDrag2;
  108323. particle._currentDrag2 = nextGradient.getFactor();
  108324. particle._currentDragGradient = currentGradient;
  108325. }
  108326. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  108327. _this._scaledDirection.scaleInPlace(1.0 - drag);
  108328. });
  108329. }
  108330. particle.position.addInPlace(_this._scaledDirection);
  108331. // Noise
  108332. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  108333. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  108334. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  108335. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  108336. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  108337. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  108338. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  108339. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  108340. particle.direction.addInPlace(scaledForce);
  108341. }
  108342. // Gravity
  108343. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  108344. particle.direction.addInPlace(_this._scaledGravity);
  108345. // Size
  108346. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  108347. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  108348. if (currentGradient !== particle._currentSizeGradient) {
  108349. particle._currentSize1 = particle._currentSize2;
  108350. particle._currentSize2 = nextGradient.getFactor();
  108351. particle._currentSizeGradient = currentGradient;
  108352. }
  108353. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  108354. });
  108355. }
  108356. // Remap data
  108357. if (_this._useRampGradients) {
  108358. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  108359. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  108360. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  108361. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  108362. particle.remapData.x = min;
  108363. particle.remapData.y = max - min;
  108364. });
  108365. }
  108366. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  108367. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  108368. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  108369. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  108370. particle.remapData.z = min;
  108371. particle.remapData.w = max - min;
  108372. });
  108373. }
  108374. }
  108375. if (_this._isAnimationSheetEnabled) {
  108376. particle.updateCellIndex();
  108377. }
  108378. // Update the position of the attached sub-emitters to match their attached particle
  108379. particle._inheritParticleInfoToSubEmitters();
  108380. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  108381. _this._emitFromParticle(particle);
  108382. if (particle._attachedSubEmitters) {
  108383. particle._attachedSubEmitters.forEach(function (subEmitter) {
  108384. subEmitter.particleSystem.disposeOnStop = true;
  108385. subEmitter.particleSystem.stop();
  108386. });
  108387. particle._attachedSubEmitters = null;
  108388. }
  108389. _this.recycleParticle(particle);
  108390. index--;
  108391. return "continue";
  108392. }
  108393. };
  108394. var particle;
  108395. for (var index = 0; index < particles.length; index++) {
  108396. _loop_1();
  108397. }
  108398. };
  108399. return _this;
  108400. }
  108401. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  108402. /**
  108403. * Sets a callback that will be triggered when the system is disposed
  108404. */
  108405. set: function (callback) {
  108406. if (this._onDisposeObserver) {
  108407. this.onDisposeObservable.remove(this._onDisposeObserver);
  108408. }
  108409. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  108410. },
  108411. enumerable: true,
  108412. configurable: true
  108413. });
  108414. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  108415. /** Gets or sets a boolean indicating that ramp gradients must be used
  108416. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108417. */
  108418. get: function () {
  108419. return this._useRampGradients;
  108420. },
  108421. set: function (value) {
  108422. if (this._useRampGradients === value) {
  108423. return;
  108424. }
  108425. this._useRampGradients = value;
  108426. this._resetEffect();
  108427. },
  108428. enumerable: true,
  108429. configurable: true
  108430. });
  108431. Object.defineProperty(ParticleSystem.prototype, "particles", {
  108432. //end of Sub-emitter
  108433. /**
  108434. * Gets the current list of active particles
  108435. */
  108436. get: function () {
  108437. return this._particles;
  108438. },
  108439. enumerable: true,
  108440. configurable: true
  108441. });
  108442. /**
  108443. * Returns the string "ParticleSystem"
  108444. * @returns a string containing the class name
  108445. */
  108446. ParticleSystem.prototype.getClassName = function () {
  108447. return "ParticleSystem";
  108448. };
  108449. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  108450. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  108451. newGradient.gradient = gradient;
  108452. newGradient.factor1 = factor;
  108453. newGradient.factor2 = factor2;
  108454. factorGradients.push(newGradient);
  108455. factorGradients.sort(function (a, b) {
  108456. if (a.gradient < b.gradient) {
  108457. return -1;
  108458. }
  108459. else if (a.gradient > b.gradient) {
  108460. return 1;
  108461. }
  108462. return 0;
  108463. });
  108464. };
  108465. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  108466. if (!factorGradients) {
  108467. return;
  108468. }
  108469. var index = 0;
  108470. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  108471. var factorGradient = factorGradients_1[_i];
  108472. if (factorGradient.gradient === gradient) {
  108473. factorGradients.splice(index, 1);
  108474. break;
  108475. }
  108476. index++;
  108477. }
  108478. };
  108479. /**
  108480. * Adds a new life time gradient
  108481. * @param gradient defines the gradient to use (between 0 and 1)
  108482. * @param factor defines the life time factor to affect to the specified gradient
  108483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108484. * @returns the current particle system
  108485. */
  108486. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  108487. if (!this._lifeTimeGradients) {
  108488. this._lifeTimeGradients = [];
  108489. }
  108490. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  108491. return this;
  108492. };
  108493. /**
  108494. * Remove a specific life time gradient
  108495. * @param gradient defines the gradient to remove
  108496. * @returns the current particle system
  108497. */
  108498. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  108499. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  108500. return this;
  108501. };
  108502. /**
  108503. * Adds a new size gradient
  108504. * @param gradient defines the gradient to use (between 0 and 1)
  108505. * @param factor defines the size factor to affect to the specified gradient
  108506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108507. * @returns the current particle system
  108508. */
  108509. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  108510. if (!this._sizeGradients) {
  108511. this._sizeGradients = [];
  108512. }
  108513. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  108514. return this;
  108515. };
  108516. /**
  108517. * Remove a specific size gradient
  108518. * @param gradient defines the gradient to remove
  108519. * @returns the current particle system
  108520. */
  108521. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  108522. this._removeFactorGradient(this._sizeGradients, gradient);
  108523. return this;
  108524. };
  108525. /**
  108526. * Adds a new color remap gradient
  108527. * @param gradient defines the gradient to use (between 0 and 1)
  108528. * @param min defines the color remap minimal range
  108529. * @param max defines the color remap maximal range
  108530. * @returns the current particle system
  108531. */
  108532. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  108533. if (!this._colorRemapGradients) {
  108534. this._colorRemapGradients = [];
  108535. }
  108536. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  108537. return this;
  108538. };
  108539. /**
  108540. * Remove a specific color remap gradient
  108541. * @param gradient defines the gradient to remove
  108542. * @returns the current particle system
  108543. */
  108544. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  108545. this._removeFactorGradient(this._colorRemapGradients, gradient);
  108546. return this;
  108547. };
  108548. /**
  108549. * Adds a new alpha remap gradient
  108550. * @param gradient defines the gradient to use (between 0 and 1)
  108551. * @param min defines the alpha remap minimal range
  108552. * @param max defines the alpha remap maximal range
  108553. * @returns the current particle system
  108554. */
  108555. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  108556. if (!this._alphaRemapGradients) {
  108557. this._alphaRemapGradients = [];
  108558. }
  108559. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  108560. return this;
  108561. };
  108562. /**
  108563. * Remove a specific alpha remap gradient
  108564. * @param gradient defines the gradient to remove
  108565. * @returns the current particle system
  108566. */
  108567. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  108568. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  108569. return this;
  108570. };
  108571. /**
  108572. * Adds a new angular speed gradient
  108573. * @param gradient defines the gradient to use (between 0 and 1)
  108574. * @param factor defines the angular speed to affect to the specified gradient
  108575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108576. * @returns the current particle system
  108577. */
  108578. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  108579. if (!this._angularSpeedGradients) {
  108580. this._angularSpeedGradients = [];
  108581. }
  108582. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  108583. return this;
  108584. };
  108585. /**
  108586. * Remove a specific angular speed gradient
  108587. * @param gradient defines the gradient to remove
  108588. * @returns the current particle system
  108589. */
  108590. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  108591. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  108592. return this;
  108593. };
  108594. /**
  108595. * Adds a new velocity gradient
  108596. * @param gradient defines the gradient to use (between 0 and 1)
  108597. * @param factor defines the velocity to affect to the specified gradient
  108598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108599. * @returns the current particle system
  108600. */
  108601. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  108602. if (!this._velocityGradients) {
  108603. this._velocityGradients = [];
  108604. }
  108605. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  108606. return this;
  108607. };
  108608. /**
  108609. * Remove a specific velocity gradient
  108610. * @param gradient defines the gradient to remove
  108611. * @returns the current particle system
  108612. */
  108613. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  108614. this._removeFactorGradient(this._velocityGradients, gradient);
  108615. return this;
  108616. };
  108617. /**
  108618. * Adds a new limit velocity gradient
  108619. * @param gradient defines the gradient to use (between 0 and 1)
  108620. * @param factor defines the limit velocity value to affect to the specified gradient
  108621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108622. * @returns the current particle system
  108623. */
  108624. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  108625. if (!this._limitVelocityGradients) {
  108626. this._limitVelocityGradients = [];
  108627. }
  108628. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  108629. return this;
  108630. };
  108631. /**
  108632. * Remove a specific limit velocity gradient
  108633. * @param gradient defines the gradient to remove
  108634. * @returns the current particle system
  108635. */
  108636. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  108637. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  108638. return this;
  108639. };
  108640. /**
  108641. * Adds a new drag gradient
  108642. * @param gradient defines the gradient to use (between 0 and 1)
  108643. * @param factor defines the drag value to affect to the specified gradient
  108644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108645. * @returns the current particle system
  108646. */
  108647. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  108648. if (!this._dragGradients) {
  108649. this._dragGradients = [];
  108650. }
  108651. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  108652. return this;
  108653. };
  108654. /**
  108655. * Remove a specific drag gradient
  108656. * @param gradient defines the gradient to remove
  108657. * @returns the current particle system
  108658. */
  108659. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  108660. this._removeFactorGradient(this._dragGradients, gradient);
  108661. return this;
  108662. };
  108663. /**
  108664. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  108665. * @param gradient defines the gradient to use (between 0 and 1)
  108666. * @param factor defines the emit rate value to affect to the specified gradient
  108667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108668. * @returns the current particle system
  108669. */
  108670. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  108671. if (!this._emitRateGradients) {
  108672. this._emitRateGradients = [];
  108673. }
  108674. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  108675. return this;
  108676. };
  108677. /**
  108678. * Remove a specific emit rate gradient
  108679. * @param gradient defines the gradient to remove
  108680. * @returns the current particle system
  108681. */
  108682. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  108683. this._removeFactorGradient(this._emitRateGradients, gradient);
  108684. return this;
  108685. };
  108686. /**
  108687. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  108688. * @param gradient defines the gradient to use (between 0 and 1)
  108689. * @param factor defines the start size value to affect to the specified gradient
  108690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108691. * @returns the current particle system
  108692. */
  108693. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  108694. if (!this._startSizeGradients) {
  108695. this._startSizeGradients = [];
  108696. }
  108697. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  108698. return this;
  108699. };
  108700. /**
  108701. * Remove a specific start size gradient
  108702. * @param gradient defines the gradient to remove
  108703. * @returns the current particle system
  108704. */
  108705. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  108706. this._removeFactorGradient(this._emitRateGradients, gradient);
  108707. return this;
  108708. };
  108709. ParticleSystem.prototype._createRampGradientTexture = function () {
  108710. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  108711. return;
  108712. }
  108713. var data = new Uint8Array(this._rawTextureWidth * 4);
  108714. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  108715. for (var x = 0; x < this._rawTextureWidth; x++) {
  108716. var ratio = x / this._rawTextureWidth;
  108717. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  108718. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  108719. data[x * 4] = tmpColor.r * 255;
  108720. data[x * 4 + 1] = tmpColor.g * 255;
  108721. data[x * 4 + 2] = tmpColor.b * 255;
  108722. data[x * 4 + 3] = 255;
  108723. });
  108724. }
  108725. 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);
  108726. };
  108727. /**
  108728. * Gets the current list of ramp gradients.
  108729. * You must use addRampGradient and removeRampGradient to udpate this list
  108730. * @returns the list of ramp gradients
  108731. */
  108732. ParticleSystem.prototype.getRampGradients = function () {
  108733. return this._rampGradients;
  108734. };
  108735. /**
  108736. * Adds a new ramp gradient used to remap particle colors
  108737. * @param gradient defines the gradient to use (between 0 and 1)
  108738. * @param color defines the color to affect to the specified gradient
  108739. * @returns the current particle system
  108740. */
  108741. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  108742. if (!this._rampGradients) {
  108743. this._rampGradients = [];
  108744. }
  108745. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  108746. rampGradient.gradient = gradient;
  108747. rampGradient.color = color;
  108748. this._rampGradients.push(rampGradient);
  108749. this._rampGradients.sort(function (a, b) {
  108750. if (a.gradient < b.gradient) {
  108751. return -1;
  108752. }
  108753. else if (a.gradient > b.gradient) {
  108754. return 1;
  108755. }
  108756. return 0;
  108757. });
  108758. if (this._rampGradientsTexture) {
  108759. this._rampGradientsTexture.dispose();
  108760. this._rampGradientsTexture = null;
  108761. }
  108762. this._createRampGradientTexture();
  108763. return this;
  108764. };
  108765. /**
  108766. * Remove a specific ramp gradient
  108767. * @param gradient defines the gradient to remove
  108768. * @returns the current particle system
  108769. */
  108770. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  108771. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  108772. this._rampGradientsTexture = null;
  108773. if (this._rampGradients && this._rampGradients.length > 0) {
  108774. this._createRampGradientTexture();
  108775. }
  108776. return this;
  108777. };
  108778. /**
  108779. * Adds a new color gradient
  108780. * @param gradient defines the gradient to use (between 0 and 1)
  108781. * @param color1 defines the color to affect to the specified gradient
  108782. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108783. * @returns this particle system
  108784. */
  108785. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  108786. if (!this._colorGradients) {
  108787. this._colorGradients = [];
  108788. }
  108789. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  108790. colorGradient.gradient = gradient;
  108791. colorGradient.color1 = color1;
  108792. colorGradient.color2 = color2;
  108793. this._colorGradients.push(colorGradient);
  108794. this._colorGradients.sort(function (a, b) {
  108795. if (a.gradient < b.gradient) {
  108796. return -1;
  108797. }
  108798. else if (a.gradient > b.gradient) {
  108799. return 1;
  108800. }
  108801. return 0;
  108802. });
  108803. return this;
  108804. };
  108805. /**
  108806. * Remove a specific color gradient
  108807. * @param gradient defines the gradient to remove
  108808. * @returns this particle system
  108809. */
  108810. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  108811. if (!this._colorGradients) {
  108812. return this;
  108813. }
  108814. var index = 0;
  108815. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  108816. var colorGradient = _a[_i];
  108817. if (colorGradient.gradient === gradient) {
  108818. this._colorGradients.splice(index, 1);
  108819. break;
  108820. }
  108821. index++;
  108822. }
  108823. return this;
  108824. };
  108825. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  108826. u = Math.abs(u) * 0.5 + 0.5;
  108827. v = Math.abs(v) * 0.5 + 0.5;
  108828. var wrappedU = ((u * width) % width) | 0;
  108829. var wrappedV = ((v * height) % height) | 0;
  108830. var position = (wrappedU + wrappedV * width) * 4;
  108831. return pixels[position] / 255;
  108832. };
  108833. ParticleSystem.prototype._reset = function () {
  108834. this._resetEffect();
  108835. };
  108836. ParticleSystem.prototype._resetEffect = function () {
  108837. if (this._vertexBuffer) {
  108838. this._vertexBuffer.dispose();
  108839. this._vertexBuffer = null;
  108840. }
  108841. if (this._spriteBuffer) {
  108842. this._spriteBuffer.dispose();
  108843. this._spriteBuffer = null;
  108844. }
  108845. this._createVertexBuffers();
  108846. };
  108847. ParticleSystem.prototype._createVertexBuffers = function () {
  108848. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  108849. if (this._isAnimationSheetEnabled) {
  108850. this._vertexBufferSize += 1;
  108851. }
  108852. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  108853. this._vertexBufferSize += 3;
  108854. }
  108855. if (this._useRampGradients) {
  108856. this._vertexBufferSize += 4;
  108857. }
  108858. var engine = this._scene.getEngine();
  108859. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  108860. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  108861. var dataOffset = 0;
  108862. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  108863. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  108864. dataOffset += 3;
  108865. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  108866. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  108867. dataOffset += 4;
  108868. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  108869. this._vertexBuffers["angle"] = options;
  108870. dataOffset += 1;
  108871. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  108872. this._vertexBuffers["size"] = size;
  108873. dataOffset += 2;
  108874. if (this._isAnimationSheetEnabled) {
  108875. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  108876. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  108877. dataOffset += 1;
  108878. }
  108879. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  108880. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  108881. this._vertexBuffers["direction"] = directionBuffer;
  108882. dataOffset += 3;
  108883. }
  108884. if (this._useRampGradients) {
  108885. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  108886. this._vertexBuffers["remapData"] = rampDataBuffer;
  108887. dataOffset += 4;
  108888. }
  108889. var offsets;
  108890. if (this._useInstancing) {
  108891. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  108892. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  108893. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  108894. }
  108895. else {
  108896. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  108897. dataOffset += 2;
  108898. }
  108899. this._vertexBuffers["offset"] = offsets;
  108900. };
  108901. ParticleSystem.prototype._createIndexBuffer = function () {
  108902. if (this._useInstancing) {
  108903. return;
  108904. }
  108905. var indices = [];
  108906. var index = 0;
  108907. for (var count = 0; count < this._capacity; count++) {
  108908. indices.push(index);
  108909. indices.push(index + 1);
  108910. indices.push(index + 2);
  108911. indices.push(index);
  108912. indices.push(index + 2);
  108913. indices.push(index + 3);
  108914. index += 4;
  108915. }
  108916. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  108917. };
  108918. /**
  108919. * Gets the maximum number of particles active at the same time.
  108920. * @returns The max number of active particles.
  108921. */
  108922. ParticleSystem.prototype.getCapacity = function () {
  108923. return this._capacity;
  108924. };
  108925. /**
  108926. * Gets whether there are still active particles in the system.
  108927. * @returns True if it is alive, otherwise false.
  108928. */
  108929. ParticleSystem.prototype.isAlive = function () {
  108930. return this._alive;
  108931. };
  108932. /**
  108933. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108934. * @returns True if it has been started, otherwise false.
  108935. */
  108936. ParticleSystem.prototype.isStarted = function () {
  108937. return this._started;
  108938. };
  108939. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  108940. var _this = this;
  108941. this._subEmitters = new Array();
  108942. if (this.subEmitters) {
  108943. this.subEmitters.forEach(function (subEmitter) {
  108944. if (subEmitter instanceof ParticleSystem) {
  108945. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  108946. }
  108947. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  108948. _this._subEmitters.push([subEmitter]);
  108949. }
  108950. else if (subEmitter instanceof Array) {
  108951. _this._subEmitters.push(subEmitter);
  108952. }
  108953. });
  108954. }
  108955. };
  108956. /**
  108957. * Starts the particle system and begins to emit
  108958. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108959. */
  108960. ParticleSystem.prototype.start = function (delay) {
  108961. var _this = this;
  108962. if (delay === void 0) { delay = this.startDelay; }
  108963. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  108964. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  108965. }
  108966. if (delay) {
  108967. setTimeout(function () {
  108968. _this.start(0);
  108969. }, delay);
  108970. return;
  108971. }
  108972. // Convert the subEmitters field to the constant type field _subEmitters
  108973. this._prepareSubEmitterInternalArray();
  108974. this._started = true;
  108975. this._stopped = false;
  108976. this._actualFrame = 0;
  108977. if (this._subEmitters && this._subEmitters.length != 0) {
  108978. this.activeSubSystems = new Array();
  108979. }
  108980. // Reset emit gradient so it acts the same on every start
  108981. if (this._emitRateGradients) {
  108982. if (this._emitRateGradients.length > 0) {
  108983. this._currentEmitRateGradient = this._emitRateGradients[0];
  108984. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  108985. this._currentEmitRate2 = this._currentEmitRate1;
  108986. }
  108987. if (this._emitRateGradients.length > 1) {
  108988. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  108989. }
  108990. }
  108991. // Reset start size gradient so it acts the same on every start
  108992. if (this._startSizeGradients) {
  108993. if (this._startSizeGradients.length > 0) {
  108994. this._currentStartSizeGradient = this._startSizeGradients[0];
  108995. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  108996. this._currentStartSize2 = this._currentStartSize1;
  108997. }
  108998. if (this._startSizeGradients.length > 1) {
  108999. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  109000. }
  109001. }
  109002. if (this.preWarmCycles) {
  109003. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  109004. this.emitter.computeWorldMatrix(true);
  109005. }
  109006. var noiseTextureAsProcedural_1 = this.noiseTexture;
  109007. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  109008. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  109009. setTimeout(function () {
  109010. for (var index = 0; index < _this.preWarmCycles; index++) {
  109011. _this.animate(true);
  109012. noiseTextureAsProcedural_1.render();
  109013. }
  109014. });
  109015. });
  109016. }
  109017. else {
  109018. for (var index = 0; index < this.preWarmCycles; index++) {
  109019. this.animate(true);
  109020. }
  109021. }
  109022. }
  109023. // Animations
  109024. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  109025. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  109026. }
  109027. };
  109028. /**
  109029. * Stops the particle system.
  109030. * @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.
  109031. */
  109032. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  109033. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  109034. this._stopped = true;
  109035. if (stopSubEmitters) {
  109036. this._stopSubEmitters();
  109037. }
  109038. };
  109039. // animation sheet
  109040. /**
  109041. * Remove all active particles
  109042. */
  109043. ParticleSystem.prototype.reset = function () {
  109044. this._stockParticles = [];
  109045. this._particles = [];
  109046. };
  109047. /**
  109048. * @hidden (for internal use only)
  109049. */
  109050. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  109051. var offset = index * this._vertexBufferSize;
  109052. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  109053. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  109054. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  109055. this._vertexData[offset++] = particle.color.r;
  109056. this._vertexData[offset++] = particle.color.g;
  109057. this._vertexData[offset++] = particle.color.b;
  109058. this._vertexData[offset++] = particle.color.a;
  109059. this._vertexData[offset++] = particle.angle;
  109060. this._vertexData[offset++] = particle.scale.x * particle.size;
  109061. this._vertexData[offset++] = particle.scale.y * particle.size;
  109062. if (this._isAnimationSheetEnabled) {
  109063. this._vertexData[offset++] = particle.cellIndex;
  109064. }
  109065. if (!this._isBillboardBased) {
  109066. if (particle._initialDirection) {
  109067. this._vertexData[offset++] = particle._initialDirection.x;
  109068. this._vertexData[offset++] = particle._initialDirection.y;
  109069. this._vertexData[offset++] = particle._initialDirection.z;
  109070. }
  109071. else {
  109072. this._vertexData[offset++] = particle.direction.x;
  109073. this._vertexData[offset++] = particle.direction.y;
  109074. this._vertexData[offset++] = particle.direction.z;
  109075. }
  109076. }
  109077. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  109078. this._vertexData[offset++] = particle.direction.x;
  109079. this._vertexData[offset++] = particle.direction.y;
  109080. this._vertexData[offset++] = particle.direction.z;
  109081. }
  109082. if (this._useRampGradients) {
  109083. this._vertexData[offset++] = particle.remapData.x;
  109084. this._vertexData[offset++] = particle.remapData.y;
  109085. this._vertexData[offset++] = particle.remapData.z;
  109086. this._vertexData[offset++] = particle.remapData.w;
  109087. }
  109088. if (!this._useInstancing) {
  109089. if (this._isAnimationSheetEnabled) {
  109090. if (offsetX === 0) {
  109091. offsetX = this._epsilon;
  109092. }
  109093. else if (offsetX === 1) {
  109094. offsetX = 1 - this._epsilon;
  109095. }
  109096. if (offsetY === 0) {
  109097. offsetY = this._epsilon;
  109098. }
  109099. else if (offsetY === 1) {
  109100. offsetY = 1 - this._epsilon;
  109101. }
  109102. }
  109103. this._vertexData[offset++] = offsetX;
  109104. this._vertexData[offset++] = offsetY;
  109105. }
  109106. };
  109107. ParticleSystem.prototype._stopSubEmitters = function () {
  109108. if (!this.activeSubSystems) {
  109109. return;
  109110. }
  109111. this.activeSubSystems.forEach(function (subSystem) {
  109112. subSystem.stop(true);
  109113. });
  109114. this.activeSubSystems = new Array();
  109115. };
  109116. ParticleSystem.prototype._removeFromRoot = function () {
  109117. if (!this._rootParticleSystem) {
  109118. return;
  109119. }
  109120. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  109121. if (index !== -1) {
  109122. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  109123. }
  109124. this._rootParticleSystem = null;
  109125. };
  109126. // End of sub system methods
  109127. ParticleSystem.prototype._update = function (newParticles) {
  109128. var _this = this;
  109129. // Update current
  109130. this._alive = this._particles.length > 0;
  109131. if (this.emitter.position) {
  109132. var emitterMesh = this.emitter;
  109133. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  109134. }
  109135. else {
  109136. var emitterPosition = this.emitter;
  109137. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  109138. }
  109139. this.updateFunction(this._particles);
  109140. // Add new ones
  109141. var particle;
  109142. var _loop_2 = function () {
  109143. if (this_1._particles.length === this_1._capacity) {
  109144. return "break";
  109145. }
  109146. particle = this_1._createParticle();
  109147. this_1._particles.push(particle);
  109148. // Emitter
  109149. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  109150. if (this_1.startPositionFunction) {
  109151. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  109152. }
  109153. else {
  109154. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  109155. }
  109156. if (this_1.startDirectionFunction) {
  109157. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  109158. }
  109159. else {
  109160. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  109161. }
  109162. if (emitPower === 0) {
  109163. if (!particle._initialDirection) {
  109164. particle._initialDirection = particle.direction.clone();
  109165. }
  109166. else {
  109167. particle._initialDirection.copyFrom(particle.direction);
  109168. }
  109169. }
  109170. else {
  109171. particle._initialDirection = null;
  109172. }
  109173. particle.direction.scaleInPlace(emitPower);
  109174. // Life time
  109175. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  109176. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  109177. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  109178. var factorGradient1 = currentGradient;
  109179. var factorGradient2 = nextGradient;
  109180. var lifeTime1 = factorGradient1.getFactor();
  109181. var lifeTime2 = factorGradient2.getFactor();
  109182. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  109183. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  109184. });
  109185. }
  109186. else {
  109187. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  109188. }
  109189. // Size
  109190. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  109191. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  109192. }
  109193. else {
  109194. particle._currentSizeGradient = this_1._sizeGradients[0];
  109195. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  109196. particle.size = particle._currentSize1;
  109197. if (this_1._sizeGradients.length > 1) {
  109198. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  109199. }
  109200. else {
  109201. particle._currentSize2 = particle._currentSize1;
  109202. }
  109203. }
  109204. // Size and scale
  109205. 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));
  109206. // Adjust scale by start size
  109207. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  109208. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  109209. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  109210. if (currentGradient !== _this._currentStartSizeGradient) {
  109211. _this._currentStartSize1 = _this._currentStartSize2;
  109212. _this._currentStartSize2 = nextGradient.getFactor();
  109213. _this._currentStartSizeGradient = currentGradient;
  109214. }
  109215. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  109216. particle.scale.scaleInPlace(value);
  109217. });
  109218. }
  109219. // Angle
  109220. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  109221. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  109222. }
  109223. else {
  109224. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  109225. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  109226. particle._currentAngularSpeed1 = particle.angularSpeed;
  109227. if (this_1._angularSpeedGradients.length > 1) {
  109228. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  109229. }
  109230. else {
  109231. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  109232. }
  109233. }
  109234. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  109235. // Velocity
  109236. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  109237. particle._currentVelocityGradient = this_1._velocityGradients[0];
  109238. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  109239. if (this_1._velocityGradients.length > 1) {
  109240. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  109241. }
  109242. else {
  109243. particle._currentVelocity2 = particle._currentVelocity1;
  109244. }
  109245. }
  109246. // Limit velocity
  109247. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  109248. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  109249. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  109250. if (this_1._limitVelocityGradients.length > 1) {
  109251. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  109252. }
  109253. else {
  109254. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  109255. }
  109256. }
  109257. // Drag
  109258. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  109259. particle._currentDragGradient = this_1._dragGradients[0];
  109260. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  109261. if (this_1._dragGradients.length > 1) {
  109262. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  109263. }
  109264. else {
  109265. particle._currentDrag2 = particle._currentDrag1;
  109266. }
  109267. }
  109268. // Color
  109269. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  109270. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  109271. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  109272. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  109273. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  109274. }
  109275. else {
  109276. particle._currentColorGradient = this_1._colorGradients[0];
  109277. particle._currentColorGradient.getColorToRef(particle.color);
  109278. particle._currentColor1.copyFrom(particle.color);
  109279. if (this_1._colorGradients.length > 1) {
  109280. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  109281. }
  109282. else {
  109283. particle._currentColor2.copyFrom(particle.color);
  109284. }
  109285. }
  109286. // Sheet
  109287. if (this_1._isAnimationSheetEnabled) {
  109288. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  109289. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  109290. }
  109291. // Inherited Velocity
  109292. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  109293. // Ramp
  109294. if (this_1._useRampGradients) {
  109295. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  109296. }
  109297. // Noise texture coordinates
  109298. if (this_1.noiseTexture) {
  109299. if (particle._randomNoiseCoordinates1) {
  109300. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  109301. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  109302. }
  109303. else {
  109304. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  109305. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  109306. }
  109307. }
  109308. // Update the position of the attached sub-emitters to match their attached particle
  109309. particle._inheritParticleInfoToSubEmitters();
  109310. };
  109311. var this_1 = this, step;
  109312. for (var index = 0; index < newParticles; index++) {
  109313. var state_1 = _loop_2();
  109314. if (state_1 === "break")
  109315. break;
  109316. }
  109317. };
  109318. /** @hidden */
  109319. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  109320. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  109321. if (isBillboardBased === void 0) { isBillboardBased = false; }
  109322. if (useRampGradients === void 0) { useRampGradients = false; }
  109323. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  109324. if (isAnimationSheetEnabled) {
  109325. attributeNamesOrOptions.push("cellIndex");
  109326. }
  109327. if (!isBillboardBased) {
  109328. attributeNamesOrOptions.push("direction");
  109329. }
  109330. if (useRampGradients) {
  109331. attributeNamesOrOptions.push("remapData");
  109332. }
  109333. return attributeNamesOrOptions;
  109334. };
  109335. /** @hidden */
  109336. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  109337. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  109338. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  109339. if (isAnimationSheetEnabled) {
  109340. effectCreationOption.push("particlesInfos");
  109341. }
  109342. return effectCreationOption;
  109343. };
  109344. /** @hidden */
  109345. ParticleSystem.prototype._getEffect = function (blendMode) {
  109346. if (this._customEffect) {
  109347. return this._customEffect;
  109348. }
  109349. var defines = [];
  109350. if (this._scene.clipPlane) {
  109351. defines.push("#define CLIPPLANE");
  109352. }
  109353. if (this._scene.clipPlane2) {
  109354. defines.push("#define CLIPPLANE2");
  109355. }
  109356. if (this._scene.clipPlane3) {
  109357. defines.push("#define CLIPPLANE3");
  109358. }
  109359. if (this._scene.clipPlane4) {
  109360. defines.push("#define CLIPPLANE4");
  109361. }
  109362. if (this._isAnimationSheetEnabled) {
  109363. defines.push("#define ANIMATESHEET");
  109364. }
  109365. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  109366. defines.push("#define BLENDMULTIPLYMODE");
  109367. }
  109368. if (this._useRampGradients) {
  109369. defines.push("#define RAMPGRADIENT");
  109370. }
  109371. if (this._isBillboardBased) {
  109372. defines.push("#define BILLBOARD");
  109373. switch (this.billboardMode) {
  109374. case ParticleSystem.BILLBOARDMODE_Y:
  109375. defines.push("#define BILLBOARDY");
  109376. break;
  109377. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  109378. defines.push("#define BILLBOARDSTRETCHED");
  109379. break;
  109380. case ParticleSystem.BILLBOARDMODE_ALL:
  109381. default:
  109382. break;
  109383. }
  109384. }
  109385. if (this._imageProcessingConfiguration) {
  109386. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  109387. defines.push(this._imageProcessingConfigurationDefines.toString());
  109388. }
  109389. // Effect
  109390. var join = defines.join("\n");
  109391. if (this._cachedDefines !== join) {
  109392. this._cachedDefines = join;
  109393. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  109394. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  109395. var samplers = ["diffuseSampler", "rampSampler"];
  109396. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  109397. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  109398. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  109399. }
  109400. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  109401. }
  109402. return this._effect;
  109403. };
  109404. /**
  109405. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  109406. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  109407. */
  109408. ParticleSystem.prototype.animate = function (preWarmOnly) {
  109409. var _this = this;
  109410. if (preWarmOnly === void 0) { preWarmOnly = false; }
  109411. if (!this._started) {
  109412. return;
  109413. }
  109414. if (!preWarmOnly) {
  109415. // Check
  109416. if (!this.isReady()) {
  109417. return;
  109418. }
  109419. if (this._currentRenderId === this._scene.getFrameId()) {
  109420. return;
  109421. }
  109422. this._currentRenderId = this._scene.getFrameId();
  109423. }
  109424. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  109425. // Determine the number of particles we need to create
  109426. var newParticles;
  109427. if (this.manualEmitCount > -1) {
  109428. newParticles = this.manualEmitCount;
  109429. this._newPartsExcess = 0;
  109430. this.manualEmitCount = 0;
  109431. }
  109432. else {
  109433. var rate_1 = this.emitRate;
  109434. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  109435. var ratio = this._actualFrame / this.targetStopDuration;
  109436. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  109437. if (currentGradient !== _this._currentEmitRateGradient) {
  109438. _this._currentEmitRate1 = _this._currentEmitRate2;
  109439. _this._currentEmitRate2 = nextGradient.getFactor();
  109440. _this._currentEmitRateGradient = currentGradient;
  109441. }
  109442. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  109443. });
  109444. }
  109445. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  109446. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  109447. }
  109448. if (this._newPartsExcess > 1.0) {
  109449. newParticles += this._newPartsExcess >> 0;
  109450. this._newPartsExcess -= this._newPartsExcess >> 0;
  109451. }
  109452. this._alive = false;
  109453. if (!this._stopped) {
  109454. this._actualFrame += this._scaledUpdateSpeed;
  109455. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  109456. this.stop();
  109457. }
  109458. }
  109459. else {
  109460. newParticles = 0;
  109461. }
  109462. this._update(newParticles);
  109463. // Stopped?
  109464. if (this._stopped) {
  109465. if (!this._alive) {
  109466. this._started = false;
  109467. if (this.onAnimationEnd) {
  109468. this.onAnimationEnd();
  109469. }
  109470. if (this.disposeOnStop) {
  109471. this._scene._toBeDisposed.push(this);
  109472. }
  109473. }
  109474. }
  109475. if (!preWarmOnly) {
  109476. // Update VBO
  109477. var offset = 0;
  109478. for (var index = 0; index < this._particles.length; index++) {
  109479. var particle = this._particles[index];
  109480. this._appendParticleVertices(offset, particle);
  109481. offset += this._useInstancing ? 1 : 4;
  109482. }
  109483. if (this._vertexBuffer) {
  109484. this._vertexBuffer.update(this._vertexData);
  109485. }
  109486. }
  109487. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  109488. this.stop();
  109489. }
  109490. };
  109491. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  109492. this._appendParticleVertex(offset++, particle, 0, 0);
  109493. if (!this._useInstancing) {
  109494. this._appendParticleVertex(offset++, particle, 1, 0);
  109495. this._appendParticleVertex(offset++, particle, 1, 1);
  109496. this._appendParticleVertex(offset++, particle, 0, 1);
  109497. }
  109498. };
  109499. /**
  109500. * Rebuilds the particle system.
  109501. */
  109502. ParticleSystem.prototype.rebuild = function () {
  109503. this._createIndexBuffer();
  109504. if (this._vertexBuffer) {
  109505. this._vertexBuffer._rebuild();
  109506. }
  109507. };
  109508. /**
  109509. * Is this system ready to be used/rendered
  109510. * @return true if the system is ready
  109511. */
  109512. ParticleSystem.prototype.isReady = function () {
  109513. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  109514. return false;
  109515. }
  109516. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  109517. if (!this._getEffect(this.blendMode).isReady()) {
  109518. return false;
  109519. }
  109520. }
  109521. else {
  109522. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  109523. return false;
  109524. }
  109525. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  109526. return false;
  109527. }
  109528. }
  109529. return true;
  109530. };
  109531. ParticleSystem.prototype._render = function (blendMode) {
  109532. var effect = this._getEffect(blendMode);
  109533. var engine = this._scene.getEngine();
  109534. // Render
  109535. engine.enableEffect(effect);
  109536. var viewMatrix = this._scene.getViewMatrix();
  109537. effect.setTexture("diffuseSampler", this.particleTexture);
  109538. effect.setMatrix("view", viewMatrix);
  109539. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  109540. if (this._isAnimationSheetEnabled && this.particleTexture) {
  109541. var baseSize = this.particleTexture.getBaseSize();
  109542. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  109543. }
  109544. effect.setVector2("translationPivot", this.translationPivot);
  109545. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  109546. if (this._isBillboardBased) {
  109547. var camera = this._scene.activeCamera;
  109548. effect.setVector3("eyePosition", camera.globalPosition);
  109549. }
  109550. if (this._rampGradientsTexture) {
  109551. effect.setTexture("rampSampler", this._rampGradientsTexture);
  109552. }
  109553. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  109554. var invView = viewMatrix.clone();
  109555. invView.invert();
  109556. effect.setMatrix("invView", invView);
  109557. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  109558. }
  109559. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  109560. // image processing
  109561. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  109562. this._imageProcessingConfiguration.bind(effect);
  109563. }
  109564. // Draw order
  109565. switch (blendMode) {
  109566. case ParticleSystem.BLENDMODE_ADD:
  109567. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  109568. break;
  109569. case ParticleSystem.BLENDMODE_ONEONE:
  109570. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  109571. break;
  109572. case ParticleSystem.BLENDMODE_STANDARD:
  109573. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  109574. break;
  109575. case ParticleSystem.BLENDMODE_MULTIPLY:
  109576. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  109577. break;
  109578. }
  109579. if (this._useInstancing) {
  109580. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  109581. }
  109582. else {
  109583. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  109584. }
  109585. return this._particles.length;
  109586. };
  109587. /**
  109588. * Renders the particle system in its current state.
  109589. * @returns the current number of particles
  109590. */
  109591. ParticleSystem.prototype.render = function () {
  109592. // Check
  109593. if (!this.isReady() || !this._particles.length) {
  109594. return 0;
  109595. }
  109596. var engine = this._scene.getEngine();
  109597. engine.setState(false);
  109598. if (this.forceDepthWrite) {
  109599. engine.setDepthWrite(true);
  109600. }
  109601. var outparticles = 0;
  109602. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  109603. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  109604. }
  109605. outparticles = this._render(this.blendMode);
  109606. engine.unbindInstanceAttributes();
  109607. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  109608. return outparticles;
  109609. };
  109610. /**
  109611. * Disposes the particle system and free the associated resources
  109612. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  109613. */
  109614. ParticleSystem.prototype.dispose = function (disposeTexture) {
  109615. if (disposeTexture === void 0) { disposeTexture = true; }
  109616. if (this._vertexBuffer) {
  109617. this._vertexBuffer.dispose();
  109618. this._vertexBuffer = null;
  109619. }
  109620. if (this._spriteBuffer) {
  109621. this._spriteBuffer.dispose();
  109622. this._spriteBuffer = null;
  109623. }
  109624. if (this._indexBuffer) {
  109625. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  109626. this._indexBuffer = null;
  109627. }
  109628. if (disposeTexture && this.particleTexture) {
  109629. this.particleTexture.dispose();
  109630. this.particleTexture = null;
  109631. }
  109632. if (disposeTexture && this.noiseTexture) {
  109633. this.noiseTexture.dispose();
  109634. this.noiseTexture = null;
  109635. }
  109636. if (this._rampGradientsTexture) {
  109637. this._rampGradientsTexture.dispose();
  109638. this._rampGradientsTexture = null;
  109639. }
  109640. this._removeFromRoot();
  109641. if (this._subEmitters && this._subEmitters.length) {
  109642. for (var index = 0; index < this._subEmitters.length; index++) {
  109643. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  109644. var subEmitter = _a[_i];
  109645. subEmitter.dispose();
  109646. }
  109647. }
  109648. this._subEmitters = [];
  109649. this.subEmitters = [];
  109650. }
  109651. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  109652. this.emitter.dispose(true);
  109653. }
  109654. // Remove from scene
  109655. var index = this._scene.particleSystems.indexOf(this);
  109656. if (index > -1) {
  109657. this._scene.particleSystems.splice(index, 1);
  109658. }
  109659. this._scene._activeParticleSystems.dispose();
  109660. // Callback
  109661. this.onDisposeObservable.notifyObservers(this);
  109662. this.onDisposeObservable.clear();
  109663. this.reset();
  109664. };
  109665. // Clone
  109666. /**
  109667. * Clones the particle system.
  109668. * @param name The name of the cloned object
  109669. * @param newEmitter The new emitter to use
  109670. * @returns the cloned particle system
  109671. */
  109672. ParticleSystem.prototype.clone = function (name, newEmitter) {
  109673. var custom = null;
  109674. var program = null;
  109675. if (this.customShader != null) {
  109676. program = this.customShader;
  109677. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  109678. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  109679. }
  109680. else if (this._customEffect) {
  109681. custom = this._customEffect;
  109682. }
  109683. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  109684. result.customShader = program;
  109685. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  109686. if (newEmitter === undefined) {
  109687. newEmitter = this.emitter;
  109688. }
  109689. result.noiseTexture = this.noiseTexture;
  109690. result.emitter = newEmitter;
  109691. if (this.particleTexture) {
  109692. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  109693. }
  109694. // Clone gradients
  109695. if (this._colorGradients) {
  109696. this._colorGradients.forEach(function (v) {
  109697. result.addColorGradient(v.gradient, v.color1, v.color2);
  109698. });
  109699. }
  109700. if (this._dragGradients) {
  109701. this._dragGradients.forEach(function (v) {
  109702. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  109703. });
  109704. }
  109705. if (this._angularSpeedGradients) {
  109706. this._angularSpeedGradients.forEach(function (v) {
  109707. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  109708. });
  109709. }
  109710. if (this._emitRateGradients) {
  109711. this._emitRateGradients.forEach(function (v) {
  109712. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  109713. });
  109714. }
  109715. if (this._lifeTimeGradients) {
  109716. this._lifeTimeGradients.forEach(function (v) {
  109717. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  109718. });
  109719. }
  109720. if (this._limitVelocityGradients) {
  109721. this._limitVelocityGradients.forEach(function (v) {
  109722. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  109723. });
  109724. }
  109725. if (this._sizeGradients) {
  109726. this._sizeGradients.forEach(function (v) {
  109727. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  109728. });
  109729. }
  109730. if (this._startSizeGradients) {
  109731. this._startSizeGradients.forEach(function (v) {
  109732. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  109733. });
  109734. }
  109735. if (this._velocityGradients) {
  109736. this._velocityGradients.forEach(function (v) {
  109737. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  109738. });
  109739. }
  109740. if (this._rampGradients) {
  109741. this._rampGradients.forEach(function (v) {
  109742. result.addRampGradient(v.gradient, v.color);
  109743. });
  109744. }
  109745. if (this._colorRemapGradients) {
  109746. this._colorRemapGradients.forEach(function (v) {
  109747. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  109748. });
  109749. }
  109750. if (this._alphaRemapGradients) {
  109751. this._alphaRemapGradients.forEach(function (v) {
  109752. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  109753. });
  109754. }
  109755. if (!this.preventAutoStart) {
  109756. result.start();
  109757. }
  109758. return result;
  109759. };
  109760. /**
  109761. * Serializes the particle system to a JSON object.
  109762. * @returns the JSON object
  109763. */
  109764. ParticleSystem.prototype.serialize = function () {
  109765. var serializationObject = {};
  109766. ParticleSystem._Serialize(serializationObject, this);
  109767. serializationObject.textureMask = this.textureMask.asArray();
  109768. serializationObject.customShader = this.customShader;
  109769. serializationObject.preventAutoStart = this.preventAutoStart;
  109770. // SubEmitters
  109771. if (this.subEmitters) {
  109772. serializationObject.subEmitters = [];
  109773. if (!this._subEmitters) {
  109774. this._prepareSubEmitterInternalArray();
  109775. }
  109776. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  109777. var subs = _a[_i];
  109778. var cell = [];
  109779. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  109780. var sub = subs_1[_b];
  109781. cell.push(sub.serialize());
  109782. }
  109783. serializationObject.subEmitters.push(cell);
  109784. }
  109785. }
  109786. return serializationObject;
  109787. };
  109788. /** @hidden */
  109789. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  109790. serializationObject.name = particleSystem.name;
  109791. serializationObject.id = particleSystem.id;
  109792. serializationObject.capacity = particleSystem.getCapacity();
  109793. // Emitter
  109794. if (particleSystem.emitter.position) {
  109795. var emitterMesh = particleSystem.emitter;
  109796. serializationObject.emitterId = emitterMesh.id;
  109797. }
  109798. else {
  109799. var emitterPosition = particleSystem.emitter;
  109800. serializationObject.emitter = emitterPosition.asArray();
  109801. }
  109802. // Emitter
  109803. if (particleSystem.particleEmitterType) {
  109804. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  109805. }
  109806. if (particleSystem.particleTexture) {
  109807. serializationObject.textureName = particleSystem.particleTexture.name;
  109808. serializationObject.invertY = particleSystem.particleTexture._invertY;
  109809. }
  109810. // Animations
  109811. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  109812. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  109813. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  109814. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  109815. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  109816. // Particle system
  109817. serializationObject.startDelay = particleSystem.startDelay;
  109818. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  109819. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  109820. serializationObject.billboardMode = particleSystem.billboardMode;
  109821. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  109822. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  109823. serializationObject.minSize = particleSystem.minSize;
  109824. serializationObject.maxSize = particleSystem.maxSize;
  109825. serializationObject.minScaleX = particleSystem.minScaleX;
  109826. serializationObject.maxScaleX = particleSystem.maxScaleX;
  109827. serializationObject.minScaleY = particleSystem.minScaleY;
  109828. serializationObject.maxScaleY = particleSystem.maxScaleY;
  109829. serializationObject.minEmitPower = particleSystem.minEmitPower;
  109830. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  109831. serializationObject.minLifeTime = particleSystem.minLifeTime;
  109832. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  109833. serializationObject.emitRate = particleSystem.emitRate;
  109834. serializationObject.gravity = particleSystem.gravity.asArray();
  109835. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  109836. serializationObject.color1 = particleSystem.color1.asArray();
  109837. serializationObject.color2 = particleSystem.color2.asArray();
  109838. serializationObject.colorDead = particleSystem.colorDead.asArray();
  109839. serializationObject.updateSpeed = particleSystem.updateSpeed;
  109840. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  109841. serializationObject.blendMode = particleSystem.blendMode;
  109842. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  109843. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  109844. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  109845. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  109846. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  109847. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  109848. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  109849. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  109850. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  109851. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  109852. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  109853. var colorGradients = particleSystem.getColorGradients();
  109854. if (colorGradients) {
  109855. serializationObject.colorGradients = [];
  109856. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  109857. var colorGradient = colorGradients_1[_i];
  109858. var serializedGradient = {
  109859. gradient: colorGradient.gradient,
  109860. color1: colorGradient.color1.asArray()
  109861. };
  109862. if (colorGradient.color2) {
  109863. serializedGradient.color2 = colorGradient.color2.asArray();
  109864. }
  109865. serializationObject.colorGradients.push(serializedGradient);
  109866. }
  109867. }
  109868. var rampGradients = particleSystem.getRampGradients();
  109869. if (rampGradients) {
  109870. serializationObject.rampGradients = [];
  109871. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  109872. var rampGradient = rampGradients_1[_a];
  109873. var serializedGradient = {
  109874. gradient: rampGradient.gradient,
  109875. color: rampGradient.color.asArray()
  109876. };
  109877. serializationObject.rampGradients.push(serializedGradient);
  109878. }
  109879. serializationObject.useRampGradients = particleSystem.useRampGradients;
  109880. }
  109881. var colorRemapGradients = particleSystem.getColorRemapGradients();
  109882. if (colorRemapGradients) {
  109883. serializationObject.colorRemapGradients = [];
  109884. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  109885. var colorRemapGradient = colorRemapGradients_1[_b];
  109886. var serializedGradient = {
  109887. gradient: colorRemapGradient.gradient,
  109888. factor1: colorRemapGradient.factor1
  109889. };
  109890. if (colorRemapGradient.factor2 !== undefined) {
  109891. serializedGradient.factor2 = colorRemapGradient.factor2;
  109892. }
  109893. serializationObject.colorRemapGradients.push(serializedGradient);
  109894. }
  109895. }
  109896. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  109897. if (alphaRemapGradients) {
  109898. serializationObject.alphaRemapGradients = [];
  109899. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  109900. var alphaRemapGradient = alphaRemapGradients_1[_c];
  109901. var serializedGradient = {
  109902. gradient: alphaRemapGradient.gradient,
  109903. factor1: alphaRemapGradient.factor1
  109904. };
  109905. if (alphaRemapGradient.factor2 !== undefined) {
  109906. serializedGradient.factor2 = alphaRemapGradient.factor2;
  109907. }
  109908. serializationObject.alphaRemapGradients.push(serializedGradient);
  109909. }
  109910. }
  109911. var sizeGradients = particleSystem.getSizeGradients();
  109912. if (sizeGradients) {
  109913. serializationObject.sizeGradients = [];
  109914. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  109915. var sizeGradient = sizeGradients_1[_d];
  109916. var serializedGradient = {
  109917. gradient: sizeGradient.gradient,
  109918. factor1: sizeGradient.factor1
  109919. };
  109920. if (sizeGradient.factor2 !== undefined) {
  109921. serializedGradient.factor2 = sizeGradient.factor2;
  109922. }
  109923. serializationObject.sizeGradients.push(serializedGradient);
  109924. }
  109925. }
  109926. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  109927. if (angularSpeedGradients) {
  109928. serializationObject.angularSpeedGradients = [];
  109929. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  109930. var angularSpeedGradient = angularSpeedGradients_1[_e];
  109931. var serializedGradient = {
  109932. gradient: angularSpeedGradient.gradient,
  109933. factor1: angularSpeedGradient.factor1
  109934. };
  109935. if (angularSpeedGradient.factor2 !== undefined) {
  109936. serializedGradient.factor2 = angularSpeedGradient.factor2;
  109937. }
  109938. serializationObject.angularSpeedGradients.push(serializedGradient);
  109939. }
  109940. }
  109941. var velocityGradients = particleSystem.getVelocityGradients();
  109942. if (velocityGradients) {
  109943. serializationObject.velocityGradients = [];
  109944. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  109945. var velocityGradient = velocityGradients_1[_f];
  109946. var serializedGradient = {
  109947. gradient: velocityGradient.gradient,
  109948. factor1: velocityGradient.factor1
  109949. };
  109950. if (velocityGradient.factor2 !== undefined) {
  109951. serializedGradient.factor2 = velocityGradient.factor2;
  109952. }
  109953. serializationObject.velocityGradients.push(serializedGradient);
  109954. }
  109955. }
  109956. var dragGradients = particleSystem.getDragGradients();
  109957. if (dragGradients) {
  109958. serializationObject.dragyGradients = [];
  109959. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  109960. var dragGradient = dragGradients_1[_g];
  109961. var serializedGradient = {
  109962. gradient: dragGradient.gradient,
  109963. factor1: dragGradient.factor1
  109964. };
  109965. if (dragGradient.factor2 !== undefined) {
  109966. serializedGradient.factor2 = dragGradient.factor2;
  109967. }
  109968. serializationObject.dragGradients.push(serializedGradient);
  109969. }
  109970. }
  109971. var emitRateGradients = particleSystem.getEmitRateGradients();
  109972. if (emitRateGradients) {
  109973. serializationObject.emitRateGradients = [];
  109974. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  109975. var emitRateGradient = emitRateGradients_1[_h];
  109976. var serializedGradient = {
  109977. gradient: emitRateGradient.gradient,
  109978. factor1: emitRateGradient.factor1
  109979. };
  109980. if (emitRateGradient.factor2 !== undefined) {
  109981. serializedGradient.factor2 = emitRateGradient.factor2;
  109982. }
  109983. serializationObject.emitRateGradients.push(serializedGradient);
  109984. }
  109985. }
  109986. var startSizeGradients = particleSystem.getStartSizeGradients();
  109987. if (startSizeGradients) {
  109988. serializationObject.startSizeGradients = [];
  109989. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  109990. var startSizeGradient = startSizeGradients_1[_j];
  109991. var serializedGradient = {
  109992. gradient: startSizeGradient.gradient,
  109993. factor1: startSizeGradient.factor1
  109994. };
  109995. if (startSizeGradient.factor2 !== undefined) {
  109996. serializedGradient.factor2 = startSizeGradient.factor2;
  109997. }
  109998. serializationObject.startSizeGradients.push(serializedGradient);
  109999. }
  110000. }
  110001. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  110002. if (lifeTimeGradients) {
  110003. serializationObject.lifeTimeGradients = [];
  110004. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  110005. var lifeTimeGradient = lifeTimeGradients_1[_k];
  110006. var serializedGradient = {
  110007. gradient: lifeTimeGradient.gradient,
  110008. factor1: lifeTimeGradient.factor1
  110009. };
  110010. if (lifeTimeGradient.factor2 !== undefined) {
  110011. serializedGradient.factor2 = lifeTimeGradient.factor2;
  110012. }
  110013. serializationObject.lifeTimeGradients.push(serializedGradient);
  110014. }
  110015. }
  110016. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  110017. if (limitVelocityGradients) {
  110018. serializationObject.limitVelocityGradients = [];
  110019. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  110020. var limitVelocityGradient = limitVelocityGradients_1[_l];
  110021. var serializedGradient = {
  110022. gradient: limitVelocityGradient.gradient,
  110023. factor1: limitVelocityGradient.factor1
  110024. };
  110025. if (limitVelocityGradient.factor2 !== undefined) {
  110026. serializedGradient.factor2 = limitVelocityGradient.factor2;
  110027. }
  110028. serializationObject.limitVelocityGradients.push(serializedGradient);
  110029. }
  110030. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  110031. }
  110032. if (particleSystem.noiseTexture) {
  110033. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  110034. }
  110035. };
  110036. /** @hidden */
  110037. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  110038. // Texture
  110039. if (parsedParticleSystem.textureName) {
  110040. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  110041. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  110042. }
  110043. // Emitter
  110044. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  110045. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110046. }
  110047. else if (parsedParticleSystem.emitterId) {
  110048. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  110049. }
  110050. else {
  110051. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  110052. }
  110053. // Misc.
  110054. if (parsedParticleSystem.renderingGroupId !== undefined) {
  110055. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  110056. }
  110057. if (parsedParticleSystem.isBillboardBased !== undefined) {
  110058. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  110059. }
  110060. if (parsedParticleSystem.billboardMode !== undefined) {
  110061. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  110062. }
  110063. // Animations
  110064. if (parsedParticleSystem.animations) {
  110065. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  110066. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  110067. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  110068. if (internalClass) {
  110069. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  110070. }
  110071. }
  110072. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  110073. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  110074. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  110075. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  110076. }
  110077. if (parsedParticleSystem.autoAnimate) {
  110078. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  110079. }
  110080. // Particle system
  110081. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  110082. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  110083. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  110084. particleSystem.minSize = parsedParticleSystem.minSize;
  110085. particleSystem.maxSize = parsedParticleSystem.maxSize;
  110086. if (parsedParticleSystem.minScaleX) {
  110087. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  110088. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  110089. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  110090. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  110091. }
  110092. if (parsedParticleSystem.preWarmCycles !== undefined) {
  110093. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  110094. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  110095. }
  110096. if (parsedParticleSystem.minInitialRotation !== undefined) {
  110097. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  110098. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  110099. }
  110100. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  110101. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  110102. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  110103. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  110104. particleSystem.emitRate = parsedParticleSystem.emitRate;
  110105. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  110106. if (parsedParticleSystem.noiseStrength) {
  110107. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  110108. }
  110109. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  110110. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  110111. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  110112. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  110113. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  110114. particleSystem.blendMode = parsedParticleSystem.blendMode;
  110115. if (parsedParticleSystem.colorGradients) {
  110116. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  110117. var colorGradient = _a[_i];
  110118. 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);
  110119. }
  110120. }
  110121. if (parsedParticleSystem.rampGradients) {
  110122. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  110123. var rampGradient = _c[_b];
  110124. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  110125. }
  110126. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  110127. }
  110128. if (parsedParticleSystem.colorRemapGradients) {
  110129. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  110130. var colorRemapGradient = _e[_d];
  110131. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  110132. }
  110133. }
  110134. if (parsedParticleSystem.alphaRemapGradients) {
  110135. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  110136. var alphaRemapGradient = _g[_f];
  110137. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  110138. }
  110139. }
  110140. if (parsedParticleSystem.sizeGradients) {
  110141. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  110142. var sizeGradient = _j[_h];
  110143. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  110144. }
  110145. }
  110146. if (parsedParticleSystem.sizeGradients) {
  110147. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  110148. var sizeGradient = _l[_k];
  110149. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  110150. }
  110151. }
  110152. if (parsedParticleSystem.angularSpeedGradients) {
  110153. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  110154. var angularSpeedGradient = _o[_m];
  110155. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  110156. }
  110157. }
  110158. if (parsedParticleSystem.velocityGradients) {
  110159. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  110160. var velocityGradient = _q[_p];
  110161. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  110162. }
  110163. }
  110164. if (parsedParticleSystem.dragGradients) {
  110165. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  110166. var dragGradient = _s[_r];
  110167. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  110168. }
  110169. }
  110170. if (parsedParticleSystem.emitRateGradients) {
  110171. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  110172. var emitRateGradient = _u[_t];
  110173. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  110174. }
  110175. }
  110176. if (parsedParticleSystem.startSizeGradients) {
  110177. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  110178. var startSizeGradient = _w[_v];
  110179. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  110180. }
  110181. }
  110182. if (parsedParticleSystem.lifeTimeGradients) {
  110183. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  110184. var lifeTimeGradient = _y[_x];
  110185. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  110186. }
  110187. }
  110188. if (parsedParticleSystem.limitVelocityGradients) {
  110189. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  110190. var limitVelocityGradient = _0[_z];
  110191. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  110192. }
  110193. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  110194. }
  110195. if (parsedParticleSystem.noiseTexture) {
  110196. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  110197. }
  110198. // Emitter
  110199. var emitterType;
  110200. if (parsedParticleSystem.particleEmitterType) {
  110201. switch (parsedParticleSystem.particleEmitterType.type) {
  110202. case "SphereParticleEmitter":
  110203. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  110204. break;
  110205. case "SphereDirectedParticleEmitter":
  110206. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  110207. break;
  110208. case "ConeEmitter":
  110209. case "ConeParticleEmitter":
  110210. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  110211. break;
  110212. case "CylinderParticleEmitter":
  110213. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  110214. break;
  110215. case "HemisphericParticleEmitter":
  110216. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  110217. break;
  110218. case "BoxEmitter":
  110219. case "BoxParticleEmitter":
  110220. default:
  110221. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  110222. break;
  110223. }
  110224. emitterType.parse(parsedParticleSystem.particleEmitterType);
  110225. }
  110226. else {
  110227. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  110228. emitterType.parse(parsedParticleSystem);
  110229. }
  110230. particleSystem.particleEmitterType = emitterType;
  110231. // Animation sheet
  110232. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  110233. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  110234. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  110235. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  110236. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  110237. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  110238. };
  110239. /**
  110240. * Parses a JSON object to create a particle system.
  110241. * @param parsedParticleSystem The JSON object to parse
  110242. * @param scene The scene to create the particle system in
  110243. * @param rootUrl The root url to use to load external dependencies like texture
  110244. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110245. * @returns the Parsed particle system
  110246. */
  110247. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  110248. if (doNotStart === void 0) { doNotStart = false; }
  110249. var name = parsedParticleSystem.name;
  110250. var custom = null;
  110251. var program = null;
  110252. if (parsedParticleSystem.customShader) {
  110253. program = parsedParticleSystem.customShader;
  110254. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  110255. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  110256. }
  110257. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  110258. particleSystem.customShader = program;
  110259. if (parsedParticleSystem.id) {
  110260. particleSystem.id = parsedParticleSystem.id;
  110261. }
  110262. // SubEmitters
  110263. if (parsedParticleSystem.subEmitters) {
  110264. particleSystem.subEmitters = [];
  110265. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  110266. var cell = _a[_i];
  110267. var cellArray = [];
  110268. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  110269. var sub = cell_1[_b];
  110270. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  110271. }
  110272. particleSystem.subEmitters.push(cellArray);
  110273. }
  110274. }
  110275. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  110276. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  110277. // Auto start
  110278. if (parsedParticleSystem.preventAutoStart) {
  110279. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  110280. }
  110281. if (!doNotStart && !particleSystem.preventAutoStart) {
  110282. particleSystem.start();
  110283. }
  110284. return particleSystem;
  110285. };
  110286. /**
  110287. * Billboard mode will only apply to Y axis
  110288. */
  110289. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  110290. /**
  110291. * Billboard mode will apply to all axes
  110292. */
  110293. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  110294. /**
  110295. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  110296. */
  110297. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  110298. return ParticleSystem;
  110299. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  110300. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  110301. /***/ }),
  110302. /***/ "./Particles/particleSystemComponent.ts":
  110303. /*!**********************************************!*\
  110304. !*** ./Particles/particleSystemComponent.ts ***!
  110305. \**********************************************/
  110306. /*! exports provided: _IDoNeedToBeInTheBuild */
  110307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110308. "use strict";
  110309. __webpack_require__.r(__webpack_exports__);
  110310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  110311. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  110312. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  110313. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  110314. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  110315. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  110316. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  110317. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  110318. // Adds the parsers to the scene parsers.
  110319. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  110320. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  110321. if (!individualParser) {
  110322. return;
  110323. }
  110324. // Particles Systems
  110325. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  110326. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  110327. var parsedParticleSystem = parsedData.particleSystems[index];
  110328. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  110329. }
  110330. }
  110331. });
  110332. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  110333. if (parsedParticleSystem.activeParticleCount) {
  110334. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  110335. return ps;
  110336. }
  110337. else {
  110338. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  110339. return ps;
  110340. }
  110341. });
  110342. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  110343. if (uniformsNames === void 0) { uniformsNames = []; }
  110344. if (samplers === void 0) { samplers = []; }
  110345. if (defines === void 0) { defines = ""; }
  110346. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  110347. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  110348. if (defines.indexOf(" BILLBOARD") === -1) {
  110349. defines += "\n#define BILLBOARD\n";
  110350. }
  110351. if (samplers.indexOf("diffuseSampler") === -1) {
  110352. samplers.push("diffuseSampler");
  110353. }
  110354. return this.createEffect({
  110355. vertex: "particles",
  110356. fragmentElement: fragmentName
  110357. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  110358. };
  110359. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  110360. var results = new Array();
  110361. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  110362. var particleSystem = this.getScene().particleSystems[index];
  110363. if (particleSystem.emitter === this) {
  110364. results.push(particleSystem);
  110365. }
  110366. }
  110367. return results;
  110368. };
  110369. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  110370. var results = new Array();
  110371. var descendants = this.getDescendants();
  110372. descendants.push(this);
  110373. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  110374. var particleSystem = this.getScene().particleSystems[index];
  110375. var emitter = particleSystem.emitter;
  110376. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  110377. results.push(particleSystem);
  110378. }
  110379. }
  110380. return results;
  110381. };
  110382. /**
  110383. * @hidden
  110384. */
  110385. var _IDoNeedToBeInTheBuild = 42;
  110386. /***/ }),
  110387. /***/ "./Particles/particleSystemSet.ts":
  110388. /*!****************************************!*\
  110389. !*** ./Particles/particleSystemSet.ts ***!
  110390. \****************************************/
  110391. /*! exports provided: ParticleSystemSet */
  110392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110393. "use strict";
  110394. __webpack_require__.r(__webpack_exports__);
  110395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  110396. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110397. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  110398. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  110399. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  110400. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  110401. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  110402. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  110403. /** Internal class used to store shapes for emitters */
  110404. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  110405. function ParticleSystemSetEmitterCreationOptions() {
  110406. }
  110407. return ParticleSystemSetEmitterCreationOptions;
  110408. }());
  110409. /**
  110410. * Represents a set of particle systems working together to create a specific effect
  110411. */
  110412. var ParticleSystemSet = /** @class */ (function () {
  110413. function ParticleSystemSet() {
  110414. /**
  110415. * Gets the particle system list
  110416. */
  110417. this.systems = new Array();
  110418. }
  110419. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  110420. /**
  110421. * Gets the emitter node used with this set
  110422. */
  110423. get: function () {
  110424. return this._emitterNode;
  110425. },
  110426. enumerable: true,
  110427. configurable: true
  110428. });
  110429. /**
  110430. * Creates a new emitter mesh as a sphere
  110431. * @param options defines the options used to create the sphere
  110432. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110433. * @param scene defines the hosting scene
  110434. */
  110435. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  110436. if (this._emitterNode) {
  110437. this._emitterNode.dispose();
  110438. }
  110439. this._emitterCreationOptions = {
  110440. kind: "Sphere",
  110441. options: options,
  110442. renderingGroupId: renderingGroupId
  110443. };
  110444. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  110445. emitterMesh.renderingGroupId = renderingGroupId;
  110446. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  110447. material.emissiveColor = options.color;
  110448. emitterMesh.material = material;
  110449. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  110450. var system = _a[_i];
  110451. system.emitter = emitterMesh;
  110452. }
  110453. this._emitterNode = emitterMesh;
  110454. };
  110455. /**
  110456. * Starts all particle systems of the set
  110457. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110458. */
  110459. ParticleSystemSet.prototype.start = function (emitter) {
  110460. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  110461. var system = _a[_i];
  110462. if (emitter) {
  110463. system.emitter = emitter;
  110464. }
  110465. system.start();
  110466. }
  110467. };
  110468. /**
  110469. * Release all associated resources
  110470. */
  110471. ParticleSystemSet.prototype.dispose = function () {
  110472. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  110473. var system = _a[_i];
  110474. system.dispose();
  110475. }
  110476. this.systems = [];
  110477. if (this._emitterNode) {
  110478. this._emitterNode.dispose();
  110479. this._emitterNode = null;
  110480. }
  110481. };
  110482. /**
  110483. * Serialize the set into a JSON compatible object
  110484. * @returns a JSON compatible representation of the set
  110485. */
  110486. ParticleSystemSet.prototype.serialize = function () {
  110487. var result = {};
  110488. result.systems = [];
  110489. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  110490. var system = _a[_i];
  110491. result.systems.push(system.serialize());
  110492. }
  110493. if (this._emitterNode) {
  110494. result.emitter = this._emitterCreationOptions;
  110495. }
  110496. return result;
  110497. };
  110498. /**
  110499. * Parse a new ParticleSystemSet from a serialized source
  110500. * @param data defines a JSON compatible representation of the set
  110501. * @param scene defines the hosting scene
  110502. * @param gpu defines if we want GPU particles or CPU particles
  110503. * @returns a new ParticleSystemSet
  110504. */
  110505. ParticleSystemSet.Parse = function (data, scene, gpu) {
  110506. if (gpu === void 0) { gpu = false; }
  110507. var result = new ParticleSystemSet();
  110508. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  110509. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  110510. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  110511. var system = _a[_i];
  110512. 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));
  110513. }
  110514. if (data.emitter) {
  110515. var options = data.emitter.options;
  110516. switch (data.emitter.kind) {
  110517. case "Sphere":
  110518. result.setEmitterAsSphere({
  110519. diameter: options.diameter,
  110520. segments: options.segments,
  110521. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  110522. }, data.emitter.renderingGroupId, scene);
  110523. break;
  110524. }
  110525. }
  110526. return result;
  110527. };
  110528. return ParticleSystemSet;
  110529. }());
  110530. /***/ }),
  110531. /***/ "./Particles/solidParticle.ts":
  110532. /*!************************************!*\
  110533. !*** ./Particles/solidParticle.ts ***!
  110534. \************************************/
  110535. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  110536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110537. "use strict";
  110538. __webpack_require__.r(__webpack_exports__);
  110539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  110540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  110541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  110542. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110543. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  110544. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  110545. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110546. /**
  110547. * Represents one particle of a solid particle system.
  110548. */
  110549. var SolidParticle = /** @class */ (function () {
  110550. /**
  110551. * Creates a Solid Particle object.
  110552. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110553. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  110554. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110555. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110556. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110557. * @param shapeId (integer) is the model shape identifier in the SPS.
  110558. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110559. * @param sps defines the sps it is associated to
  110560. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110561. */
  110562. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  110563. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  110564. /**
  110565. * particle global index
  110566. */
  110567. this.idx = 0;
  110568. /**
  110569. * The color of the particle
  110570. */
  110571. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  110572. /**
  110573. * The world space position of the particle.
  110574. */
  110575. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110576. /**
  110577. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110578. */
  110579. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110580. /**
  110581. * The scaling of the particle.
  110582. */
  110583. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  110584. /**
  110585. * The uvs of the particle.
  110586. */
  110587. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  110588. /**
  110589. * The current speed of the particle.
  110590. */
  110591. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110592. /**
  110593. * The pivot point in the particle local space.
  110594. */
  110595. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110596. /**
  110597. * Must the particle be translated from its pivot point in its local space ?
  110598. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110599. * Default : false
  110600. */
  110601. this.translateFromPivot = false;
  110602. /**
  110603. * Is the particle active or not ?
  110604. */
  110605. this.alive = true;
  110606. /**
  110607. * Is the particle visible or not ?
  110608. */
  110609. this.isVisible = true;
  110610. /**
  110611. * Index of this particle in the global "positions" array (Internal use)
  110612. * @hidden
  110613. */
  110614. this._pos = 0;
  110615. /**
  110616. * @hidden Index of this particle in the global "indices" array (Internal use)
  110617. */
  110618. this._ind = 0;
  110619. /**
  110620. * ModelShape id of this particle
  110621. */
  110622. this.shapeId = 0;
  110623. /**
  110624. * Index of the particle in its shape id (Internal use)
  110625. */
  110626. this.idxInShape = 0;
  110627. /**
  110628. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110629. */
  110630. this._stillInvisible = false;
  110631. /**
  110632. * @hidden Last computed particle rotation matrix
  110633. */
  110634. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  110635. /**
  110636. * Parent particle Id, if any.
  110637. * Default null.
  110638. */
  110639. this.parentId = null;
  110640. /**
  110641. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110642. * The possible values are :
  110643. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110644. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110645. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110646. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110647. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110648. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110649. * */
  110650. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  110651. /**
  110652. * @hidden Internal global position in the SPS.
  110653. */
  110654. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110655. this.idx = particleIndex;
  110656. this._pos = positionIndex;
  110657. this._ind = indiceIndex;
  110658. this._model = model;
  110659. this.shapeId = shapeId;
  110660. this.idxInShape = idxInShape;
  110661. this._sps = sps;
  110662. if (modelBoundingInfo) {
  110663. this._modelBoundingInfo = modelBoundingInfo;
  110664. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  110665. }
  110666. }
  110667. Object.defineProperty(SolidParticle.prototype, "scale", {
  110668. /**
  110669. * Legacy support, changed scale to scaling
  110670. */
  110671. get: function () {
  110672. return this.scaling;
  110673. },
  110674. /**
  110675. * Legacy support, changed scale to scaling
  110676. */
  110677. set: function (scale) {
  110678. this.scaling = scale;
  110679. },
  110680. enumerable: true,
  110681. configurable: true
  110682. });
  110683. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  110684. /**
  110685. * Legacy support, changed quaternion to rotationQuaternion
  110686. */
  110687. get: function () {
  110688. return this.rotationQuaternion;
  110689. },
  110690. /**
  110691. * Legacy support, changed quaternion to rotationQuaternion
  110692. */
  110693. set: function (q) {
  110694. this.rotationQuaternion = q;
  110695. },
  110696. enumerable: true,
  110697. configurable: true
  110698. });
  110699. /**
  110700. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110701. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110702. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110703. * @returns true if it intersects
  110704. */
  110705. SolidParticle.prototype.intersectsMesh = function (target) {
  110706. if (!this._boundingInfo || !target._boundingInfo) {
  110707. return false;
  110708. }
  110709. if (this._sps._bSphereOnly) {
  110710. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  110711. }
  110712. return this._boundingInfo.intersects(target._boundingInfo, false);
  110713. };
  110714. /**
  110715. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110716. * A particle is in the frustum if its bounding box intersects the frustum
  110717. * @param frustumPlanes defines the frustum to test
  110718. * @returns true if the particle is in the frustum planes
  110719. */
  110720. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  110721. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  110722. };
  110723. /**
  110724. * get the rotation matrix of the particle
  110725. * @hidden
  110726. */
  110727. SolidParticle.prototype.getRotationMatrix = function (m) {
  110728. var quaternion;
  110729. if (this.rotationQuaternion) {
  110730. quaternion = this.rotationQuaternion;
  110731. }
  110732. else {
  110733. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  110734. var rotation = this.rotation;
  110735. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  110736. }
  110737. quaternion.toRotationMatrix(m);
  110738. };
  110739. return SolidParticle;
  110740. }());
  110741. /**
  110742. * Represents the shape of the model used by one particle of a solid particle system.
  110743. * SPS internal tool, don't use it manually.
  110744. */
  110745. var ModelShape = /** @class */ (function () {
  110746. /**
  110747. * 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.
  110748. * SPS internal tool, don't use it manually.
  110749. * @hidden
  110750. */
  110751. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  110752. /**
  110753. * length of the shape in the model indices array (internal use)
  110754. * @hidden
  110755. */
  110756. this._indicesLength = 0;
  110757. this.shapeID = id;
  110758. this._shape = shape;
  110759. this._indicesLength = indicesLength;
  110760. this._shapeUV = shapeUV;
  110761. this._positionFunction = posFunction;
  110762. this._vertexFunction = vtxFunction;
  110763. }
  110764. return ModelShape;
  110765. }());
  110766. /**
  110767. * Represents a Depth Sorted Particle in the solid particle system.
  110768. */
  110769. var DepthSortedParticle = /** @class */ (function () {
  110770. function DepthSortedParticle() {
  110771. /**
  110772. * Index of the particle in the "indices" array
  110773. */
  110774. this.ind = 0;
  110775. /**
  110776. * Length of the particle shape in the "indices" array
  110777. */
  110778. this.indicesLength = 0;
  110779. /**
  110780. * Squared distance from the particle to the camera
  110781. */
  110782. this.sqDistance = 0.0;
  110783. }
  110784. return DepthSortedParticle;
  110785. }());
  110786. /***/ }),
  110787. /***/ "./Particles/solidParticleSystem.ts":
  110788. /*!******************************************!*\
  110789. !*** ./Particles/solidParticleSystem.ts ***!
  110790. \******************************************/
  110791. /*! exports provided: SolidParticleSystem */
  110792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110793. "use strict";
  110794. __webpack_require__.r(__webpack_exports__);
  110795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  110796. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110797. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  110798. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  110799. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  110800. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  110801. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  110802. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  110803. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  110804. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  110805. /**
  110806. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  110807. *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.
  110808. * The SPS is also a particle system. It provides some methods to manage the particles.
  110809. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  110810. *
  110811. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  110812. */
  110813. var SolidParticleSystem = /** @class */ (function () {
  110814. /**
  110815. * Creates a SPS (Solid Particle System) object.
  110816. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110817. * @param scene (Scene) is the scene in which the SPS is added.
  110818. * @param options defines the options of the sps e.g.
  110819. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110820. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110821. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110822. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110823. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110824. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110825. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110826. */
  110827. function SolidParticleSystem(name, scene, options) {
  110828. /**
  110829. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  110830. * Example : var p = SPS.particles[i];
  110831. */
  110832. this.particles = new Array();
  110833. /**
  110834. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  110835. */
  110836. this.nbParticles = 0;
  110837. /**
  110838. * If the particles must ever face the camera (default false). Useful for planar particles.
  110839. */
  110840. this.billboard = false;
  110841. /**
  110842. * Recompute normals when adding a shape
  110843. */
  110844. this.recomputeNormals = true;
  110845. /**
  110846. * This a counter ofr your own usage. It's not set by any SPS functions.
  110847. */
  110848. this.counter = 0;
  110849. /**
  110850. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110851. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  110852. */
  110853. this.vars = {};
  110854. /**
  110855. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  110856. * @hidden
  110857. */
  110858. this._bSphereOnly = false;
  110859. /**
  110860. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  110861. * @hidden
  110862. */
  110863. this._bSphereRadiusFactor = 1.0;
  110864. this._positions = new Array();
  110865. this._indices = new Array();
  110866. this._normals = new Array();
  110867. this._colors = new Array();
  110868. this._uvs = new Array();
  110869. this._index = 0; // indices index
  110870. this._updatable = true;
  110871. this._pickable = false;
  110872. this._isVisibilityBoxLocked = false;
  110873. this._alwaysVisible = false;
  110874. this._depthSort = false;
  110875. this._shapeCounter = 0;
  110876. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  110877. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  110878. this._computeParticleColor = true;
  110879. this._computeParticleTexture = true;
  110880. this._computeParticleRotation = true;
  110881. this._computeParticleVertex = false;
  110882. this._computeBoundingBox = false;
  110883. this._depthSortParticles = true;
  110884. this._mustUnrotateFixedNormals = false;
  110885. this._particlesIntersect = false;
  110886. this._needs32Bits = false;
  110887. this.name = name;
  110888. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  110889. this._camera = scene.activeCamera;
  110890. this._pickable = options ? options.isPickable : false;
  110891. this._depthSort = options ? options.enableDepthSort : false;
  110892. this._particlesIntersect = options ? options.particleIntersection : false;
  110893. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  110894. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  110895. if (options && options.updatable !== undefined) {
  110896. this._updatable = options.updatable;
  110897. }
  110898. else {
  110899. this._updatable = true;
  110900. }
  110901. if (this._pickable) {
  110902. this.pickedParticles = [];
  110903. }
  110904. if (this._depthSort) {
  110905. this.depthSortedParticles = [];
  110906. }
  110907. }
  110908. /**
  110909. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110910. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110911. * @returns the created mesh
  110912. */
  110913. SolidParticleSystem.prototype.buildMesh = function () {
  110914. if (this.nbParticles === 0) {
  110915. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  110916. this.addShape(triangle, 1);
  110917. triangle.dispose();
  110918. }
  110919. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  110920. this._positions32 = new Float32Array(this._positions);
  110921. this._uvs32 = new Float32Array(this._uvs);
  110922. this._colors32 = new Float32Array(this._colors);
  110923. if (this.recomputeNormals) {
  110924. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  110925. }
  110926. this._normals32 = new Float32Array(this._normals);
  110927. this._fixedNormal32 = new Float32Array(this._normals);
  110928. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  110929. this._unrotateFixedNormals();
  110930. }
  110931. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  110932. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  110933. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  110934. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  110935. if (this._uvs32.length > 0) {
  110936. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  110937. }
  110938. if (this._colors32.length > 0) {
  110939. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  110940. }
  110941. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  110942. vertexData.applyToMesh(mesh, this._updatable);
  110943. this.mesh = mesh;
  110944. this.mesh.isPickable = this._pickable;
  110945. // free memory
  110946. if (!this._depthSort) {
  110947. this._indices = null;
  110948. }
  110949. this._positions = null;
  110950. this._normals = null;
  110951. this._uvs = null;
  110952. this._colors = null;
  110953. if (!this._updatable) {
  110954. this.particles.length = 0;
  110955. }
  110956. return mesh;
  110957. };
  110958. /**
  110959. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110960. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110961. * Thus the particles generated from `digest()` have their property `position` set yet.
  110962. * @param mesh ( Mesh ) is the mesh to be digested
  110963. * @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
  110964. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110965. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110966. * @returns the current SPS
  110967. */
  110968. SolidParticleSystem.prototype.digest = function (mesh, options) {
  110969. var size = (options && options.facetNb) || 1;
  110970. var number = (options && options.number) || 0;
  110971. var delta = (options && options.delta) || 0;
  110972. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  110973. var meshInd = mesh.getIndices();
  110974. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  110975. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  110976. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  110977. var f = 0; // facet counter
  110978. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  110979. // compute size from number
  110980. if (number) {
  110981. number = (number > totalFacets) ? totalFacets : number;
  110982. size = Math.round(totalFacets / number);
  110983. delta = 0;
  110984. }
  110985. else {
  110986. size = (size > totalFacets) ? totalFacets : size;
  110987. }
  110988. var facetPos = []; // submesh positions
  110989. var facetInd = []; // submesh indices
  110990. var facetUV = []; // submesh UV
  110991. var facetCol = []; // submesh colors
  110992. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110993. var sizeO = size;
  110994. while (f < totalFacets) {
  110995. size = sizeO + Math.floor((1 + delta) * Math.random());
  110996. if (f > totalFacets - size) {
  110997. size = totalFacets - f;
  110998. }
  110999. // reset temp arrays
  111000. facetPos.length = 0;
  111001. facetInd.length = 0;
  111002. facetUV.length = 0;
  111003. facetCol.length = 0;
  111004. // iterate over "size" facets
  111005. var fi = 0;
  111006. for (var j = f * 3; j < (f + size) * 3; j++) {
  111007. facetInd.push(fi);
  111008. var i = meshInd[j];
  111009. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  111010. if (meshUV) {
  111011. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  111012. }
  111013. if (meshCol) {
  111014. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  111015. }
  111016. fi++;
  111017. }
  111018. // create a model shape for each single particle
  111019. var idx = this.nbParticles;
  111020. var shape = this._posToShape(facetPos);
  111021. var shapeUV = this._uvsToShapeUV(facetUV);
  111022. // compute the barycenter of the shape
  111023. var v;
  111024. for (v = 0; v < shape.length; v++) {
  111025. barycenter.addInPlace(shape[v]);
  111026. }
  111027. barycenter.scaleInPlace(1 / shape.length);
  111028. // shift the shape from its barycenter to the origin
  111029. for (v = 0; v < shape.length; v++) {
  111030. shape[v].subtractInPlace(barycenter);
  111031. }
  111032. var bInfo;
  111033. if (this._particlesIntersect) {
  111034. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  111035. }
  111036. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  111037. // add the particle in the SPS
  111038. var currentPos = this._positions.length;
  111039. var currentInd = this._indices.length;
  111040. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  111041. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  111042. // initialize the particle position
  111043. this.particles[this.nbParticles].position.addInPlace(barycenter);
  111044. this._index += shape.length;
  111045. idx++;
  111046. this.nbParticles++;
  111047. this._shapeCounter++;
  111048. f += size;
  111049. }
  111050. return this;
  111051. };
  111052. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111053. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  111054. var index = 0;
  111055. var idx = 0;
  111056. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  111057. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  111058. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111059. for (var p = 0; p < this.particles.length; p++) {
  111060. var particle = this.particles[p];
  111061. var shape = particle._model._shape;
  111062. // computing the inverse of the rotation matrix from the quaternion
  111063. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  111064. if (particle.rotationQuaternion) {
  111065. particle.rotationQuaternion.conjugateToRef(quaternion);
  111066. }
  111067. else {
  111068. var rotation = particle.rotation;
  111069. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  111070. quaternion.conjugateInPlace();
  111071. }
  111072. quaternion.toRotationMatrix(invertedRotMatrix);
  111073. for (var pt = 0; pt < shape.length; pt++) {
  111074. idx = index + pt * 3;
  111075. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  111076. tmpNormal.toArray(this._fixedNormal32, idx);
  111077. }
  111078. index = idx + 3;
  111079. }
  111080. };
  111081. //reset copy
  111082. SolidParticleSystem.prototype._resetCopy = function () {
  111083. var copy = this._copy;
  111084. copy.position.setAll(0);
  111085. copy.rotation.setAll(0);
  111086. copy.rotationQuaternion = null;
  111087. copy.scaling.setAll(1);
  111088. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  111089. copy.color = null;
  111090. copy.translateFromPivot = false;
  111091. };
  111092. // _meshBuilder : inserts the shape model in the global SPS mesh
  111093. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  111094. var i;
  111095. var u = 0;
  111096. var c = 0;
  111097. var n = 0;
  111098. this._resetCopy();
  111099. var copy = this._copy;
  111100. if (options && options.positionFunction) { // call to custom positionFunction
  111101. options.positionFunction(copy, idx, idxInShape);
  111102. this._mustUnrotateFixedNormals = true;
  111103. }
  111104. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111105. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  111106. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  111107. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  111108. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  111109. copy.getRotationMatrix(rotMatrix);
  111110. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  111111. if (copy.translateFromPivot) {
  111112. pivotBackTranslation.setAll(0.0);
  111113. }
  111114. else {
  111115. pivotBackTranslation.copyFrom(scaledPivot);
  111116. }
  111117. for (i = 0; i < shape.length; i++) {
  111118. tmpVertex.copyFrom(shape[i]);
  111119. if (options && options.vertexFunction) {
  111120. options.vertexFunction(copy, tmpVertex, i);
  111121. }
  111122. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  111123. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  111124. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  111125. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  111126. if (meshUV) {
  111127. var copyUvs = copy.uvs;
  111128. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  111129. u += 2;
  111130. }
  111131. if (copy.color) {
  111132. this._color = copy.color;
  111133. }
  111134. else {
  111135. var color = this._color;
  111136. if (meshCol && meshCol[c] !== undefined) {
  111137. color.r = meshCol[c];
  111138. color.g = meshCol[c + 1];
  111139. color.b = meshCol[c + 2];
  111140. color.a = meshCol[c + 3];
  111141. }
  111142. else {
  111143. color.r = 1.0;
  111144. color.g = 1.0;
  111145. color.b = 1.0;
  111146. color.a = 1.0;
  111147. }
  111148. }
  111149. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  111150. c += 4;
  111151. if (!this.recomputeNormals && meshNor) {
  111152. tmpVertex.x = meshNor[n];
  111153. tmpVertex.y = meshNor[n + 1];
  111154. tmpVertex.z = meshNor[n + 2];
  111155. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  111156. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  111157. n += 3;
  111158. }
  111159. }
  111160. for (i = 0; i < meshInd.length; i++) {
  111161. var current_ind = p + meshInd[i];
  111162. indices.push(current_ind);
  111163. if (current_ind > 65535) {
  111164. this._needs32Bits = true;
  111165. }
  111166. }
  111167. if (this._pickable) {
  111168. var nbfaces = meshInd.length / 3;
  111169. for (i = 0; i < nbfaces; i++) {
  111170. this.pickedParticles.push({ idx: idx, faceId: i });
  111171. }
  111172. }
  111173. if (this._depthSort) {
  111174. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  111175. }
  111176. return copy;
  111177. };
  111178. // returns a shape array from positions array
  111179. SolidParticleSystem.prototype._posToShape = function (positions) {
  111180. var shape = [];
  111181. for (var i = 0; i < positions.length; i += 3) {
  111182. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  111183. }
  111184. return shape;
  111185. };
  111186. // returns a shapeUV array from a Vector4 uvs
  111187. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  111188. var shapeUV = [];
  111189. if (uvs) {
  111190. for (var i = 0; i < uvs.length; i++) {
  111191. shapeUV.push(uvs[i]);
  111192. }
  111193. }
  111194. return shapeUV;
  111195. };
  111196. // adds a new particle object in the particles array
  111197. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  111198. if (bInfo === void 0) { bInfo = null; }
  111199. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  111200. this.particles.push(sp);
  111201. return sp;
  111202. };
  111203. /**
  111204. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111205. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  111206. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111207. * @param nb (positive integer) the number of particles to be created from this model
  111208. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111209. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111210. * @returns the number of shapes in the system
  111211. */
  111212. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  111213. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  111214. var meshInd = mesh.getIndices();
  111215. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  111216. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  111217. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  111218. var bbInfo;
  111219. if (this._particlesIntersect) {
  111220. bbInfo = mesh.getBoundingInfo();
  111221. }
  111222. var shape = this._posToShape(meshPos);
  111223. var shapeUV = this._uvsToShapeUV(meshUV);
  111224. var posfunc = options ? options.positionFunction : null;
  111225. var vtxfunc = options ? options.vertexFunction : null;
  111226. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  111227. // particles
  111228. var sp;
  111229. var currentCopy;
  111230. var idx = this.nbParticles;
  111231. for (var i = 0; i < nb; i++) {
  111232. var currentPos = this._positions.length;
  111233. var currentInd = this._indices.length;
  111234. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  111235. if (this._updatable) {
  111236. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  111237. sp.position.copyFrom(currentCopy.position);
  111238. sp.rotation.copyFrom(currentCopy.rotation);
  111239. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  111240. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  111241. }
  111242. if (currentCopy.color && sp.color) {
  111243. sp.color.copyFrom(currentCopy.color);
  111244. }
  111245. sp.scaling.copyFrom(currentCopy.scaling);
  111246. sp.uvs.copyFrom(currentCopy.uvs);
  111247. }
  111248. this._index += shape.length;
  111249. idx++;
  111250. }
  111251. this.nbParticles += nb;
  111252. this._shapeCounter++;
  111253. return this._shapeCounter - 1;
  111254. };
  111255. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111256. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  111257. this._resetCopy();
  111258. var copy = this._copy;
  111259. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  111260. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  111261. }
  111262. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111263. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  111264. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  111265. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  111266. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  111267. copy.getRotationMatrix(rotMatrix);
  111268. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  111269. if (copy.translateFromPivot) {
  111270. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  111271. }
  111272. else {
  111273. pivotBackTranslation.copyFrom(scaledPivot);
  111274. }
  111275. var shape = particle._model._shape;
  111276. for (var pt = 0; pt < shape.length; pt++) {
  111277. tmpVertex.copyFrom(shape[pt]);
  111278. if (particle._model._vertexFunction) {
  111279. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  111280. }
  111281. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  111282. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  111283. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  111284. }
  111285. particle.position.setAll(0.0);
  111286. particle.rotation.setAll(0.0);
  111287. particle.rotationQuaternion = null;
  111288. particle.scaling.setAll(1.0);
  111289. particle.uvs.setAll(0.0);
  111290. particle.pivot.setAll(0.0);
  111291. particle.translateFromPivot = false;
  111292. particle.parentId = null;
  111293. };
  111294. /**
  111295. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111296. * @returns the SPS.
  111297. */
  111298. SolidParticleSystem.prototype.rebuildMesh = function () {
  111299. for (var p = 0; p < this.particles.length; p++) {
  111300. this._rebuildParticle(this.particles[p]);
  111301. }
  111302. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  111303. return this;
  111304. };
  111305. /**
  111306. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111307. * This method calls `updateParticle()` for each particle of the SPS.
  111308. * For an animated SPS, it is usually called within the render loop.
  111309. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111310. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111311. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111312. * @returns the SPS.
  111313. */
  111314. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  111315. if (start === void 0) { start = 0; }
  111316. if (end === void 0) { end = this.nbParticles - 1; }
  111317. if (update === void 0) { update = true; }
  111318. if (!this._updatable) {
  111319. return this;
  111320. }
  111321. // custom beforeUpdate
  111322. this.beforeUpdateParticles(start, end, update);
  111323. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111324. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  111325. var mesh = this.mesh;
  111326. var colors32 = this._colors32;
  111327. var positions32 = this._positions32;
  111328. var normals32 = this._normals32;
  111329. var uvs32 = this._uvs32;
  111330. var indices32 = this._indices32;
  111331. var indices = this._indices;
  111332. var fixedNormal32 = this._fixedNormal32;
  111333. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  111334. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  111335. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  111336. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  111337. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  111338. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  111339. var camInvertedPosition = tempVectors[10].setAll(0);
  111340. // cases when the World Matrix is to be computed first
  111341. if (this.billboard || this._depthSort) {
  111342. this.mesh.computeWorldMatrix(true);
  111343. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  111344. }
  111345. // if the particles will always face the camera
  111346. if (this.billboard) {
  111347. // compute the camera position and un-rotate it by the current mesh rotation
  111348. var tmpVertex = tempVectors[0];
  111349. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  111350. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  111351. camAxisZ.normalize();
  111352. // same for camera up vector extracted from the cam view matrix
  111353. var view = this._camera.getViewMatrix(true);
  111354. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  111355. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  111356. camAxisY.normalize();
  111357. camAxisX.normalize();
  111358. }
  111359. // if depthSort, compute the camera global position in the mesh local system
  111360. if (this._depthSort) {
  111361. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  111362. }
  111363. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  111364. var idx = 0; // current position index in the global array positions32
  111365. var index = 0; // position start index in the global array positions32 of the current particle
  111366. var colidx = 0; // current color index in the global array colors32
  111367. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  111368. var uvidx = 0; // current uv index in the global array uvs32
  111369. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  111370. var pt = 0; // current index in the particle model shape
  111371. if (this.mesh.isFacetDataEnabled) {
  111372. this._computeBoundingBox = true;
  111373. }
  111374. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  111375. if (this._computeBoundingBox) {
  111376. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  111377. var boundingInfo = this.mesh._boundingInfo;
  111378. if (boundingInfo) {
  111379. minimum.copyFrom(boundingInfo.minimum);
  111380. maximum.copyFrom(boundingInfo.maximum);
  111381. }
  111382. }
  111383. }
  111384. // particle loop
  111385. index = this.particles[start]._pos;
  111386. var vpos = (index / 3) | 0;
  111387. colorIndex = vpos * 4;
  111388. uvIndex = vpos * 2;
  111389. for (var p = start; p <= end; p++) {
  111390. var particle = this.particles[p];
  111391. // call to custom user function to update the particle properties
  111392. this.updateParticle(particle);
  111393. var shape = particle._model._shape;
  111394. var shapeUV = particle._model._shapeUV;
  111395. var particleRotationMatrix = particle._rotationMatrix;
  111396. var particlePosition = particle.position;
  111397. var particleRotation = particle.rotation;
  111398. var particleScaling = particle.scaling;
  111399. var particleGlobalPosition = particle._globalPosition;
  111400. // camera-particle distance for depth sorting
  111401. if (this._depthSort && this._depthSortParticles) {
  111402. var dsp = this.depthSortedParticles[p];
  111403. dsp.ind = particle._ind;
  111404. dsp.indicesLength = particle._model._indicesLength;
  111405. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  111406. }
  111407. // skip the computations for inactive or already invisible particles
  111408. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  111409. // increment indexes for the next particle
  111410. pt = shape.length;
  111411. index += pt * 3;
  111412. colorIndex += pt * 4;
  111413. uvIndex += pt * 2;
  111414. continue;
  111415. }
  111416. if (particle.isVisible) {
  111417. particle._stillInvisible = false; // un-mark permanent invisibility
  111418. var scaledPivot = tempVectors[12];
  111419. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  111420. // particle rotation matrix
  111421. if (this.billboard) {
  111422. particleRotation.x = 0.0;
  111423. particleRotation.y = 0.0;
  111424. }
  111425. if (this._computeParticleRotation || this.billboard) {
  111426. particle.getRotationMatrix(rotMatrix);
  111427. }
  111428. var particleHasParent = (particle.parentId !== null);
  111429. if (particleHasParent) {
  111430. var parent_1 = this.particles[particle.parentId];
  111431. var parentRotationMatrix = parent_1._rotationMatrix;
  111432. var parentGlobalPosition = parent_1._globalPosition;
  111433. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  111434. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  111435. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  111436. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  111437. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  111438. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  111439. if (this._computeParticleRotation || this.billboard) {
  111440. var rotMatrixValues = rotMatrix.m;
  111441. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  111442. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  111443. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  111444. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  111445. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  111446. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  111447. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  111448. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  111449. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  111450. }
  111451. }
  111452. else {
  111453. particleGlobalPosition.x = particlePosition.x;
  111454. particleGlobalPosition.y = particlePosition.y;
  111455. particleGlobalPosition.z = particlePosition.z;
  111456. if (this._computeParticleRotation || this.billboard) {
  111457. var rotMatrixValues = rotMatrix.m;
  111458. particleRotationMatrix[0] = rotMatrixValues[0];
  111459. particleRotationMatrix[1] = rotMatrixValues[1];
  111460. particleRotationMatrix[2] = rotMatrixValues[2];
  111461. particleRotationMatrix[3] = rotMatrixValues[4];
  111462. particleRotationMatrix[4] = rotMatrixValues[5];
  111463. particleRotationMatrix[5] = rotMatrixValues[6];
  111464. particleRotationMatrix[6] = rotMatrixValues[8];
  111465. particleRotationMatrix[7] = rotMatrixValues[9];
  111466. particleRotationMatrix[8] = rotMatrixValues[10];
  111467. }
  111468. }
  111469. var pivotBackTranslation = tempVectors[11];
  111470. if (particle.translateFromPivot) {
  111471. pivotBackTranslation.setAll(0.0);
  111472. }
  111473. else {
  111474. pivotBackTranslation.copyFrom(scaledPivot);
  111475. }
  111476. // particle vertex loop
  111477. for (pt = 0; pt < shape.length; pt++) {
  111478. idx = index + pt * 3;
  111479. colidx = colorIndex + pt * 4;
  111480. uvidx = uvIndex + pt * 2;
  111481. var tmpVertex = tempVectors[0];
  111482. tmpVertex.copyFrom(shape[pt]);
  111483. if (this._computeParticleVertex) {
  111484. this.updateParticleVertex(particle, tmpVertex, pt);
  111485. }
  111486. // positions
  111487. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  111488. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  111489. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  111490. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  111491. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  111492. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  111493. rotatedX += pivotBackTranslation.x;
  111494. rotatedY += pivotBackTranslation.y;
  111495. rotatedZ += pivotBackTranslation.z;
  111496. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  111497. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  111498. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  111499. if (this._computeBoundingBox) {
  111500. minimum.minimizeInPlaceFromFloats(px, py, pz);
  111501. maximum.maximizeInPlaceFromFloats(px, py, pz);
  111502. }
  111503. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  111504. if (!this._computeParticleVertex) {
  111505. var normalx = fixedNormal32[idx];
  111506. var normaly = fixedNormal32[idx + 1];
  111507. var normalz = fixedNormal32[idx + 2];
  111508. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  111509. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  111510. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  111511. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  111512. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  111513. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  111514. }
  111515. if (this._computeParticleColor && particle.color) {
  111516. var color = particle.color;
  111517. var colors32_1 = this._colors32;
  111518. colors32_1[colidx] = color.r;
  111519. colors32_1[colidx + 1] = color.g;
  111520. colors32_1[colidx + 2] = color.b;
  111521. colors32_1[colidx + 3] = color.a;
  111522. }
  111523. if (this._computeParticleTexture) {
  111524. var uvs = particle.uvs;
  111525. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  111526. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  111527. }
  111528. }
  111529. }
  111530. // particle just set invisible : scaled to zero and positioned at the origin
  111531. else {
  111532. particle._stillInvisible = true; // mark the particle as invisible
  111533. for (pt = 0; pt < shape.length; pt++) {
  111534. idx = index + pt * 3;
  111535. colidx = colorIndex + pt * 4;
  111536. uvidx = uvIndex + pt * 2;
  111537. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  111538. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  111539. if (this._computeParticleColor && particle.color) {
  111540. var color = particle.color;
  111541. colors32[colidx] = color.r;
  111542. colors32[colidx + 1] = color.g;
  111543. colors32[colidx + 2] = color.b;
  111544. colors32[colidx + 3] = color.a;
  111545. }
  111546. if (this._computeParticleTexture) {
  111547. var uvs = particle.uvs;
  111548. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  111549. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  111550. }
  111551. }
  111552. }
  111553. // if the particle intersections must be computed : update the bbInfo
  111554. if (this._particlesIntersect) {
  111555. var bInfo = particle._boundingInfo;
  111556. var bBox = bInfo.boundingBox;
  111557. var bSphere = bInfo.boundingSphere;
  111558. var modelBoundingInfo = particle._modelBoundingInfo;
  111559. if (!this._bSphereOnly) {
  111560. // place, scale and rotate the particle bbox within the SPS local system, then update it
  111561. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  111562. var tempMin = tempVectors[1];
  111563. var tempMax = tempVectors[2];
  111564. tempMin.setAll(Number.MAX_VALUE);
  111565. tempMax.setAll(-Number.MAX_VALUE);
  111566. for (var b = 0; b < 8; b++) {
  111567. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  111568. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  111569. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  111570. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  111571. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  111572. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  111573. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  111574. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  111575. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  111576. tempMin.minimizeInPlaceFromFloats(x, y, z);
  111577. tempMax.maximizeInPlaceFromFloats(x, y, z);
  111578. }
  111579. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  111580. }
  111581. // place and scale the particle bouding sphere in the SPS local system, then update it
  111582. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  111583. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  111584. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  111585. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  111586. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  111587. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  111588. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  111589. }
  111590. // increment indexes for the next particle
  111591. index = idx + 3;
  111592. colorIndex = colidx + 4;
  111593. uvIndex = uvidx + 2;
  111594. }
  111595. // if the VBO must be updated
  111596. if (update) {
  111597. if (this._computeParticleColor) {
  111598. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  111599. }
  111600. if (this._computeParticleTexture) {
  111601. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  111602. }
  111603. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  111604. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  111605. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  111606. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  111607. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  111608. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  111609. for (var i = 0; i < normals32.length; i++) {
  111610. fixedNormal32[i] = normals32[i];
  111611. }
  111612. }
  111613. if (!mesh.areNormalsFrozen) {
  111614. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  111615. }
  111616. }
  111617. if (this._depthSort && this._depthSortParticles) {
  111618. var depthSortedParticles = this.depthSortedParticles;
  111619. depthSortedParticles.sort(depthSortFunction);
  111620. var dspl = depthSortedParticles.length;
  111621. var sid = 0;
  111622. for (var sorted = 0; sorted < dspl; sorted++) {
  111623. var lind = depthSortedParticles[sorted].indicesLength;
  111624. var sind = depthSortedParticles[sorted].ind;
  111625. for (var i = 0; i < lind; i++) {
  111626. indices32[sid] = indices[sind + i];
  111627. sid++;
  111628. }
  111629. }
  111630. mesh.updateIndices(indices32);
  111631. }
  111632. }
  111633. if (this._computeBoundingBox) {
  111634. if (mesh._boundingInfo) {
  111635. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  111636. }
  111637. else {
  111638. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  111639. }
  111640. }
  111641. this.afterUpdateParticles(start, end, update);
  111642. return this;
  111643. };
  111644. /**
  111645. * Disposes the SPS.
  111646. */
  111647. SolidParticleSystem.prototype.dispose = function () {
  111648. this.mesh.dispose();
  111649. this.vars = null;
  111650. // drop references to internal big arrays for the GC
  111651. this._positions = null;
  111652. this._indices = null;
  111653. this._normals = null;
  111654. this._uvs = null;
  111655. this._colors = null;
  111656. this._indices32 = null;
  111657. this._positions32 = null;
  111658. this._normals32 = null;
  111659. this._fixedNormal32 = null;
  111660. this._uvs32 = null;
  111661. this._colors32 = null;
  111662. this.pickedParticles = null;
  111663. };
  111664. /**
  111665. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111666. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  111667. * @returns the SPS.
  111668. */
  111669. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  111670. if (!this._isVisibilityBoxLocked) {
  111671. this.mesh.refreshBoundingInfo();
  111672. }
  111673. return this;
  111674. };
  111675. /**
  111676. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111677. * @param size the size (float) of the visibility box
  111678. * note : this doesn't lock the SPS mesh bounding box.
  111679. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  111680. */
  111681. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  111682. var vis = size / 2;
  111683. 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));
  111684. };
  111685. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  111686. /**
  111687. * Gets whether the SPS as always visible or not
  111688. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  111689. */
  111690. get: function () {
  111691. return this._alwaysVisible;
  111692. },
  111693. /**
  111694. * Sets the SPS as always visible or not
  111695. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  111696. */
  111697. set: function (val) {
  111698. this._alwaysVisible = val;
  111699. this.mesh.alwaysSelectAsActiveMesh = val;
  111700. },
  111701. enumerable: true,
  111702. configurable: true
  111703. });
  111704. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  111705. /**
  111706. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111707. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  111708. */
  111709. get: function () {
  111710. return this._isVisibilityBoxLocked;
  111711. },
  111712. /**
  111713. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111714. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  111715. */
  111716. set: function (val) {
  111717. this._isVisibilityBoxLocked = val;
  111718. var boundingInfo = this.mesh.getBoundingInfo();
  111719. boundingInfo.isLocked = val;
  111720. },
  111721. enumerable: true,
  111722. configurable: true
  111723. });
  111724. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  111725. /**
  111726. * Gets if `setParticles()` computes the particle rotations or not.
  111727. * Default value : true. The SPS is faster when it's set to false.
  111728. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111729. */
  111730. get: function () {
  111731. return this._computeParticleRotation;
  111732. },
  111733. /**
  111734. * Tells to `setParticles()` to compute the particle rotations or not.
  111735. * Default value : true. The SPS is faster when it's set to false.
  111736. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111737. */
  111738. set: function (val) {
  111739. this._computeParticleRotation = val;
  111740. },
  111741. enumerable: true,
  111742. configurable: true
  111743. });
  111744. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  111745. /**
  111746. * Gets if `setParticles()` computes the particle colors or not.
  111747. * Default value : true. The SPS is faster when it's set to false.
  111748. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111749. */
  111750. get: function () {
  111751. return this._computeParticleColor;
  111752. },
  111753. /**
  111754. * Tells to `setParticles()` to compute the particle colors or not.
  111755. * Default value : true. The SPS is faster when it's set to false.
  111756. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111757. */
  111758. set: function (val) {
  111759. this._computeParticleColor = val;
  111760. },
  111761. enumerable: true,
  111762. configurable: true
  111763. });
  111764. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  111765. /**
  111766. * Gets if `setParticles()` computes the particle textures or not.
  111767. * Default value : true. The SPS is faster when it's set to false.
  111768. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111769. */
  111770. get: function () {
  111771. return this._computeParticleTexture;
  111772. },
  111773. set: function (val) {
  111774. this._computeParticleTexture = val;
  111775. },
  111776. enumerable: true,
  111777. configurable: true
  111778. });
  111779. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  111780. /**
  111781. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111782. * Default value : false. The SPS is faster when it's set to false.
  111783. * Note : the particle custom vertex positions aren't stored values.
  111784. */
  111785. get: function () {
  111786. return this._computeParticleVertex;
  111787. },
  111788. /**
  111789. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111790. * Default value : false. The SPS is faster when it's set to false.
  111791. * Note : the particle custom vertex positions aren't stored values.
  111792. */
  111793. set: function (val) {
  111794. this._computeParticleVertex = val;
  111795. },
  111796. enumerable: true,
  111797. configurable: true
  111798. });
  111799. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  111800. /**
  111801. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111802. */
  111803. get: function () {
  111804. return this._computeBoundingBox;
  111805. },
  111806. /**
  111807. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111808. */
  111809. set: function (val) {
  111810. this._computeBoundingBox = val;
  111811. },
  111812. enumerable: true,
  111813. configurable: true
  111814. });
  111815. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  111816. /**
  111817. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111818. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111819. * Default : `true`
  111820. */
  111821. get: function () {
  111822. return this._depthSortParticles;
  111823. },
  111824. /**
  111825. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111826. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111827. * Default : `true`
  111828. */
  111829. set: function (val) {
  111830. this._depthSortParticles = val;
  111831. },
  111832. enumerable: true,
  111833. configurable: true
  111834. });
  111835. // =======================================================================
  111836. // Particle behavior logic
  111837. // these following methods may be overwritten by the user to fit his needs
  111838. /**
  111839. * This function does nothing. It may be overwritten to set all the particle first values.
  111840. * The SPS doesn't call this function, you may have to call it by your own.
  111841. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  111842. */
  111843. SolidParticleSystem.prototype.initParticles = function () {
  111844. };
  111845. /**
  111846. * This function does nothing. It may be overwritten to recycle a particle.
  111847. * The SPS doesn't call this function, you may have to call it by your own.
  111848. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  111849. * @param particle The particle to recycle
  111850. * @returns the recycled particle
  111851. */
  111852. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  111853. return particle;
  111854. };
  111855. /**
  111856. * Updates a particle : this function should be overwritten by the user.
  111857. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111858. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  111859. * @example : just set a particle position or velocity and recycle conditions
  111860. * @param particle The particle to update
  111861. * @returns the updated particle
  111862. */
  111863. SolidParticleSystem.prototype.updateParticle = function (particle) {
  111864. return particle;
  111865. };
  111866. /**
  111867. * Updates a vertex of a particle : it can be overwritten by the user.
  111868. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111869. * @param particle the current particle
  111870. * @param vertex the current index of the current particle
  111871. * @param pt the index of the current vertex in the particle shape
  111872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  111873. * @example : just set a vertex particle position
  111874. * @returns the updated vertex
  111875. */
  111876. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  111877. return vertex;
  111878. };
  111879. /**
  111880. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111881. * This does nothing and may be overwritten by the user.
  111882. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111883. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111884. * @param update the boolean update value actually passed to setParticles()
  111885. */
  111886. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  111887. };
  111888. /**
  111889. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111890. * This will be passed three parameters.
  111891. * This does nothing and may be overwritten by the user.
  111892. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111894. * @param update the boolean update value actually passed to setParticles()
  111895. */
  111896. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  111897. };
  111898. return SolidParticleSystem;
  111899. }());
  111900. /***/ }),
  111901. /***/ "./Particles/subEmitter.ts":
  111902. /*!*********************************!*\
  111903. !*** ./Particles/subEmitter.ts ***!
  111904. \*********************************/
  111905. /*! exports provided: SubEmitterType, SubEmitter */
  111906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111907. "use strict";
  111908. __webpack_require__.r(__webpack_exports__);
  111909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  111910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  111911. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111912. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111913. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111914. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  111915. /**
  111916. * Type of sub emitter
  111917. */
  111918. var SubEmitterType;
  111919. (function (SubEmitterType) {
  111920. /**
  111921. * Attached to the particle over it's lifetime
  111922. */
  111923. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  111924. /**
  111925. * Created when the particle dies
  111926. */
  111927. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  111928. })(SubEmitterType || (SubEmitterType = {}));
  111929. /**
  111930. * Sub emitter class used to emit particles from an existing particle
  111931. */
  111932. var SubEmitter = /** @class */ (function () {
  111933. /**
  111934. * Creates a sub emitter
  111935. * @param particleSystem the particle system to be used by the sub emitter
  111936. */
  111937. function SubEmitter(
  111938. /**
  111939. * the particle system to be used by the sub emitter
  111940. */
  111941. particleSystem) {
  111942. this.particleSystem = particleSystem;
  111943. /**
  111944. * Type of the submitter (Default: END)
  111945. */
  111946. this.type = SubEmitterType.END;
  111947. /**
  111948. * 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)
  111949. * Note: This only is supported when using an emitter of type Mesh
  111950. */
  111951. this.inheritDirection = false;
  111952. /**
  111953. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  111954. */
  111955. this.inheritedVelocityAmount = 0;
  111956. // Create mesh as emitter to support rotation
  111957. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  111958. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  111959. }
  111960. // Automatically dispose of subemitter when system is disposed
  111961. particleSystem.onDisposeObservable.add(function () {
  111962. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  111963. particleSystem.emitter.dispose();
  111964. }
  111965. });
  111966. }
  111967. /**
  111968. * Clones the sub emitter
  111969. * @returns the cloned sub emitter
  111970. */
  111971. SubEmitter.prototype.clone = function () {
  111972. // Clone particle system
  111973. var emitter = this.particleSystem.emitter;
  111974. if (!emitter) {
  111975. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  111976. }
  111977. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  111978. emitter = emitter.clone();
  111979. }
  111980. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  111981. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  111982. emitter.isVisible = false;
  111983. }
  111984. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  111985. // Clone properties
  111986. clone.type = this.type;
  111987. clone.inheritDirection = this.inheritDirection;
  111988. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  111989. clone.particleSystem._disposeEmitterOnDispose = true;
  111990. clone.particleSystem.disposeOnStop = true;
  111991. return clone;
  111992. };
  111993. /**
  111994. * Serialize current object to a JSON object
  111995. * @returns the serialized object
  111996. */
  111997. SubEmitter.prototype.serialize = function () {
  111998. var serializationObject = {};
  111999. serializationObject.type = this.type;
  112000. serializationObject.inheritDirection = this.inheritDirection;
  112001. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  112002. serializationObject.particleSystem = this.particleSystem.serialize();
  112003. return serializationObject;
  112004. };
  112005. /** @hidden */
  112006. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  112007. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  112008. };
  112009. /**
  112010. * Creates a new SubEmitter from a serialized JSON version
  112011. * @param serializationObject defines the JSON object to read from
  112012. * @param scene defines the hosting scene
  112013. * @param rootUrl defines the rootUrl for data loading
  112014. * @returns a new SubEmitter
  112015. */
  112016. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  112017. var system = serializationObject.particleSystem;
  112018. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  112019. subEmitter.type = serializationObject.type;
  112020. subEmitter.inheritDirection = serializationObject.inheritDirection;
  112021. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  112022. subEmitter.particleSystem._isSubEmitter = true;
  112023. return subEmitter;
  112024. };
  112025. /** Release associated resources */
  112026. SubEmitter.prototype.dispose = function () {
  112027. this.particleSystem.dispose();
  112028. };
  112029. return SubEmitter;
  112030. }());
  112031. /***/ }),
  112032. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  112033. /*!*****************************************!*\
  112034. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  112035. \*****************************************/
  112036. /*! exports provided: AmmoJSPlugin */
  112037. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112038. "use strict";
  112039. __webpack_require__.r(__webpack_exports__);
  112040. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  112041. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  112042. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  112043. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  112044. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  112045. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  112046. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  112047. /* harmony import */ var _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  112048. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  112049. /**
  112050. * AmmoJS Physics plugin
  112051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112052. * @see https://github.com/kripken/ammo.js/
  112053. */
  112054. var AmmoJSPlugin = /** @class */ (function () {
  112055. /**
  112056. * Initializes the ammoJS plugin
  112057. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112058. * @param ammoInjection can be used to inject your own ammo reference
  112059. */
  112060. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  112061. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  112062. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  112063. var _this = this;
  112064. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  112065. /**
  112066. * Reference to the Ammo library
  112067. */
  112068. this.bjsAMMO = {};
  112069. /**
  112070. * Name of the plugin
  112071. */
  112072. this.name = "AmmoJSPlugin";
  112073. this._timeStep = 1 / 60;
  112074. this._fixedTimeStep = 1 / 60;
  112075. this._maxSteps = 5;
  112076. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  112077. this._tmpContactCallbackResult = false;
  112078. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  112079. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  112080. if (typeof ammoInjection === "function") {
  112081. ammoInjection(this.bjsAMMO);
  112082. }
  112083. else {
  112084. this.bjsAMMO = ammoInjection;
  112085. }
  112086. if (!this.isSupported()) {
  112087. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  112088. return;
  112089. }
  112090. // Initialize the physics world
  112091. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
  112092. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  112093. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  112094. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  112095. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
  112096. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);
  112097. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  112098. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  112099. // Create temp ammo variables
  112100. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  112101. this._tmpAmmoTransform.setIdentity();
  112102. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  112103. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  112104. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  112105. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  112106. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0);
  112107. }
  112108. /**
  112109. * Sets the gravity of the physics world (m/(s^2))
  112110. * @param gravity Gravity to set
  112111. */
  112112. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  112113. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  112114. this.world.setGravity(this._tmpAmmoVectorA);
  112115. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
  112116. };
  112117. /**
  112118. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112119. * @param timeStep timestep to use in seconds
  112120. */
  112121. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  112122. this._timeStep = timeStep;
  112123. };
  112124. /**
  112125. * 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)
  112126. * @param fixedTimeStep fixedTimeStep to use in seconds
  112127. */
  112128. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  112129. this._fixedTimeStep = fixedTimeStep;
  112130. };
  112131. /**
  112132. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112133. * @param maxSteps the maximum number of steps by the physics engine per frame
  112134. */
  112135. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  112136. this._maxSteps = maxSteps;
  112137. };
  112138. /**
  112139. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112140. * @returns the current timestep in seconds
  112141. */
  112142. AmmoJSPlugin.prototype.getTimeStep = function () {
  112143. return this._timeStep;
  112144. };
  112145. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  112146. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  112147. this._tmpContactCallbackResult = false;
  112148. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  112149. return this._tmpContactCallbackResult;
  112150. };
  112151. // Ammo's collision events have some weird quirks
  112152. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  112153. // so only fire event if both contactTest and contactPairTest have a hit
  112154. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  112155. this._tmpContactCallbackResult = false;
  112156. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  112157. return this._tmpContactCallbackResult;
  112158. };
  112159. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  112160. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  112161. //
  112162. // When maxSteps is 0 do the entire simulation in one step
  112163. // 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)
  112164. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  112165. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  112166. if (timeStep === void 0) { timeStep = 1 / 60; }
  112167. if (maxSteps === void 0) { maxSteps = 10; }
  112168. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  112169. if (maxSteps == 0) {
  112170. this.world.stepSimulation(timeStep, 0);
  112171. }
  112172. else {
  112173. while (maxSteps > 0 && timeStep > 0) {
  112174. if (timeStep - fixedTimeStep < fixedTimeStep) {
  112175. this.world.stepSimulation(timeStep, 0);
  112176. timeStep = 0;
  112177. }
  112178. else {
  112179. timeStep -= fixedTimeStep;
  112180. this.world.stepSimulation(fixedTimeStep, 0);
  112181. }
  112182. maxSteps--;
  112183. }
  112184. }
  112185. };
  112186. /**
  112187. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112188. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112189. * After the step the babylon meshes are set to the position of the physics imposters
  112190. * @param delta amount of time to step forward
  112191. * @param impostors array of imposters to update before/after the step
  112192. */
  112193. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  112194. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  112195. var impostor = impostors_1[_i];
  112196. // Update physics world objects to match babylon world
  112197. if (!impostor.soft) {
  112198. impostor.beforeStep();
  112199. }
  112200. }
  112201. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  112202. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  112203. var mainImpostor = impostors_2[_a];
  112204. // After physics update make babylon world objects match physics world objects
  112205. if (mainImpostor.soft) {
  112206. this._afterSoftStep(mainImpostor);
  112207. }
  112208. else {
  112209. mainImpostor.afterStep();
  112210. }
  112211. // Handle collision event
  112212. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  112213. if (this._isImpostorInContact(mainImpostor)) {
  112214. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  112215. var collideCallback = _c[_b];
  112216. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  112217. var otherImpostor = _e[_d];
  112218. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  112219. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  112220. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  112221. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  112222. }
  112223. }
  112224. }
  112225. }
  112226. }
  112227. }
  112228. }
  112229. };
  112230. /**
  112231. * Update babylon mesh to match physics world object
  112232. * @param impostor imposter to match
  112233. */
  112234. AmmoJSPlugin.prototype._afterSoftStep = function (impostor) {
  112235. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor) {
  112236. this._ropeStep(impostor);
  112237. }
  112238. else {
  112239. this._softbodyOrClothStep(impostor);
  112240. }
  112241. };
  112242. /**
  112243. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112244. * @param impostor imposter to match
  112245. */
  112246. AmmoJSPlugin.prototype._ropeStep = function (impostor) {
  112247. var bodyVertices = impostor.physicsBody.get_m_nodes();
  112248. var nbVertices = bodyVertices.size();
  112249. var node;
  112250. var nodePositions;
  112251. var x, y, z;
  112252. var path = new Array();
  112253. for (var n = 0; n < nbVertices; n++) {
  112254. node = bodyVertices.at(n);
  112255. nodePositions = node.get_m_x();
  112256. x = nodePositions.x();
  112257. y = nodePositions.y();
  112258. z = nodePositions.z();
  112259. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](x, y, z));
  112260. }
  112261. var object = impostor.object;
  112262. var shape = impostor.getParam("shape");
  112263. if (impostor._isFromLine) {
  112264. impostor.object = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines("lines", { points: path, instance: object });
  112265. }
  112266. else {
  112267. impostor.object = _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__["ShapeBuilder"].ExtrudeShape("ext", { shape: shape, path: path, instance: object });
  112268. }
  112269. };
  112270. /**
  112271. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112272. * @param impostor imposter to match
  112273. */
  112274. AmmoJSPlugin.prototype._softbodyOrClothStep = function (impostor) {
  112275. var normalDirection = (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor) ? 1 : -1;
  112276. var object = impostor.object;
  112277. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  112278. if (!vertexPositions) {
  112279. vertexPositions = [];
  112280. }
  112281. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  112282. if (!vertexNormals) {
  112283. vertexNormals = [];
  112284. }
  112285. var nbVertices = vertexPositions.length / 3;
  112286. var bodyVertices = impostor.physicsBody.get_m_nodes();
  112287. var node;
  112288. var nodePositions;
  112289. var nodeNormals;
  112290. var x, y, z;
  112291. var nx, ny, nz;
  112292. for (var n = 0; n < nbVertices; n++) {
  112293. node = bodyVertices.at(n);
  112294. nodePositions = node.get_m_x();
  112295. x = nodePositions.x();
  112296. y = nodePositions.y();
  112297. z = nodePositions.z() * normalDirection;
  112298. var nodeNormals = node.get_m_n();
  112299. nx = nodeNormals.x();
  112300. ny = nodeNormals.y();
  112301. nz = nodeNormals.z() * normalDirection;
  112302. vertexPositions[3 * n] = x;
  112303. vertexPositions[3 * n + 1] = y;
  112304. vertexPositions[3 * n + 2] = z;
  112305. vertexNormals[3 * n] = nx;
  112306. vertexNormals[3 * n + 1] = ny;
  112307. vertexNormals[3 * n + 2] = nz;
  112308. }
  112309. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  112310. vertex_data.positions = vertexPositions;
  112311. vertex_data.normals = vertexNormals;
  112312. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  112313. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  112314. if (object && object.getIndices) {
  112315. vertex_data.indices = object.getIndices();
  112316. }
  112317. vertex_data.applyToMesh(object);
  112318. };
  112319. /**
  112320. * Applies an impulse on the imposter
  112321. * @param impostor imposter to apply impulse to
  112322. * @param force amount of force to be applied to the imposter
  112323. * @param contactPoint the location to apply the impulse on the imposter
  112324. */
  112325. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  112326. if (!impostor.soft) {
  112327. impostor.physicsBody.activate();
  112328. var worldPoint = this._tmpAmmoVectorA;
  112329. var impulse = this._tmpAmmoVectorB;
  112330. // Convert contactPoint into world space
  112331. if (impostor.object && impostor.object.getWorldMatrix) {
  112332. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  112333. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  112334. contactPoint = this._tmpVector;
  112335. }
  112336. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  112337. impulse.setValue(force.x, force.y, force.z);
  112338. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  112339. }
  112340. else {
  112341. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  112342. }
  112343. };
  112344. /**
  112345. * Applies a force on the imposter
  112346. * @param impostor imposter to apply force
  112347. * @param force amount of force to be applied to the imposter
  112348. * @param contactPoint the location to apply the force on the imposter
  112349. */
  112350. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  112351. if (!impostor.soft) {
  112352. impostor.physicsBody.activate();
  112353. var worldPoint = this._tmpAmmoVectorA;
  112354. var impulse = this._tmpAmmoVectorB;
  112355. // Convert contactPoint into world space
  112356. if (impostor.object && impostor.object.getWorldMatrix) {
  112357. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  112358. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  112359. contactPoint = this._tmpVector;
  112360. }
  112361. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  112362. impulse.setValue(force.x, force.y, force.z);
  112363. impostor.physicsBody.applyForce(impulse, worldPoint);
  112364. }
  112365. else {
  112366. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  112367. }
  112368. };
  112369. /**
  112370. * Creates a physics body using the plugin
  112371. * @param impostor the imposter to create the physics body on
  112372. */
  112373. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  112374. impostor._pluginData = { toDispose: [] };
  112375. //parent-child relationship
  112376. if (impostor.parent) {
  112377. if (impostor.physicsBody) {
  112378. this.removePhysicsBody(impostor);
  112379. impostor.forceUpdate();
  112380. }
  112381. return;
  112382. }
  112383. if (impostor.isBodyInitRequired()) {
  112384. var colShape = this._createShape(impostor);
  112385. var mass = impostor.getParam("mass");
  112386. impostor._pluginData.mass = mass;
  112387. if (impostor.soft) {
  112388. colShape.get_m_cfg().set_collisions(0x11);
  112389. colShape.get_m_cfg().set_kDP(impostor.getParam("damping"));
  112390. Ammo.castObject(colShape, Ammo.btCollisionObject).getCollisionShape().setMargin(impostor.getParam("margin"));
  112391. colShape.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  112392. this.world.addSoftBody(colShape, 1, -1);
  112393. impostor.physicsBody = colShape;
  112394. impostor._pluginData.toDispose.concat([colShape]);
  112395. this.setBodyPressure(impostor, 0);
  112396. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  112397. this.setBodyPressure(impostor, impostor.getParam("pressure"));
  112398. }
  112399. this.setBodyStiffness(impostor, impostor.getParam("stiffness"));
  112400. this.setBodyVelocityIterations(impostor, impostor.getParam("velocityIterations"));
  112401. this.setBodyPositionIterations(impostor, impostor.getParam("positionIterations"));
  112402. }
  112403. else {
  112404. var localInertia = new Ammo.btVector3(0, 0, 0);
  112405. var startTransform = new Ammo.btTransform();
  112406. startTransform.setIdentity();
  112407. if (mass !== 0) {
  112408. colShape.calculateLocalInertia(mass, localInertia);
  112409. }
  112410. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  112411. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  112412. startTransform.setOrigin(this._tmpAmmoVectorA);
  112413. startTransform.setRotation(this._tmpAmmoQuaternion);
  112414. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  112415. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  112416. var body = new Ammo.btRigidBody(rbInfo);
  112417. // Make objects kinematic if it's mass is 0
  112418. if (mass === 0) {
  112419. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  112420. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  112421. }
  112422. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  112423. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  112424. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  112425. }
  112426. this.world.addRigidBody(body);
  112427. impostor.physicsBody = body;
  112428. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  112429. }
  112430. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  112431. this.setBodyFriction(impostor, impostor.getParam("friction"));
  112432. }
  112433. };
  112434. /**
  112435. * Removes the physics body from the imposter and disposes of the body's memory
  112436. * @param impostor imposter to remove the physics body from
  112437. */
  112438. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  112439. var _this = this;
  112440. if (this.world) {
  112441. this.world.removeRigidBody(impostor.physicsBody);
  112442. impostor._pluginData.toDispose.forEach(function (d) {
  112443. _this.bjsAMMO.destroy(d);
  112444. });
  112445. }
  112446. };
  112447. /**
  112448. * Generates a joint
  112449. * @param impostorJoint the imposter joint to create the joint with
  112450. */
  112451. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  112452. var mainBody = impostorJoint.mainImpostor.physicsBody;
  112453. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  112454. if (!mainBody || !connectedBody) {
  112455. return;
  112456. }
  112457. var jointData = impostorJoint.joint.jointData;
  112458. if (!jointData.mainPivot) {
  112459. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  112460. }
  112461. if (!jointData.connectedPivot) {
  112462. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  112463. }
  112464. var joint;
  112465. switch (impostorJoint.joint.type) {
  112466. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  112467. var distance = jointData.maxDistance;
  112468. if (distance) {
  112469. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  112470. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  112471. }
  112472. 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));
  112473. break;
  112474. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  112475. if (!jointData.mainAxis) {
  112476. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  112477. }
  112478. if (!jointData.connectedAxis) {
  112479. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  112480. }
  112481. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  112482. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  112483. 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);
  112484. break;
  112485. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  112486. 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));
  112487. break;
  112488. default:
  112489. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  112490. 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));
  112491. break;
  112492. }
  112493. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  112494. impostorJoint.joint.physicsJoint = joint;
  112495. };
  112496. /**
  112497. * Removes a joint
  112498. * @param impostorJoint the imposter joint to remove the joint from
  112499. */
  112500. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  112501. if (this.world) {
  112502. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  112503. }
  112504. };
  112505. // adds all verticies (including child verticies) to the triangle mesh
  112506. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  112507. var _this = this;
  112508. var triangleCount = 0;
  112509. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  112510. var indices = object.getIndices();
  112511. if (!indices) {
  112512. indices = [];
  112513. }
  112514. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  112515. if (!vertexPositions) {
  112516. vertexPositions = [];
  112517. }
  112518. object.computeWorldMatrix(false);
  112519. var faceCount = indices.length / 3;
  112520. for (var i = 0; i < faceCount; i++) {
  112521. var triPoints = [];
  112522. for (var point = 0; point < 3; point++) {
  112523. 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]);
  112524. // Adjust for initial scaling
  112525. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  112526. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  112527. var vec;
  112528. if (point == 0) {
  112529. vec = this._tmpAmmoVectorA;
  112530. }
  112531. else if (point == 1) {
  112532. vec = this._tmpAmmoVectorB;
  112533. }
  112534. else {
  112535. vec = this._tmpAmmoVectorC;
  112536. }
  112537. vec.setValue(v.x, v.y, v.z);
  112538. triPoints.push(vec);
  112539. }
  112540. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  112541. triangleCount++;
  112542. }
  112543. object.getChildMeshes().forEach(function (m) {
  112544. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  112545. });
  112546. }
  112547. return triangleCount;
  112548. };
  112549. /**
  112550. * Initialise the soft body vertices to match its object's (mesh) vertices
  112551. * Softbody vertices (nodes) are in world space and to match this
  112552. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112553. * @param impostor to create the softbody for
  112554. */
  112555. AmmoJSPlugin.prototype._softVertexData = function (impostor) {
  112556. var object = impostor.object;
  112557. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  112558. var indices = object.getIndices();
  112559. if (!indices) {
  112560. indices = [];
  112561. }
  112562. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  112563. if (!vertexPositions) {
  112564. vertexPositions = [];
  112565. }
  112566. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  112567. if (!vertexNormals) {
  112568. vertexNormals = [];
  112569. }
  112570. object.computeWorldMatrix(false);
  112571. var newPoints = [];
  112572. var newNorms = [];
  112573. for (var i = 0; i < vertexPositions.length; i += 3) {
  112574. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  112575. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  112576. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  112577. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(n, object.getWorldMatrix());
  112578. newPoints.push(v.x, v.y, v.z);
  112579. newNorms.push(n.x, n.y, n.z);
  112580. }
  112581. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  112582. vertex_data.positions = newPoints;
  112583. vertex_data.normals = newNorms;
  112584. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  112585. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  112586. if (object && object.getIndices) {
  112587. vertex_data.indices = object.getIndices();
  112588. }
  112589. vertex_data.applyToMesh(object);
  112590. object.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112591. object.rotationQuaternion = null;
  112592. object.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112593. object.computeWorldMatrix(true);
  112594. return vertex_data;
  112595. }
  112596. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"].ExtractFromMesh(object);
  112597. };
  112598. /**
  112599. * Create an impostor's soft body
  112600. * @param impostor to create the softbody for
  112601. */
  112602. AmmoJSPlugin.prototype._createSoftbody = function (impostor) {
  112603. var object = impostor.object;
  112604. if (object && object.getIndices) {
  112605. var indices = object.getIndices();
  112606. if (!indices) {
  112607. indices = [];
  112608. }
  112609. var vertex_data = this._softVertexData(impostor);
  112610. var vertexPositions = vertex_data.positions;
  112611. var vertexNormals = vertex_data.normals;
  112612. if (vertexPositions === null || vertexNormals === null) {
  112613. return new Ammo.btCompoundShape();
  112614. }
  112615. else {
  112616. var triPoints = [];
  112617. var triNorms = [];
  112618. for (var i = 0; i < vertexPositions.length; i += 3) {
  112619. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  112620. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  112621. triPoints.push(v.x, v.y, -v.z);
  112622. triNorms.push(n.x, n.y, -n.z);
  112623. }
  112624. var softBody = new Ammo.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), triPoints, object.getIndices(), indices.length / 3, true);
  112625. var nbVertices = vertexPositions.length / 3;
  112626. var bodyVertices = softBody.get_m_nodes();
  112627. var node;
  112628. var nodeNormals;
  112629. for (var i = 0; i < nbVertices; i++) {
  112630. node = bodyVertices.at(i);
  112631. var nodeNormals = node.get_m_n();
  112632. nodeNormals.setX(triNorms[3 * i]);
  112633. nodeNormals.setY(triNorms[3 * i + 1]);
  112634. nodeNormals.setZ(triNorms[3 * i + 2]);
  112635. }
  112636. return softBody;
  112637. }
  112638. }
  112639. };
  112640. /**
  112641. * Create cloth for an impostor
  112642. * @param impostor to create the softbody for
  112643. */
  112644. AmmoJSPlugin.prototype._createCloth = function (impostor) {
  112645. var object = impostor.object;
  112646. if (object && object.getIndices) {
  112647. var indices = object.getIndices();
  112648. if (!indices) {
  112649. indices = [];
  112650. }
  112651. var vertex_data = this._softVertexData(impostor);
  112652. var vertexPositions = vertex_data.positions;
  112653. var vertexNormals = vertex_data.normals;
  112654. if (vertexPositions === null || vertexNormals === null) {
  112655. return new Ammo.btCompoundShape();
  112656. }
  112657. else {
  112658. var len = vertexPositions.length;
  112659. var segments = Math.sqrt(len / 3);
  112660. impostor.segments = segments;
  112661. var segs = segments - 1;
  112662. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  112663. this._tmpAmmoVectorB.setValue(vertexPositions[3 * segs], vertexPositions[3 * segs + 1], vertexPositions[3 * segs + 2]);
  112664. this._tmpAmmoVectorD.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  112665. this._tmpAmmoVectorC.setValue(vertexPositions[len - 3 - 3 * segs], vertexPositions[len - 2 - 3 * segs], vertexPositions[len - 1 - 3 * segs]);
  112666. var clothBody = new Ammo.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, segments, segments, impostor.getParam("fixedPoints"), true);
  112667. return clothBody;
  112668. }
  112669. }
  112670. };
  112671. /**
  112672. * Create rope for an impostor
  112673. * @param impostor to create the softbody for
  112674. */
  112675. AmmoJSPlugin.prototype._createRope = function (impostor) {
  112676. var len;
  112677. var segments;
  112678. var vertex_data = this._softVertexData(impostor);
  112679. var vertexPositions = vertex_data.positions;
  112680. var vertexNormals = vertex_data.normals;
  112681. if (vertexPositions === null || vertexNormals === null) {
  112682. return new Ammo.btCompoundShape();
  112683. }
  112684. //force the mesh to be updatable
  112685. vertex_data.applyToMesh(impostor.object, true);
  112686. impostor._isFromLine = true;
  112687. // If in lines mesh all normals will be zero
  112688. var vertexSquared = vertexNormals.map(function (x) { return x * x; });
  112689. var reducer = function (accumulator, currentValue) { return accumulator + currentValue; };
  112690. var reduced = vertexSquared.reduce(reducer);
  112691. if (reduced === 0) { // line mesh
  112692. len = vertexPositions.length;
  112693. segments = len / 3 - 1;
  112694. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  112695. this._tmpAmmoVectorB.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  112696. }
  112697. else { //extruded mesh
  112698. impostor._isFromLine = false;
  112699. var pathVectors = impostor.getParam("path");
  112700. var shape = impostor.getParam("shape");
  112701. if (shape === null) {
  112702. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("No shape available for extruded mesh");
  112703. return new Ammo.btCompoundShape();
  112704. }
  112705. if ((vertexPositions.length % (3 * pathVectors.length)) !== 0) {
  112706. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Path does not match extrusion");
  112707. return new Ammo.btCompoundShape();
  112708. }
  112709. len = pathVectors.length;
  112710. segments = len - 1;
  112711. this._tmpAmmoVectorA.setValue(pathVectors[0].x, pathVectors[0].y, pathVectors[0].z);
  112712. this._tmpAmmoVectorB.setValue(pathVectors[len - 1].x, pathVectors[len - 1].y, pathVectors[len - 1].z);
  112713. }
  112714. impostor.segments = segments;
  112715. var fixedPoints = impostor.getParam("fixedPoints");
  112716. fixedPoints = (fixedPoints > 3) ? 3 : fixedPoints;
  112717. var ropeBody = new Ammo.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, segments - 1, fixedPoints);
  112718. ropeBody.get_m_cfg().set_collisions(0x11);
  112719. return ropeBody;
  112720. };
  112721. // adds all verticies (including child verticies) to the convex hull shape
  112722. AmmoJSPlugin.prototype._addHullVerts = function (btConvexHullShape, topLevelObject, object) {
  112723. var _this = this;
  112724. var triangleCount = 0;
  112725. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  112726. var indices = object.getIndices();
  112727. if (!indices) {
  112728. indices = [];
  112729. }
  112730. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  112731. if (!vertexPositions) {
  112732. vertexPositions = [];
  112733. }
  112734. object.computeWorldMatrix(false);
  112735. var faceCount = indices.length / 3;
  112736. for (var i = 0; i < faceCount; i++) {
  112737. var triPoints = [];
  112738. for (var point = 0; point < 3; point++) {
  112739. 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]);
  112740. // Adjust for initial scaling
  112741. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  112742. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  112743. var vec;
  112744. if (point == 0) {
  112745. vec = this._tmpAmmoVectorA;
  112746. }
  112747. else if (point == 1) {
  112748. vec = this._tmpAmmoVectorB;
  112749. }
  112750. else {
  112751. vec = this._tmpAmmoVectorC;
  112752. }
  112753. vec.setValue(v.x, v.y, v.z);
  112754. triPoints.push(vec);
  112755. }
  112756. btConvexHullShape.addPoint(triPoints[0], true);
  112757. btConvexHullShape.addPoint(triPoints[1], true);
  112758. btConvexHullShape.addPoint(triPoints[2], true);
  112759. triangleCount++;
  112760. }
  112761. object.getChildMeshes().forEach(function (m) {
  112762. triangleCount += _this._addHullVerts(btConvexHullShape, topLevelObject, m);
  112763. });
  112764. }
  112765. return triangleCount;
  112766. };
  112767. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  112768. var _this = this;
  112769. if (ignoreChildren === void 0) { ignoreChildren = false; }
  112770. var object = impostor.object;
  112771. var returnValue;
  112772. var extendSize = impostor.getObjectExtendSize();
  112773. if (!ignoreChildren) {
  112774. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  112775. returnValue = new Ammo.btCompoundShape();
  112776. // Add shape of all children to the compound shape
  112777. var childrenAdded = 0;
  112778. meshChildren.forEach(function (childMesh) {
  112779. var childImpostor = childMesh.getPhysicsImpostor();
  112780. if (childImpostor) {
  112781. var shape = _this._createShape(childImpostor);
  112782. // Position needs to be scaled based on parent's scaling
  112783. var parentMat = childMesh.parent.getWorldMatrix().clone();
  112784. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  112785. parentMat.decompose(s);
  112786. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  112787. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  112788. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  112789. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  112790. childImpostor.dispose();
  112791. childrenAdded++;
  112792. }
  112793. });
  112794. if (childrenAdded > 0) {
  112795. // Add parents shape as a child if present
  112796. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  112797. var shape = this._createShape(impostor, true);
  112798. if (shape) {
  112799. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  112800. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  112801. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  112802. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  112803. }
  112804. }
  112805. return returnValue;
  112806. }
  112807. else {
  112808. // If no children with impostors create the actual shape below instead
  112809. Ammo.destroy(returnValue);
  112810. returnValue = null;
  112811. }
  112812. }
  112813. switch (impostor.type) {
  112814. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  112815. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  112816. break;
  112817. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  112818. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  112819. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  112820. break;
  112821. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  112822. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  112823. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  112824. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  112825. break;
  112826. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  112827. if (impostor.getParam("mass") == 0) {
  112828. // Only create btBvhTriangleMeshShape impostor is static
  112829. // See https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=7283
  112830. var tetraMesh = new Ammo.btTriangleMesh();
  112831. impostor._pluginData.toDispose.concat([tetraMesh]);
  112832. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  112833. if (triangeCount == 0) {
  112834. returnValue = new Ammo.btCompoundShape();
  112835. }
  112836. else {
  112837. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  112838. }
  112839. break;
  112840. }
  112841. // Otherwise create convexHullImpostor
  112842. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ConvexHullImpostor:
  112843. var convexMesh = new Ammo.btConvexHullShape();
  112844. var triangeCount = this._addHullVerts(convexMesh, object, object);
  112845. if (triangeCount == 0) {
  112846. // Cleanup Unused Convex Hull Shape
  112847. impostor._pluginData.toDispose.concat([convexMesh]);
  112848. returnValue = new Ammo.btCompoundShape();
  112849. }
  112850. else {
  112851. returnValue = convexMesh;
  112852. }
  112853. break;
  112854. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  112855. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  112856. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  112857. break;
  112858. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor:
  112859. // Only usable with a mesh that has sufficient and shared vertices
  112860. returnValue = this._createSoftbody(impostor);
  112861. break;
  112862. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor:
  112863. // Only usable with a ground mesh that has sufficient and shared vertices
  112864. returnValue = this._createCloth(impostor);
  112865. break;
  112866. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor:
  112867. // Only usable with a line mesh or an extruded mesh that is updatable
  112868. returnValue = this._createRope(impostor);
  112869. break;
  112870. default:
  112871. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  112872. break;
  112873. }
  112874. return returnValue;
  112875. };
  112876. /**
  112877. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112878. * @param impostor imposter containing the physics body and babylon object
  112879. */
  112880. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  112881. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  112882. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  112883. if (!impostor.object.rotationQuaternion) {
  112884. if (impostor.object.rotation) {
  112885. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  112886. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  112887. }
  112888. }
  112889. else {
  112890. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  112891. }
  112892. };
  112893. /**
  112894. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112895. * @param impostor imposter containing the physics body and babylon object
  112896. * @param newPosition new position
  112897. * @param newRotation new rotation
  112898. */
  112899. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  112900. var trans = impostor.physicsBody.getWorldTransform();
  112901. // If rotation/position has changed update and activate riged body
  112902. if (trans.getOrigin().x() != newPosition.x ||
  112903. trans.getOrigin().y() != newPosition.y ||
  112904. trans.getOrigin().z() != newPosition.z ||
  112905. trans.getRotation().x() != newRotation.x ||
  112906. trans.getRotation().y() != newRotation.y ||
  112907. trans.getRotation().z() != newRotation.z ||
  112908. trans.getRotation().w() != newRotation.w) {
  112909. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  112910. trans.setOrigin(this._tmpAmmoVectorA);
  112911. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  112912. trans.setRotation(this._tmpAmmoQuaternion);
  112913. impostor.physicsBody.setWorldTransform(trans);
  112914. if (impostor.mass == 0) {
  112915. // Kinematic objects must be updated using motion state
  112916. var motionState = impostor.physicsBody.getMotionState();
  112917. if (motionState) {
  112918. motionState.setWorldTransform(trans);
  112919. }
  112920. }
  112921. else {
  112922. impostor.physicsBody.activate();
  112923. }
  112924. }
  112925. };
  112926. /**
  112927. * If this plugin is supported
  112928. * @returns true if its supported
  112929. */
  112930. AmmoJSPlugin.prototype.isSupported = function () {
  112931. return this.bjsAMMO !== undefined;
  112932. };
  112933. /**
  112934. * Sets the linear velocity of the physics body
  112935. * @param impostor imposter to set the velocity on
  112936. * @param velocity velocity to set
  112937. */
  112938. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  112939. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  112940. if (impostor.soft) {
  112941. impostor.physicsBody.linearVelocity(this._tmpAmmoVectorA);
  112942. }
  112943. else {
  112944. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  112945. }
  112946. };
  112947. /**
  112948. * Sets the angular velocity of the physics body
  112949. * @param impostor imposter to set the velocity on
  112950. * @param velocity velocity to set
  112951. */
  112952. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  112953. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  112954. if (impostor.soft) {
  112955. impostor.physicsBody.angularVelocity(this._tmpAmmoVectorA);
  112956. }
  112957. else {
  112958. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  112959. }
  112960. };
  112961. /**
  112962. * gets the linear velocity
  112963. * @param impostor imposter to get linear velocity from
  112964. * @returns linear velocity
  112965. */
  112966. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  112967. if (impostor.soft) {
  112968. var v = impostor.physicsBody.linearVelocity();
  112969. }
  112970. else {
  112971. var v = impostor.physicsBody.getLinearVelocity();
  112972. }
  112973. if (!v) {
  112974. return null;
  112975. }
  112976. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  112977. };
  112978. /**
  112979. * gets the angular velocity
  112980. * @param impostor imposter to get angular velocity from
  112981. * @returns angular velocity
  112982. */
  112983. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  112984. if (impostor.soft) {
  112985. var v = impostor.physicsBody.angularVelocity();
  112986. }
  112987. else {
  112988. var v = impostor.physicsBody.getAngularVelocity();
  112989. }
  112990. if (!v) {
  112991. return null;
  112992. }
  112993. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  112994. };
  112995. /**
  112996. * Sets the mass of physics body
  112997. * @param impostor imposter to set the mass on
  112998. * @param mass mass to set
  112999. */
  113000. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  113001. if (impostor.soft) {
  113002. impostor.physicsBody.setTotalMass(mass, false);
  113003. }
  113004. else {
  113005. impostor.physicsBody.setMassProps(mass);
  113006. }
  113007. impostor._pluginData.mass = mass;
  113008. };
  113009. /**
  113010. * Gets the mass of the physics body
  113011. * @param impostor imposter to get the mass from
  113012. * @returns mass
  113013. */
  113014. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  113015. return impostor._pluginData.mass;
  113016. };
  113017. /**
  113018. * Gets friction of the impostor
  113019. * @param impostor impostor to get friction from
  113020. * @returns friction value
  113021. */
  113022. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  113023. return impostor._pluginData.friction;
  113024. };
  113025. /**
  113026. * Sets friction of the impostor
  113027. * @param impostor impostor to set friction on
  113028. * @param friction friction value
  113029. */
  113030. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  113031. if (impostor.soft) {
  113032. impostor.physicsBody.get_m_cfg().set_kDF(friction);
  113033. }
  113034. else {
  113035. impostor.physicsBody.setFriction(friction);
  113036. }
  113037. impostor._pluginData.friction = friction;
  113038. };
  113039. /**
  113040. * Gets restitution of the impostor
  113041. * @param impostor impostor to get restitution from
  113042. * @returns restitution value
  113043. */
  113044. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  113045. return impostor._pluginData.restitution;
  113046. };
  113047. /**
  113048. * Sets resitution of the impostor
  113049. * @param impostor impostor to set resitution on
  113050. * @param restitution resitution value
  113051. */
  113052. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  113053. impostor.physicsBody.setRestitution(restitution);
  113054. impostor._pluginData.restitution = restitution;
  113055. };
  113056. /**
  113057. * Gets pressure inside the impostor
  113058. * @param impostor impostor to get pressure from
  113059. * @returns pressure value
  113060. */
  113061. AmmoJSPlugin.prototype.getBodyPressure = function (impostor) {
  113062. if (!impostor.soft) {
  113063. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure is not a property of a rigid body");
  113064. return 0;
  113065. }
  113066. return impostor._pluginData.pressure;
  113067. };
  113068. /**
  113069. * Sets pressure inside a soft body impostor
  113070. * Cloth and rope must remain 0 pressure
  113071. * @param impostor impostor to set pressure on
  113072. * @param pressure pressure value
  113073. */
  113074. AmmoJSPlugin.prototype.setBodyPressure = function (impostor, pressure) {
  113075. if (impostor.soft) {
  113076. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  113077. impostor.physicsBody.get_m_cfg().set_kPR(pressure);
  113078. impostor._pluginData.pressure = pressure;
  113079. }
  113080. else {
  113081. impostor.physicsBody.get_m_cfg().set_kPR(0);
  113082. impostor._pluginData.pressure = 0;
  113083. }
  113084. }
  113085. else {
  113086. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure can only be applied to a softbody");
  113087. }
  113088. };
  113089. /**
  113090. * Gets stiffness of the impostor
  113091. * @param impostor impostor to get stiffness from
  113092. * @returns pressure value
  113093. */
  113094. AmmoJSPlugin.prototype.getBodyStiffness = function (impostor) {
  113095. if (!impostor.soft) {
  113096. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness is not a property of a rigid body");
  113097. return 0;
  113098. }
  113099. return impostor._pluginData.stiffness;
  113100. };
  113101. /**
  113102. * Sets stiffness of the impostor
  113103. * @param impostor impostor to set stiffness on
  113104. * @param stiffness stiffness value from 0 to 1
  113105. */
  113106. AmmoJSPlugin.prototype.setBodyStiffness = function (impostor, stiffness) {
  113107. if (impostor.soft) {
  113108. stiffness = stiffness < 0 ? 0 : stiffness;
  113109. stiffness = stiffness > 1 ? 1 : stiffness;
  113110. impostor.physicsBody.get_m_materials().at(0).set_m_kLST(stiffness);
  113111. impostor._pluginData.stiffness = stiffness;
  113112. }
  113113. else {
  113114. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness cannot be applied to a rigid body");
  113115. }
  113116. };
  113117. /**
  113118. * Gets velocityIterations of the impostor
  113119. * @param impostor impostor to get velocity iterations from
  113120. * @returns velocityIterations value
  113121. */
  113122. AmmoJSPlugin.prototype.getBodyVelocityIterations = function (impostor) {
  113123. if (!impostor.soft) {
  113124. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations is not a property of a rigid body");
  113125. return 0;
  113126. }
  113127. return impostor._pluginData.velocityIterations;
  113128. };
  113129. /**
  113130. * Sets velocityIterations of the impostor
  113131. * @param impostor impostor to set velocity iterations on
  113132. * @param velocityIterations velocityIterations value
  113133. */
  113134. AmmoJSPlugin.prototype.setBodyVelocityIterations = function (impostor, velocityIterations) {
  113135. if (impostor.soft) {
  113136. velocityIterations = velocityIterations < 0 ? 0 : velocityIterations;
  113137. impostor.physicsBody.get_m_cfg().set_viterations(velocityIterations);
  113138. impostor._pluginData.velocityIterations = velocityIterations;
  113139. }
  113140. else {
  113141. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations cannot be applied to a rigid body");
  113142. }
  113143. };
  113144. /**
  113145. * Gets positionIterations of the impostor
  113146. * @param impostor impostor to get position iterations from
  113147. * @returns positionIterations value
  113148. */
  113149. AmmoJSPlugin.prototype.getBodyPositionIterations = function (impostor) {
  113150. if (!impostor.soft) {
  113151. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations is not a property of a rigid body");
  113152. return 0;
  113153. }
  113154. return impostor._pluginData.positionIterations;
  113155. };
  113156. /**
  113157. * Sets positionIterations of the impostor
  113158. * @param impostor impostor to set position on
  113159. * @param positionIterations positionIterations value
  113160. */
  113161. AmmoJSPlugin.prototype.setBodyPositionIterations = function (impostor, positionIterations) {
  113162. if (impostor.soft) {
  113163. positionIterations = positionIterations < 0 ? 0 : positionIterations;
  113164. impostor.physicsBody.get_m_cfg().set_piterations(positionIterations);
  113165. impostor._pluginData.positionIterations = positionIterations;
  113166. }
  113167. else {
  113168. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations cannot be applied to a rigid body");
  113169. }
  113170. };
  113171. /**
  113172. * Append an anchor to a cloth object
  113173. * @param impostor is the cloth impostor to add anchor to
  113174. * @param otherImpostor is the rigid impostor to anchor to
  113175. * @param width ratio across width from 0 to 1
  113176. * @param height ratio up height from 0 to 1
  113177. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113178. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113179. */
  113180. AmmoJSPlugin.prototype.appendAnchor = function (impostor, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  113181. if (influence === void 0) { influence = 1; }
  113182. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  113183. var segs = impostor.segments;
  113184. var nbAcross = Math.round((segs - 1) * width);
  113185. var nbUp = Math.round((segs - 1) * height);
  113186. var nbDown = segs - 1 - nbUp;
  113187. var node = nbAcross + segs * nbDown;
  113188. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  113189. };
  113190. /**
  113191. * Append an hook to a rope object
  113192. * @param impostor is the rope impostor to add hook to
  113193. * @param otherImpostor is the rigid impostor to hook to
  113194. * @param length ratio along the rope from 0 to 1
  113195. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  113196. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113197. */
  113198. AmmoJSPlugin.prototype.appendHook = function (impostor, otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  113199. if (influence === void 0) { influence = 1; }
  113200. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  113201. var node = Math.round(impostor.segments * length);
  113202. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  113203. };
  113204. /**
  113205. * Sleeps the physics body and stops it from being active
  113206. * @param impostor impostor to sleep
  113207. */
  113208. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  113209. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  113210. };
  113211. /**
  113212. * Activates the physics body
  113213. * @param impostor impostor to activate
  113214. */
  113215. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  113216. impostor.physicsBody.activate();
  113217. };
  113218. /**
  113219. * Updates the distance parameters of the joint
  113220. * @param joint joint to update
  113221. * @param maxDistance maximum distance of the joint
  113222. * @param minDistance minimum distance of the joint
  113223. */
  113224. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  113225. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  113226. };
  113227. /**
  113228. * Sets a motor on the joint
  113229. * @param joint joint to set motor on
  113230. * @param speed speed of the motor
  113231. * @param maxForce maximum force of the motor
  113232. * @param motorIndex index of the motor
  113233. */
  113234. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  113235. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  113236. };
  113237. /**
  113238. * Sets the motors limit
  113239. * @param joint joint to set limit on
  113240. * @param upperLimit upper limit
  113241. * @param lowerLimit lower limit
  113242. */
  113243. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  113244. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  113245. };
  113246. /**
  113247. * Syncs the position and rotation of a mesh with the impostor
  113248. * @param mesh mesh to sync
  113249. * @param impostor impostor to update the mesh with
  113250. */
  113251. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  113252. var body = impostor.physicsBody;
  113253. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  113254. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  113255. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  113256. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  113257. if (mesh.rotationQuaternion) {
  113258. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  113259. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  113260. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  113261. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  113262. }
  113263. };
  113264. /**
  113265. * Gets the radius of the impostor
  113266. * @param impostor impostor to get radius from
  113267. * @returns the radius
  113268. */
  113269. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  113270. var exntend = impostor.getObjectExtendSize();
  113271. return exntend.x / 2;
  113272. };
  113273. /**
  113274. * Gets the box size of the impostor
  113275. * @param impostor impostor to get box size from
  113276. * @param result the resulting box size
  113277. */
  113278. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  113279. var exntend = impostor.getObjectExtendSize();
  113280. result.x = exntend.x;
  113281. result.y = exntend.y;
  113282. result.z = exntend.z;
  113283. };
  113284. /**
  113285. * Disposes of the impostor
  113286. */
  113287. AmmoJSPlugin.prototype.dispose = function () {
  113288. // Dispose of world
  113289. Ammo.destroy(this.world);
  113290. Ammo.destroy(this._solver);
  113291. Ammo.destroy(this._overlappingPairCache);
  113292. Ammo.destroy(this._dispatcher);
  113293. Ammo.destroy(this._collisionConfiguration);
  113294. // Dispose of tmp variables
  113295. Ammo.destroy(this._tmpAmmoVectorA);
  113296. Ammo.destroy(this._tmpAmmoVectorB);
  113297. Ammo.destroy(this._tmpAmmoVectorC);
  113298. Ammo.destroy(this._tmpAmmoTransform);
  113299. Ammo.destroy(this._tmpAmmoQuaternion);
  113300. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  113301. this.world = null;
  113302. };
  113303. /**
  113304. * Does a raycast in the physics world
  113305. * @param from when should the ray start?
  113306. * @param to when should the ray end?
  113307. * @returns PhysicsRaycastResult
  113308. */
  113309. AmmoJSPlugin.prototype.raycast = function (from, to) {
  113310. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
  113311. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
  113312. var rayCallback = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
  113313. this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, rayCallback);
  113314. this._raycastResult.reset(from, to);
  113315. if (rayCallback.hasHit()) {
  113316. // TODO: do we want/need the body? If so, set all the data
  113317. /*
  113318. var rigidBody = this.bjsAMMO.btRigidBody.prototype.upcast(
  113319. rayCallback.get_m_collisionObject()
  113320. );
  113321. var body = {};
  113322. */
  113323. this._raycastResult.setHitData({
  113324. x: rayCallback.get_m_hitNormalWorld().x(),
  113325. y: rayCallback.get_m_hitNormalWorld().y(),
  113326. z: rayCallback.get_m_hitNormalWorld().z(),
  113327. }, {
  113328. x: rayCallback.get_m_hitPointWorld().x(),
  113329. y: rayCallback.get_m_hitPointWorld().y(),
  113330. z: rayCallback.get_m_hitPointWorld().z(),
  113331. });
  113332. this._raycastResult.calculateHitDistance();
  113333. }
  113334. return this._raycastResult;
  113335. };
  113336. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  113337. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  113338. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  113339. return AmmoJSPlugin;
  113340. }());
  113341. /***/ }),
  113342. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  113343. /*!*******************************************!*\
  113344. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  113345. \*******************************************/
  113346. /*! exports provided: CannonJSPlugin */
  113347. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113348. "use strict";
  113349. __webpack_require__.r(__webpack_exports__);
  113350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  113351. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  113352. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  113353. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  113354. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  113355. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  113356. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  113357. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  113358. /** @hidden */
  113359. var CannonJSPlugin = /** @class */ (function () {
  113360. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  113361. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  113362. if (iterations === void 0) { iterations = 10; }
  113363. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  113364. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  113365. this.name = "CannonJSPlugin";
  113366. this._physicsMaterials = new Array();
  113367. this._fixedTimeStep = 1 / 60;
  113368. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  113369. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  113370. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  113371. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  113372. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  113373. this.BJSCANNON = cannonInjection;
  113374. if (!this.isSupported()) {
  113375. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  113376. return;
  113377. }
  113378. this._extendNamespace();
  113379. this.world = new this.BJSCANNON.World();
  113380. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  113381. this.world.solver.iterations = iterations;
  113382. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();
  113383. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__["PhysicsRaycastResult"]();
  113384. }
  113385. CannonJSPlugin.prototype.setGravity = function (gravity) {
  113386. this.world.gravity.copy(gravity);
  113387. };
  113388. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  113389. this._fixedTimeStep = timeStep;
  113390. };
  113391. CannonJSPlugin.prototype.getTimeStep = function () {
  113392. return this._fixedTimeStep;
  113393. };
  113394. CannonJSPlugin.prototype.executeStep = function (delta) {
  113395. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  113396. };
  113397. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  113398. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  113399. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  113400. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  113401. };
  113402. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  113403. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  113404. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  113405. impostor.physicsBody.applyForce(impulse, worldPoint);
  113406. };
  113407. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  113408. //parent-child relationship. Does this impostor has a parent impostor?
  113409. if (impostor.parent) {
  113410. if (impostor.physicsBody) {
  113411. this.removePhysicsBody(impostor);
  113412. //TODO is that needed?
  113413. impostor.forceUpdate();
  113414. }
  113415. return;
  113416. }
  113417. //should a new body be created for this impostor?
  113418. if (impostor.isBodyInitRequired()) {
  113419. var shape = this._createShape(impostor);
  113420. //unregister events, if body is being changed
  113421. var oldBody = impostor.physicsBody;
  113422. if (oldBody) {
  113423. this.removePhysicsBody(impostor);
  113424. }
  113425. //create the body and material
  113426. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  113427. var bodyCreationObject = {
  113428. mass: impostor.getParam("mass"),
  113429. material: material
  113430. };
  113431. // A simple extend, in case native options were used.
  113432. var nativeOptions = impostor.getParam("nativeOptions");
  113433. for (var key in nativeOptions) {
  113434. if (nativeOptions.hasOwnProperty(key)) {
  113435. bodyCreationObject[key] = nativeOptions[key];
  113436. }
  113437. }
  113438. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  113439. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  113440. this.world.addEventListener("preStep", impostor.beforeStep);
  113441. this.world.addEventListener("postStep", impostor.afterStep);
  113442. impostor.physicsBody.addShape(shape);
  113443. this.world.add(impostor.physicsBody);
  113444. //try to keep the body moving in the right direction by taking old properties.
  113445. //Should be tested!
  113446. if (oldBody) {
  113447. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  113448. impostor.physicsBody[param].copy(oldBody[param]);
  113449. });
  113450. }
  113451. this._processChildMeshes(impostor);
  113452. }
  113453. //now update the body's transformation
  113454. this._updatePhysicsBodyTransformation(impostor);
  113455. };
  113456. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  113457. var _this = this;
  113458. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  113459. var currentRotation = mainImpostor.object.rotationQuaternion;
  113460. if (meshChildren.length) {
  113461. var processMesh = function (localPosition, mesh) {
  113462. if (!currentRotation || !mesh.rotationQuaternion) {
  113463. return;
  113464. }
  113465. var childImpostor = mesh.getPhysicsImpostor();
  113466. if (childImpostor) {
  113467. var parent = childImpostor.parent;
  113468. if (parent !== mainImpostor) {
  113469. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  113470. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  113471. if (childImpostor.physicsBody) {
  113472. _this.removePhysicsBody(childImpostor);
  113473. childImpostor.physicsBody = null;
  113474. }
  113475. childImpostor.parent = mainImpostor;
  113476. childImpostor.resetUpdateFlags();
  113477. 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));
  113478. //Add the mass of the children.
  113479. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  113480. }
  113481. }
  113482. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  113483. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  113484. };
  113485. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  113486. }
  113487. };
  113488. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  113489. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  113490. this.world.removeEventListener("preStep", impostor.beforeStep);
  113491. this.world.removeEventListener("postStep", impostor.afterStep);
  113492. this.world.remove(impostor.physicsBody);
  113493. };
  113494. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  113495. var mainBody = impostorJoint.mainImpostor.physicsBody;
  113496. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  113497. if (!mainBody || !connectedBody) {
  113498. return;
  113499. }
  113500. var constraint;
  113501. var jointData = impostorJoint.joint.jointData;
  113502. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  113503. var constraintData = {
  113504. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  113505. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  113506. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  113507. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  113508. maxForce: jointData.nativeParams.maxForce,
  113509. collideConnected: !!jointData.collision
  113510. };
  113511. switch (impostorJoint.joint.type) {
  113512. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  113513. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  113514. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  113515. break;
  113516. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  113517. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  113518. break;
  113519. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  113520. var springData = jointData;
  113521. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  113522. restLength: springData.length,
  113523. stiffness: springData.stiffness,
  113524. damping: springData.damping,
  113525. localAnchorA: constraintData.pivotA,
  113526. localAnchorB: constraintData.pivotB
  113527. });
  113528. break;
  113529. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  113530. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  113531. break;
  113532. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  113533. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  113534. default:
  113535. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  113536. break;
  113537. }
  113538. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  113539. constraint.collideConnected = !!jointData.collision;
  113540. impostorJoint.joint.physicsJoint = constraint;
  113541. //don't add spring as constraint, as it is not one.
  113542. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  113543. this.world.addConstraint(constraint);
  113544. }
  113545. else {
  113546. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  113547. constraint.applyForce();
  113548. };
  113549. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  113550. }
  113551. };
  113552. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  113553. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  113554. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  113555. }
  113556. else {
  113557. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  113558. }
  113559. };
  113560. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  113561. var index;
  113562. var mat;
  113563. for (index = 0; index < this._physicsMaterials.length; index++) {
  113564. mat = this._physicsMaterials[index];
  113565. if (mat.friction === friction && mat.restitution === restitution) {
  113566. return mat;
  113567. }
  113568. }
  113569. var currentMat = new this.BJSCANNON.Material(name);
  113570. currentMat.friction = friction;
  113571. currentMat.restitution = restitution;
  113572. this._physicsMaterials.push(currentMat);
  113573. return currentMat;
  113574. };
  113575. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  113576. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  113577. };
  113578. CannonJSPlugin.prototype._createShape = function (impostor) {
  113579. var object = impostor.object;
  113580. var returnValue;
  113581. var extendSize = impostor.getObjectExtendSize();
  113582. switch (impostor.type) {
  113583. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  113584. var radiusX = extendSize.x;
  113585. var radiusY = extendSize.y;
  113586. var radiusZ = extendSize.z;
  113587. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  113588. break;
  113589. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  113590. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  113591. var nativeParams = impostor.getParam("nativeOptions");
  113592. if (!nativeParams) {
  113593. nativeParams = {};
  113594. }
  113595. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  113596. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  113597. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  113598. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  113599. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  113600. // Rotate 90 degrees as this shape is horizontal in cannon
  113601. var quat = new this.BJSCANNON.Quaternion();
  113602. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  113603. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  113604. returnValue.transformAllPoints(translation, quat);
  113605. break;
  113606. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  113607. var box = extendSize.scale(0.5);
  113608. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  113609. break;
  113610. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  113611. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  113612. returnValue = new this.BJSCANNON.Plane();
  113613. break;
  113614. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  113615. // should transform the vertex data to world coordinates!!
  113616. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  113617. var rawFaces = object.getIndices ? object.getIndices() : [];
  113618. if (!rawVerts) {
  113619. return;
  113620. }
  113621. // get only scale! so the object could transform correctly.
  113622. var oldPosition = object.position.clone();
  113623. var oldRotation = object.rotation && object.rotation.clone();
  113624. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  113625. object.position.copyFromFloats(0, 0, 0);
  113626. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  113627. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  113628. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  113629. var transform = object.computeWorldMatrix(true);
  113630. // convert rawVerts to object space
  113631. var temp = new Array();
  113632. var index;
  113633. for (index = 0; index < rawVerts.length; index += 3) {
  113634. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  113635. }
  113636. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  113637. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  113638. //now set back the transformation!
  113639. object.position.copyFrom(oldPosition);
  113640. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  113641. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  113642. break;
  113643. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  113644. var oldPosition2 = object.position.clone();
  113645. var oldRotation2 = object.rotation && object.rotation.clone();
  113646. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  113647. object.position.copyFromFloats(0, 0, 0);
  113648. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  113649. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  113650. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  113651. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  113652. returnValue = this._createHeightmap(object);
  113653. object.position.copyFrom(oldPosition2);
  113654. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  113655. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  113656. object.computeWorldMatrix(true);
  113657. break;
  113658. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  113659. returnValue = new this.BJSCANNON.Particle();
  113660. break;
  113661. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  113662. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  113663. break;
  113664. }
  113665. return returnValue;
  113666. };
  113667. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  113668. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  113669. var transform = object.computeWorldMatrix(true);
  113670. // convert rawVerts to object space
  113671. var temp = new Array();
  113672. var index;
  113673. for (index = 0; index < pos.length; index += 3) {
  113674. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  113675. }
  113676. pos = temp;
  113677. var matrix = new Array();
  113678. //For now pointDepth will not be used and will be automatically calculated.
  113679. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  113680. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  113681. var boundingInfo = object.getBoundingInfo();
  113682. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  113683. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  113684. var elementSize = dim * 2 / arraySize;
  113685. for (var i = 0; i < pos.length; i = i + 3) {
  113686. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  113687. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  113688. var y = -pos[i + 2] + minY;
  113689. if (!matrix[x]) {
  113690. matrix[x] = [];
  113691. }
  113692. if (!matrix[x][z]) {
  113693. matrix[x][z] = y;
  113694. }
  113695. matrix[x][z] = Math.max(y, matrix[x][z]);
  113696. }
  113697. for (var x = 0; x <= arraySize; ++x) {
  113698. if (!matrix[x]) {
  113699. var loc = 1;
  113700. while (!matrix[(x + loc) % arraySize]) {
  113701. loc++;
  113702. }
  113703. matrix[x] = matrix[(x + loc) % arraySize].slice();
  113704. //console.log("missing x", x);
  113705. }
  113706. for (var z = 0; z <= arraySize; ++z) {
  113707. if (!matrix[x][z]) {
  113708. var loc = 1;
  113709. var newValue;
  113710. while (newValue === undefined) {
  113711. newValue = matrix[x][(z + loc++) % arraySize];
  113712. }
  113713. matrix[x][z] = newValue;
  113714. }
  113715. }
  113716. }
  113717. var shape = new this.BJSCANNON.Heightfield(matrix, {
  113718. elementSize: elementSize
  113719. });
  113720. //For future reference, needed for body transformation
  113721. shape.minY = minY;
  113722. return shape;
  113723. };
  113724. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  113725. var object = impostor.object;
  113726. //make sure it is updated...
  113727. object.computeWorldMatrix && object.computeWorldMatrix(true);
  113728. // The delta between the mesh position and the mesh bounding box center
  113729. var bInfo = object.getBoundingInfo();
  113730. if (!bInfo) {
  113731. return;
  113732. }
  113733. var center = impostor.getObjectCenter();
  113734. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  113735. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  113736. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  113737. this._tmpPosition.copyFrom(center);
  113738. var quaternion = object.rotationQuaternion;
  113739. if (!quaternion) {
  113740. return;
  113741. }
  113742. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  113743. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  113744. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  113745. //-90 DEG in X, precalculated
  113746. quaternion = quaternion.multiply(this._minus90X);
  113747. //Invert! (Precalculated, 90 deg in X)
  113748. //No need to clone. this will never change.
  113749. impostor.setDeltaRotation(this._plus90X);
  113750. }
  113751. //If it is a heightfield, if should be centered.
  113752. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  113753. var mesh = object;
  113754. var boundingInfo = mesh.getBoundingInfo();
  113755. //calculate the correct body position:
  113756. var rotationQuaternion = mesh.rotationQuaternion;
  113757. mesh.rotationQuaternion = this._tmpUnityRotation;
  113758. mesh.computeWorldMatrix(true);
  113759. //get original center with no rotation
  113760. var c = center.clone();
  113761. var oldPivot = mesh.getPivotMatrix();
  113762. if (oldPivot) {
  113763. // create a copy the pivot Matrix as it is modified in place
  113764. oldPivot = oldPivot.clone();
  113765. }
  113766. else {
  113767. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  113768. }
  113769. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  113770. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  113771. mesh.setPreTransformMatrix(p);
  113772. mesh.computeWorldMatrix(true);
  113773. //calculate the translation
  113774. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  113775. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  113776. //add it inverted to the delta
  113777. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  113778. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  113779. //rotation is back
  113780. mesh.rotationQuaternion = rotationQuaternion;
  113781. mesh.setPreTransformMatrix(oldPivot);
  113782. mesh.computeWorldMatrix(true);
  113783. }
  113784. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  113785. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  113786. //this._tmpPosition.copyFrom(object.position);
  113787. }
  113788. impostor.setDeltaPosition(this._tmpDeltaPosition);
  113789. //Now update the impostor object
  113790. impostor.physicsBody.position.copy(this._tmpPosition);
  113791. impostor.physicsBody.quaternion.copy(quaternion);
  113792. };
  113793. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  113794. impostor.object.position.copyFrom(impostor.physicsBody.position);
  113795. if (impostor.object.rotationQuaternion) {
  113796. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  113797. }
  113798. };
  113799. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  113800. impostor.physicsBody.position.copy(newPosition);
  113801. impostor.physicsBody.quaternion.copy(newRotation);
  113802. };
  113803. CannonJSPlugin.prototype.isSupported = function () {
  113804. return this.BJSCANNON !== undefined;
  113805. };
  113806. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  113807. impostor.physicsBody.velocity.copy(velocity);
  113808. };
  113809. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  113810. impostor.physicsBody.angularVelocity.copy(velocity);
  113811. };
  113812. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  113813. var v = impostor.physicsBody.velocity;
  113814. if (!v) {
  113815. return null;
  113816. }
  113817. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  113818. };
  113819. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  113820. var v = impostor.physicsBody.angularVelocity;
  113821. if (!v) {
  113822. return null;
  113823. }
  113824. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  113825. };
  113826. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  113827. impostor.physicsBody.mass = mass;
  113828. impostor.physicsBody.updateMassProperties();
  113829. };
  113830. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  113831. return impostor.physicsBody.mass;
  113832. };
  113833. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  113834. return impostor.physicsBody.material.friction;
  113835. };
  113836. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  113837. impostor.physicsBody.material.friction = friction;
  113838. };
  113839. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  113840. return impostor.physicsBody.material.restitution;
  113841. };
  113842. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  113843. impostor.physicsBody.material.restitution = restitution;
  113844. };
  113845. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  113846. impostor.physicsBody.sleep();
  113847. };
  113848. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  113849. impostor.physicsBody.wakeUp();
  113850. };
  113851. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  113852. joint.physicsJoint.distance = maxDistance;
  113853. };
  113854. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  113855. // if (!motorIndex) {
  113856. // joint.physicsJoint.enableMotor();
  113857. // }
  113858. // }
  113859. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  113860. // if (!motorIndex) {
  113861. // joint.physicsJoint.disableMotor();
  113862. // }
  113863. // }
  113864. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  113865. if (!motorIndex) {
  113866. joint.physicsJoint.enableMotor();
  113867. joint.physicsJoint.setMotorSpeed(speed);
  113868. if (maxForce) {
  113869. this.setLimit(joint, maxForce);
  113870. }
  113871. }
  113872. };
  113873. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  113874. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  113875. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  113876. };
  113877. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  113878. var body = impostor.physicsBody;
  113879. mesh.position.x = body.position.x;
  113880. mesh.position.y = body.position.y;
  113881. mesh.position.z = body.position.z;
  113882. if (mesh.rotationQuaternion) {
  113883. mesh.rotationQuaternion.x = body.quaternion.x;
  113884. mesh.rotationQuaternion.y = body.quaternion.y;
  113885. mesh.rotationQuaternion.z = body.quaternion.z;
  113886. mesh.rotationQuaternion.w = body.quaternion.w;
  113887. }
  113888. };
  113889. CannonJSPlugin.prototype.getRadius = function (impostor) {
  113890. var shape = impostor.physicsBody.shapes[0];
  113891. return shape.boundingSphereRadius;
  113892. };
  113893. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  113894. var shape = impostor.physicsBody.shapes[0];
  113895. result.x = shape.halfExtents.x * 2;
  113896. result.y = shape.halfExtents.y * 2;
  113897. result.z = shape.halfExtents.z * 2;
  113898. };
  113899. CannonJSPlugin.prototype.dispose = function () {
  113900. };
  113901. CannonJSPlugin.prototype._extendNamespace = function () {
  113902. //this will force cannon to execute at least one step when using interpolation
  113903. var step_tmp1 = new this.BJSCANNON.Vec3();
  113904. var Engine = this.BJSCANNON;
  113905. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  113906. maxSubSteps = maxSubSteps || 10;
  113907. timeSinceLastCalled = timeSinceLastCalled || 0;
  113908. if (timeSinceLastCalled === 0) {
  113909. this.internalStep(dt);
  113910. this.time += dt;
  113911. }
  113912. else {
  113913. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  113914. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  113915. var t0 = performance.now();
  113916. for (var i = 0; i !== internalSteps; i++) {
  113917. this.internalStep(dt);
  113918. if (performance.now() - t0 > dt * 1000) {
  113919. break;
  113920. }
  113921. }
  113922. this.time += timeSinceLastCalled;
  113923. var h = this.time % dt;
  113924. var h_div_dt = h / dt;
  113925. var interpvelo = step_tmp1;
  113926. var bodies = this.bodies;
  113927. for (var j = 0; j !== bodies.length; j++) {
  113928. var b = bodies[j];
  113929. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  113930. b.position.vsub(b.previousPosition, interpvelo);
  113931. interpvelo.scale(h_div_dt, interpvelo);
  113932. b.position.vadd(interpvelo, b.interpolatedPosition);
  113933. }
  113934. else {
  113935. b.interpolatedPosition.copy(b.position);
  113936. b.interpolatedQuaternion.copy(b.quaternion);
  113937. }
  113938. }
  113939. }
  113940. };
  113941. };
  113942. /**
  113943. * Does a raycast in the physics world
  113944. * @param from when should the ray start?
  113945. * @param to when should the ray end?
  113946. * @returns PhysicsRaycastResult
  113947. */
  113948. CannonJSPlugin.prototype.raycast = function (from, to) {
  113949. this._cannonRaycastResult.reset();
  113950. this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
  113951. this._raycastResult.reset(from, to);
  113952. if (this._cannonRaycastResult.hasHit) {
  113953. // TODO: do we also want to get the body it hit?
  113954. this._raycastResult.setHitData({
  113955. x: this._cannonRaycastResult.hitNormalWorld.x,
  113956. y: this._cannonRaycastResult.hitNormalWorld.y,
  113957. z: this._cannonRaycastResult.hitNormalWorld.z,
  113958. }, {
  113959. x: this._cannonRaycastResult.hitPointWorld.x,
  113960. y: this._cannonRaycastResult.hitPointWorld.y,
  113961. z: this._cannonRaycastResult.hitPointWorld.z,
  113962. });
  113963. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);
  113964. }
  113965. return this._raycastResult;
  113966. };
  113967. return CannonJSPlugin;
  113968. }());
  113969. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  113970. /***/ }),
  113971. /***/ "./Physics/Plugins/index.ts":
  113972. /*!**********************************!*\
  113973. !*** ./Physics/Plugins/index.ts ***!
  113974. \**********************************/
  113975. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  113976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113977. "use strict";
  113978. __webpack_require__.r(__webpack_exports__);
  113979. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  113980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  113981. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  113982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  113983. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  113984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  113985. /***/ }),
  113986. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  113987. /*!*****************************************!*\
  113988. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  113989. \*****************************************/
  113990. /*! exports provided: OimoJSPlugin */
  113991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113992. "use strict";
  113993. __webpack_require__.r(__webpack_exports__);
  113994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  113995. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  113996. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  113997. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  113998. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  113999. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  114000. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  114001. /** @hidden */
  114002. var OimoJSPlugin = /** @class */ (function () {
  114003. function OimoJSPlugin(iterations, oimoInjection) {
  114004. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  114005. this.name = "OimoJSPlugin";
  114006. this._tmpImpostorsArray = [];
  114007. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  114008. this.BJSOIMO = oimoInjection;
  114009. this.world = new this.BJSOIMO.World({
  114010. iterations: iterations
  114011. });
  114012. this.world.clear();
  114013. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__["PhysicsRaycastResult"]();
  114014. }
  114015. OimoJSPlugin.prototype.setGravity = function (gravity) {
  114016. this.world.gravity.copy(gravity);
  114017. };
  114018. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  114019. this.world.timeStep = timeStep;
  114020. };
  114021. OimoJSPlugin.prototype.getTimeStep = function () {
  114022. return this.world.timeStep;
  114023. };
  114024. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  114025. var _this = this;
  114026. impostors.forEach(function (impostor) {
  114027. impostor.beforeStep();
  114028. });
  114029. this.world.step();
  114030. impostors.forEach(function (impostor) {
  114031. impostor.afterStep();
  114032. //update the ordered impostors array
  114033. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  114034. });
  114035. //check for collisions
  114036. var contact = this.world.contacts;
  114037. while (contact !== null) {
  114038. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  114039. contact = contact.next;
  114040. continue;
  114041. }
  114042. //is this body colliding with any other? get the impostor
  114043. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  114044. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  114045. if (!mainImpostor || !collidingImpostor) {
  114046. contact = contact.next;
  114047. continue;
  114048. }
  114049. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  114050. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  114051. contact = contact.next;
  114052. }
  114053. };
  114054. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  114055. var mass = impostor.physicsBody.mass;
  114056. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  114057. };
  114058. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  114059. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  114060. this.applyImpulse(impostor, force, contactPoint);
  114061. };
  114062. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  114063. var _this = this;
  114064. //parent-child relationship. Does this impostor has a parent impostor?
  114065. if (impostor.parent) {
  114066. if (impostor.physicsBody) {
  114067. this.removePhysicsBody(impostor);
  114068. //TODO is that needed?
  114069. impostor.forceUpdate();
  114070. }
  114071. return;
  114072. }
  114073. if (impostor.isBodyInitRequired()) {
  114074. var bodyConfig = {
  114075. name: impostor.uniqueId,
  114076. //Oimo must have mass, also for static objects.
  114077. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  114078. size: [],
  114079. type: [],
  114080. pos: [],
  114081. posShape: [],
  114082. rot: [],
  114083. rotShape: [],
  114084. move: impostor.getParam("mass") !== 0,
  114085. density: impostor.getParam("mass"),
  114086. friction: impostor.getParam("friction"),
  114087. restitution: impostor.getParam("restitution"),
  114088. //Supporting older versions of Oimo
  114089. world: this.world
  114090. };
  114091. var impostors = [impostor];
  114092. var addToArray = function (parent) {
  114093. if (!parent.getChildMeshes) {
  114094. return;
  114095. }
  114096. parent.getChildMeshes().forEach(function (m) {
  114097. if (m.physicsImpostor) {
  114098. impostors.push(m.physicsImpostor);
  114099. //m.physicsImpostor._init();
  114100. }
  114101. });
  114102. };
  114103. addToArray(impostor.object);
  114104. var checkWithEpsilon_1 = function (value) {
  114105. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  114106. };
  114107. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  114108. impostors.forEach(function (i) {
  114109. if (!i.object.rotationQuaternion) {
  114110. return;
  114111. }
  114112. //get the correct bounding box
  114113. var oldQuaternion = i.object.rotationQuaternion;
  114114. globalQuaternion_1 = oldQuaternion.clone();
  114115. var rot = oldQuaternion.toEulerAngles();
  114116. var extendSize = i.getObjectExtendSize();
  114117. var radToDeg = 57.295779513082320876;
  114118. if (i === impostor) {
  114119. var center = impostor.getObjectCenter();
  114120. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  114121. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  114122. //Can also use Array.prototype.push.apply
  114123. bodyConfig.pos.push(center.x);
  114124. bodyConfig.pos.push(center.y);
  114125. bodyConfig.pos.push(center.z);
  114126. bodyConfig.posShape.push(0, 0, 0);
  114127. bodyConfig.rotShape.push(0, 0, 0);
  114128. }
  114129. else {
  114130. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  114131. bodyConfig.posShape.push(localPosition.x);
  114132. bodyConfig.posShape.push(localPosition.y);
  114133. bodyConfig.posShape.push(localPosition.z);
  114134. bodyConfig.pos.push(0, 0, 0);
  114135. bodyConfig.rotShape.push(rot.x * radToDeg);
  114136. bodyConfig.rotShape.push(rot.y * radToDeg);
  114137. bodyConfig.rotShape.push(rot.z * radToDeg);
  114138. }
  114139. // register mesh
  114140. switch (i.type) {
  114141. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  114142. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  114143. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  114144. var radiusX = extendSize.x;
  114145. var radiusY = extendSize.y;
  114146. var radiusZ = extendSize.z;
  114147. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  114148. bodyConfig.type.push('sphere');
  114149. //due to the way oimo works with compounds, add 3 times
  114150. bodyConfig.size.push(size);
  114151. bodyConfig.size.push(size);
  114152. bodyConfig.size.push(size);
  114153. break;
  114154. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  114155. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  114156. var sizeY = checkWithEpsilon_1(extendSize.y);
  114157. bodyConfig.type.push('cylinder');
  114158. bodyConfig.size.push(sizeX);
  114159. bodyConfig.size.push(sizeY);
  114160. //due to the way oimo works with compounds, add one more value.
  114161. bodyConfig.size.push(sizeY);
  114162. break;
  114163. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  114164. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  114165. default:
  114166. var sizeX = checkWithEpsilon_1(extendSize.x);
  114167. var sizeY = checkWithEpsilon_1(extendSize.y);
  114168. var sizeZ = checkWithEpsilon_1(extendSize.z);
  114169. bodyConfig.type.push('box');
  114170. //if (i === impostor) {
  114171. bodyConfig.size.push(sizeX);
  114172. bodyConfig.size.push(sizeY);
  114173. bodyConfig.size.push(sizeZ);
  114174. //} else {
  114175. // bodyConfig.size.push(0,0,0);
  114176. //}
  114177. break;
  114178. }
  114179. //actually not needed, but hey...
  114180. i.object.rotationQuaternion = oldQuaternion;
  114181. });
  114182. impostor.physicsBody = this.world.add(bodyConfig);
  114183. // set the quaternion, ignoring the previously defined (euler) rotation
  114184. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  114185. // update with delta 0, so the body will reveive the new rotation.
  114186. impostor.physicsBody.updatePosition(0);
  114187. }
  114188. else {
  114189. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  114190. }
  114191. impostor.setDeltaPosition(this._tmpPositionVector);
  114192. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  114193. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  114194. };
  114195. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  114196. //impostor.physicsBody.dispose();
  114197. //Same as : (older oimo versions)
  114198. this.world.removeRigidBody(impostor.physicsBody);
  114199. };
  114200. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  114201. var mainBody = impostorJoint.mainImpostor.physicsBody;
  114202. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  114203. if (!mainBody || !connectedBody) {
  114204. return;
  114205. }
  114206. var jointData = impostorJoint.joint.jointData;
  114207. var options = jointData.nativeParams || {};
  114208. var type;
  114209. var nativeJointData = {
  114210. body1: mainBody,
  114211. body2: connectedBody,
  114212. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  114213. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  114214. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  114215. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  114216. min: options.min,
  114217. max: options.max,
  114218. collision: options.collision || jointData.collision,
  114219. spring: options.spring,
  114220. //supporting older version of Oimo
  114221. world: this.world
  114222. };
  114223. switch (impostorJoint.joint.type) {
  114224. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  114225. type = "jointBall";
  114226. break;
  114227. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  114228. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  114229. var springData = jointData;
  114230. nativeJointData.min = springData.length || nativeJointData.min;
  114231. //Max should also be set, just make sure it is at least min
  114232. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  114233. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  114234. type = "jointDistance";
  114235. nativeJointData.max = jointData.maxDistance;
  114236. break;
  114237. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  114238. type = "jointPrisme";
  114239. break;
  114240. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  114241. type = "jointSlide";
  114242. break;
  114243. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  114244. type = "jointWheel";
  114245. break;
  114246. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  114247. default:
  114248. type = "jointHinge";
  114249. break;
  114250. }
  114251. nativeJointData.type = type;
  114252. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  114253. };
  114254. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  114255. //Bug in Oimo prevents us from disposing a joint in the playground
  114256. //joint.joint.physicsJoint.dispose();
  114257. //So we will bruteforce it!
  114258. try {
  114259. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  114260. }
  114261. catch (e) {
  114262. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  114263. }
  114264. };
  114265. OimoJSPlugin.prototype.isSupported = function () {
  114266. return this.BJSOIMO !== undefined;
  114267. };
  114268. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  114269. if (!impostor.physicsBody.sleeping) {
  114270. //TODO check that
  114271. /*if (impostor.physicsBody.shapes.next) {
  114272. var parentShape = this._getLastShape(impostor.physicsBody);
  114273. impostor.object.position.copyFrom(parentShape.position);
  114274. console.log(parentShape.position);
  114275. } else {*/
  114276. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  114277. //}
  114278. if (impostor.object.rotationQuaternion) {
  114279. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  114280. }
  114281. }
  114282. };
  114283. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  114284. var body = impostor.physicsBody;
  114285. body.position.copy(newPosition);
  114286. body.orientation.copy(newRotation);
  114287. body.syncShapes();
  114288. body.awake();
  114289. };
  114290. /*private _getLastShape(body: any): any {
  114291. var lastShape = body.shapes;
  114292. while (lastShape.next) {
  114293. lastShape = lastShape.next;
  114294. }
  114295. return lastShape;
  114296. }*/
  114297. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  114298. impostor.physicsBody.linearVelocity.copy(velocity);
  114299. };
  114300. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  114301. impostor.physicsBody.angularVelocity.copy(velocity);
  114302. };
  114303. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  114304. var v = impostor.physicsBody.linearVelocity;
  114305. if (!v) {
  114306. return null;
  114307. }
  114308. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  114309. };
  114310. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  114311. var v = impostor.physicsBody.angularVelocity;
  114312. if (!v) {
  114313. return null;
  114314. }
  114315. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  114316. };
  114317. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  114318. var staticBody = mass === 0;
  114319. //this will actually set the body's density and not its mass.
  114320. //But this is how oimo treats the mass variable.
  114321. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  114322. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  114323. };
  114324. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  114325. return impostor.physicsBody.shapes.density;
  114326. };
  114327. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  114328. return impostor.physicsBody.shapes.friction;
  114329. };
  114330. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  114331. impostor.physicsBody.shapes.friction = friction;
  114332. };
  114333. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  114334. return impostor.physicsBody.shapes.restitution;
  114335. };
  114336. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  114337. impostor.physicsBody.shapes.restitution = restitution;
  114338. };
  114339. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  114340. impostor.physicsBody.sleep();
  114341. };
  114342. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  114343. impostor.physicsBody.awake();
  114344. };
  114345. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  114346. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  114347. if (minDistance !== void 0) {
  114348. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  114349. }
  114350. };
  114351. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  114352. if (force !== undefined) {
  114353. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  114354. }
  114355. else {
  114356. force = 1e6;
  114357. }
  114358. speed *= -1;
  114359. //TODO separate rotational and transational motors.
  114360. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  114361. if (motor) {
  114362. motor.setMotor(speed, force);
  114363. }
  114364. };
  114365. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  114366. //TODO separate rotational and transational motors.
  114367. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  114368. if (motor) {
  114369. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  114370. }
  114371. };
  114372. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  114373. var body = impostor.physicsBody;
  114374. mesh.position.x = body.position.x;
  114375. mesh.position.y = body.position.y;
  114376. mesh.position.z = body.position.z;
  114377. if (mesh.rotationQuaternion) {
  114378. mesh.rotationQuaternion.x = body.orientation.x;
  114379. mesh.rotationQuaternion.y = body.orientation.y;
  114380. mesh.rotationQuaternion.z = body.orientation.z;
  114381. mesh.rotationQuaternion.w = body.orientation.s;
  114382. }
  114383. };
  114384. OimoJSPlugin.prototype.getRadius = function (impostor) {
  114385. return impostor.physicsBody.shapes.radius;
  114386. };
  114387. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  114388. var shape = impostor.physicsBody.shapes;
  114389. result.x = shape.halfWidth * 2;
  114390. result.y = shape.halfHeight * 2;
  114391. result.z = shape.halfDepth * 2;
  114392. };
  114393. OimoJSPlugin.prototype.dispose = function () {
  114394. this.world.clear();
  114395. };
  114396. /**
  114397. * Does a raycast in the physics world
  114398. * @param from when should the ray start?
  114399. * @param to when should the ray end?
  114400. * @returns PhysicsRaycastResult
  114401. */
  114402. OimoJSPlugin.prototype.raycast = function (from, to) {
  114403. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("raycast is not currently supported by the Oimo physics plugin");
  114404. this._raycastResult.reset(from, to);
  114405. return this._raycastResult;
  114406. };
  114407. return OimoJSPlugin;
  114408. }());
  114409. /***/ }),
  114410. /***/ "./Physics/index.ts":
  114411. /*!**************************!*\
  114412. !*** ./Physics/index.ts ***!
  114413. \**************************/
  114414. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  114415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114416. "use strict";
  114417. __webpack_require__.r(__webpack_exports__);
  114418. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  114419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  114420. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  114421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  114422. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  114423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  114424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEventOptions"]; });
  114425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEventOptions"]; });
  114426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEventOptions"]; });
  114427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  114428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  114429. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  114430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  114431. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  114432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  114433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  114434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  114435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  114436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  114437. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  114438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  114439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  114440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  114441. /***/ }),
  114442. /***/ "./Physics/physicsEngine.ts":
  114443. /*!**********************************!*\
  114444. !*** ./Physics/physicsEngine.ts ***!
  114445. \**********************************/
  114446. /*! exports provided: PhysicsEngine */
  114447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114448. "use strict";
  114449. __webpack_require__.r(__webpack_exports__);
  114450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  114451. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  114452. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  114453. /**
  114454. * Class used to control physics engine
  114455. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114456. */
  114457. var PhysicsEngine = /** @class */ (function () {
  114458. /**
  114459. * Creates a new Physics Engine
  114460. * @param gravity defines the gravity vector used by the simulation
  114461. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114462. */
  114463. function PhysicsEngine(gravity, _physicsPlugin) {
  114464. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  114465. this._physicsPlugin = _physicsPlugin;
  114466. this._impostors = [];
  114467. this._joints = [];
  114468. if (!this._physicsPlugin.isSupported()) {
  114469. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  114470. + "Please make sure it is included.");
  114471. }
  114472. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  114473. this.setGravity(gravity);
  114474. this.setTimeStep();
  114475. }
  114476. /**
  114477. * Factory used to create the default physics plugin.
  114478. * @returns The default physics plugin
  114479. */
  114480. PhysicsEngine.DefaultPluginFactory = function () {
  114481. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  114482. };
  114483. /**
  114484. * Sets the gravity vector used by the simulation
  114485. * @param gravity defines the gravity vector to use
  114486. */
  114487. PhysicsEngine.prototype.setGravity = function (gravity) {
  114488. this.gravity = gravity;
  114489. this._physicsPlugin.setGravity(this.gravity);
  114490. };
  114491. /**
  114492. * Set the time step of the physics engine.
  114493. * Default is 1/60.
  114494. * To slow it down, enter 1/600 for example.
  114495. * To speed it up, 1/30
  114496. * @param newTimeStep defines the new timestep to apply to this world.
  114497. */
  114498. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  114499. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  114500. this._physicsPlugin.setTimeStep(newTimeStep);
  114501. };
  114502. /**
  114503. * Get the time step of the physics engine.
  114504. * @returns the current time step
  114505. */
  114506. PhysicsEngine.prototype.getTimeStep = function () {
  114507. return this._physicsPlugin.getTimeStep();
  114508. };
  114509. /**
  114510. * Release all resources
  114511. */
  114512. PhysicsEngine.prototype.dispose = function () {
  114513. this._impostors.forEach(function (impostor) {
  114514. impostor.dispose();
  114515. });
  114516. this._physicsPlugin.dispose();
  114517. };
  114518. /**
  114519. * Gets the name of the current physics plugin
  114520. * @returns the name of the plugin
  114521. */
  114522. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  114523. return this._physicsPlugin.name;
  114524. };
  114525. /**
  114526. * Adding a new impostor for the impostor tracking.
  114527. * This will be done by the impostor itself.
  114528. * @param impostor the impostor to add
  114529. */
  114530. PhysicsEngine.prototype.addImpostor = function (impostor) {
  114531. impostor.uniqueId = this._impostors.push(impostor);
  114532. //if no parent, generate the body
  114533. if (!impostor.parent) {
  114534. this._physicsPlugin.generatePhysicsBody(impostor);
  114535. }
  114536. };
  114537. /**
  114538. * Remove an impostor from the engine.
  114539. * This impostor and its mesh will not longer be updated by the physics engine.
  114540. * @param impostor the impostor to remove
  114541. */
  114542. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  114543. var index = this._impostors.indexOf(impostor);
  114544. if (index > -1) {
  114545. var removed = this._impostors.splice(index, 1);
  114546. //Is it needed?
  114547. if (removed.length) {
  114548. //this will also remove it from the world.
  114549. removed[0].physicsBody = null;
  114550. }
  114551. }
  114552. };
  114553. /**
  114554. * Add a joint to the physics engine
  114555. * @param mainImpostor defines the main impostor to which the joint is added.
  114556. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114557. * @param joint defines the joint that will connect both impostors.
  114558. */
  114559. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  114560. var impostorJoint = {
  114561. mainImpostor: mainImpostor,
  114562. connectedImpostor: connectedImpostor,
  114563. joint: joint
  114564. };
  114565. joint.physicsPlugin = this._physicsPlugin;
  114566. this._joints.push(impostorJoint);
  114567. this._physicsPlugin.generateJoint(impostorJoint);
  114568. };
  114569. /**
  114570. * Removes a joint from the simulation
  114571. * @param mainImpostor defines the impostor used with the joint
  114572. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114573. * @param joint defines the joint to remove
  114574. */
  114575. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  114576. var matchingJoints = this._joints.filter(function (impostorJoint) {
  114577. return (impostorJoint.connectedImpostor === connectedImpostor
  114578. && impostorJoint.joint === joint
  114579. && impostorJoint.mainImpostor === mainImpostor);
  114580. });
  114581. if (matchingJoints.length) {
  114582. this._physicsPlugin.removeJoint(matchingJoints[0]);
  114583. //TODO remove it from the list as well
  114584. }
  114585. };
  114586. /**
  114587. * Called by the scene. No need to call it.
  114588. * @param delta defines the timespam between frames
  114589. */
  114590. PhysicsEngine.prototype._step = function (delta) {
  114591. var _this = this;
  114592. //check if any mesh has no body / requires an update
  114593. this._impostors.forEach(function (impostor) {
  114594. if (impostor.isBodyInitRequired()) {
  114595. _this._physicsPlugin.generatePhysicsBody(impostor);
  114596. }
  114597. });
  114598. if (delta > 0.1) {
  114599. delta = 0.1;
  114600. }
  114601. else if (delta <= 0) {
  114602. delta = 1.0 / 60.0;
  114603. }
  114604. this._physicsPlugin.executeStep(delta, this._impostors);
  114605. };
  114606. /**
  114607. * Gets the current plugin used to run the simulation
  114608. * @returns current plugin
  114609. */
  114610. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  114611. return this._physicsPlugin;
  114612. };
  114613. /**
  114614. * Gets the list of physic impostors
  114615. * @returns an array of PhysicsImpostor
  114616. */
  114617. PhysicsEngine.prototype.getImpostors = function () {
  114618. return this._impostors;
  114619. };
  114620. /**
  114621. * Gets the impostor for a physics enabled object
  114622. * @param object defines the object impersonated by the impostor
  114623. * @returns the PhysicsImpostor or null if not found
  114624. */
  114625. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  114626. for (var i = 0; i < this._impostors.length; ++i) {
  114627. if (this._impostors[i].object === object) {
  114628. return this._impostors[i];
  114629. }
  114630. }
  114631. return null;
  114632. };
  114633. /**
  114634. * Gets the impostor for a physics body object
  114635. * @param body defines physics body used by the impostor
  114636. * @returns the PhysicsImpostor or null if not found
  114637. */
  114638. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  114639. for (var i = 0; i < this._impostors.length; ++i) {
  114640. if (this._impostors[i].physicsBody === body) {
  114641. return this._impostors[i];
  114642. }
  114643. }
  114644. return null;
  114645. };
  114646. /**
  114647. * Does a raycast in the physics world
  114648. * @param from when should the ray start?
  114649. * @param to when should the ray end?
  114650. * @returns PhysicsRaycastResult
  114651. */
  114652. PhysicsEngine.prototype.raycast = function (from, to) {
  114653. return this._physicsPlugin.raycast(from, to);
  114654. };
  114655. /**
  114656. * Global value used to control the smallest number supported by the simulation
  114657. */
  114658. PhysicsEngine.Epsilon = 0.001;
  114659. return PhysicsEngine;
  114660. }());
  114661. /***/ }),
  114662. /***/ "./Physics/physicsEngineComponent.ts":
  114663. /*!*******************************************!*\
  114664. !*** ./Physics/physicsEngineComponent.ts ***!
  114665. \*******************************************/
  114666. /*! exports provided: PhysicsEngineSceneComponent */
  114667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114668. "use strict";
  114669. __webpack_require__.r(__webpack_exports__);
  114670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  114671. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  114672. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  114673. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  114674. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  114675. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  114676. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  114677. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  114678. /**
  114679. * Gets the current physics engine
  114680. * @returns a IPhysicsEngine or null if none attached
  114681. */
  114682. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  114683. return this._physicsEngine;
  114684. };
  114685. /**
  114686. * Enables physics to the current scene
  114687. * @param gravity defines the scene's gravity for the physics engine
  114688. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  114689. * @return a boolean indicating if the physics engine was initialized
  114690. */
  114691. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  114692. if (gravity === void 0) { gravity = null; }
  114693. if (this._physicsEngine) {
  114694. return true;
  114695. }
  114696. // Register the component to the scene
  114697. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  114698. if (!component) {
  114699. component = new PhysicsEngineSceneComponent(this);
  114700. this._addComponent(component);
  114701. }
  114702. try {
  114703. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  114704. return true;
  114705. }
  114706. catch (e) {
  114707. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  114708. return false;
  114709. }
  114710. };
  114711. /**
  114712. * Disables and disposes the physics engine associated with the scene
  114713. */
  114714. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  114715. if (!this._physicsEngine) {
  114716. return;
  114717. }
  114718. this._physicsEngine.dispose();
  114719. this._physicsEngine = null;
  114720. };
  114721. /**
  114722. * Gets a boolean indicating if there is an active physics engine
  114723. * @returns a boolean indicating if there is an active physics engine
  114724. */
  114725. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  114726. return this._physicsEngine !== undefined;
  114727. };
  114728. /**
  114729. * Deletes a physics compound impostor
  114730. * @param compound defines the compound to delete
  114731. */
  114732. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  114733. var mesh = compound.parts[0].mesh;
  114734. if (mesh.physicsImpostor) {
  114735. mesh.physicsImpostor.dispose( /*true*/);
  114736. mesh.physicsImpostor = null;
  114737. }
  114738. };
  114739. /** @hidden */
  114740. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  114741. if (this._physicsEngine) {
  114742. this.onBeforePhysicsObservable.notifyObservers(this);
  114743. this._physicsEngine._step(step / 1000);
  114744. this.onAfterPhysicsObservable.notifyObservers(this);
  114745. }
  114746. };
  114747. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  114748. get: function () {
  114749. return this._physicsImpostor;
  114750. },
  114751. set: function (value) {
  114752. var _this = this;
  114753. if (this._physicsImpostor === value) {
  114754. return;
  114755. }
  114756. if (this._disposePhysicsObserver) {
  114757. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  114758. }
  114759. this._physicsImpostor = value;
  114760. if (value) {
  114761. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  114762. // Physics
  114763. if (_this.physicsImpostor) {
  114764. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  114765. _this.physicsImpostor = null;
  114766. }
  114767. });
  114768. }
  114769. },
  114770. enumerable: true,
  114771. configurable: true
  114772. });
  114773. /**
  114774. * Gets the current physics impostor
  114775. * @see http://doc.babylonjs.com/features/physics_engine
  114776. * @returns a physics impostor or null
  114777. */
  114778. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  114779. return this.physicsImpostor;
  114780. };
  114781. /**
  114782. * Apply a physic impulse to the mesh
  114783. * @param force defines the force to apply
  114784. * @param contactPoint defines where to apply the force
  114785. * @returns the current mesh
  114786. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114787. */
  114788. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  114789. if (!this.physicsImpostor) {
  114790. return this;
  114791. }
  114792. this.physicsImpostor.applyImpulse(force, contactPoint);
  114793. return this;
  114794. };
  114795. /**
  114796. * Creates a physic joint between two meshes
  114797. * @param otherMesh defines the other mesh to use
  114798. * @param pivot1 defines the pivot to use on this mesh
  114799. * @param pivot2 defines the pivot to use on the other mesh
  114800. * @param options defines additional options (can be plugin dependent)
  114801. * @returns the current mesh
  114802. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  114803. */
  114804. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  114805. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  114806. return this;
  114807. }
  114808. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  114809. mainPivot: pivot1,
  114810. connectedPivot: pivot2,
  114811. nativeParams: options
  114812. });
  114813. return this;
  114814. };
  114815. /**
  114816. * Defines the physics engine scene component responsible to manage a physics engine
  114817. */
  114818. var PhysicsEngineSceneComponent = /** @class */ (function () {
  114819. /**
  114820. * Creates a new instance of the component for the given scene
  114821. * @param scene Defines the scene to register the component in
  114822. */
  114823. function PhysicsEngineSceneComponent(scene) {
  114824. var _this = this;
  114825. /**
  114826. * The component name helpful to identify the component in the list of scene components.
  114827. */
  114828. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  114829. this.scene = scene;
  114830. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  114831. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  114832. // Replace the function used to get the deterministic frame time
  114833. this.scene.getDeterministicFrameTime = function () {
  114834. if (_this.scene._physicsEngine) {
  114835. return _this.scene._physicsEngine.getTimeStep() * 1000;
  114836. }
  114837. return 1000.0 / 60.0;
  114838. };
  114839. }
  114840. /**
  114841. * Registers the component in a given scene
  114842. */
  114843. PhysicsEngineSceneComponent.prototype.register = function () {
  114844. };
  114845. /**
  114846. * Rebuilds the elements related to this component in case of
  114847. * context lost for instance.
  114848. */
  114849. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  114850. // Nothing to do for this component
  114851. };
  114852. /**
  114853. * Disposes the component and the associated ressources
  114854. */
  114855. PhysicsEngineSceneComponent.prototype.dispose = function () {
  114856. this.scene.onBeforePhysicsObservable.clear();
  114857. this.scene.onAfterPhysicsObservable.clear();
  114858. if (this.scene._physicsEngine) {
  114859. this.scene.disablePhysicsEngine();
  114860. }
  114861. };
  114862. return PhysicsEngineSceneComponent;
  114863. }());
  114864. /***/ }),
  114865. /***/ "./Physics/physicsHelper.ts":
  114866. /*!**********************************!*\
  114867. !*** ./Physics/physicsHelper.ts ***!
  114868. \**********************************/
  114869. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  114870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114871. "use strict";
  114872. __webpack_require__.r(__webpack_exports__);
  114873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  114874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return PhysicsRadialExplosionEventOptions; });
  114875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return PhysicsUpdraftEventOptions; });
  114876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return PhysicsVortexEventOptions; });
  114877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  114878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  114879. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114880. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  114881. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  114882. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  114883. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  114884. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  114885. /**
  114886. * A helper for physics simulations
  114887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  114888. */
  114889. var PhysicsHelper = /** @class */ (function () {
  114890. /**
  114891. * Initializes the Physics helper
  114892. * @param scene Babylon.js scene
  114893. */
  114894. function PhysicsHelper(scene) {
  114895. this._scene = scene;
  114896. this._physicsEngine = this._scene.getPhysicsEngine();
  114897. if (!this._physicsEngine) {
  114898. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  114899. return;
  114900. }
  114901. }
  114902. /**
  114903. * Applies a radial explosion impulse
  114904. * @param origin the origin of the explosion
  114905. * @param radiusOrEventOptions the radius or the options of radial explosion
  114906. * @param strength the explosion strength
  114907. * @param falloff possible options: Constant & Linear. Defaults to Constant
  114908. * @returns A physics radial explosion event, or null
  114909. */
  114910. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radiusOrEventOptions, strength, falloff) {
  114911. if (!this._physicsEngine) {
  114912. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  114913. return null;
  114914. }
  114915. var impostors = this._physicsEngine.getImpostors();
  114916. if (impostors.length === 0) {
  114917. return null;
  114918. }
  114919. if (typeof radiusOrEventOptions === 'number') {
  114920. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  114921. radiusOrEventOptions.radius = radiusOrEventOptions;
  114922. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  114923. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  114924. }
  114925. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  114926. impostors.forEach(function (impostor) {
  114927. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin);
  114928. if (!impostorForceAndContactPoint) {
  114929. return;
  114930. }
  114931. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  114932. });
  114933. event.dispose(false);
  114934. return event;
  114935. };
  114936. /**
  114937. * Applies a radial explosion force
  114938. * @param origin the origin of the explosion
  114939. * @param radiusOrEventOptions the radius or the options of radial explosion
  114940. * @param strength the explosion strength
  114941. * @param falloff possible options: Constant & Linear. Defaults to Constant
  114942. * @returns A physics radial explosion event, or null
  114943. */
  114944. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radiusOrEventOptions, strength, falloff) {
  114945. if (!this._physicsEngine) {
  114946. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  114947. return null;
  114948. }
  114949. var impostors = this._physicsEngine.getImpostors();
  114950. if (impostors.length === 0) {
  114951. return null;
  114952. }
  114953. if (typeof radiusOrEventOptions === 'number') {
  114954. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  114955. radiusOrEventOptions.radius = radiusOrEventOptions;
  114956. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  114957. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  114958. }
  114959. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  114960. impostors.forEach(function (impostor) {
  114961. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin);
  114962. if (!impostorForceAndContactPoint) {
  114963. return;
  114964. }
  114965. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  114966. });
  114967. event.dispose(false);
  114968. return event;
  114969. };
  114970. /**
  114971. * Creates a gravitational field
  114972. * @param origin the origin of the explosion
  114973. * @param radiusOrEventOptions the radius or the options of radial explosion
  114974. * @param strength the explosion strength
  114975. * @param falloff possible options: Constant & Linear. Defaults to Constant
  114976. * @returns A physics gravitational field event, or null
  114977. */
  114978. PhysicsHelper.prototype.gravitationalField = function (origin, radiusOrEventOptions, strength, falloff) {
  114979. if (!this._physicsEngine) {
  114980. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  114981. return null;
  114982. }
  114983. var impostors = this._physicsEngine.getImpostors();
  114984. if (impostors.length === 0) {
  114985. return null;
  114986. }
  114987. if (typeof radiusOrEventOptions === 'number') {
  114988. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  114989. radiusOrEventOptions.radius = radiusOrEventOptions;
  114990. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  114991. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  114992. }
  114993. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radiusOrEventOptions);
  114994. event.dispose(false);
  114995. return event;
  114996. };
  114997. /**
  114998. * Creates a physics updraft event
  114999. * @param origin the origin of the updraft
  115000. * @param radiusOrEventOptions the radius or the options of the updraft
  115001. * @param strength the strength of the updraft
  115002. * @param height the height of the updraft
  115003. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  115004. * @returns A physics updraft event, or null
  115005. */
  115006. PhysicsHelper.prototype.updraft = function (origin, radiusOrEventOptions, strength, height, updraftMode) {
  115007. if (!this._physicsEngine) {
  115008. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115009. return null;
  115010. }
  115011. if (this._physicsEngine.getImpostors().length === 0) {
  115012. return null;
  115013. }
  115014. if (typeof radiusOrEventOptions === 'number') {
  115015. radiusOrEventOptions = new PhysicsUpdraftEventOptions();
  115016. radiusOrEventOptions.radius = radiusOrEventOptions;
  115017. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115018. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  115019. radiusOrEventOptions.updraftMode = updraftMode || radiusOrEventOptions.updraftMode;
  115020. }
  115021. var event = new PhysicsUpdraftEvent(this._scene, origin, radiusOrEventOptions);
  115022. event.dispose(false);
  115023. return event;
  115024. };
  115025. /**
  115026. * Creates a physics vortex event
  115027. * @param origin the of the vortex
  115028. * @param radiusOrEventOptions the radius or the options of the vortex
  115029. * @param strength the strength of the vortex
  115030. * @param height the height of the vortex
  115031. * @returns a Physics vortex event, or null
  115032. * A physics vortex event or null
  115033. */
  115034. PhysicsHelper.prototype.vortex = function (origin, radiusOrEventOptions, strength, height) {
  115035. if (!this._physicsEngine) {
  115036. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115037. return null;
  115038. }
  115039. if (this._physicsEngine.getImpostors().length === 0) {
  115040. return null;
  115041. }
  115042. if (typeof radiusOrEventOptions === 'number') {
  115043. radiusOrEventOptions = new PhysicsVortexEventOptions();
  115044. radiusOrEventOptions.radius = radiusOrEventOptions;
  115045. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115046. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  115047. }
  115048. var event = new PhysicsVortexEvent(this._scene, origin, radiusOrEventOptions);
  115049. event.dispose(false);
  115050. return event;
  115051. };
  115052. return PhysicsHelper;
  115053. }());
  115054. /**
  115055. * Represents a physics radial explosion event
  115056. */
  115057. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  115058. /**
  115059. * Initializes a radial explosioin event
  115060. * @param _scene BabylonJS scene
  115061. * @param _options The options for the vortex event
  115062. */
  115063. function PhysicsRadialExplosionEvent(_scene, _options) {
  115064. this._scene = _scene;
  115065. this._options = _options;
  115066. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  115067. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  115068. }
  115069. /**
  115070. * Returns the data related to the radial explosion event (sphere).
  115071. * @returns The radial explosion event data
  115072. */
  115073. PhysicsRadialExplosionEvent.prototype.getData = function () {
  115074. this._dataFetched = true;
  115075. return {
  115076. sphere: this._sphere,
  115077. };
  115078. };
  115079. /**
  115080. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  115081. * @param impostor A physics imposter
  115082. * @param origin the origin of the explosion
  115083. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  115084. */
  115085. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin) {
  115086. if (impostor.mass === 0) {
  115087. return null;
  115088. }
  115089. if (!this._intersectsWithSphere(impostor, origin, this._options.radius)) {
  115090. return null;
  115091. }
  115092. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  115093. return null;
  115094. }
  115095. var impostorObjectCenter = impostor.getObjectCenter();
  115096. var direction = impostorObjectCenter.subtract(origin);
  115097. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, this._options.radius);
  115098. var hit = ray.intersectsMesh(impostor.object);
  115099. var contactPoint = hit.pickedPoint;
  115100. if (!contactPoint) {
  115101. return null;
  115102. }
  115103. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(origin, contactPoint);
  115104. if (distanceFromOrigin > this._options.radius) {
  115105. return null;
  115106. }
  115107. var multiplier = this._options.falloff === PhysicsRadialImpulseFalloff.Constant
  115108. ? this._options.strength
  115109. : this._options.strength * (1 - (distanceFromOrigin / this._options.radius));
  115110. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  115111. return { force: force, contactPoint: contactPoint };
  115112. };
  115113. /**
  115114. * Disposes the sphere.
  115115. * @param force Specifies if the sphere should be disposed by force
  115116. */
  115117. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  115118. var _this = this;
  115119. if (force === void 0) { force = true; }
  115120. if (force) {
  115121. this._sphere.dispose();
  115122. }
  115123. else {
  115124. setTimeout(function () {
  115125. if (!_this._dataFetched) {
  115126. _this._sphere.dispose();
  115127. }
  115128. }, 0);
  115129. }
  115130. };
  115131. /*** Helpers ***/
  115132. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  115133. if (!this._sphere) {
  115134. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene);
  115135. this._sphere.isVisible = false;
  115136. }
  115137. };
  115138. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  115139. var impostorObject = impostor.object;
  115140. this._prepareSphere();
  115141. this._sphere.position = origin;
  115142. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * 2, radius * 2, radius * 2);
  115143. this._sphere._updateBoundingInfo();
  115144. this._sphere.computeWorldMatrix(true);
  115145. return this._sphere.intersectsMesh(impostorObject, true);
  115146. };
  115147. return PhysicsRadialExplosionEvent;
  115148. }());
  115149. /**
  115150. * Represents a gravitational field event
  115151. */
  115152. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  115153. /**
  115154. * Initializes the physics gravitational field event
  115155. * @param _physicsHelper A physics helper
  115156. * @param _scene BabylonJS scene
  115157. * @param _origin The origin position of the gravitational field event
  115158. * @param _options The options for the vortex event
  115159. */
  115160. function PhysicsGravitationalFieldEvent(_physicsHelper, _scene, _origin, _options) {
  115161. this._physicsHelper = _physicsHelper;
  115162. this._scene = _scene;
  115163. this._origin = _origin;
  115164. this._options = _options;
  115165. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  115166. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  115167. this._tickCallback = this._tick.bind(this);
  115168. this._options.strength = this._options.strength * -1;
  115169. }
  115170. /**
  115171. * Returns the data related to the gravitational field event (sphere).
  115172. * @returns A gravitational field event
  115173. */
  115174. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  115175. this._dataFetched = true;
  115176. return {
  115177. sphere: this._sphere,
  115178. };
  115179. };
  115180. /**
  115181. * Enables the gravitational field.
  115182. */
  115183. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  115184. this._tickCallback.call(this);
  115185. this._scene.registerBeforeRender(this._tickCallback);
  115186. };
  115187. /**
  115188. * Disables the gravitational field.
  115189. */
  115190. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  115191. this._scene.unregisterBeforeRender(this._tickCallback);
  115192. };
  115193. /**
  115194. * Disposes the sphere.
  115195. * @param force The force to dispose from the gravitational field event
  115196. */
  115197. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  115198. var _this = this;
  115199. if (force === void 0) { force = true; }
  115200. if (force) {
  115201. this._sphere.dispose();
  115202. }
  115203. else {
  115204. setTimeout(function () {
  115205. if (!_this._dataFetched) {
  115206. _this._sphere.dispose();
  115207. }
  115208. }, 0);
  115209. }
  115210. };
  115211. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  115212. // Since the params won't change, we fetch the event only once
  115213. if (this._sphere) {
  115214. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  115215. }
  115216. else {
  115217. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  115218. if (radialExplosionEvent) {
  115219. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  115220. }
  115221. }
  115222. };
  115223. return PhysicsGravitationalFieldEvent;
  115224. }());
  115225. /**
  115226. * Represents a physics updraft event
  115227. */
  115228. var PhysicsUpdraftEvent = /** @class */ (function () {
  115229. /**
  115230. * Initializes the physics updraft event
  115231. * @param _scene BabylonJS scene
  115232. * @param _origin The origin position of the updraft
  115233. * @param _options The options for the updraft event
  115234. */
  115235. function PhysicsUpdraftEvent(_scene, _origin, _options) {
  115236. this._scene = _scene;
  115237. this._origin = _origin;
  115238. this._options = _options;
  115239. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  115240. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  115241. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  115242. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  115243. this._physicsEngine = this._scene.getPhysicsEngine();
  115244. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsUpdraftEventOptions()), this._options);
  115245. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  115246. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  115247. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  115248. this._originDirection = this._origin.subtract(this._originTop).normalize();
  115249. }
  115250. this._tickCallback = this._tick.bind(this);
  115251. this._prepareCylinder();
  115252. }
  115253. /**
  115254. * Returns the data related to the updraft event (cylinder).
  115255. * @returns A physics updraft event
  115256. */
  115257. PhysicsUpdraftEvent.prototype.getData = function () {
  115258. this._dataFetched = true;
  115259. return {
  115260. cylinder: this._cylinder,
  115261. };
  115262. };
  115263. /**
  115264. * Enables the updraft.
  115265. */
  115266. PhysicsUpdraftEvent.prototype.enable = function () {
  115267. this._tickCallback.call(this);
  115268. this._scene.registerBeforeRender(this._tickCallback);
  115269. };
  115270. /**
  115271. * Disables the updraft.
  115272. */
  115273. PhysicsUpdraftEvent.prototype.disable = function () {
  115274. this._scene.unregisterBeforeRender(this._tickCallback);
  115275. };
  115276. /**
  115277. * Disposes the cylinder.
  115278. * @param force Specifies if the updraft should be disposed by force
  115279. */
  115280. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  115281. var _this = this;
  115282. if (force === void 0) { force = true; }
  115283. if (!this._cylinder) {
  115284. return;
  115285. }
  115286. if (force) {
  115287. this._cylinder.dispose();
  115288. }
  115289. else {
  115290. setTimeout(function () {
  115291. if (!_this._dataFetched) {
  115292. _this._cylinder.dispose();
  115293. }
  115294. }, 0);
  115295. }
  115296. };
  115297. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  115298. if (impostor.mass === 0) {
  115299. return null;
  115300. }
  115301. if (!this._intersectsWithCylinder(impostor)) {
  115302. return null;
  115303. }
  115304. var impostorObjectCenter = impostor.getObjectCenter();
  115305. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  115306. var direction = this._originDirection;
  115307. }
  115308. else {
  115309. var direction = impostorObjectCenter.subtract(this._originTop);
  115310. }
  115311. var multiplier = this._options.strength * -1;
  115312. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  115313. return { force: force, contactPoint: impostorObjectCenter };
  115314. };
  115315. PhysicsUpdraftEvent.prototype._tick = function () {
  115316. var _this = this;
  115317. this._physicsEngine.getImpostors().forEach(function (impostor) {
  115318. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  115319. if (!impostorForceAndContactPoint) {
  115320. return;
  115321. }
  115322. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  115323. });
  115324. };
  115325. /*** Helpers ***/
  115326. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  115327. if (!this._cylinder) {
  115328. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  115329. height: this._options.height,
  115330. diameter: this._options.radius * 2,
  115331. }, this._scene);
  115332. this._cylinder.isVisible = false;
  115333. }
  115334. };
  115335. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  115336. var impostorObject = impostor.object;
  115337. this._cylinder.position = this._cylinderPosition;
  115338. return this._cylinder.intersectsMesh(impostorObject, true);
  115339. };
  115340. return PhysicsUpdraftEvent;
  115341. }());
  115342. /**
  115343. * Represents a physics vortex event
  115344. */
  115345. var PhysicsVortexEvent = /** @class */ (function () {
  115346. /**
  115347. * Initializes the physics vortex event
  115348. * @param _scene The BabylonJS scene
  115349. * @param _origin The origin position of the vortex
  115350. * @param _options The options for the vortex event
  115351. */
  115352. function PhysicsVortexEvent(_scene, _origin, _options) {
  115353. this._scene = _scene;
  115354. this._origin = _origin;
  115355. this._options = _options;
  115356. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  115357. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  115358. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  115359. this._physicsEngine = this._scene.getPhysicsEngine();
  115360. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsVortexEventOptions()), this._options);
  115361. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  115362. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  115363. this._tickCallback = this._tick.bind(this);
  115364. this._prepareCylinder();
  115365. }
  115366. /**
  115367. * Returns the data related to the vortex event (cylinder).
  115368. * @returns The physics vortex event data
  115369. */
  115370. PhysicsVortexEvent.prototype.getData = function () {
  115371. this._dataFetched = true;
  115372. return {
  115373. cylinder: this._cylinder,
  115374. };
  115375. };
  115376. /**
  115377. * Enables the vortex.
  115378. */
  115379. PhysicsVortexEvent.prototype.enable = function () {
  115380. this._tickCallback.call(this);
  115381. this._scene.registerBeforeRender(this._tickCallback);
  115382. };
  115383. /**
  115384. * Disables the cortex.
  115385. */
  115386. PhysicsVortexEvent.prototype.disable = function () {
  115387. this._scene.unregisterBeforeRender(this._tickCallback);
  115388. };
  115389. /**
  115390. * Disposes the sphere.
  115391. * @param force
  115392. */
  115393. PhysicsVortexEvent.prototype.dispose = function (force) {
  115394. var _this = this;
  115395. if (force === void 0) { force = true; }
  115396. if (force) {
  115397. this._cylinder.dispose();
  115398. }
  115399. else {
  115400. setTimeout(function () {
  115401. if (!_this._dataFetched) {
  115402. _this._cylinder.dispose();
  115403. }
  115404. }, 0);
  115405. }
  115406. };
  115407. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  115408. if (impostor.mass === 0) {
  115409. return null;
  115410. }
  115411. if (!this._intersectsWithCylinder(impostor)) {
  115412. return null;
  115413. }
  115414. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  115415. return null;
  115416. }
  115417. var impostorObjectCenter = impostor.getObjectCenter();
  115418. var originOnPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
  115419. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  115420. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](originOnPlane, originToImpostorDirection, this._options.radius);
  115421. var hit = ray.intersectsMesh(impostor.object);
  115422. var contactPoint = hit.pickedPoint;
  115423. if (!contactPoint) {
  115424. return null;
  115425. }
  115426. var absoluteDistanceFromOrigin = hit.distance / this._options.radius;
  115427. var directionToOrigin = contactPoint.normalize();
  115428. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  115429. directionToOrigin = directionToOrigin.negate();
  115430. }
  115431. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  115432. var forceX = directionToOrigin.x * this._options.centripetalForceMultiplier;
  115433. var forceY = directionToOrigin.y * this._options.updraftForceMultiplier;
  115434. var forceZ = directionToOrigin.z * this._options.centripetalForceMultiplier;
  115435. }
  115436. else {
  115437. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  115438. var forceX = (perpendicularDirection.x + directionToOrigin.x) * this._options.centrifugalForceMultiplier;
  115439. var forceY = this._originTop.y * this._options.updraftForceMultiplier;
  115440. var forceZ = (perpendicularDirection.z + directionToOrigin.z) * this._options.centrifugalForceMultiplier;
  115441. }
  115442. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](forceX, forceY, forceZ);
  115443. force = force.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength);
  115444. return { force: force, contactPoint: impostorObjectCenter };
  115445. };
  115446. PhysicsVortexEvent.prototype._tick = function () {
  115447. var _this = this;
  115448. this._physicsEngine.getImpostors().forEach(function (impostor) {
  115449. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  115450. if (!impostorForceAndContactPoint) {
  115451. return;
  115452. }
  115453. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  115454. });
  115455. };
  115456. /*** Helpers ***/
  115457. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  115458. if (!this._cylinder) {
  115459. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  115460. height: this._options.height,
  115461. diameter: this._options.radius * 2,
  115462. }, this._scene);
  115463. this._cylinder.isVisible = false;
  115464. }
  115465. };
  115466. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  115467. var impostorObject = impostor.object;
  115468. this._cylinder.position = this._cylinderPosition;
  115469. return this._cylinder.intersectsMesh(impostorObject, true);
  115470. };
  115471. return PhysicsVortexEvent;
  115472. }());
  115473. /**
  115474. * Options fot the radial explosion event
  115475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115476. */
  115477. var PhysicsRadialExplosionEventOptions = /** @class */ (function () {
  115478. function PhysicsRadialExplosionEventOptions() {
  115479. /**
  115480. * The radius of the sphere for the radial explosion.
  115481. */
  115482. this.radius = 5;
  115483. /**
  115484. * The strenth of the explosion.
  115485. */
  115486. this.strength = 10;
  115487. /**
  115488. * The strenght of the force in correspondence to the distance of the affected object
  115489. */
  115490. this.falloff = PhysicsRadialImpulseFalloff.Constant;
  115491. /**
  115492. * Sphere options for the radial explosion.
  115493. */
  115494. this.sphere = { segments: 32, diameter: 1 };
  115495. }
  115496. return PhysicsRadialExplosionEventOptions;
  115497. }());
  115498. /**
  115499. * Options fot the updraft event
  115500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115501. */
  115502. var PhysicsUpdraftEventOptions = /** @class */ (function () {
  115503. function PhysicsUpdraftEventOptions() {
  115504. /**
  115505. * The radius of the cylinder for the vortex
  115506. */
  115507. this.radius = 5;
  115508. /**
  115509. * The strenth of the updraft.
  115510. */
  115511. this.strength = 10;
  115512. /**
  115513. * The height of the cylinder for the updraft.
  115514. */
  115515. this.height = 10;
  115516. /**
  115517. * The mode for the the updraft.
  115518. */
  115519. this.updraftMode = PhysicsUpdraftMode.Center;
  115520. }
  115521. return PhysicsUpdraftEventOptions;
  115522. }());
  115523. /**
  115524. * Options fot the vortex event
  115525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115526. */
  115527. var PhysicsVortexEventOptions = /** @class */ (function () {
  115528. function PhysicsVortexEventOptions() {
  115529. /**
  115530. * The radius of the cylinder for the vortex
  115531. */
  115532. this.radius = 5;
  115533. /**
  115534. * The strenth of the vortex.
  115535. */
  115536. this.strength = 10;
  115537. /**
  115538. * The height of the cylinder for the vortex.
  115539. */
  115540. this.height = 10;
  115541. /**
  115542. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  115543. */
  115544. this.centripetalForceThreshold = 0.7;
  115545. /**
  115546. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  115547. */
  115548. this.centripetalForceMultiplier = 5;
  115549. /**
  115550. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  115551. */
  115552. this.centrifugalForceMultiplier = 0.5;
  115553. /**
  115554. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  115555. */
  115556. this.updraftForceMultiplier = 0.02;
  115557. }
  115558. return PhysicsVortexEventOptions;
  115559. }());
  115560. /**
  115561. * The strenght of the force in correspondence to the distance of the affected object
  115562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115563. */
  115564. var PhysicsRadialImpulseFalloff;
  115565. (function (PhysicsRadialImpulseFalloff) {
  115566. /** Defines that impulse is constant in strength across it's whole radius */
  115567. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  115568. /** Defines that impulse gets weaker if it's further from the origin */
  115569. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  115570. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  115571. /**
  115572. * The strength of the force in correspondence to the distance of the affected object
  115573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115574. */
  115575. var PhysicsUpdraftMode;
  115576. (function (PhysicsUpdraftMode) {
  115577. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  115578. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  115579. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  115580. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  115581. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  115582. /***/ }),
  115583. /***/ "./Physics/physicsImpostor.ts":
  115584. /*!************************************!*\
  115585. !*** ./Physics/physicsImpostor.ts ***!
  115586. \************************************/
  115587. /*! exports provided: PhysicsImpostor */
  115588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115589. "use strict";
  115590. __webpack_require__.r(__webpack_exports__);
  115591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  115592. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115593. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  115594. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115595. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  115596. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  115597. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  115598. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  115599. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  115600. mass: jsonObject.physicsMass,
  115601. friction: jsonObject.physicsFriction,
  115602. restitution: jsonObject.physicsRestitution
  115603. }, scene);
  115604. };
  115605. /**
  115606. * Represents a physics imposter
  115607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  115608. */
  115609. var PhysicsImpostor = /** @class */ (function () {
  115610. /**
  115611. * Initializes the physics imposter
  115612. * @param object The physics-enabled object used as the physics imposter
  115613. * @param type The type of the physics imposter
  115614. * @param _options The options for the physics imposter
  115615. * @param _scene The Babylon scene
  115616. */
  115617. function PhysicsImpostor(
  115618. /**
  115619. * The physics-enabled object used as the physics imposter
  115620. */
  115621. object,
  115622. /**
  115623. * The type of the physics imposter
  115624. */
  115625. type, _options, _scene) {
  115626. if (_options === void 0) { _options = { mass: 0 }; }
  115627. var _this = this;
  115628. this.object = object;
  115629. this.type = type;
  115630. this._options = _options;
  115631. this._scene = _scene;
  115632. this._bodyUpdateRequired = false;
  115633. this._onBeforePhysicsStepCallbacks = new Array();
  115634. this._onAfterPhysicsStepCallbacks = new Array();
  115635. /** @hidden */
  115636. this._onPhysicsCollideCallbacks = [];
  115637. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  115638. this._isDisposed = false;
  115639. /**
  115640. * @hidden
  115641. */
  115642. this.soft = false;
  115643. /**
  115644. * @hidden
  115645. */
  115646. this.segments = 0;
  115647. //temp variables for parent rotation calculations
  115648. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  115649. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  115650. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  115651. /**
  115652. * this function is executed by the physics engine.
  115653. */
  115654. this.beforeStep = function () {
  115655. if (!_this._physicsEngine) {
  115656. return;
  115657. }
  115658. _this.object.translate(_this._deltaPosition, -1);
  115659. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  115660. _this.object.computeWorldMatrix(false);
  115661. if (_this.object.parent && _this.object.rotationQuaternion) {
  115662. _this.getParentsRotation();
  115663. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  115664. }
  115665. else {
  115666. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  115667. }
  115668. if (!_this._options.disableBidirectionalTransformation) {
  115669. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  115670. }
  115671. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  115672. func(_this);
  115673. });
  115674. };
  115675. /**
  115676. * this function is executed by the physics engine
  115677. */
  115678. this.afterStep = function () {
  115679. if (!_this._physicsEngine) {
  115680. return;
  115681. }
  115682. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  115683. func(_this);
  115684. });
  115685. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  115686. // object has now its world rotation. needs to be converted to local.
  115687. if (_this.object.parent && _this.object.rotationQuaternion) {
  115688. _this.getParentsRotation();
  115689. _this._tmpQuat.conjugateInPlace();
  115690. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  115691. }
  115692. // take the position set and make it the absolute position of this object.
  115693. _this.object.setAbsolutePosition(_this.object.position);
  115694. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  115695. _this.object.translate(_this._deltaPosition, 1);
  115696. };
  115697. /**
  115698. * Legacy collision detection event support
  115699. */
  115700. this.onCollideEvent = null;
  115701. /**
  115702. * event and body object due to cannon's event-based architecture.
  115703. */
  115704. this.onCollide = function (e) {
  115705. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  115706. return;
  115707. }
  115708. if (!_this._physicsEngine) {
  115709. return;
  115710. }
  115711. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  115712. if (otherImpostor) {
  115713. // Legacy collision detection event support
  115714. if (_this.onCollideEvent) {
  115715. _this.onCollideEvent(_this, otherImpostor);
  115716. }
  115717. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  115718. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  115719. }).forEach(function (obj) {
  115720. obj.callback(_this, otherImpostor);
  115721. });
  115722. }
  115723. };
  115724. //sanity check!
  115725. if (!this.object) {
  115726. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  115727. return;
  115728. }
  115729. // Legacy support for old syntax.
  115730. if (!this._scene && object.getScene) {
  115731. this._scene = object.getScene();
  115732. }
  115733. if (!this._scene) {
  115734. return;
  115735. }
  115736. if (this.type > 100) {
  115737. this.soft = true;
  115738. }
  115739. this._physicsEngine = this._scene.getPhysicsEngine();
  115740. if (!this._physicsEngine) {
  115741. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  115742. }
  115743. else {
  115744. //set the object's quaternion, if not set
  115745. if (!this.object.rotationQuaternion) {
  115746. if (this.object.rotation) {
  115747. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  115748. }
  115749. else {
  115750. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  115751. }
  115752. }
  115753. //default options params
  115754. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  115755. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  115756. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  115757. if (this.soft) {
  115758. //softbody mass must be above 0;
  115759. this._options.mass = this._options.mass > 0 ? this._options.mass : 1;
  115760. this._options.pressure = (_options.pressure === void 0) ? 200 : _options.pressure;
  115761. this._options.stiffness = (_options.stiffness === void 0) ? 1 : _options.stiffness;
  115762. this._options.velocityIterations = (_options.velocityIterations === void 0) ? 20 : _options.velocityIterations;
  115763. this._options.positionIterations = (_options.positionIterations === void 0) ? 20 : _options.positionIterations;
  115764. this._options.fixedPoints = (_options.fixedPoints === void 0) ? 0 : _options.fixedPoints;
  115765. this._options.margin = (_options.margin === void 0) ? 0 : _options.margin;
  115766. this._options.damping = (_options.damping === void 0) ? 0 : _options.damping;
  115767. this._options.path = (_options.path === void 0) ? null : _options.path;
  115768. this._options.shape = (_options.shape === void 0) ? null : _options.shape;
  115769. }
  115770. this._joints = [];
  115771. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  115772. if (!this.object.parent || this._options.ignoreParent) {
  115773. this._init();
  115774. }
  115775. else if (this.object.parent.physicsImpostor) {
  115776. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  115777. }
  115778. }
  115779. }
  115780. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  115781. /**
  115782. * Specifies if the physics imposter is disposed
  115783. */
  115784. get: function () {
  115785. return this._isDisposed;
  115786. },
  115787. enumerable: true,
  115788. configurable: true
  115789. });
  115790. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  115791. /**
  115792. * Gets the mass of the physics imposter
  115793. */
  115794. get: function () {
  115795. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  115796. },
  115797. set: function (value) {
  115798. this.setMass(value);
  115799. },
  115800. enumerable: true,
  115801. configurable: true
  115802. });
  115803. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  115804. /**
  115805. * Gets the coefficient of friction
  115806. */
  115807. get: function () {
  115808. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  115809. },
  115810. /**
  115811. * Sets the coefficient of friction
  115812. */
  115813. set: function (value) {
  115814. if (!this._physicsEngine) {
  115815. return;
  115816. }
  115817. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  115818. },
  115819. enumerable: true,
  115820. configurable: true
  115821. });
  115822. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  115823. /**
  115824. * Gets the coefficient of restitution
  115825. */
  115826. get: function () {
  115827. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  115828. },
  115829. /**
  115830. * Sets the coefficient of restitution
  115831. */
  115832. set: function (value) {
  115833. if (!this._physicsEngine) {
  115834. return;
  115835. }
  115836. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  115837. },
  115838. enumerable: true,
  115839. configurable: true
  115840. });
  115841. Object.defineProperty(PhysicsImpostor.prototype, "pressure", {
  115842. /**
  115843. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  115844. */
  115845. get: function () {
  115846. if (!this._physicsEngine) {
  115847. return 0;
  115848. }
  115849. var plugin = this._physicsEngine.getPhysicsPlugin();
  115850. if (!plugin.setBodyPressure) {
  115851. return 0;
  115852. }
  115853. return plugin.getBodyPressure(this);
  115854. },
  115855. /**
  115856. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  115857. */
  115858. set: function (value) {
  115859. if (!this._physicsEngine) {
  115860. return;
  115861. }
  115862. var plugin = this._physicsEngine.getPhysicsPlugin();
  115863. if (!plugin.setBodyPressure) {
  115864. return;
  115865. }
  115866. plugin.setBodyPressure(this, value);
  115867. },
  115868. enumerable: true,
  115869. configurable: true
  115870. });
  115871. Object.defineProperty(PhysicsImpostor.prototype, "stiffness", {
  115872. /**
  115873. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  115874. */
  115875. get: function () {
  115876. if (!this._physicsEngine) {
  115877. return 0;
  115878. }
  115879. var plugin = this._physicsEngine.getPhysicsPlugin();
  115880. if (!plugin.getBodyStiffness) {
  115881. return 0;
  115882. }
  115883. return plugin.getBodyStiffness(this);
  115884. },
  115885. /**
  115886. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  115887. */
  115888. set: function (value) {
  115889. if (!this._physicsEngine) {
  115890. return;
  115891. }
  115892. var plugin = this._physicsEngine.getPhysicsPlugin();
  115893. if (!plugin.setBodyStiffness) {
  115894. return;
  115895. }
  115896. plugin.setBodyStiffness(this, value);
  115897. },
  115898. enumerable: true,
  115899. configurable: true
  115900. });
  115901. Object.defineProperty(PhysicsImpostor.prototype, "velocityIterations", {
  115902. /**
  115903. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  115904. */
  115905. get: function () {
  115906. if (!this._physicsEngine) {
  115907. return 0;
  115908. }
  115909. var plugin = this._physicsEngine.getPhysicsPlugin();
  115910. if (!plugin.getBodyVelocityIterations) {
  115911. return 0;
  115912. }
  115913. return plugin.getBodyVelocityIterations(this);
  115914. },
  115915. /**
  115916. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  115917. */
  115918. set: function (value) {
  115919. if (!this._physicsEngine) {
  115920. return;
  115921. }
  115922. var plugin = this._physicsEngine.getPhysicsPlugin();
  115923. if (!plugin.setBodyVelocityIterations) {
  115924. return;
  115925. }
  115926. plugin.setBodyVelocityIterations(this, value);
  115927. },
  115928. enumerable: true,
  115929. configurable: true
  115930. });
  115931. Object.defineProperty(PhysicsImpostor.prototype, "positionIterations", {
  115932. /**
  115933. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  115934. */
  115935. get: function () {
  115936. if (!this._physicsEngine) {
  115937. return 0;
  115938. }
  115939. var plugin = this._physicsEngine.getPhysicsPlugin();
  115940. if (!plugin.getBodyPositionIterations) {
  115941. return 0;
  115942. }
  115943. return plugin.getBodyPositionIterations(this);
  115944. },
  115945. /**
  115946. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  115947. */
  115948. set: function (value) {
  115949. if (!this._physicsEngine) {
  115950. return;
  115951. }
  115952. var plugin = this._physicsEngine.getPhysicsPlugin();
  115953. if (!plugin.setBodyPositionIterations) {
  115954. return;
  115955. }
  115956. plugin.setBodyPositionIterations(this, value);
  115957. },
  115958. enumerable: true,
  115959. configurable: true
  115960. });
  115961. /**
  115962. * This function will completly initialize this impostor.
  115963. * It will create a new body - but only if this mesh has no parent.
  115964. * If it has, this impostor will not be used other than to define the impostor
  115965. * of the child mesh.
  115966. * @hidden
  115967. */
  115968. PhysicsImpostor.prototype._init = function () {
  115969. if (!this._physicsEngine) {
  115970. return;
  115971. }
  115972. this._physicsEngine.removeImpostor(this);
  115973. this.physicsBody = null;
  115974. this._parent = this._parent || this._getPhysicsParent();
  115975. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  115976. this._physicsEngine.addImpostor(this);
  115977. }
  115978. };
  115979. PhysicsImpostor.prototype._getPhysicsParent = function () {
  115980. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  115981. var parentMesh = this.object.parent;
  115982. return parentMesh.physicsImpostor;
  115983. }
  115984. return null;
  115985. };
  115986. /**
  115987. * Should a new body be generated.
  115988. * @returns boolean specifying if body initialization is required
  115989. */
  115990. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  115991. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  115992. };
  115993. /**
  115994. * Sets the updated scaling
  115995. * @param updated Specifies if the scaling is updated
  115996. */
  115997. PhysicsImpostor.prototype.setScalingUpdated = function () {
  115998. this.forceUpdate();
  115999. };
  116000. /**
  116001. * Force a regeneration of this or the parent's impostor's body.
  116002. * Use under cautious - This will remove all joints already implemented.
  116003. */
  116004. PhysicsImpostor.prototype.forceUpdate = function () {
  116005. this._init();
  116006. if (this.parent && !this._options.ignoreParent) {
  116007. this.parent.forceUpdate();
  116008. }
  116009. };
  116010. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  116011. /*public get mesh(): AbstractMesh {
  116012. return this._mesh;
  116013. }*/
  116014. /**
  116015. * Gets the body that holds this impostor. Either its own, or its parent.
  116016. */
  116017. get: function () {
  116018. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  116019. },
  116020. /**
  116021. * Set the physics body. Used mainly by the physics engine/plugin
  116022. */
  116023. set: function (physicsBody) {
  116024. if (this._physicsBody && this._physicsEngine) {
  116025. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  116026. }
  116027. this._physicsBody = physicsBody;
  116028. this.resetUpdateFlags();
  116029. },
  116030. enumerable: true,
  116031. configurable: true
  116032. });
  116033. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  116034. /**
  116035. * Get the parent of the physics imposter
  116036. * @returns Physics imposter or null
  116037. */
  116038. get: function () {
  116039. return !this._options.ignoreParent && this._parent ? this._parent : null;
  116040. },
  116041. /**
  116042. * Sets the parent of the physics imposter
  116043. */
  116044. set: function (value) {
  116045. this._parent = value;
  116046. },
  116047. enumerable: true,
  116048. configurable: true
  116049. });
  116050. /**
  116051. * Resets the update flags
  116052. */
  116053. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  116054. this._bodyUpdateRequired = false;
  116055. };
  116056. /**
  116057. * Gets the object extend size
  116058. * @returns the object extend size
  116059. */
  116060. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  116061. if (this.object.getBoundingInfo) {
  116062. var q = this.object.rotationQuaternion;
  116063. //reset rotation
  116064. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  116065. //calculate the world matrix with no rotation
  116066. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  116067. var boundingInfo = this.object.getBoundingInfo();
  116068. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  116069. //bring back the rotation
  116070. this.object.rotationQuaternion = q;
  116071. //calculate the world matrix with the new rotation
  116072. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  116073. return size;
  116074. }
  116075. else {
  116076. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  116077. }
  116078. };
  116079. /**
  116080. * Gets the object center
  116081. * @returns The object center
  116082. */
  116083. PhysicsImpostor.prototype.getObjectCenter = function () {
  116084. if (this.object.getBoundingInfo) {
  116085. var boundingInfo = this.object.getBoundingInfo();
  116086. return boundingInfo.boundingBox.centerWorld;
  116087. }
  116088. else {
  116089. return this.object.position;
  116090. }
  116091. };
  116092. /**
  116093. * Get a specific parametes from the options parameter
  116094. * @param paramName The object parameter name
  116095. * @returns The object parameter
  116096. */
  116097. PhysicsImpostor.prototype.getParam = function (paramName) {
  116098. return this._options[paramName];
  116099. };
  116100. /**
  116101. * Sets a specific parameter in the options given to the physics plugin
  116102. * @param paramName The parameter name
  116103. * @param value The value of the parameter
  116104. */
  116105. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  116106. this._options[paramName] = value;
  116107. this._bodyUpdateRequired = true;
  116108. };
  116109. /**
  116110. * Specifically change the body's mass option. Won't recreate the physics body object
  116111. * @param mass The mass of the physics imposter
  116112. */
  116113. PhysicsImpostor.prototype.setMass = function (mass) {
  116114. if (this.getParam("mass") !== mass) {
  116115. this.setParam("mass", mass);
  116116. }
  116117. if (this._physicsEngine) {
  116118. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  116119. }
  116120. };
  116121. /**
  116122. * Gets the linear velocity
  116123. * @returns linear velocity or null
  116124. */
  116125. PhysicsImpostor.prototype.getLinearVelocity = function () {
  116126. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  116127. };
  116128. /**
  116129. * Sets the linear velocity
  116130. * @param velocity linear velocity or null
  116131. */
  116132. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  116133. if (this._physicsEngine) {
  116134. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  116135. }
  116136. };
  116137. /**
  116138. * Gets the angular velocity
  116139. * @returns angular velocity or null
  116140. */
  116141. PhysicsImpostor.prototype.getAngularVelocity = function () {
  116142. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  116143. };
  116144. /**
  116145. * Sets the angular velocity
  116146. * @param velocity The velocity or null
  116147. */
  116148. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  116149. if (this._physicsEngine) {
  116150. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  116151. }
  116152. };
  116153. /**
  116154. * Execute a function with the physics plugin native code
  116155. * Provide a function the will have two variables - the world object and the physics body object
  116156. * @param func The function to execute with the physics plugin native code
  116157. */
  116158. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  116159. if (this._physicsEngine) {
  116160. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  116161. }
  116162. };
  116163. /**
  116164. * Register a function that will be executed before the physics world is stepping forward
  116165. * @param func The function to execute before the physics world is stepped forward
  116166. */
  116167. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  116168. this._onBeforePhysicsStepCallbacks.push(func);
  116169. };
  116170. /**
  116171. * Unregister a function that will be executed before the physics world is stepping forward
  116172. * @param func The function to execute before the physics world is stepped forward
  116173. */
  116174. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  116175. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  116176. if (index > -1) {
  116177. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  116178. }
  116179. else {
  116180. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  116181. }
  116182. };
  116183. /**
  116184. * Register a function that will be executed after the physics step
  116185. * @param func The function to execute after physics step
  116186. */
  116187. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  116188. this._onAfterPhysicsStepCallbacks.push(func);
  116189. };
  116190. /**
  116191. * Unregisters a function that will be executed after the physics step
  116192. * @param func The function to execute after physics step
  116193. */
  116194. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  116195. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  116196. if (index > -1) {
  116197. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  116198. }
  116199. else {
  116200. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  116201. }
  116202. };
  116203. /**
  116204. * register a function that will be executed when this impostor collides against a different body
  116205. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  116206. * @param func Callback that is executed on collision
  116207. */
  116208. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  116209. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  116210. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  116211. };
  116212. /**
  116213. * Unregisters the physics imposter on contact
  116214. * @param collideAgainst The physics object to collide against
  116215. * @param func Callback to execute on collision
  116216. */
  116217. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  116218. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  116219. var index = -1;
  116220. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  116221. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  116222. // chcek the arrays match
  116223. var sameList = cbDef.otherImpostors.every(function (impostor) {
  116224. return collidedAgainstList.indexOf(impostor) > -1;
  116225. });
  116226. if (sameList) {
  116227. index = idx;
  116228. }
  116229. return sameList;
  116230. }
  116231. return false;
  116232. });
  116233. if (found) {
  116234. this._onPhysicsCollideCallbacks.splice(index, 1);
  116235. }
  116236. else {
  116237. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  116238. }
  116239. };
  116240. /**
  116241. * Get the parent rotation
  116242. * @returns The parent rotation
  116243. */
  116244. PhysicsImpostor.prototype.getParentsRotation = function () {
  116245. var parent = this.object.parent;
  116246. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  116247. while (parent) {
  116248. if (parent.rotationQuaternion) {
  116249. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  116250. }
  116251. else {
  116252. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  116253. }
  116254. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  116255. parent = parent.parent;
  116256. }
  116257. return this._tmpQuat;
  116258. };
  116259. /**
  116260. * Apply a force
  116261. * @param force The force to apply
  116262. * @param contactPoint The contact point for the force
  116263. * @returns The physics imposter
  116264. */
  116265. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  116266. if (this._physicsEngine) {
  116267. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  116268. }
  116269. return this;
  116270. };
  116271. /**
  116272. * Apply an impulse
  116273. * @param force The impulse force
  116274. * @param contactPoint The contact point for the impulse force
  116275. * @returns The physics imposter
  116276. */
  116277. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  116278. if (this._physicsEngine) {
  116279. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  116280. }
  116281. return this;
  116282. };
  116283. /**
  116284. * A help function to create a joint
  116285. * @param otherImpostor A physics imposter used to create a joint
  116286. * @param jointType The type of joint
  116287. * @param jointData The data for the joint
  116288. * @returns The physics imposter
  116289. */
  116290. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  116291. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  116292. this.addJoint(otherImpostor, joint);
  116293. return this;
  116294. };
  116295. /**
  116296. * Add a joint to this impostor with a different impostor
  116297. * @param otherImpostor A physics imposter used to add a joint
  116298. * @param joint The joint to add
  116299. * @returns The physics imposter
  116300. */
  116301. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  116302. this._joints.push({
  116303. otherImpostor: otherImpostor,
  116304. joint: joint
  116305. });
  116306. if (this._physicsEngine) {
  116307. this._physicsEngine.addJoint(this, otherImpostor, joint);
  116308. }
  116309. return this;
  116310. };
  116311. /**
  116312. * Add an anchor to a cloth impostor
  116313. * @param otherImpostor rigid impostor to anchor to
  116314. * @param width ratio across width from 0 to 1
  116315. * @param height ratio up height from 0 to 1
  116316. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116317. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  116318. * @returns impostor the soft imposter
  116319. */
  116320. PhysicsImpostor.prototype.addAnchor = function (otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  116321. if (!this._physicsEngine) {
  116322. return this;
  116323. }
  116324. var plugin = this._physicsEngine.getPhysicsPlugin();
  116325. if (!plugin.appendAnchor) {
  116326. return this;
  116327. }
  116328. if (this._physicsEngine) {
  116329. plugin.appendAnchor(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);
  116330. }
  116331. return this;
  116332. };
  116333. /**
  116334. * Add a hook to a rope impostor
  116335. * @param otherImpostor rigid impostor to anchor to
  116336. * @param length ratio across rope from 0 to 1
  116337. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  116338. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116339. * @returns impostor the rope imposter
  116340. */
  116341. PhysicsImpostor.prototype.addHook = function (otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  116342. if (!this._physicsEngine) {
  116343. return this;
  116344. }
  116345. var plugin = this._physicsEngine.getPhysicsPlugin();
  116346. if (!plugin.appendAnchor) {
  116347. return this;
  116348. }
  116349. if (this._physicsEngine) {
  116350. plugin.appendHook(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);
  116351. }
  116352. return this;
  116353. };
  116354. /**
  116355. * Will keep this body still, in a sleep mode.
  116356. * @returns the physics imposter
  116357. */
  116358. PhysicsImpostor.prototype.sleep = function () {
  116359. if (this._physicsEngine) {
  116360. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  116361. }
  116362. return this;
  116363. };
  116364. /**
  116365. * Wake the body up.
  116366. * @returns The physics imposter
  116367. */
  116368. PhysicsImpostor.prototype.wakeUp = function () {
  116369. if (this._physicsEngine) {
  116370. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  116371. }
  116372. return this;
  116373. };
  116374. /**
  116375. * Clones the physics imposter
  116376. * @param newObject The physics imposter clones to this physics-enabled object
  116377. * @returns A nullable physics imposter
  116378. */
  116379. PhysicsImpostor.prototype.clone = function (newObject) {
  116380. if (!newObject) {
  116381. return null;
  116382. }
  116383. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  116384. };
  116385. /**
  116386. * Disposes the physics imposter
  116387. */
  116388. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  116389. var _this = this;
  116390. //no dispose if no physics engine is available.
  116391. if (!this._physicsEngine) {
  116392. return;
  116393. }
  116394. this._joints.forEach(function (j) {
  116395. if (_this._physicsEngine) {
  116396. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  116397. }
  116398. });
  116399. //dispose the physics body
  116400. this._physicsEngine.removeImpostor(this);
  116401. if (this.parent) {
  116402. this.parent.forceUpdate();
  116403. }
  116404. else {
  116405. /*this._object.getChildMeshes().forEach(function(mesh) {
  116406. if (mesh.physicsImpostor) {
  116407. if (disposeChildren) {
  116408. mesh.physicsImpostor.dispose();
  116409. mesh.physicsImpostor = null;
  116410. }
  116411. }
  116412. })*/
  116413. }
  116414. this._isDisposed = true;
  116415. };
  116416. /**
  116417. * Sets the delta position
  116418. * @param position The delta position amount
  116419. */
  116420. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  116421. this._deltaPosition.copyFrom(position);
  116422. };
  116423. /**
  116424. * Sets the delta rotation
  116425. * @param rotation The delta rotation amount
  116426. */
  116427. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  116428. if (!this._deltaRotation) {
  116429. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  116430. }
  116431. this._deltaRotation.copyFrom(rotation);
  116432. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  116433. };
  116434. /**
  116435. * Gets the box size of the physics imposter and stores the result in the input parameter
  116436. * @param result Stores the box size
  116437. * @returns The physics imposter
  116438. */
  116439. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  116440. if (this._physicsEngine) {
  116441. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  116442. }
  116443. return this;
  116444. };
  116445. /**
  116446. * Gets the radius of the physics imposter
  116447. * @returns Radius of the physics imposter
  116448. */
  116449. PhysicsImpostor.prototype.getRadius = function () {
  116450. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  116451. };
  116452. /**
  116453. * Sync a bone with this impostor
  116454. * @param bone The bone to sync to the impostor.
  116455. * @param boneMesh The mesh that the bone is influencing.
  116456. * @param jointPivot The pivot of the joint / bone in local space.
  116457. * @param distToJoint Optional distance from the impostor to the joint.
  116458. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  116459. */
  116460. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  116461. var tempVec = PhysicsImpostor._tmpVecs[0];
  116462. var mesh = this.object;
  116463. if (mesh.rotationQuaternion) {
  116464. if (adjustRotation) {
  116465. var tempQuat = PhysicsImpostor._tmpQuat;
  116466. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  116467. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  116468. }
  116469. else {
  116470. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  116471. }
  116472. }
  116473. tempVec.x = 0;
  116474. tempVec.y = 0;
  116475. tempVec.z = 0;
  116476. if (jointPivot) {
  116477. tempVec.x = jointPivot.x;
  116478. tempVec.y = jointPivot.y;
  116479. tempVec.z = jointPivot.z;
  116480. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  116481. if (distToJoint === undefined || distToJoint === null) {
  116482. distToJoint = jointPivot.length();
  116483. }
  116484. tempVec.x *= distToJoint;
  116485. tempVec.y *= distToJoint;
  116486. tempVec.z *= distToJoint;
  116487. }
  116488. if (bone.getParent()) {
  116489. tempVec.addInPlace(mesh.getAbsolutePosition());
  116490. bone.setAbsolutePosition(tempVec, boneMesh);
  116491. }
  116492. else {
  116493. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  116494. boneMesh.position.x -= tempVec.x;
  116495. boneMesh.position.y -= tempVec.y;
  116496. boneMesh.position.z -= tempVec.z;
  116497. }
  116498. };
  116499. /**
  116500. * Sync impostor to a bone
  116501. * @param bone The bone that the impostor will be synced to.
  116502. * @param boneMesh The mesh that the bone is influencing.
  116503. * @param jointPivot The pivot of the joint / bone in local space.
  116504. * @param distToJoint Optional distance from the impostor to the joint.
  116505. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  116506. * @param boneAxis Optional vector3 axis the bone is aligned with
  116507. */
  116508. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  116509. var mesh = this.object;
  116510. if (mesh.rotationQuaternion) {
  116511. if (adjustRotation) {
  116512. var tempQuat = PhysicsImpostor._tmpQuat;
  116513. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  116514. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  116515. }
  116516. else {
  116517. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  116518. }
  116519. }
  116520. var pos = PhysicsImpostor._tmpVecs[0];
  116521. var boneDir = PhysicsImpostor._tmpVecs[1];
  116522. if (!boneAxis) {
  116523. boneAxis = PhysicsImpostor._tmpVecs[2];
  116524. boneAxis.x = 0;
  116525. boneAxis.y = 1;
  116526. boneAxis.z = 0;
  116527. }
  116528. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  116529. bone.getAbsolutePositionToRef(boneMesh, pos);
  116530. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  116531. distToJoint = jointPivot.length();
  116532. }
  116533. if (distToJoint !== undefined && distToJoint !== null) {
  116534. pos.x += boneDir.x * distToJoint;
  116535. pos.y += boneDir.y * distToJoint;
  116536. pos.z += boneDir.z * distToJoint;
  116537. }
  116538. mesh.setAbsolutePosition(pos);
  116539. };
  116540. /**
  116541. * The default object size of the imposter
  116542. */
  116543. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  116544. /**
  116545. * The identity quaternion of the imposter
  116546. */
  116547. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  116548. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  116549. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  116550. //Impostor types
  116551. /**
  116552. * No-Imposter type
  116553. */
  116554. PhysicsImpostor.NoImpostor = 0;
  116555. /**
  116556. * Sphere-Imposter type
  116557. */
  116558. PhysicsImpostor.SphereImpostor = 1;
  116559. /**
  116560. * Box-Imposter type
  116561. */
  116562. PhysicsImpostor.BoxImpostor = 2;
  116563. /**
  116564. * Plane-Imposter type
  116565. */
  116566. PhysicsImpostor.PlaneImpostor = 3;
  116567. /**
  116568. * Mesh-imposter type
  116569. */
  116570. PhysicsImpostor.MeshImpostor = 4;
  116571. /**
  116572. * Cylinder-Imposter type
  116573. */
  116574. PhysicsImpostor.CylinderImpostor = 7;
  116575. /**
  116576. * Particle-Imposter type
  116577. */
  116578. PhysicsImpostor.ParticleImpostor = 8;
  116579. /**
  116580. * Heightmap-Imposter type
  116581. */
  116582. PhysicsImpostor.HeightmapImpostor = 9;
  116583. /**
  116584. * ConvexHull-Impostor type (Ammo.js plugin only)
  116585. */
  116586. PhysicsImpostor.ConvexHullImpostor = 10;
  116587. /**
  116588. * Rope-Imposter type
  116589. */
  116590. PhysicsImpostor.RopeImpostor = 101;
  116591. /**
  116592. * Cloth-Imposter type
  116593. */
  116594. PhysicsImpostor.ClothImpostor = 102;
  116595. /**
  116596. * Softbody-Imposter type
  116597. */
  116598. PhysicsImpostor.SoftbodyImpostor = 103;
  116599. return PhysicsImpostor;
  116600. }());
  116601. /***/ }),
  116602. /***/ "./Physics/physicsJoint.ts":
  116603. /*!*********************************!*\
  116604. !*** ./Physics/physicsJoint.ts ***!
  116605. \*********************************/
  116606. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  116607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116608. "use strict";
  116609. __webpack_require__.r(__webpack_exports__);
  116610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  116611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  116612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  116613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  116614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  116615. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116616. /**
  116617. * This is a holder class for the physics joint created by the physics plugin
  116618. * It holds a set of functions to control the underlying joint
  116619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116620. */
  116621. var PhysicsJoint = /** @class */ (function () {
  116622. /**
  116623. * Initializes the physics joint
  116624. * @param type The type of the physics joint
  116625. * @param jointData The data for the physics joint
  116626. */
  116627. function PhysicsJoint(
  116628. /**
  116629. * The type of the physics joint
  116630. */
  116631. type,
  116632. /**
  116633. * The data for the physics joint
  116634. */
  116635. jointData) {
  116636. this.type = type;
  116637. this.jointData = jointData;
  116638. jointData.nativeParams = jointData.nativeParams || {};
  116639. }
  116640. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  116641. /**
  116642. * Gets the physics joint
  116643. */
  116644. get: function () {
  116645. return this._physicsJoint;
  116646. },
  116647. /**
  116648. * Sets the physics joint
  116649. */
  116650. set: function (newJoint) {
  116651. if (this._physicsJoint) {
  116652. //remove from the wolrd
  116653. }
  116654. this._physicsJoint = newJoint;
  116655. },
  116656. enumerable: true,
  116657. configurable: true
  116658. });
  116659. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  116660. /**
  116661. * Sets the physics plugin
  116662. */
  116663. set: function (physicsPlugin) {
  116664. this._physicsPlugin = physicsPlugin;
  116665. },
  116666. enumerable: true,
  116667. configurable: true
  116668. });
  116669. /**
  116670. * Execute a function that is physics-plugin specific.
  116671. * @param {Function} func the function that will be executed.
  116672. * It accepts two parameters: the physics world and the physics joint
  116673. */
  116674. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  116675. func(this._physicsPlugin.world, this._physicsJoint);
  116676. };
  116677. //TODO check if the native joints are the same
  116678. //Joint Types
  116679. /**
  116680. * Distance-Joint type
  116681. */
  116682. PhysicsJoint.DistanceJoint = 0;
  116683. /**
  116684. * Hinge-Joint type
  116685. */
  116686. PhysicsJoint.HingeJoint = 1;
  116687. /**
  116688. * Ball-and-Socket joint type
  116689. */
  116690. PhysicsJoint.BallAndSocketJoint = 2;
  116691. /**
  116692. * Wheel-Joint type
  116693. */
  116694. PhysicsJoint.WheelJoint = 3;
  116695. /**
  116696. * Slider-Joint type
  116697. */
  116698. PhysicsJoint.SliderJoint = 4;
  116699. //OIMO
  116700. /**
  116701. * Prismatic-Joint type
  116702. */
  116703. PhysicsJoint.PrismaticJoint = 5;
  116704. //
  116705. /**
  116706. * Universal-Joint type
  116707. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  116708. */
  116709. PhysicsJoint.UniversalJoint = 6;
  116710. /**
  116711. * Hinge-Joint 2 type
  116712. */
  116713. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  116714. //Cannon
  116715. /**
  116716. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  116717. */
  116718. PhysicsJoint.PointToPointJoint = 8;
  116719. //Cannon only at the moment
  116720. /**
  116721. * Spring-Joint type
  116722. */
  116723. PhysicsJoint.SpringJoint = 9;
  116724. /**
  116725. * Lock-Joint type
  116726. */
  116727. PhysicsJoint.LockJoint = 10;
  116728. return PhysicsJoint;
  116729. }());
  116730. /**
  116731. * A class representing a physics distance joint
  116732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116733. */
  116734. var DistanceJoint = /** @class */ (function (_super) {
  116735. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  116736. /**
  116737. *
  116738. * @param jointData The data for the Distance-Joint
  116739. */
  116740. function DistanceJoint(jointData) {
  116741. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  116742. }
  116743. /**
  116744. * Update the predefined distance.
  116745. * @param maxDistance The maximum preferred distance
  116746. * @param minDistance The minimum preferred distance
  116747. */
  116748. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  116749. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  116750. };
  116751. return DistanceJoint;
  116752. }(PhysicsJoint));
  116753. /**
  116754. * Represents a Motor-Enabled Joint
  116755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116756. */
  116757. var MotorEnabledJoint = /** @class */ (function (_super) {
  116758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  116759. /**
  116760. * Initializes the Motor-Enabled Joint
  116761. * @param type The type of the joint
  116762. * @param jointData The physica joint data for the joint
  116763. */
  116764. function MotorEnabledJoint(type, jointData) {
  116765. return _super.call(this, type, jointData) || this;
  116766. }
  116767. /**
  116768. * Set the motor values.
  116769. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116770. * @param force the force to apply
  116771. * @param maxForce max force for this motor.
  116772. */
  116773. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  116774. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  116775. };
  116776. /**
  116777. * Set the motor's limits.
  116778. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116779. * @param upperLimit The upper limit of the motor
  116780. * @param lowerLimit The lower limit of the motor
  116781. */
  116782. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  116783. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  116784. };
  116785. return MotorEnabledJoint;
  116786. }(PhysicsJoint));
  116787. /**
  116788. * This class represents a single physics Hinge-Joint
  116789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116790. */
  116791. var HingeJoint = /** @class */ (function (_super) {
  116792. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  116793. /**
  116794. * Initializes the Hinge-Joint
  116795. * @param jointData The joint data for the Hinge-Joint
  116796. */
  116797. function HingeJoint(jointData) {
  116798. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  116799. }
  116800. /**
  116801. * Set the motor values.
  116802. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116803. * @param {number} force the force to apply
  116804. * @param {number} maxForce max force for this motor.
  116805. */
  116806. HingeJoint.prototype.setMotor = function (force, maxForce) {
  116807. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  116808. };
  116809. /**
  116810. * Set the motor's limits.
  116811. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116812. * @param upperLimit The upper limit of the motor
  116813. * @param lowerLimit The lower limit of the motor
  116814. */
  116815. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  116816. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  116817. };
  116818. return HingeJoint;
  116819. }(MotorEnabledJoint));
  116820. /**
  116821. * This class represents a dual hinge physics joint (same as wheel joint)
  116822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116823. */
  116824. var Hinge2Joint = /** @class */ (function (_super) {
  116825. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  116826. /**
  116827. * Initializes the Hinge2-Joint
  116828. * @param jointData The joint data for the Hinge2-Joint
  116829. */
  116830. function Hinge2Joint(jointData) {
  116831. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  116832. }
  116833. /**
  116834. * Set the motor values.
  116835. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116836. * @param {number} targetSpeed the speed the motor is to reach
  116837. * @param {number} maxForce max force for this motor.
  116838. * @param {motorIndex} the motor's index, 0 or 1.
  116839. */
  116840. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  116841. if (motorIndex === void 0) { motorIndex = 0; }
  116842. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  116843. };
  116844. /**
  116845. * Set the motor limits.
  116846. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116847. * @param {number} upperLimit the upper limit
  116848. * @param {number} lowerLimit lower limit
  116849. * @param {motorIndex} the motor's index, 0 or 1.
  116850. */
  116851. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  116852. if (motorIndex === void 0) { motorIndex = 0; }
  116853. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  116854. };
  116855. return Hinge2Joint;
  116856. }(MotorEnabledJoint));
  116857. /***/ }),
  116858. /***/ "./Physics/physicsRaycastResult.ts":
  116859. /*!*****************************************!*\
  116860. !*** ./Physics/physicsRaycastResult.ts ***!
  116861. \*****************************************/
  116862. /*! exports provided: PhysicsRaycastResult */
  116863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116864. "use strict";
  116865. __webpack_require__.r(__webpack_exports__);
  116866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRaycastResult", function() { return PhysicsRaycastResult; });
  116867. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116868. /**
  116869. * Holds the data for the raycast result
  116870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116871. */
  116872. var PhysicsRaycastResult = /** @class */ (function () {
  116873. function PhysicsRaycastResult() {
  116874. this._hasHit = false;
  116875. this._hitDistance = 0;
  116876. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116877. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116878. this._rayFromWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116879. this._rayToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116880. }
  116881. Object.defineProperty(PhysicsRaycastResult.prototype, "hasHit", {
  116882. /**
  116883. * Gets if there was a hit
  116884. */
  116885. get: function () {
  116886. return this._hasHit;
  116887. },
  116888. enumerable: true,
  116889. configurable: true
  116890. });
  116891. Object.defineProperty(PhysicsRaycastResult.prototype, "hitDistance", {
  116892. /**
  116893. * Gets the distance from the hit
  116894. */
  116895. get: function () {
  116896. return this._hitDistance;
  116897. },
  116898. enumerable: true,
  116899. configurable: true
  116900. });
  116901. Object.defineProperty(PhysicsRaycastResult.prototype, "hitNormalWorld", {
  116902. /**
  116903. * Gets the hit normal/direction in the world
  116904. */
  116905. get: function () {
  116906. return this._hitNormalWorld;
  116907. },
  116908. enumerable: true,
  116909. configurable: true
  116910. });
  116911. Object.defineProperty(PhysicsRaycastResult.prototype, "hitPointWorld", {
  116912. /**
  116913. * Gets the hit point in the world
  116914. */
  116915. get: function () {
  116916. return this._hitPointWorld;
  116917. },
  116918. enumerable: true,
  116919. configurable: true
  116920. });
  116921. Object.defineProperty(PhysicsRaycastResult.prototype, "rayFromWorld", {
  116922. /**
  116923. * Gets the ray "start point" of the ray in the world
  116924. */
  116925. get: function () {
  116926. return this._rayFromWorld;
  116927. },
  116928. enumerable: true,
  116929. configurable: true
  116930. });
  116931. Object.defineProperty(PhysicsRaycastResult.prototype, "rayToWorld", {
  116932. /**
  116933. * Gets the ray "end point" of the ray in the world
  116934. */
  116935. get: function () {
  116936. return this._rayToWorld;
  116937. },
  116938. enumerable: true,
  116939. configurable: true
  116940. });
  116941. /**
  116942. * Sets the hit data (normal & point in world space)
  116943. * @param hitNormalWorld defines the normal in world space
  116944. * @param hitPointWorld defines the point in world space
  116945. */
  116946. PhysicsRaycastResult.prototype.setHitData = function (hitNormalWorld, hitPointWorld) {
  116947. this._hasHit = true;
  116948. this._hitNormalWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z);
  116949. this._hitPointWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitPointWorld.x, hitPointWorld.y, hitPointWorld.z);
  116950. };
  116951. /**
  116952. * Sets the distance from the start point to the hit point
  116953. * @param distance
  116954. */
  116955. PhysicsRaycastResult.prototype.setHitDistance = function (distance) {
  116956. this._hitDistance = distance;
  116957. };
  116958. /**
  116959. * Calculates the distance manually
  116960. */
  116961. PhysicsRaycastResult.prototype.calculateHitDistance = function () {
  116962. this._hitDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._rayFromWorld, this._hitPointWorld);
  116963. };
  116964. /**
  116965. * Resets all the values to default
  116966. * @param from The from point on world space
  116967. * @param to The to point on world space
  116968. */
  116969. PhysicsRaycastResult.prototype.reset = function (from, to) {
  116970. if (from === void 0) { from = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  116971. if (to === void 0) { to = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  116972. this._rayFromWorld = from;
  116973. this._rayToWorld = to;
  116974. this._hasHit = false;
  116975. this._hitDistance = 0;
  116976. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116977. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116978. };
  116979. return PhysicsRaycastResult;
  116980. }());
  116981. /***/ }),
  116982. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  116983. /*!****************************************************************************!*\
  116984. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  116985. \****************************************************************************/
  116986. /*! exports provided: DefaultRenderingPipeline */
  116987. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116988. "use strict";
  116989. __webpack_require__.r(__webpack_exports__);
  116990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  116991. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116992. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  116993. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  116994. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116995. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  116996. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  116997. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  116998. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  116999. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  117000. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  117001. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  117002. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  117003. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117004. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  117005. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  117006. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  117007. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  117008. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  117009. /**
  117010. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  117011. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117012. */
  117013. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  117014. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  117015. /**
  117016. * @constructor
  117017. * @param name - The rendering pipeline name (default: "")
  117018. * @param hdr - If high dynamic range textures should be used (default: true)
  117019. * @param scene - The scene linked to this pipeline (default: the last created scene)
  117020. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  117021. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  117022. */
  117023. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  117024. if (name === void 0) { name = ""; }
  117025. if (hdr === void 0) { hdr = true; }
  117026. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  117027. if (automaticBuild === void 0) { automaticBuild = true; }
  117028. var _this = _super.call(this, scene.getEngine(), name) || this;
  117029. _this._camerasToBeAttached = [];
  117030. /**
  117031. * ID of the sharpen post process,
  117032. */
  117033. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  117034. /**
  117035. * @ignore
  117036. * ID of the image processing post process;
  117037. */
  117038. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  117039. /**
  117040. * @ignore
  117041. * ID of the Fast Approximate Anti-Aliasing post process;
  117042. */
  117043. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  117044. /**
  117045. * ID of the chromatic aberration post process,
  117046. */
  117047. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  117048. /**
  117049. * ID of the grain post process
  117050. */
  117051. _this.GrainPostProcessId = "GrainPostProcessEffect";
  117052. /**
  117053. * Glow post process which adds a glow to emissive areas of the image
  117054. */
  117055. _this._glowLayer = null;
  117056. /**
  117057. * Animations which can be used to tweak settings over a period of time
  117058. */
  117059. _this.animations = [];
  117060. _this._imageProcessingConfigurationObserver = null;
  117061. // Values
  117062. _this._sharpenEnabled = false;
  117063. _this._bloomEnabled = false;
  117064. _this._depthOfFieldEnabled = false;
  117065. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  117066. _this._fxaaEnabled = false;
  117067. _this._imageProcessingEnabled = true;
  117068. _this._bloomScale = 0.5;
  117069. _this._chromaticAberrationEnabled = false;
  117070. _this._grainEnabled = false;
  117071. _this._buildAllowed = true;
  117072. _this._resizeObserver = null;
  117073. _this._hardwareScaleLevel = 1.0;
  117074. _this._bloomKernel = 64;
  117075. /**
  117076. * Specifies the weight of the bloom in the final rendering
  117077. */
  117078. _this._bloomWeight = 0.15;
  117079. /**
  117080. * Specifies the luma threshold for the area that will be blurred by the bloom
  117081. */
  117082. _this._bloomThreshold = 0.9;
  117083. _this._samples = 1;
  117084. _this._hasCleared = false;
  117085. _this._prevPostProcess = null;
  117086. _this._prevPrevPostProcess = null;
  117087. _this._depthOfFieldSceneObserver = null;
  117088. _this._cameras = cameras || scene.cameras;
  117089. _this._cameras = _this._cameras.slice();
  117090. _this._camerasToBeAttached = _this._cameras.slice();
  117091. _this._buildAllowed = automaticBuild;
  117092. // Initialize
  117093. _this._scene = scene;
  117094. var caps = _this._scene.getEngine().getCaps();
  117095. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  117096. // Misc
  117097. if (_this._hdr) {
  117098. if (caps.textureHalfFloatRender) {
  117099. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  117100. }
  117101. else if (caps.textureFloatRender) {
  117102. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  117103. }
  117104. }
  117105. else {
  117106. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  117107. }
  117108. // Attach
  117109. scene.postProcessRenderPipelineManager.addPipeline(_this);
  117110. var engine = _this._scene.getEngine();
  117111. // Create post processes before hand so they can be modified before enabled.
  117112. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  117113. _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);
  117114. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  117115. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  117116. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  117117. _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);
  117118. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  117119. _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);
  117120. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  117121. _this._resizeObserver = engine.onResizeObservable.add(function () {
  117122. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  117123. _this.bloomKernel = _this.bloomKernel;
  117124. });
  117125. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  117126. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  117127. });
  117128. _this._buildPipeline();
  117129. return _this;
  117130. }
  117131. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  117132. /**
  117133. * Gets active scene
  117134. */
  117135. get: function () {
  117136. return this._scene;
  117137. },
  117138. enumerable: true,
  117139. configurable: true
  117140. });
  117141. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  117142. get: function () {
  117143. return this._sharpenEnabled;
  117144. },
  117145. /**
  117146. * Enable or disable the sharpen process from the pipeline
  117147. */
  117148. set: function (enabled) {
  117149. if (this._sharpenEnabled === enabled) {
  117150. return;
  117151. }
  117152. this._sharpenEnabled = enabled;
  117153. this._buildPipeline();
  117154. },
  117155. enumerable: true,
  117156. configurable: true
  117157. });
  117158. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  117159. /**
  117160. * Specifies the size of the bloom blur kernel, relative to the final output size
  117161. */
  117162. get: function () {
  117163. return this._bloomKernel;
  117164. },
  117165. set: function (value) {
  117166. this._bloomKernel = value;
  117167. this.bloom.kernel = value / this._hardwareScaleLevel;
  117168. },
  117169. enumerable: true,
  117170. configurable: true
  117171. });
  117172. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  117173. get: function () {
  117174. return this._bloomWeight;
  117175. },
  117176. /**
  117177. * The strength of the bloom.
  117178. */
  117179. set: function (value) {
  117180. if (this._bloomWeight === value) {
  117181. return;
  117182. }
  117183. this.bloom.weight = value;
  117184. this._bloomWeight = value;
  117185. },
  117186. enumerable: true,
  117187. configurable: true
  117188. });
  117189. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  117190. get: function () {
  117191. return this._bloomThreshold;
  117192. },
  117193. /**
  117194. * The strength of the bloom.
  117195. */
  117196. set: function (value) {
  117197. if (this._bloomThreshold === value) {
  117198. return;
  117199. }
  117200. this.bloom.threshold = value;
  117201. this._bloomThreshold = value;
  117202. },
  117203. enumerable: true,
  117204. configurable: true
  117205. });
  117206. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  117207. get: function () {
  117208. return this._bloomScale;
  117209. },
  117210. /**
  117211. * The scale of the bloom, lower value will provide better performance.
  117212. */
  117213. set: function (value) {
  117214. if (this._bloomScale === value) {
  117215. return;
  117216. }
  117217. this._bloomScale = value;
  117218. // recreate bloom and dispose old as this setting is not dynamic
  117219. this._rebuildBloom();
  117220. this._buildPipeline();
  117221. },
  117222. enumerable: true,
  117223. configurable: true
  117224. });
  117225. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  117226. get: function () {
  117227. return this._bloomEnabled;
  117228. },
  117229. /**
  117230. * Enable or disable the bloom from the pipeline
  117231. */
  117232. set: function (enabled) {
  117233. if (this._bloomEnabled === enabled) {
  117234. return;
  117235. }
  117236. this._bloomEnabled = enabled;
  117237. this._buildPipeline();
  117238. },
  117239. enumerable: true,
  117240. configurable: true
  117241. });
  117242. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  117243. // recreate bloom and dispose old as this setting is not dynamic
  117244. var oldBloom = this.bloom;
  117245. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  117246. this.bloom.threshold = oldBloom.threshold;
  117247. for (var i = 0; i < this._cameras.length; i++) {
  117248. oldBloom.disposeEffects(this._cameras[i]);
  117249. }
  117250. };
  117251. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  117252. /**
  117253. * If the depth of field is enabled.
  117254. */
  117255. get: function () {
  117256. return this._depthOfFieldEnabled;
  117257. },
  117258. set: function (enabled) {
  117259. if (this._depthOfFieldEnabled === enabled) {
  117260. return;
  117261. }
  117262. this._depthOfFieldEnabled = enabled;
  117263. this._buildPipeline();
  117264. },
  117265. enumerable: true,
  117266. configurable: true
  117267. });
  117268. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  117269. /**
  117270. * Blur level of the depth of field effect. (Higher blur will effect performance)
  117271. */
  117272. get: function () {
  117273. return this._depthOfFieldBlurLevel;
  117274. },
  117275. set: function (value) {
  117276. if (this._depthOfFieldBlurLevel === value) {
  117277. return;
  117278. }
  117279. this._depthOfFieldBlurLevel = value;
  117280. // recreate dof and dispose old as this setting is not dynamic
  117281. var oldDof = this.depthOfField;
  117282. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  117283. this.depthOfField.focalLength = oldDof.focalLength;
  117284. this.depthOfField.focusDistance = oldDof.focusDistance;
  117285. this.depthOfField.fStop = oldDof.fStop;
  117286. this.depthOfField.lensSize = oldDof.lensSize;
  117287. for (var i = 0; i < this._cameras.length; i++) {
  117288. oldDof.disposeEffects(this._cameras[i]);
  117289. }
  117290. this._buildPipeline();
  117291. },
  117292. enumerable: true,
  117293. configurable: true
  117294. });
  117295. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  117296. get: function () {
  117297. return this._fxaaEnabled;
  117298. },
  117299. /**
  117300. * If the anti aliasing is enabled.
  117301. */
  117302. set: function (enabled) {
  117303. if (this._fxaaEnabled === enabled) {
  117304. return;
  117305. }
  117306. this._fxaaEnabled = enabled;
  117307. this._buildPipeline();
  117308. },
  117309. enumerable: true,
  117310. configurable: true
  117311. });
  117312. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  117313. get: function () {
  117314. return this._samples;
  117315. },
  117316. /**
  117317. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  117318. */
  117319. set: function (sampleCount) {
  117320. if (this._samples === sampleCount) {
  117321. return;
  117322. }
  117323. this._samples = sampleCount;
  117324. this._buildPipeline();
  117325. },
  117326. enumerable: true,
  117327. configurable: true
  117328. });
  117329. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  117330. get: function () {
  117331. return this._imageProcessingEnabled;
  117332. },
  117333. /**
  117334. * If image processing is enabled.
  117335. */
  117336. set: function (enabled) {
  117337. if (this._imageProcessingEnabled === enabled) {
  117338. return;
  117339. }
  117340. this._imageProcessingEnabled = enabled;
  117341. this._buildPipeline();
  117342. },
  117343. enumerable: true,
  117344. configurable: true
  117345. });
  117346. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  117347. get: function () {
  117348. return this._glowLayer != null;
  117349. },
  117350. /**
  117351. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  117352. */
  117353. set: function (enabled) {
  117354. if (enabled && !this._glowLayer) {
  117355. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  117356. }
  117357. else if (!enabled && this._glowLayer) {
  117358. this._glowLayer.dispose();
  117359. this._glowLayer = null;
  117360. }
  117361. },
  117362. enumerable: true,
  117363. configurable: true
  117364. });
  117365. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  117366. get: function () {
  117367. return this._chromaticAberrationEnabled;
  117368. },
  117369. /**
  117370. * Enable or disable the chromaticAberration process from the pipeline
  117371. */
  117372. set: function (enabled) {
  117373. if (this._chromaticAberrationEnabled === enabled) {
  117374. return;
  117375. }
  117376. this._chromaticAberrationEnabled = enabled;
  117377. this._buildPipeline();
  117378. },
  117379. enumerable: true,
  117380. configurable: true
  117381. });
  117382. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  117383. get: function () {
  117384. return this._grainEnabled;
  117385. },
  117386. /**
  117387. * Enable or disable the grain process from the pipeline
  117388. */
  117389. set: function (enabled) {
  117390. if (this._grainEnabled === enabled) {
  117391. return;
  117392. }
  117393. this._grainEnabled = enabled;
  117394. this._buildPipeline();
  117395. },
  117396. enumerable: true,
  117397. configurable: true
  117398. });
  117399. /**
  117400. * Get the class name
  117401. * @returns "DefaultRenderingPipeline"
  117402. */
  117403. DefaultRenderingPipeline.prototype.getClassName = function () {
  117404. return "DefaultRenderingPipeline";
  117405. };
  117406. /**
  117407. * Force the compilation of the entire pipeline.
  117408. */
  117409. DefaultRenderingPipeline.prototype.prepare = function () {
  117410. var previousState = this._buildAllowed;
  117411. this._buildAllowed = true;
  117412. this._buildPipeline();
  117413. this._buildAllowed = previousState;
  117414. };
  117415. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  117416. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  117417. if (this._hasCleared) {
  117418. postProcess.autoClear = false;
  117419. }
  117420. else {
  117421. postProcess.autoClear = true;
  117422. this._scene.autoClear = false;
  117423. this._hasCleared = true;
  117424. }
  117425. if (!skipTextureSharing) {
  117426. if (this._prevPrevPostProcess) {
  117427. postProcess.shareOutputWith(this._prevPrevPostProcess);
  117428. }
  117429. else {
  117430. postProcess.useOwnOutput();
  117431. }
  117432. if (this._prevPostProcess) {
  117433. this._prevPrevPostProcess = this._prevPostProcess;
  117434. }
  117435. this._prevPostProcess = postProcess;
  117436. }
  117437. };
  117438. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  117439. var _this = this;
  117440. if (!this._buildAllowed) {
  117441. return;
  117442. }
  117443. this._scene.autoClear = true;
  117444. var engine = this._scene.getEngine();
  117445. this._disposePostProcesses();
  117446. if (this._cameras !== null) {
  117447. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  117448. // get back cameras to be used to reattach pipeline
  117449. this._cameras = this._camerasToBeAttached.slice();
  117450. }
  117451. this._reset();
  117452. this._prevPostProcess = null;
  117453. this._prevPrevPostProcess = null;
  117454. this._hasCleared = false;
  117455. if (this.depthOfFieldEnabled) {
  117456. // Multi camera suport
  117457. if (this._cameras.length > 1) {
  117458. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  117459. var camera = _a[_i];
  117460. var depthRenderer = this._scene.enableDepthRenderer(camera);
  117461. depthRenderer.useOnlyInActiveCamera = true;
  117462. }
  117463. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  117464. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  117465. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  117466. }
  117467. });
  117468. }
  117469. else {
  117470. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  117471. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  117472. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  117473. }
  117474. if (!this.depthOfField._isReady()) {
  117475. this.depthOfField._updateEffects();
  117476. }
  117477. this.addEffect(this.depthOfField);
  117478. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  117479. }
  117480. else {
  117481. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  117482. }
  117483. if (this.bloomEnabled) {
  117484. if (!this.bloom._isReady()) {
  117485. this.bloom._updateEffects();
  117486. }
  117487. this.addEffect(this.bloom);
  117488. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  117489. }
  117490. if (this._imageProcessingEnabled) {
  117491. 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);
  117492. if (this._hdr) {
  117493. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  117494. this._setAutoClearAndTextureSharing(this.imageProcessing);
  117495. }
  117496. else {
  117497. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  117498. }
  117499. }
  117500. if (this.sharpenEnabled) {
  117501. if (!this.sharpen.isReady()) {
  117502. this.sharpen.updateEffect();
  117503. }
  117504. this.addEffect(this._sharpenEffect);
  117505. this._setAutoClearAndTextureSharing(this.sharpen);
  117506. }
  117507. if (this.grainEnabled) {
  117508. if (!this.grain.isReady()) {
  117509. this.grain.updateEffect();
  117510. }
  117511. this.addEffect(this._grainEffect);
  117512. this._setAutoClearAndTextureSharing(this.grain);
  117513. }
  117514. if (this.chromaticAberrationEnabled) {
  117515. if (!this.chromaticAberration.isReady()) {
  117516. this.chromaticAberration.updateEffect();
  117517. }
  117518. this.addEffect(this._chromaticAberrationEffect);
  117519. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  117520. }
  117521. if (this.fxaaEnabled) {
  117522. 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);
  117523. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  117524. this._setAutoClearAndTextureSharing(this.fxaa, true);
  117525. }
  117526. if (this._cameras !== null) {
  117527. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  117528. }
  117529. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  117530. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  117531. }
  117532. };
  117533. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  117534. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  117535. for (var i = 0; i < this._cameras.length; i++) {
  117536. var camera = this._cameras[i];
  117537. if (this.imageProcessing) {
  117538. this.imageProcessing.dispose(camera);
  117539. }
  117540. if (this.fxaa) {
  117541. this.fxaa.dispose(camera);
  117542. }
  117543. // These are created in the constructor and should not be disposed on every pipeline change
  117544. if (disposeNonRecreated) {
  117545. if (this.sharpen) {
  117546. this.sharpen.dispose(camera);
  117547. }
  117548. if (this.depthOfField) {
  117549. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  117550. this.depthOfField.disposeEffects(camera);
  117551. }
  117552. if (this.bloom) {
  117553. this.bloom.disposeEffects(camera);
  117554. }
  117555. if (this.chromaticAberration) {
  117556. this.chromaticAberration.dispose(camera);
  117557. }
  117558. if (this.grain) {
  117559. this.grain.dispose(camera);
  117560. }
  117561. if (this._glowLayer) {
  117562. this._glowLayer.dispose();
  117563. }
  117564. }
  117565. }
  117566. this.imageProcessing = null;
  117567. this.fxaa = null;
  117568. if (disposeNonRecreated) {
  117569. this.sharpen = null;
  117570. this._sharpenEffect = null;
  117571. this.depthOfField = null;
  117572. this.bloom = null;
  117573. this.chromaticAberration = null;
  117574. this._chromaticAberrationEffect = null;
  117575. this.grain = null;
  117576. this._grainEffect = null;
  117577. this._glowLayer = null;
  117578. }
  117579. };
  117580. /**
  117581. * Adds a camera to the pipeline
  117582. * @param camera the camera to be added
  117583. */
  117584. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  117585. this._camerasToBeAttached.push(camera);
  117586. this._buildPipeline();
  117587. };
  117588. /**
  117589. * Removes a camera from the pipeline
  117590. * @param camera the camera to remove
  117591. */
  117592. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  117593. var index = this._camerasToBeAttached.indexOf(camera);
  117594. this._camerasToBeAttached.splice(index, 1);
  117595. this._buildPipeline();
  117596. };
  117597. /**
  117598. * Dispose of the pipeline and stop all post processes
  117599. */
  117600. DefaultRenderingPipeline.prototype.dispose = function () {
  117601. this._disposePostProcesses(true);
  117602. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  117603. this._scene.autoClear = true;
  117604. if (this._resizeObserver) {
  117605. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  117606. this._resizeObserver = null;
  117607. }
  117608. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  117609. _super.prototype.dispose.call(this);
  117610. };
  117611. /**
  117612. * Serialize the rendering pipeline (Used when exporting)
  117613. * @returns the serialized object
  117614. */
  117615. DefaultRenderingPipeline.prototype.serialize = function () {
  117616. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  117617. serializationObject.customType = "DefaultRenderingPipeline";
  117618. return serializationObject;
  117619. };
  117620. /**
  117621. * Parse the serialized pipeline
  117622. * @param source Source pipeline.
  117623. * @param scene The scene to load the pipeline to.
  117624. * @param rootUrl The URL of the serialized pipeline.
  117625. * @returns An instantiated pipeline from the serialized object.
  117626. */
  117627. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  117628. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  117629. };
  117630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117632. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  117633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117635. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  117636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117638. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  117639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117641. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  117642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117644. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  117645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117647. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  117648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117650. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  117651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117653. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  117654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117656. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  117657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117659. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  117660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117662. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  117663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117665. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  117666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117668. ], DefaultRenderingPipeline.prototype, "samples", null);
  117669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117671. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  117672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117674. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  117675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117677. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  117678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117680. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  117681. return DefaultRenderingPipeline;
  117682. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  117683. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  117684. /***/ }),
  117685. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  117686. /*!*********************************************************!*\
  117687. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  117688. \*********************************************************/
  117689. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  117690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117691. "use strict";
  117692. __webpack_require__.r(__webpack_exports__);
  117693. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  117694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  117695. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  117696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  117697. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  117698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  117699. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  117700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  117701. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  117702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  117703. /***/ }),
  117704. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  117705. /*!*************************************************************************!*\
  117706. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  117707. \*************************************************************************/
  117708. /*! exports provided: LensRenderingPipeline */
  117709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117710. "use strict";
  117711. __webpack_require__.r(__webpack_exports__);
  117712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  117713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117714. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117715. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  117716. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  117717. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  117718. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117719. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  117720. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  117721. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  117722. /**
  117723. * BABYLON.JS Chromatic Aberration GLSL Shader
  117724. * Author: Olivier Guyot
  117725. * Separates very slightly R, G and B colors on the edges of the screen
  117726. * Inspired by Francois Tarlier & Martins Upitis
  117727. */
  117728. var LensRenderingPipeline = /** @class */ (function (_super) {
  117729. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  117730. /**
  117731. * @constructor
  117732. *
  117733. * Effect parameters are as follow:
  117734. * {
  117735. * chromatic_aberration: number; // from 0 to x (1 for realism)
  117736. * edge_blur: number; // from 0 to x (1 for realism)
  117737. * distortion: number; // from 0 to x (1 for realism)
  117738. * grain_amount: number; // from 0 to 1
  117739. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  117740. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  117741. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  117742. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  117743. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  117744. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  117745. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  117746. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  117747. * }
  117748. * Note: if an effect parameter is unset, effect is disabled
  117749. *
  117750. * @param name The rendering pipeline name
  117751. * @param parameters - An object containing all parameters (see above)
  117752. * @param scene The scene linked to this pipeline
  117753. * @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)
  117754. * @param cameras The array of cameras that the rendering pipeline will be attached to
  117755. */
  117756. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  117757. if (ratio === void 0) { ratio = 1.0; }
  117758. var _this = _super.call(this, scene.getEngine(), name) || this;
  117759. // Lens effects can be of the following:
  117760. // - chromatic aberration (slight shift of RGB colors)
  117761. // - blur on the edge of the lens
  117762. // - lens distortion
  117763. // - depth-of-field blur & highlights enhancing
  117764. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  117765. // - grain effect (noise or custom texture)
  117766. // Two additional texture samplers are needed:
  117767. // - depth map (for depth-of-field)
  117768. // - grain texture
  117769. /**
  117770. * @ignore
  117771. * The chromatic aberration PostProcess id in the pipeline
  117772. */
  117773. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  117774. /**
  117775. * @ignore
  117776. * The highlights enhancing PostProcess id in the pipeline
  117777. */
  117778. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  117779. /**
  117780. * @ignore
  117781. * The depth-of-field PostProcess id in the pipeline
  117782. */
  117783. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  117784. _this._pentagonBokehIsEnabled = false;
  117785. _this._scene = scene;
  117786. // Fetch texture samplers
  117787. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  117788. if (parameters.grain_texture) {
  117789. _this._grainTexture = parameters.grain_texture;
  117790. }
  117791. else {
  117792. _this._createGrainTexture();
  117793. }
  117794. // save parameters
  117795. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  117796. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  117797. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  117798. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  117799. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  117800. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  117801. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  117802. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  117803. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  117804. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  117805. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  117806. // Create effects
  117807. _this._createChromaticAberrationPostProcess(ratio);
  117808. _this._createHighlightsPostProcess(ratio);
  117809. _this._createDepthOfFieldPostProcess(ratio / 4);
  117810. // Set up pipeline
  117811. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  117812. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  117813. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  117814. if (_this._highlightsGain === -1) {
  117815. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  117816. }
  117817. // Finish
  117818. scene.postProcessRenderPipelineManager.addPipeline(_this);
  117819. if (cameras) {
  117820. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  117821. }
  117822. return _this;
  117823. }
  117824. /**
  117825. * Get the class name
  117826. * @returns "LensRenderingPipeline"
  117827. */
  117828. LensRenderingPipeline.prototype.getClassName = function () {
  117829. return "LensRenderingPipeline";
  117830. };
  117831. Object.defineProperty(LensRenderingPipeline.prototype, "scene", {
  117832. // Properties
  117833. /**
  117834. * Gets associated scene
  117835. */
  117836. get: function () {
  117837. return this._scene;
  117838. },
  117839. enumerable: true,
  117840. configurable: true
  117841. });
  117842. Object.defineProperty(LensRenderingPipeline.prototype, "edgeBlur", {
  117843. /**
  117844. * Gets or sets the edge blur
  117845. */
  117846. get: function () {
  117847. return this._edgeBlur;
  117848. },
  117849. set: function (value) {
  117850. this.setEdgeBlur(value);
  117851. },
  117852. enumerable: true,
  117853. configurable: true
  117854. });
  117855. Object.defineProperty(LensRenderingPipeline.prototype, "grainAmount", {
  117856. /**
  117857. * Gets or sets the grain amount
  117858. */
  117859. get: function () {
  117860. return this._grainAmount;
  117861. },
  117862. set: function (value) {
  117863. this.setGrainAmount(value);
  117864. },
  117865. enumerable: true,
  117866. configurable: true
  117867. });
  117868. Object.defineProperty(LensRenderingPipeline.prototype, "chromaticAberration", {
  117869. /**
  117870. * Gets or sets the chromatic aberration amount
  117871. */
  117872. get: function () {
  117873. return this._chromaticAberration;
  117874. },
  117875. set: function (value) {
  117876. this.setChromaticAberration(value);
  117877. },
  117878. enumerable: true,
  117879. configurable: true
  117880. });
  117881. Object.defineProperty(LensRenderingPipeline.prototype, "dofAperture", {
  117882. /**
  117883. * Gets or sets the depth of field aperture
  117884. */
  117885. get: function () {
  117886. return this._dofAperture;
  117887. },
  117888. set: function (value) {
  117889. this.setAperture(value);
  117890. },
  117891. enumerable: true,
  117892. configurable: true
  117893. });
  117894. Object.defineProperty(LensRenderingPipeline.prototype, "edgeDistortion", {
  117895. /**
  117896. * Gets or sets the edge distortion
  117897. */
  117898. get: function () {
  117899. return this._distortion;
  117900. },
  117901. set: function (value) {
  117902. this.setEdgeDistortion(value);
  117903. },
  117904. enumerable: true,
  117905. configurable: true
  117906. });
  117907. Object.defineProperty(LensRenderingPipeline.prototype, "dofDistortion", {
  117908. /**
  117909. * Gets or sets the depth of field distortion
  117910. */
  117911. get: function () {
  117912. return this._dofDistance;
  117913. },
  117914. set: function (value) {
  117915. this.setFocusDistance(value);
  117916. },
  117917. enumerable: true,
  117918. configurable: true
  117919. });
  117920. Object.defineProperty(LensRenderingPipeline.prototype, "darkenOutOfFocus", {
  117921. /**
  117922. * Gets or sets the darken out of focus amount
  117923. */
  117924. get: function () {
  117925. return this._dofDarken;
  117926. },
  117927. set: function (value) {
  117928. this.setDarkenOutOfFocus(value);
  117929. },
  117930. enumerable: true,
  117931. configurable: true
  117932. });
  117933. Object.defineProperty(LensRenderingPipeline.prototype, "blurNoise", {
  117934. /**
  117935. * Gets or sets a boolean indicating if blur noise is enabled
  117936. */
  117937. get: function () {
  117938. return this._blurNoise;
  117939. },
  117940. set: function (value) {
  117941. this._blurNoise = value;
  117942. },
  117943. enumerable: true,
  117944. configurable: true
  117945. });
  117946. Object.defineProperty(LensRenderingPipeline.prototype, "pentagonBokeh", {
  117947. /**
  117948. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  117949. */
  117950. get: function () {
  117951. return this._pentagonBokehIsEnabled;
  117952. },
  117953. set: function (value) {
  117954. if (value) {
  117955. this.enablePentagonBokeh();
  117956. }
  117957. else {
  117958. this.disablePentagonBokeh();
  117959. }
  117960. },
  117961. enumerable: true,
  117962. configurable: true
  117963. });
  117964. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsGain", {
  117965. /**
  117966. * Gets or sets the highlight grain amount
  117967. */
  117968. get: function () {
  117969. return this._highlightsGain;
  117970. },
  117971. set: function (value) {
  117972. this.setHighlightsGain(value);
  117973. },
  117974. enumerable: true,
  117975. configurable: true
  117976. });
  117977. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsThreshold", {
  117978. /**
  117979. * Gets or sets the highlight threshold
  117980. */
  117981. get: function () {
  117982. return this._highlightsThreshold;
  117983. },
  117984. set: function (value) {
  117985. this.setHighlightsThreshold(value);
  117986. },
  117987. enumerable: true,
  117988. configurable: true
  117989. });
  117990. // public methods (self explanatory)
  117991. /**
  117992. * Sets the amount of blur at the edges
  117993. * @param amount blur amount
  117994. */
  117995. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  117996. /**
  117997. * Sets edge blur to 0
  117998. */
  117999. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  118000. /**
  118001. * Sets the amout of grain
  118002. * @param amount Amount of grain
  118003. */
  118004. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  118005. /**
  118006. * Set grain amount to 0
  118007. */
  118008. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  118009. /**
  118010. * Sets the chromatic aberration amount
  118011. * @param amount amount of chromatic aberration
  118012. */
  118013. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  118014. /**
  118015. * Sets chromatic aberration amount to 0
  118016. */
  118017. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  118018. /**
  118019. * Sets the EdgeDistortion amount
  118020. * @param amount amount of EdgeDistortion
  118021. */
  118022. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  118023. /**
  118024. * Sets edge distortion to 0
  118025. */
  118026. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  118027. /**
  118028. * Sets the FocusDistance amount
  118029. * @param amount amount of FocusDistance
  118030. */
  118031. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  118032. /**
  118033. * Disables depth of field
  118034. */
  118035. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  118036. /**
  118037. * Sets the Aperture amount
  118038. * @param amount amount of Aperture
  118039. */
  118040. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  118041. /**
  118042. * Sets the DarkenOutOfFocus amount
  118043. * @param amount amount of DarkenOutOfFocus
  118044. */
  118045. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  118046. /**
  118047. * Creates a pentagon bokeh effect
  118048. */
  118049. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  118050. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  118051. this._pentagonBokehIsEnabled = true;
  118052. };
  118053. /**
  118054. * Disables the pentagon bokeh effect
  118055. */
  118056. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  118057. this._pentagonBokehIsEnabled = false;
  118058. this._highlightsPostProcess.updateEffect();
  118059. };
  118060. /**
  118061. * Enables noise blur
  118062. */
  118063. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  118064. /**
  118065. * Disables noise blur
  118066. */
  118067. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  118068. /**
  118069. * Sets the HighlightsGain amount
  118070. * @param amount amount of HighlightsGain
  118071. */
  118072. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  118073. this._highlightsGain = amount;
  118074. };
  118075. /**
  118076. * Sets the HighlightsThreshold amount
  118077. * @param amount amount of HighlightsThreshold
  118078. */
  118079. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  118080. if (this._highlightsGain === -1) {
  118081. this._highlightsGain = 1.0;
  118082. }
  118083. this._highlightsThreshold = amount;
  118084. };
  118085. /**
  118086. * Disables highlights
  118087. */
  118088. LensRenderingPipeline.prototype.disableHighlights = function () {
  118089. this._highlightsGain = -1;
  118090. };
  118091. /**
  118092. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118093. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118094. */
  118095. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  118096. if (disableDepthRender === void 0) { disableDepthRender = false; }
  118097. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  118098. this._chromaticAberrationPostProcess = null;
  118099. this._highlightsPostProcess = null;
  118100. this._depthOfFieldPostProcess = null;
  118101. this._grainTexture.dispose();
  118102. if (disableDepthRender) {
  118103. this._scene.disableDepthRenderer();
  118104. }
  118105. };
  118106. // colors shifting and distortion
  118107. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  118108. var _this = this;
  118109. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  118110. [], // samplers
  118111. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  118112. this._chromaticAberrationPostProcess.onApply = function (effect) {
  118113. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  118114. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  118115. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  118116. effect.setFloat('radialIntensity', 1);
  118117. effect.setFloat2('direction', 17, 17);
  118118. effect.setFloat2('centerPosition', 0.5, 0.5);
  118119. };
  118120. };
  118121. // highlights enhancing
  118122. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  118123. var _this = this;
  118124. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  118125. [], // samplers
  118126. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  118127. this._highlightsPostProcess.onApply = function (effect) {
  118128. effect.setFloat('gain', _this._highlightsGain);
  118129. effect.setFloat('threshold', _this._highlightsThreshold);
  118130. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  118131. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  118132. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  118133. };
  118134. };
  118135. // colors shifting and distortion
  118136. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  118137. var _this = this;
  118138. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  118139. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  118140. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  118141. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  118142. this._depthOfFieldPostProcess.onApply = function (effect) {
  118143. effect.setTexture("depthSampler", _this._depthTexture);
  118144. effect.setTexture("grainSampler", _this._grainTexture);
  118145. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  118146. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  118147. effect.setFloat('grain_amount', _this._grainAmount);
  118148. effect.setBool('blur_noise', _this._blurNoise);
  118149. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  118150. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  118151. effect.setFloat('distortion', _this._distortion);
  118152. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  118153. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  118154. effect.setFloat('aperture', _this._dofAperture);
  118155. effect.setFloat('darken', _this._dofDarken);
  118156. effect.setFloat('edge_blur', _this._edgeBlur);
  118157. effect.setBool('highlights', (_this._highlightsGain !== -1));
  118158. if (_this._scene.activeCamera) {
  118159. effect.setFloat('near', _this._scene.activeCamera.minZ);
  118160. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  118161. }
  118162. };
  118163. };
  118164. // creates a black and white random noise texture, 512x512
  118165. LensRenderingPipeline.prototype._createGrainTexture = function () {
  118166. var size = 512;
  118167. 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);
  118168. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  118169. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  118170. var context = this._grainTexture.getContext();
  118171. var rand = function (min, max) {
  118172. return Math.random() * (max - min) + min;
  118173. };
  118174. var value;
  118175. for (var x = 0; x < size; x++) {
  118176. for (var y = 0; y < size; y++) {
  118177. value = Math.floor(rand(0.42, 0.58) * 255);
  118178. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  118179. context.fillRect(x, y, 1, 1);
  118180. }
  118181. }
  118182. this._grainTexture.update(false);
  118183. };
  118184. return LensRenderingPipeline;
  118185. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  118186. /***/ }),
  118187. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  118188. /*!**************************************************************************!*\
  118189. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  118190. \**************************************************************************/
  118191. /*! exports provided: SSAO2RenderingPipeline */
  118192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118193. "use strict";
  118194. __webpack_require__.r(__webpack_exports__);
  118195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  118196. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118197. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  118198. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  118199. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  118200. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118201. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  118202. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  118203. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  118204. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118205. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  118206. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  118207. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  118208. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  118209. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  118210. /**
  118211. * Render pipeline to produce ssao effect
  118212. */
  118213. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  118214. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  118215. /**
  118216. * @constructor
  118217. * @param name The rendering pipeline name
  118218. * @param scene The scene linked to this pipeline
  118219. * @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 }
  118220. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118221. */
  118222. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  118223. var _this = _super.call(this, scene.getEngine(), name) || this;
  118224. // Members
  118225. /**
  118226. * @ignore
  118227. * The PassPostProcess id in the pipeline that contains the original scene color
  118228. */
  118229. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  118230. /**
  118231. * @ignore
  118232. * The SSAO PostProcess id in the pipeline
  118233. */
  118234. _this.SSAORenderEffect = "SSAORenderEffect";
  118235. /**
  118236. * @ignore
  118237. * The horizontal blur PostProcess id in the pipeline
  118238. */
  118239. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  118240. /**
  118241. * @ignore
  118242. * The vertical blur PostProcess id in the pipeline
  118243. */
  118244. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  118245. /**
  118246. * @ignore
  118247. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118248. */
  118249. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  118250. /**
  118251. * The output strength of the SSAO post-process. Default value is 1.0.
  118252. */
  118253. _this.totalStrength = 1.0;
  118254. /**
  118255. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  118256. */
  118257. _this.maxZ = 100.0;
  118258. /**
  118259. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  118260. */
  118261. _this.minZAspect = 0.2;
  118262. _this._samples = 8;
  118263. _this._textureSamples = 1;
  118264. _this._expensiveBlur = true;
  118265. /**
  118266. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  118267. */
  118268. _this.radius = 2.0;
  118269. /**
  118270. * The base color of the SSAO post-process
  118271. * The final result is "base + ssao" between [0, 1]
  118272. */
  118273. _this.base = 0;
  118274. _this._firstUpdate = true;
  118275. _this._bits = new Uint32Array(1);
  118276. _this._scene = scene;
  118277. _this._ratio = ratio;
  118278. if (!_this.isSupported) {
  118279. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  118280. return _this;
  118281. }
  118282. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  118283. var blurRatio = _this._ratio.blurRatio || ratio;
  118284. // Set up assets
  118285. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  118286. _this._createRandomTexture();
  118287. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  118288. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  118289. _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);
  118290. _this._originalColorPostProcess.samples = _this.textureSamples;
  118291. _this._createSSAOPostProcess(1.0);
  118292. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  118293. _this._createSSAOCombinePostProcess(blurRatio);
  118294. // Set up pipeline
  118295. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  118296. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  118297. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  118298. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  118299. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  118300. // Finish
  118301. scene.postProcessRenderPipelineManager.addPipeline(_this);
  118302. if (cameras) {
  118303. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  118304. }
  118305. return _this;
  118306. }
  118307. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  118308. get: function () {
  118309. return this._samples;
  118310. },
  118311. /**
  118312. * Number of samples used for the SSAO calculations. Default value is 8
  118313. */
  118314. set: function (n) {
  118315. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  118316. this._samples = n;
  118317. this._sampleSphere = this._generateHemisphere();
  118318. this._firstUpdate = true;
  118319. },
  118320. enumerable: true,
  118321. configurable: true
  118322. });
  118323. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  118324. get: function () {
  118325. return this._textureSamples;
  118326. },
  118327. /**
  118328. * Number of samples to use for antialiasing
  118329. */
  118330. set: function (n) {
  118331. this._textureSamples = n;
  118332. this._originalColorPostProcess.samples = n;
  118333. this._blurHPostProcess.samples = n;
  118334. this._blurVPostProcess.samples = n;
  118335. this._ssaoPostProcess.samples = n;
  118336. this._ssaoCombinePostProcess.samples = n;
  118337. },
  118338. enumerable: true,
  118339. configurable: true
  118340. });
  118341. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  118342. get: function () {
  118343. return this._expensiveBlur;
  118344. },
  118345. /**
  118346. * If bilateral blur should be used
  118347. */
  118348. set: function (b) {
  118349. 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"]);
  118350. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  118351. this._expensiveBlur = b;
  118352. this._firstUpdate = true;
  118353. },
  118354. enumerable: true,
  118355. configurable: true
  118356. });
  118357. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  118358. /**
  118359. * Support test.
  118360. */
  118361. get: function () {
  118362. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  118363. if (!engine) {
  118364. return false;
  118365. }
  118366. return engine.getCaps().drawBuffersExtension;
  118367. },
  118368. enumerable: true,
  118369. configurable: true
  118370. });
  118371. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  118372. /**
  118373. * Gets active scene
  118374. */
  118375. get: function () {
  118376. return this._scene;
  118377. },
  118378. enumerable: true,
  118379. configurable: true
  118380. });
  118381. // Public Methods
  118382. /**
  118383. * Get the class name
  118384. * @returns "SSAO2RenderingPipeline"
  118385. */
  118386. SSAO2RenderingPipeline.prototype.getClassName = function () {
  118387. return "SSAO2RenderingPipeline";
  118388. };
  118389. /**
  118390. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118391. */
  118392. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  118393. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  118394. for (var i = 0; i < this._scene.cameras.length; i++) {
  118395. var camera = this._scene.cameras[i];
  118396. this._originalColorPostProcess.dispose(camera);
  118397. this._ssaoPostProcess.dispose(camera);
  118398. this._blurHPostProcess.dispose(camera);
  118399. this._blurVPostProcess.dispose(camera);
  118400. this._ssaoCombinePostProcess.dispose(camera);
  118401. }
  118402. this._randomTexture.dispose();
  118403. if (disableGeometryBufferRenderer) {
  118404. this._scene.disableGeometryBufferRenderer();
  118405. }
  118406. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  118407. _super.prototype.dispose.call(this);
  118408. };
  118409. // Private Methods
  118410. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  118411. var _this = this;
  118412. this._samplerOffsets = [];
  118413. var expensive = this.expensiveBlur;
  118414. for (var i = -8; i < 8; i++) {
  118415. this._samplerOffsets.push(i * 2 + 0.5);
  118416. }
  118417. 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");
  118418. this._blurHPostProcess.onApply = function (effect) {
  118419. if (!_this._scene.activeCamera) {
  118420. return;
  118421. }
  118422. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  118423. effect.setFloat("near", _this._scene.activeCamera.minZ);
  118424. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  118425. effect.setFloat("radius", _this.radius);
  118426. effect.setTexture("depthSampler", _this._depthTexture);
  118427. if (_this._firstUpdate) {
  118428. effect.setArray("samplerOffsets", _this._samplerOffsets);
  118429. }
  118430. };
  118431. 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");
  118432. this._blurVPostProcess.onApply = function (effect) {
  118433. if (!_this._scene.activeCamera) {
  118434. return;
  118435. }
  118436. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  118437. effect.setFloat("near", _this._scene.activeCamera.minZ);
  118438. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  118439. effect.setFloat("radius", _this.radius);
  118440. effect.setTexture("depthSampler", _this._depthTexture);
  118441. if (_this._firstUpdate) {
  118442. effect.setArray("samplerOffsets", _this._samplerOffsets);
  118443. _this._firstUpdate = false;
  118444. }
  118445. };
  118446. this._blurHPostProcess.samples = this.textureSamples;
  118447. this._blurVPostProcess.samples = this.textureSamples;
  118448. };
  118449. /** @hidden */
  118450. SSAO2RenderingPipeline.prototype._rebuild = function () {
  118451. this._firstUpdate = true;
  118452. _super.prototype._rebuild.call(this);
  118453. };
  118454. //Van der Corput radical inverse
  118455. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  118456. this._bits[0] = i;
  118457. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  118458. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  118459. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  118460. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  118461. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  118462. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  118463. };
  118464. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  118465. return [i / n, this._radicalInverse_VdC(i)];
  118466. };
  118467. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  118468. var phi = v * 2.0 * Math.PI;
  118469. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  118470. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  118471. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  118472. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  118473. };
  118474. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  118475. var numSamples = this.samples;
  118476. var result = [];
  118477. var vector;
  118478. var i = 0;
  118479. while (i < numSamples) {
  118480. if (numSamples < 16) {
  118481. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  118482. }
  118483. else {
  118484. var rand = this._hammersley(i, numSamples);
  118485. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  118486. }
  118487. result.push(vector.x, vector.y, vector.z);
  118488. i++;
  118489. }
  118490. return result;
  118491. };
  118492. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  118493. var _this = this;
  118494. var numSamples = this.samples;
  118495. this._sampleSphere = this._generateHemisphere();
  118496. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  118497. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  118498. "base", "range", "projection", "near", "far", "texelSize",
  118499. "xViewport", "yViewport", "maxZ", "minZAspect"
  118500. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  118501. this._ssaoPostProcess.onApply = function (effect) {
  118502. if (_this._firstUpdate) {
  118503. effect.setArray3("sampleSphere", _this._sampleSphere);
  118504. effect.setFloat("randTextureTiles", 32.0);
  118505. }
  118506. if (!_this._scene.activeCamera) {
  118507. return;
  118508. }
  118509. effect.setFloat("samplesFactor", 1 / _this.samples);
  118510. effect.setFloat("totalStrength", _this.totalStrength);
  118511. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  118512. effect.setFloat("radius", _this.radius);
  118513. effect.setFloat("maxZ", _this.maxZ);
  118514. effect.setFloat("minZAspect", _this.minZAspect);
  118515. effect.setFloat("base", _this.base);
  118516. effect.setFloat("near", _this._scene.activeCamera.minZ);
  118517. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  118518. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  118519. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  118520. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  118521. effect.setTexture("textureSampler", _this._depthTexture);
  118522. effect.setTexture("normalSampler", _this._normalTexture);
  118523. effect.setTexture("randomSampler", _this._randomTexture);
  118524. };
  118525. this._ssaoPostProcess.samples = this.textureSamples;
  118526. };
  118527. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  118528. var _this = this;
  118529. 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);
  118530. this._ssaoCombinePostProcess.onApply = function (effect) {
  118531. var viewport = _this._scene.activeCamera.viewport;
  118532. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  118533. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  118534. };
  118535. this._ssaoCombinePostProcess.samples = this.textureSamples;
  118536. };
  118537. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  118538. var size = 128;
  118539. 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);
  118540. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  118541. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  118542. var context = this._randomTexture.getContext();
  118543. var rand = function (min, max) {
  118544. return Math.random() * (max - min) + min;
  118545. };
  118546. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118547. for (var x = 0; x < size; x++) {
  118548. for (var y = 0; y < size; y++) {
  118549. randVector.x = rand(0.0, 1.0);
  118550. randVector.y = rand(0.0, 1.0);
  118551. randVector.z = 0.0;
  118552. randVector.normalize();
  118553. randVector.scaleInPlace(255);
  118554. randVector.x = Math.floor(randVector.x);
  118555. randVector.y = Math.floor(randVector.y);
  118556. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  118557. context.fillRect(x, y, 1, 1);
  118558. }
  118559. }
  118560. this._randomTexture.update(false);
  118561. };
  118562. /**
  118563. * Serialize the rendering pipeline (Used when exporting)
  118564. * @returns the serialized object
  118565. */
  118566. SSAO2RenderingPipeline.prototype.serialize = function () {
  118567. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  118568. serializationObject.customType = "SSAO2RenderingPipeline";
  118569. return serializationObject;
  118570. };
  118571. /**
  118572. * Parse the serialized pipeline
  118573. * @param source Source pipeline.
  118574. * @param scene The scene to load the pipeline to.
  118575. * @param rootUrl The URL of the serialized pipeline.
  118576. * @returns An instantiated pipeline from the serialized object.
  118577. */
  118578. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  118579. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  118580. };
  118581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118583. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  118584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118586. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  118587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118589. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  118590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  118592. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  118593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  118595. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  118596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118598. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  118599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  118601. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  118602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118604. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  118605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118607. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  118608. return SSAO2RenderingPipeline;
  118609. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  118610. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  118611. /***/ }),
  118612. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  118613. /*!*************************************************************************!*\
  118614. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  118615. \*************************************************************************/
  118616. /*! exports provided: SSAORenderingPipeline */
  118617. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118618. "use strict";
  118619. __webpack_require__.r(__webpack_exports__);
  118620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  118621. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118622. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  118623. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118624. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  118625. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  118626. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  118627. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118628. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  118629. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118630. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  118631. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  118632. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  118633. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  118634. /**
  118635. * Render pipeline to produce ssao effect
  118636. */
  118637. var SSAORenderingPipeline = /** @class */ (function (_super) {
  118638. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  118639. /**
  118640. * @constructor
  118641. * @param name - The rendering pipeline name
  118642. * @param scene - The scene linked to this pipeline
  118643. * @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 }
  118644. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  118645. */
  118646. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  118647. var _this = _super.call(this, scene.getEngine(), name) || this;
  118648. // Members
  118649. /**
  118650. * @ignore
  118651. * The PassPostProcess id in the pipeline that contains the original scene color
  118652. */
  118653. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  118654. /**
  118655. * @ignore
  118656. * The SSAO PostProcess id in the pipeline
  118657. */
  118658. _this.SSAORenderEffect = "SSAORenderEffect";
  118659. /**
  118660. * @ignore
  118661. * The horizontal blur PostProcess id in the pipeline
  118662. */
  118663. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  118664. /**
  118665. * @ignore
  118666. * The vertical blur PostProcess id in the pipeline
  118667. */
  118668. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  118669. /**
  118670. * @ignore
  118671. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118672. */
  118673. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  118674. /**
  118675. * The output strength of the SSAO post-process. Default value is 1.0.
  118676. */
  118677. _this.totalStrength = 1.0;
  118678. /**
  118679. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  118680. */
  118681. _this.radius = 0.0001;
  118682. /**
  118683. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  118684. * Must not be equal to fallOff and superior to fallOff.
  118685. * Default value is 0.0075
  118686. */
  118687. _this.area = 0.0075;
  118688. /**
  118689. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  118690. * Must not be equal to area and inferior to area.
  118691. * Default value is 0.000001
  118692. */
  118693. _this.fallOff = 0.000001;
  118694. /**
  118695. * The base color of the SSAO post-process
  118696. * The final result is "base + ssao" between [0, 1]
  118697. */
  118698. _this.base = 0.5;
  118699. _this._firstUpdate = true;
  118700. _this._scene = scene;
  118701. // Set up assets
  118702. _this._createRandomTexture();
  118703. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  118704. var ssaoRatio = ratio.ssaoRatio || ratio;
  118705. var combineRatio = ratio.combineRatio || ratio;
  118706. _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);
  118707. _this._createSSAOPostProcess(ssaoRatio);
  118708. _this._createBlurPostProcess(ssaoRatio);
  118709. _this._createSSAOCombinePostProcess(combineRatio);
  118710. // Set up pipeline
  118711. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  118712. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  118713. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  118714. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  118715. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  118716. // Finish
  118717. scene.postProcessRenderPipelineManager.addPipeline(_this);
  118718. if (cameras) {
  118719. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  118720. }
  118721. return _this;
  118722. }
  118723. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  118724. /**
  118725. * Gets active scene
  118726. */
  118727. get: function () {
  118728. return this._scene;
  118729. },
  118730. enumerable: true,
  118731. configurable: true
  118732. });
  118733. // Public Methods
  118734. /**
  118735. * Get the class name
  118736. * @returns "SSAORenderingPipeline"
  118737. */
  118738. SSAORenderingPipeline.prototype.getClassName = function () {
  118739. return "SSAORenderingPipeline";
  118740. };
  118741. /**
  118742. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118743. */
  118744. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  118745. if (disableDepthRender === void 0) { disableDepthRender = false; }
  118746. for (var i = 0; i < this._scene.cameras.length; i++) {
  118747. var camera = this._scene.cameras[i];
  118748. this._originalColorPostProcess.dispose(camera);
  118749. this._ssaoPostProcess.dispose(camera);
  118750. this._blurHPostProcess.dispose(camera);
  118751. this._blurVPostProcess.dispose(camera);
  118752. this._ssaoCombinePostProcess.dispose(camera);
  118753. }
  118754. this._randomTexture.dispose();
  118755. if (disableDepthRender) {
  118756. this._scene.disableDepthRenderer();
  118757. }
  118758. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  118759. _super.prototype.dispose.call(this);
  118760. };
  118761. // Private Methods
  118762. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  118763. var _this = this;
  118764. var size = 16;
  118765. 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);
  118766. 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);
  118767. this._blurHPostProcess.onActivateObservable.add(function () {
  118768. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  118769. _this._blurHPostProcess.kernel = size * dw;
  118770. });
  118771. this._blurVPostProcess.onActivateObservable.add(function () {
  118772. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  118773. _this._blurVPostProcess.kernel = size * dw;
  118774. });
  118775. };
  118776. /** @hidden */
  118777. SSAORenderingPipeline.prototype._rebuild = function () {
  118778. this._firstUpdate = true;
  118779. _super.prototype._rebuild.call(this);
  118780. };
  118781. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  118782. var _this = this;
  118783. var numSamples = 16;
  118784. var sampleSphere = [
  118785. 0.5381, 0.1856, -0.4319,
  118786. 0.1379, 0.2486, 0.4430,
  118787. 0.3371, 0.5679, -0.0057,
  118788. -0.6999, -0.0451, -0.0019,
  118789. 0.0689, -0.1598, -0.8547,
  118790. 0.0560, 0.0069, -0.1843,
  118791. -0.0146, 0.1402, 0.0762,
  118792. 0.0100, -0.1924, -0.0344,
  118793. -0.3577, -0.5301, -0.4358,
  118794. -0.3169, 0.1063, 0.0158,
  118795. 0.0103, -0.5869, 0.0046,
  118796. -0.0897, -0.4940, 0.3287,
  118797. 0.7119, -0.0154, -0.0918,
  118798. -0.0533, 0.0596, -0.5411,
  118799. 0.0352, -0.0631, 0.5460,
  118800. -0.4776, 0.2847, -0.0271
  118801. ];
  118802. var samplesFactor = 1.0 / numSamples;
  118803. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  118804. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  118805. "area", "fallOff", "base", "range", "viewport"
  118806. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  118807. this._ssaoPostProcess.onApply = function (effect) {
  118808. if (_this._firstUpdate) {
  118809. effect.setArray3("sampleSphere", sampleSphere);
  118810. effect.setFloat("samplesFactor", samplesFactor);
  118811. effect.setFloat("randTextureTiles", 4.0);
  118812. }
  118813. effect.setFloat("totalStrength", _this.totalStrength);
  118814. effect.setFloat("radius", _this.radius);
  118815. effect.setFloat("area", _this.area);
  118816. effect.setFloat("fallOff", _this.fallOff);
  118817. effect.setFloat("base", _this.base);
  118818. effect.setTexture("textureSampler", _this._depthTexture);
  118819. effect.setTexture("randomSampler", _this._randomTexture);
  118820. };
  118821. };
  118822. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  118823. var _this = this;
  118824. 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);
  118825. this._ssaoCombinePostProcess.onApply = function (effect) {
  118826. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  118827. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  118828. };
  118829. };
  118830. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  118831. var size = 512;
  118832. 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);
  118833. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  118834. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  118835. var context = this._randomTexture.getContext();
  118836. var rand = function (min, max) {
  118837. return Math.random() * (max - min) + min;
  118838. };
  118839. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  118840. for (var x = 0; x < size; x++) {
  118841. for (var y = 0; y < size; y++) {
  118842. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  118843. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  118844. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  118845. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  118846. context.fillRect(x, y, 1, 1);
  118847. }
  118848. }
  118849. this._randomTexture.update(false);
  118850. };
  118851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  118853. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  118854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  118856. ], SSAORenderingPipeline.prototype, "radius", void 0);
  118857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  118859. ], SSAORenderingPipeline.prototype, "area", void 0);
  118860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  118862. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  118863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  118865. ], SSAORenderingPipeline.prototype, "base", void 0);
  118866. return SSAORenderingPipeline;
  118867. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  118868. /***/ }),
  118869. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  118870. /*!*****************************************************************************!*\
  118871. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  118872. \*****************************************************************************/
  118873. /*! exports provided: StandardRenderingPipeline */
  118874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118875. "use strict";
  118876. __webpack_require__.r(__webpack_exports__);
  118877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  118878. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118879. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  118880. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  118881. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  118882. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  118883. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118884. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  118885. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  118886. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118887. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118888. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  118889. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  118890. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  118891. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  118892. /**
  118893. * Standard rendering pipeline
  118894. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118895. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  118896. */
  118897. var StandardRenderingPipeline = /** @class */ (function (_super) {
  118898. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  118899. /**
  118900. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118901. * @constructor
  118902. * @param name The rendering pipeline name
  118903. * @param scene The scene linked to this pipeline
  118904. * @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)
  118905. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  118906. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118907. */
  118908. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  118909. if (originalPostProcess === void 0) { originalPostProcess = null; }
  118910. var _this = _super.call(this, scene.getEngine(), name) || this;
  118911. /**
  118912. * Post-process used to down scale an image x4
  118913. */
  118914. _this.downSampleX4PostProcess = null;
  118915. /**
  118916. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  118917. */
  118918. _this.brightPassPostProcess = null;
  118919. /**
  118920. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  118921. */
  118922. _this.blurHPostProcesses = [];
  118923. /**
  118924. * Post-process array storing all the vertical blur post-processes used by the pipeline
  118925. */
  118926. _this.blurVPostProcesses = [];
  118927. /**
  118928. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  118929. */
  118930. _this.textureAdderPostProcess = null;
  118931. /**
  118932. * Post-process used to create volumetric lighting effect
  118933. */
  118934. _this.volumetricLightPostProcess = null;
  118935. /**
  118936. * Post-process used to smooth the previous volumetric light post-process on the X axis
  118937. */
  118938. _this.volumetricLightSmoothXPostProcess = null;
  118939. /**
  118940. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  118941. */
  118942. _this.volumetricLightSmoothYPostProcess = null;
  118943. /**
  118944. * Post-process used to merge the volumetric light effect and the real scene color
  118945. */
  118946. _this.volumetricLightMergePostProces = null;
  118947. /**
  118948. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  118949. */
  118950. _this.volumetricLightFinalPostProcess = null;
  118951. /**
  118952. * Base post-process used to calculate the average luminance of the final image for HDR
  118953. */
  118954. _this.luminancePostProcess = null;
  118955. /**
  118956. * Post-processes used to create down sample post-processes in order to get
  118957. * the average luminance of the final image for HDR
  118958. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  118959. */
  118960. _this.luminanceDownSamplePostProcesses = [];
  118961. /**
  118962. * Post-process used to create a HDR effect (light adaptation)
  118963. */
  118964. _this.hdrPostProcess = null;
  118965. /**
  118966. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  118967. */
  118968. _this.textureAdderFinalPostProcess = null;
  118969. /**
  118970. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  118971. */
  118972. _this.lensFlareFinalPostProcess = null;
  118973. /**
  118974. * Post-process used to merge the final HDR post-process and the real scene color
  118975. */
  118976. _this.hdrFinalPostProcess = null;
  118977. /**
  118978. * Post-process used to create a lens flare effect
  118979. */
  118980. _this.lensFlarePostProcess = null;
  118981. /**
  118982. * Post-process that merges the result of the lens flare post-process and the real scene color
  118983. */
  118984. _this.lensFlareComposePostProcess = null;
  118985. /**
  118986. * Post-process used to create a motion blur effect
  118987. */
  118988. _this.motionBlurPostProcess = null;
  118989. /**
  118990. * Post-process used to create a depth of field effect
  118991. */
  118992. _this.depthOfFieldPostProcess = null;
  118993. /**
  118994. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118995. */
  118996. _this.fxaaPostProcess = null;
  118997. // Values
  118998. /**
  118999. * Represents the brightness threshold in order to configure the illuminated surfaces
  119000. */
  119001. _this.brightThreshold = 1.0;
  119002. /**
  119003. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119004. */
  119005. _this.blurWidth = 512.0;
  119006. /**
  119007. * Sets if the blur for highlighted surfaces must be only horizontal
  119008. */
  119009. _this.horizontalBlur = false;
  119010. /**
  119011. * Sets the overall exposure used by the pipeline
  119012. */
  119013. _this.exposure = 1.0;
  119014. /**
  119015. * Texture used typically to simulate "dirty" on camera lens
  119016. */
  119017. _this.lensTexture = null;
  119018. /**
  119019. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119020. */
  119021. _this.volumetricLightCoefficient = 0.2;
  119022. /**
  119023. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119024. */
  119025. _this.volumetricLightPower = 4.0;
  119026. /**
  119027. * Used the set the blur intensity to smooth the volumetric lights
  119028. */
  119029. _this.volumetricLightBlurScale = 64.0;
  119030. /**
  119031. * Light (spot or directional) used to generate the volumetric lights rays
  119032. * The source light must have a shadow generate so the pipeline can get its
  119033. * depth map
  119034. */
  119035. _this.sourceLight = null;
  119036. /**
  119037. * For eye adaptation, represents the minimum luminance the eye can see
  119038. */
  119039. _this.hdrMinimumLuminance = 1.0;
  119040. /**
  119041. * For eye adaptation, represents the decrease luminance speed
  119042. */
  119043. _this.hdrDecreaseRate = 0.5;
  119044. /**
  119045. * For eye adaptation, represents the increase luminance speed
  119046. */
  119047. _this.hdrIncreaseRate = 0.5;
  119048. /**
  119049. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119050. */
  119051. _this.lensColorTexture = null;
  119052. /**
  119053. * The overall strengh for the lens flare effect
  119054. */
  119055. _this.lensFlareStrength = 20.0;
  119056. /**
  119057. * Dispersion coefficient for lens flare ghosts
  119058. */
  119059. _this.lensFlareGhostDispersal = 1.4;
  119060. /**
  119061. * Main lens flare halo width
  119062. */
  119063. _this.lensFlareHaloWidth = 0.7;
  119064. /**
  119065. * Based on the lens distortion effect, defines how much the lens flare result
  119066. * is distorted
  119067. */
  119068. _this.lensFlareDistortionStrength = 16.0;
  119069. /**
  119070. * Lens star texture must be used to simulate rays on the flares and is available
  119071. * in the documentation
  119072. */
  119073. _this.lensStarTexture = null;
  119074. /**
  119075. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119076. * flare effect by taking account of the dirt texture
  119077. */
  119078. _this.lensFlareDirtTexture = null;
  119079. /**
  119080. * Represents the focal length for the depth of field effect
  119081. */
  119082. _this.depthOfFieldDistance = 10.0;
  119083. /**
  119084. * Represents the blur intensity for the blurred part of the depth of field effect
  119085. */
  119086. _this.depthOfFieldBlurWidth = 64.0;
  119087. /**
  119088. * For motion blur, defines how much the image is blurred by the movement
  119089. */
  119090. _this.motionStrength = 1.0;
  119091. /**
  119092. * List of animations for the pipeline (IAnimatable implementation)
  119093. */
  119094. _this.animations = [];
  119095. _this._currentDepthOfFieldSource = null;
  119096. _this._hdrCurrentLuminance = 1.0;
  119097. // Getters and setters
  119098. _this._bloomEnabled = false;
  119099. _this._depthOfFieldEnabled = false;
  119100. _this._vlsEnabled = false;
  119101. _this._lensFlareEnabled = false;
  119102. _this._hdrEnabled = false;
  119103. _this._motionBlurEnabled = false;
  119104. _this._fxaaEnabled = false;
  119105. _this._motionBlurSamples = 64.0;
  119106. _this._volumetricLightStepsCount = 50.0;
  119107. _this._samples = 1;
  119108. _this._cameras = cameras || [];
  119109. // Initialize
  119110. _this._scene = scene;
  119111. _this._basePostProcess = originalPostProcess;
  119112. _this._ratio = ratio;
  119113. // Misc
  119114. _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;
  119115. // Finish
  119116. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119117. _this._buildPipeline();
  119118. return _this;
  119119. }
  119120. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  119121. /**
  119122. * @ignore
  119123. * Specifies if the bloom pipeline is enabled
  119124. */
  119125. get: function () {
  119126. return this._bloomEnabled;
  119127. },
  119128. set: function (enabled) {
  119129. if (this._bloomEnabled === enabled) {
  119130. return;
  119131. }
  119132. this._bloomEnabled = enabled;
  119133. this._buildPipeline();
  119134. },
  119135. enumerable: true,
  119136. configurable: true
  119137. });
  119138. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  119139. /**
  119140. * @ignore
  119141. * Specifies if the depth of field pipeline is enabed
  119142. */
  119143. get: function () {
  119144. return this._depthOfFieldEnabled;
  119145. },
  119146. set: function (enabled) {
  119147. if (this._depthOfFieldEnabled === enabled) {
  119148. return;
  119149. }
  119150. this._depthOfFieldEnabled = enabled;
  119151. this._buildPipeline();
  119152. },
  119153. enumerable: true,
  119154. configurable: true
  119155. });
  119156. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  119157. /**
  119158. * @ignore
  119159. * Specifies if the lens flare pipeline is enabed
  119160. */
  119161. get: function () {
  119162. return this._lensFlareEnabled;
  119163. },
  119164. set: function (enabled) {
  119165. if (this._lensFlareEnabled === enabled) {
  119166. return;
  119167. }
  119168. this._lensFlareEnabled = enabled;
  119169. this._buildPipeline();
  119170. },
  119171. enumerable: true,
  119172. configurable: true
  119173. });
  119174. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  119175. /**
  119176. * @ignore
  119177. * Specifies if the HDR pipeline is enabled
  119178. */
  119179. get: function () {
  119180. return this._hdrEnabled;
  119181. },
  119182. set: function (enabled) {
  119183. if (this._hdrEnabled === enabled) {
  119184. return;
  119185. }
  119186. this._hdrEnabled = enabled;
  119187. this._buildPipeline();
  119188. },
  119189. enumerable: true,
  119190. configurable: true
  119191. });
  119192. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  119193. /**
  119194. * @ignore
  119195. * Specifies if the volumetric lights scattering effect is enabled
  119196. */
  119197. get: function () {
  119198. return this._vlsEnabled;
  119199. },
  119200. set: function (enabled) {
  119201. if (this._vlsEnabled === enabled) {
  119202. return;
  119203. }
  119204. if (enabled) {
  119205. var geometry = this._scene.enableGeometryBufferRenderer();
  119206. if (!geometry) {
  119207. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  119208. return;
  119209. }
  119210. }
  119211. this._vlsEnabled = enabled;
  119212. this._buildPipeline();
  119213. },
  119214. enumerable: true,
  119215. configurable: true
  119216. });
  119217. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  119218. /**
  119219. * @ignore
  119220. * Specifies if the motion blur effect is enabled
  119221. */
  119222. get: function () {
  119223. return this._motionBlurEnabled;
  119224. },
  119225. set: function (enabled) {
  119226. if (this._motionBlurEnabled === enabled) {
  119227. return;
  119228. }
  119229. this._motionBlurEnabled = enabled;
  119230. this._buildPipeline();
  119231. },
  119232. enumerable: true,
  119233. configurable: true
  119234. });
  119235. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  119236. /**
  119237. * Specifies if anti-aliasing is enabled
  119238. */
  119239. get: function () {
  119240. return this._fxaaEnabled;
  119241. },
  119242. set: function (enabled) {
  119243. if (this._fxaaEnabled === enabled) {
  119244. return;
  119245. }
  119246. this._fxaaEnabled = enabled;
  119247. this._buildPipeline();
  119248. },
  119249. enumerable: true,
  119250. configurable: true
  119251. });
  119252. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  119253. /**
  119254. * Specifies the number of steps used to calculate the volumetric lights
  119255. * Typically in interval [50, 200]
  119256. */
  119257. get: function () {
  119258. return this._volumetricLightStepsCount;
  119259. },
  119260. set: function (count) {
  119261. if (this.volumetricLightPostProcess) {
  119262. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  119263. }
  119264. this._volumetricLightStepsCount = count;
  119265. },
  119266. enumerable: true,
  119267. configurable: true
  119268. });
  119269. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  119270. /**
  119271. * Specifies the number of samples used for the motion blur effect
  119272. * Typically in interval [16, 64]
  119273. */
  119274. get: function () {
  119275. return this._motionBlurSamples;
  119276. },
  119277. set: function (samples) {
  119278. if (this.motionBlurPostProcess) {
  119279. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  119280. }
  119281. this._motionBlurSamples = samples;
  119282. },
  119283. enumerable: true,
  119284. configurable: true
  119285. });
  119286. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  119287. /**
  119288. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119289. */
  119290. get: function () {
  119291. return this._samples;
  119292. },
  119293. set: function (sampleCount) {
  119294. if (this._samples === sampleCount) {
  119295. return;
  119296. }
  119297. this._samples = sampleCount;
  119298. this._buildPipeline();
  119299. },
  119300. enumerable: true,
  119301. configurable: true
  119302. });
  119303. StandardRenderingPipeline.prototype._buildPipeline = function () {
  119304. var _this = this;
  119305. var ratio = this._ratio;
  119306. var scene = this._scene;
  119307. this._disposePostProcesses();
  119308. this._reset();
  119309. // Create pass post-process
  119310. if (!this._basePostProcess) {
  119311. 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);
  119312. this.originalPostProcess.onApply = function () {
  119313. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  119314. };
  119315. }
  119316. else {
  119317. this.originalPostProcess = this._basePostProcess;
  119318. }
  119319. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  119320. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  119321. }
  119322. this._currentDepthOfFieldSource = this.originalPostProcess;
  119323. if (this._bloomEnabled) {
  119324. // Create down sample X4 post-process
  119325. this._createDownSampleX4PostProcess(scene, ratio / 2);
  119326. // Create bright pass post-process
  119327. this._createBrightPassPostProcess(scene, ratio / 2);
  119328. // Create gaussian blur post-processes (down sampling blurs)
  119329. this._createBlurPostProcesses(scene, ratio / 4, 1);
  119330. // Create texture adder post-process
  119331. this._createTextureAdderPostProcess(scene, ratio);
  119332. // Create depth-of-field source post-process
  119333. 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);
  119334. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  119335. }
  119336. if (this._vlsEnabled) {
  119337. // Create volumetric light
  119338. this._createVolumetricLightPostProcess(scene, ratio);
  119339. // Create volumetric light final post-process
  119340. 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);
  119341. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  119342. }
  119343. if (this._lensFlareEnabled) {
  119344. // Create lens flare post-process
  119345. this._createLensFlarePostProcess(scene, ratio);
  119346. // Create depth-of-field source post-process post lens-flare and disable it now
  119347. 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);
  119348. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  119349. }
  119350. if (this._hdrEnabled) {
  119351. // Create luminance
  119352. this._createLuminancePostProcesses(scene, this._floatTextureType);
  119353. // Create HDR
  119354. this._createHdrPostProcess(scene, ratio);
  119355. // Create depth-of-field source post-process post hdr and disable it now
  119356. 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);
  119357. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  119358. }
  119359. if (this._depthOfFieldEnabled) {
  119360. // Create gaussian blur used by depth-of-field
  119361. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  119362. // Create depth-of-field post-process
  119363. this._createDepthOfFieldPostProcess(scene, ratio);
  119364. }
  119365. if (this._motionBlurEnabled) {
  119366. // Create motion blur post-process
  119367. this._createMotionBlurPostProcess(scene, ratio);
  119368. }
  119369. if (this._fxaaEnabled) {
  119370. // Create fxaa post-process
  119371. 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);
  119372. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  119373. }
  119374. if (this._cameras !== null) {
  119375. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  119376. }
  119377. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  119378. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  119379. }
  119380. };
  119381. // Down Sample X4 Post-Processs
  119382. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  119383. var _this = this;
  119384. var downSampleX4Offsets = new Array(32);
  119385. 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);
  119386. this.downSampleX4PostProcess.onApply = function (effect) {
  119387. var id = 0;
  119388. var width = _this.downSampleX4PostProcess.width;
  119389. var height = _this.downSampleX4PostProcess.height;
  119390. for (var i = -2; i < 2; i++) {
  119391. for (var j = -2; j < 2; j++) {
  119392. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  119393. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  119394. id += 2;
  119395. }
  119396. }
  119397. effect.setArray2("dsOffsets", downSampleX4Offsets);
  119398. };
  119399. // Add to pipeline
  119400. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  119401. };
  119402. // Brightpass Post-Process
  119403. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  119404. var _this = this;
  119405. var brightOffsets = new Array(8);
  119406. 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);
  119407. this.brightPassPostProcess.onApply = function (effect) {
  119408. var sU = (1.0 / _this.brightPassPostProcess.width);
  119409. var sV = (1.0 / _this.brightPassPostProcess.height);
  119410. brightOffsets[0] = -0.5 * sU;
  119411. brightOffsets[1] = 0.5 * sV;
  119412. brightOffsets[2] = 0.5 * sU;
  119413. brightOffsets[3] = 0.5 * sV;
  119414. brightOffsets[4] = -0.5 * sU;
  119415. brightOffsets[5] = -0.5 * sV;
  119416. brightOffsets[6] = 0.5 * sU;
  119417. brightOffsets[7] = -0.5 * sV;
  119418. effect.setArray2("dsOffsets", brightOffsets);
  119419. effect.setFloat("brightThreshold", _this.brightThreshold);
  119420. };
  119421. // Add to pipeline
  119422. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  119423. };
  119424. // Create blur H&V post-processes
  119425. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  119426. var _this = this;
  119427. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  119428. var engine = scene.getEngine();
  119429. 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);
  119430. 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);
  119431. blurX.onActivateObservable.add(function () {
  119432. var dw = blurX.width / engine.getRenderWidth();
  119433. blurX.kernel = _this[blurWidthKey] * dw;
  119434. });
  119435. blurY.onActivateObservable.add(function () {
  119436. var dw = blurY.height / engine.getRenderHeight();
  119437. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  119438. });
  119439. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  119440. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  119441. this.blurHPostProcesses.push(blurX);
  119442. this.blurVPostProcesses.push(blurY);
  119443. };
  119444. // Create texture adder post-process
  119445. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  119446. var _this = this;
  119447. 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);
  119448. this.textureAdderPostProcess.onApply = function (effect) {
  119449. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  119450. effect.setTexture("lensSampler", _this.lensTexture);
  119451. effect.setFloat("exposure", _this.exposure);
  119452. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  119453. };
  119454. // Add to pipeline
  119455. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  119456. };
  119457. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  119458. var _this = this;
  119459. var geometryRenderer = scene.enableGeometryBufferRenderer();
  119460. geometryRenderer.enablePosition = true;
  119461. var geometry = geometryRenderer.getGBuffer();
  119462. // Base post-process
  119463. 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));
  119464. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119465. this.volumetricLightPostProcess.onApply = function (effect) {
  119466. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  119467. var generator = _this.sourceLight.getShadowGenerator();
  119468. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  119469. effect.setTexture("positionSampler", geometry.textures[2]);
  119470. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  119471. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  119472. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  119473. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  119474. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  119475. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  119476. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  119477. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  119478. effect.setVector2("depthValues", depthValues);
  119479. }
  119480. };
  119481. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  119482. // Smooth
  119483. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  119484. // Merge
  119485. 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");
  119486. this.volumetricLightMergePostProces.onApply = function (effect) {
  119487. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  119488. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  119489. };
  119490. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  119491. };
  119492. // Create luminance
  119493. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  119494. var _this = this;
  119495. // Create luminance
  119496. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  119497. 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);
  119498. var offsets = [];
  119499. this.luminancePostProcess.onApply = function (effect) {
  119500. var sU = (1.0 / _this.luminancePostProcess.width);
  119501. var sV = (1.0 / _this.luminancePostProcess.height);
  119502. offsets[0] = -0.5 * sU;
  119503. offsets[1] = 0.5 * sV;
  119504. offsets[2] = 0.5 * sU;
  119505. offsets[3] = 0.5 * sV;
  119506. offsets[4] = -0.5 * sU;
  119507. offsets[5] = -0.5 * sV;
  119508. offsets[6] = 0.5 * sU;
  119509. offsets[7] = -0.5 * sV;
  119510. effect.setArray2("lumOffsets", offsets);
  119511. };
  119512. // Add to pipeline
  119513. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  119514. // Create down sample luminance
  119515. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  119516. var size = Math.pow(3, i);
  119517. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  119518. if (i === 0) {
  119519. defines += "#define FINAL_DOWN_SAMPLER";
  119520. }
  119521. 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);
  119522. this.luminanceDownSamplePostProcesses.push(postProcess);
  119523. }
  119524. // Create callbacks and add effects
  119525. var lastLuminance = this.luminancePostProcess;
  119526. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  119527. var downSampleOffsets = new Array(18);
  119528. pp.onApply = function (effect) {
  119529. if (!lastLuminance) {
  119530. return;
  119531. }
  119532. var id = 0;
  119533. for (var x = -1; x < 2; x++) {
  119534. for (var y = -1; y < 2; y++) {
  119535. downSampleOffsets[id] = x / lastLuminance.width;
  119536. downSampleOffsets[id + 1] = y / lastLuminance.height;
  119537. id += 2;
  119538. }
  119539. }
  119540. effect.setArray2("dsOffsets", downSampleOffsets);
  119541. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  119542. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  119543. lastLuminance = _this.luminancePostProcess;
  119544. }
  119545. else {
  119546. lastLuminance = pp;
  119547. }
  119548. };
  119549. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  119550. pp.onAfterRender = function () {
  119551. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  119552. 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);
  119553. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  119554. };
  119555. }
  119556. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  119557. });
  119558. };
  119559. // Create HDR post-process
  119560. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  119561. var _this = this;
  119562. 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);
  119563. var outputLiminance = 1;
  119564. var time = 0;
  119565. var lastTime = 0;
  119566. this.hdrPostProcess.onApply = function (effect) {
  119567. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  119568. time += scene.getEngine().getDeltaTime();
  119569. if (outputLiminance < 0) {
  119570. outputLiminance = _this._hdrCurrentLuminance;
  119571. }
  119572. else {
  119573. var dt = (lastTime - time) / 1000.0;
  119574. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  119575. outputLiminance += _this.hdrDecreaseRate * dt;
  119576. }
  119577. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  119578. outputLiminance -= _this.hdrIncreaseRate * dt;
  119579. }
  119580. else {
  119581. outputLiminance = _this._hdrCurrentLuminance;
  119582. }
  119583. }
  119584. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  119585. effect.setFloat("averageLuminance", outputLiminance);
  119586. lastTime = time;
  119587. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  119588. };
  119589. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  119590. };
  119591. // Create lens flare post-process
  119592. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  119593. var _this = this;
  119594. 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);
  119595. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  119596. this._createBlurPostProcesses(scene, ratio / 4, 2);
  119597. 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);
  119598. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  119599. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  119600. // Lens flare
  119601. this.lensFlarePostProcess.onApply = function (effect) {
  119602. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  119603. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  119604. effect.setFloat("strength", _this.lensFlareStrength);
  119605. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  119606. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  119607. // Shift
  119608. resolution.x = _this.lensFlarePostProcess.width;
  119609. resolution.y = _this.lensFlarePostProcess.height;
  119610. effect.setVector2("resolution", resolution);
  119611. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  119612. };
  119613. // Compose
  119614. 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);
  119615. 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);
  119616. this.lensFlareComposePostProcess.onApply = function (effect) {
  119617. if (!_this._scene.activeCamera) {
  119618. return;
  119619. }
  119620. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  119621. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  119622. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  119623. // Lens start rotation matrix
  119624. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  119625. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  119626. 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));
  119627. camRot *= 4.0;
  119628. 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);
  119629. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  119630. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  119631. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  119632. };
  119633. };
  119634. // Create depth-of-field post-process
  119635. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  119636. var _this = this;
  119637. 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);
  119638. this.depthOfFieldPostProcess.onApply = function (effect) {
  119639. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  119640. effect.setTexture("depthSampler", _this._getDepthTexture());
  119641. effect.setFloat("distance", _this.depthOfFieldDistance);
  119642. };
  119643. // Add to pipeline
  119644. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  119645. };
  119646. // Create motion blur post-process
  119647. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  119648. var _this = this;
  119649. 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);
  119650. var motionScale = 0;
  119651. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  119652. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  119653. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  119654. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119655. this.motionBlurPostProcess.onApply = function (effect) {
  119656. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  119657. viewProjection.invertToRef(invViewProjection);
  119658. effect.setMatrix("inverseViewProjection", invViewProjection);
  119659. effect.setMatrix("prevViewProjection", prevViewProjection);
  119660. prevViewProjection = viewProjection;
  119661. screenSize.x = _this.motionBlurPostProcess.width;
  119662. screenSize.y = _this.motionBlurPostProcess.height;
  119663. effect.setVector2("screenSize", screenSize);
  119664. motionScale = scene.getEngine().getFps() / 60.0;
  119665. effect.setFloat("motionScale", motionScale);
  119666. effect.setFloat("motionStrength", _this.motionStrength);
  119667. effect.setTexture("depthSampler", _this._getDepthTexture());
  119668. };
  119669. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  119670. };
  119671. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  119672. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  119673. var renderer = this._scene.enableGeometryBufferRenderer();
  119674. return renderer.getGBuffer().textures[0];
  119675. }
  119676. return this._scene.enableDepthRenderer().getDepthMap();
  119677. };
  119678. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  119679. for (var i = 0; i < this._cameras.length; i++) {
  119680. var camera = this._cameras[i];
  119681. if (this.originalPostProcess) {
  119682. this.originalPostProcess.dispose(camera);
  119683. }
  119684. if (this.downSampleX4PostProcess) {
  119685. this.downSampleX4PostProcess.dispose(camera);
  119686. }
  119687. if (this.brightPassPostProcess) {
  119688. this.brightPassPostProcess.dispose(camera);
  119689. }
  119690. if (this.textureAdderPostProcess) {
  119691. this.textureAdderPostProcess.dispose(camera);
  119692. }
  119693. if (this.textureAdderFinalPostProcess) {
  119694. this.textureAdderFinalPostProcess.dispose(camera);
  119695. }
  119696. if (this.volumetricLightPostProcess) {
  119697. this.volumetricLightPostProcess.dispose(camera);
  119698. }
  119699. if (this.volumetricLightSmoothXPostProcess) {
  119700. this.volumetricLightSmoothXPostProcess.dispose(camera);
  119701. }
  119702. if (this.volumetricLightSmoothYPostProcess) {
  119703. this.volumetricLightSmoothYPostProcess.dispose(camera);
  119704. }
  119705. if (this.volumetricLightMergePostProces) {
  119706. this.volumetricLightMergePostProces.dispose(camera);
  119707. }
  119708. if (this.volumetricLightFinalPostProcess) {
  119709. this.volumetricLightFinalPostProcess.dispose(camera);
  119710. }
  119711. if (this.lensFlarePostProcess) {
  119712. this.lensFlarePostProcess.dispose(camera);
  119713. }
  119714. if (this.lensFlareComposePostProcess) {
  119715. this.lensFlareComposePostProcess.dispose(camera);
  119716. }
  119717. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  119718. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  119719. }
  119720. if (this.luminancePostProcess) {
  119721. this.luminancePostProcess.dispose(camera);
  119722. }
  119723. if (this.hdrPostProcess) {
  119724. this.hdrPostProcess.dispose(camera);
  119725. }
  119726. if (this.hdrFinalPostProcess) {
  119727. this.hdrFinalPostProcess.dispose(camera);
  119728. }
  119729. if (this.depthOfFieldPostProcess) {
  119730. this.depthOfFieldPostProcess.dispose(camera);
  119731. }
  119732. if (this.motionBlurPostProcess) {
  119733. this.motionBlurPostProcess.dispose(camera);
  119734. }
  119735. if (this.fxaaPostProcess) {
  119736. this.fxaaPostProcess.dispose(camera);
  119737. }
  119738. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  119739. this.blurHPostProcesses[j].dispose(camera);
  119740. }
  119741. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  119742. this.blurVPostProcesses[j].dispose(camera);
  119743. }
  119744. }
  119745. this.originalPostProcess = null;
  119746. this.downSampleX4PostProcess = null;
  119747. this.brightPassPostProcess = null;
  119748. this.textureAdderPostProcess = null;
  119749. this.textureAdderFinalPostProcess = null;
  119750. this.volumetricLightPostProcess = null;
  119751. this.volumetricLightSmoothXPostProcess = null;
  119752. this.volumetricLightSmoothYPostProcess = null;
  119753. this.volumetricLightMergePostProces = null;
  119754. this.volumetricLightFinalPostProcess = null;
  119755. this.lensFlarePostProcess = null;
  119756. this.lensFlareComposePostProcess = null;
  119757. this.luminancePostProcess = null;
  119758. this.hdrPostProcess = null;
  119759. this.hdrFinalPostProcess = null;
  119760. this.depthOfFieldPostProcess = null;
  119761. this.motionBlurPostProcess = null;
  119762. this.fxaaPostProcess = null;
  119763. this.luminanceDownSamplePostProcesses = [];
  119764. this.blurHPostProcesses = [];
  119765. this.blurVPostProcesses = [];
  119766. };
  119767. /**
  119768. * Dispose of the pipeline and stop all post processes
  119769. */
  119770. StandardRenderingPipeline.prototype.dispose = function () {
  119771. this._disposePostProcesses();
  119772. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  119773. _super.prototype.dispose.call(this);
  119774. };
  119775. /**
  119776. * Serialize the rendering pipeline (Used when exporting)
  119777. * @returns the serialized object
  119778. */
  119779. StandardRenderingPipeline.prototype.serialize = function () {
  119780. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  119781. if (this.sourceLight) {
  119782. serializationObject.sourceLightId = this.sourceLight.id;
  119783. }
  119784. serializationObject.customType = "StandardRenderingPipeline";
  119785. return serializationObject;
  119786. };
  119787. /**
  119788. * Parse the serialized pipeline
  119789. * @param source Source pipeline.
  119790. * @param scene The scene to load the pipeline to.
  119791. * @param rootUrl The URL of the serialized pipeline.
  119792. * @returns An instantiated pipeline from the serialized object.
  119793. */
  119794. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  119795. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  119796. if (source.sourceLightId) {
  119797. p.sourceLight = scene.getLightByID(source.sourceLightId);
  119798. }
  119799. return p;
  119800. };
  119801. /**
  119802. * Luminance steps
  119803. */
  119804. StandardRenderingPipeline.LuminanceSteps = 6;
  119805. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119807. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  119808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119810. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  119811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119813. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  119814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119816. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  119817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  119819. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  119820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119822. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  119823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119825. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  119826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119828. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  119829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119831. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  119832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119834. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  119835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119837. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  119838. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119839. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  119840. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  119841. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119843. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  119844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119846. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  119847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119849. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  119850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119852. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  119853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  119855. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  119856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  119858. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  119859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119861. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  119862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119864. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  119865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119867. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  119868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119870. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  119871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119873. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  119874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119876. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  119877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119879. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  119880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119882. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  119883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119885. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  119886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119888. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  119889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119891. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  119892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119894. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  119895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119897. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  119898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119900. ], StandardRenderingPipeline.prototype, "samples", null);
  119901. return StandardRenderingPipeline;
  119902. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  119903. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  119904. /***/ }),
  119905. /***/ "./PostProcesses/RenderPipeline/index.ts":
  119906. /*!***********************************************!*\
  119907. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  119908. \***********************************************/
  119909. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  119910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119911. "use strict";
  119912. __webpack_require__.r(__webpack_exports__);
  119913. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  119914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  119915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  119916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  119917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  119918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  119919. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  119921. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  119923. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  119924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  119925. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  119926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  119927. /***/ }),
  119928. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  119929. /*!*****************************************************************!*\
  119930. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  119931. \*****************************************************************/
  119932. /*! exports provided: PostProcessRenderEffect */
  119933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119934. "use strict";
  119935. __webpack_require__.r(__webpack_exports__);
  119936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  119937. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  119938. /**
  119939. * This represents a set of one or more post processes in Babylon.
  119940. * A post process can be used to apply a shader to a texture after it is rendered.
  119941. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119942. */
  119943. var PostProcessRenderEffect = /** @class */ (function () {
  119944. /**
  119945. * Instantiates a post process render effect.
  119946. * A post process can be used to apply a shader to a texture after it is rendered.
  119947. * @param engine The engine the effect is tied to
  119948. * @param name The name of the effect
  119949. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  119950. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  119951. */
  119952. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  119953. this._name = name;
  119954. this._singleInstance = singleInstance || true;
  119955. this._getPostProcesses = getPostProcesses;
  119956. this._cameras = {};
  119957. this._indicesForCamera = {};
  119958. this._postProcesses = {};
  119959. }
  119960. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  119961. /**
  119962. * Checks if all the post processes in the effect are supported.
  119963. */
  119964. get: function () {
  119965. for (var index in this._postProcesses) {
  119966. if (this._postProcesses.hasOwnProperty(index)) {
  119967. var pps = this._postProcesses[index];
  119968. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  119969. if (!pps[ppIndex].isSupported) {
  119970. return false;
  119971. }
  119972. }
  119973. }
  119974. }
  119975. return true;
  119976. },
  119977. enumerable: true,
  119978. configurable: true
  119979. });
  119980. /**
  119981. * Updates the current state of the effect
  119982. * @hidden
  119983. */
  119984. PostProcessRenderEffect.prototype._update = function () {
  119985. };
  119986. /**
  119987. * Attaches the effect on cameras
  119988. * @param cameras The camera to attach to.
  119989. * @hidden
  119990. */
  119991. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  119992. var _this = this;
  119993. var cameraKey;
  119994. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  119995. if (!cams) {
  119996. return;
  119997. }
  119998. for (var i = 0; i < cams.length; i++) {
  119999. var camera = cams[i];
  120000. var cameraName = camera.name;
  120001. if (this._singleInstance) {
  120002. cameraKey = 0;
  120003. }
  120004. else {
  120005. cameraKey = cameraName;
  120006. }
  120007. if (!this._postProcesses[cameraKey]) {
  120008. var postProcess = this._getPostProcesses();
  120009. if (postProcess) {
  120010. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  120011. }
  120012. }
  120013. if (!this._indicesForCamera[cameraName]) {
  120014. this._indicesForCamera[cameraName] = [];
  120015. }
  120016. this._postProcesses[cameraKey].forEach(function (postProcess) {
  120017. var index = camera.attachPostProcess(postProcess);
  120018. _this._indicesForCamera[cameraName].push(index);
  120019. });
  120020. if (!this._cameras[cameraName]) {
  120021. this._cameras[cameraName] = camera;
  120022. }
  120023. }
  120024. };
  120025. /**
  120026. * Detatches the effect on cameras
  120027. * @param cameras The camera to detatch from.
  120028. * @hidden
  120029. */
  120030. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  120031. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  120032. if (!cams) {
  120033. return;
  120034. }
  120035. for (var i = 0; i < cams.length; i++) {
  120036. var camera = cams[i];
  120037. var cameraName = camera.name;
  120038. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  120039. if (postProcesses) {
  120040. postProcesses.forEach(function (postProcess) {
  120041. camera.detachPostProcess(postProcess);
  120042. });
  120043. }
  120044. if (this._cameras[cameraName]) {
  120045. this._cameras[cameraName] = null;
  120046. }
  120047. }
  120048. };
  120049. /**
  120050. * Enables the effect on given cameras
  120051. * @param cameras The camera to enable.
  120052. * @hidden
  120053. */
  120054. PostProcessRenderEffect.prototype._enable = function (cameras) {
  120055. var _this = this;
  120056. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  120057. if (!cams) {
  120058. return;
  120059. }
  120060. for (var i = 0; i < cams.length; i++) {
  120061. var camera = cams[i];
  120062. var cameraName = camera.name;
  120063. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  120064. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  120065. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  120066. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  120067. });
  120068. }
  120069. }
  120070. }
  120071. };
  120072. /**
  120073. * Disables the effect on the given cameras
  120074. * @param cameras The camera to disable.
  120075. * @hidden
  120076. */
  120077. PostProcessRenderEffect.prototype._disable = function (cameras) {
  120078. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  120079. if (!cams) {
  120080. return;
  120081. }
  120082. for (var i = 0; i < cams.length; i++) {
  120083. var camera = cams[i];
  120084. var cameraName = camera.name;
  120085. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  120086. camera.detachPostProcess(postProcess);
  120087. });
  120088. }
  120089. };
  120090. /**
  120091. * Gets a list of the post processes contained in the effect.
  120092. * @param camera The camera to get the post processes on.
  120093. * @returns The list of the post processes in the effect.
  120094. */
  120095. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  120096. if (this._singleInstance) {
  120097. return this._postProcesses[0];
  120098. }
  120099. else {
  120100. if (!camera) {
  120101. return null;
  120102. }
  120103. return this._postProcesses[camera.name];
  120104. }
  120105. };
  120106. return PostProcessRenderEffect;
  120107. }());
  120108. /***/ }),
  120109. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  120110. /*!*******************************************************************!*\
  120111. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  120112. \*******************************************************************/
  120113. /*! exports provided: PostProcessRenderPipeline */
  120114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120115. "use strict";
  120116. __webpack_require__.r(__webpack_exports__);
  120117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  120118. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120119. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  120120. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  120121. /**
  120122. * PostProcessRenderPipeline
  120123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120124. */
  120125. var PostProcessRenderPipeline = /** @class */ (function () {
  120126. /**
  120127. * Initializes a PostProcessRenderPipeline
  120128. * @param engine engine to add the pipeline to
  120129. * @param name name of the pipeline
  120130. */
  120131. function PostProcessRenderPipeline(engine, name) {
  120132. this.engine = engine;
  120133. this._name = name;
  120134. this._renderEffects = {};
  120135. this._renderEffectsForIsolatedPass = new Array();
  120136. this._cameras = [];
  120137. }
  120138. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  120139. /**
  120140. * Gets pipeline name
  120141. */
  120142. get: function () {
  120143. return this._name;
  120144. },
  120145. enumerable: true,
  120146. configurable: true
  120147. });
  120148. /**
  120149. * Gets the class name
  120150. * @returns "PostProcessRenderPipeline"
  120151. */
  120152. PostProcessRenderPipeline.prototype.getClassName = function () {
  120153. return "PostProcessRenderPipeline";
  120154. };
  120155. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  120156. /**
  120157. * If all the render effects in the pipeline are supported
  120158. */
  120159. get: function () {
  120160. for (var renderEffectName in this._renderEffects) {
  120161. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  120162. if (!this._renderEffects[renderEffectName].isSupported) {
  120163. return false;
  120164. }
  120165. }
  120166. }
  120167. return true;
  120168. },
  120169. enumerable: true,
  120170. configurable: true
  120171. });
  120172. /**
  120173. * Adds an effect to the pipeline
  120174. * @param renderEffect the effect to add
  120175. */
  120176. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  120177. this._renderEffects[renderEffect._name] = renderEffect;
  120178. };
  120179. // private
  120180. /** @hidden */
  120181. PostProcessRenderPipeline.prototype._rebuild = function () {
  120182. };
  120183. /** @hidden */
  120184. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  120185. var renderEffects = this._renderEffects[renderEffectName];
  120186. if (!renderEffects) {
  120187. return;
  120188. }
  120189. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  120190. };
  120191. /** @hidden */
  120192. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  120193. var renderEffects = this._renderEffects[renderEffectName];
  120194. if (!renderEffects) {
  120195. return;
  120196. }
  120197. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  120198. };
  120199. /** @hidden */
  120200. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  120201. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  120202. if (!cams) {
  120203. return;
  120204. }
  120205. var indicesToDelete = [];
  120206. var i;
  120207. for (i = 0; i < cams.length; i++) {
  120208. var camera = cams[i];
  120209. var cameraName = camera.name;
  120210. if (this._cameras.indexOf(camera) === -1) {
  120211. this._cameras[cameraName] = camera;
  120212. }
  120213. else if (unique) {
  120214. indicesToDelete.push(i);
  120215. }
  120216. }
  120217. for (i = 0; i < indicesToDelete.length; i++) {
  120218. cameras.splice(indicesToDelete[i], 1);
  120219. }
  120220. for (var renderEffectName in this._renderEffects) {
  120221. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  120222. this._renderEffects[renderEffectName]._attachCameras(cams);
  120223. }
  120224. }
  120225. };
  120226. /** @hidden */
  120227. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  120228. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  120229. if (!cams) {
  120230. return;
  120231. }
  120232. for (var renderEffectName in this._renderEffects) {
  120233. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  120234. this._renderEffects[renderEffectName]._detachCameras(cams);
  120235. }
  120236. }
  120237. for (var i = 0; i < cams.length; i++) {
  120238. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  120239. }
  120240. };
  120241. /** @hidden */
  120242. PostProcessRenderPipeline.prototype._update = function () {
  120243. for (var renderEffectName in this._renderEffects) {
  120244. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  120245. this._renderEffects[renderEffectName]._update();
  120246. }
  120247. }
  120248. for (var i = 0; i < this._cameras.length; i++) {
  120249. var cameraName = this._cameras[i].name;
  120250. if (this._renderEffectsForIsolatedPass[cameraName]) {
  120251. this._renderEffectsForIsolatedPass[cameraName]._update();
  120252. }
  120253. }
  120254. };
  120255. /** @hidden */
  120256. PostProcessRenderPipeline.prototype._reset = function () {
  120257. this._renderEffects = {};
  120258. this._renderEffectsForIsolatedPass = new Array();
  120259. };
  120260. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  120261. // 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)
  120262. var effectKeys = Object.keys(this._renderEffects);
  120263. if (this.engine.webGLVersion === 1) {
  120264. return false;
  120265. }
  120266. if (effectKeys.length > 0) {
  120267. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  120268. if (postProcesses) {
  120269. postProcesses[0].samples = sampleCount;
  120270. }
  120271. }
  120272. return true;
  120273. };
  120274. /**
  120275. * Disposes of the pipeline
  120276. */
  120277. PostProcessRenderPipeline.prototype.dispose = function () {
  120278. // Must be implemented by children
  120279. };
  120280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120282. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  120283. return PostProcessRenderPipeline;
  120284. }());
  120285. /***/ }),
  120286. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  120287. /*!**************************************************************************!*\
  120288. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  120289. \**************************************************************************/
  120290. /*! exports provided: PostProcessRenderPipelineManager */
  120291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120292. "use strict";
  120293. __webpack_require__.r(__webpack_exports__);
  120294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  120295. /**
  120296. * PostProcessRenderPipelineManager class
  120297. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120298. */
  120299. var PostProcessRenderPipelineManager = /** @class */ (function () {
  120300. /**
  120301. * Initializes a PostProcessRenderPipelineManager
  120302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120303. */
  120304. function PostProcessRenderPipelineManager() {
  120305. this._renderPipelines = {};
  120306. }
  120307. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  120308. /**
  120309. * Gets the list of supported render pipelines
  120310. */
  120311. get: function () {
  120312. var result = [];
  120313. for (var renderPipelineName in this._renderPipelines) {
  120314. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  120315. var pipeline = this._renderPipelines[renderPipelineName];
  120316. if (pipeline.isSupported) {
  120317. result.push(pipeline);
  120318. }
  120319. }
  120320. }
  120321. return result;
  120322. },
  120323. enumerable: true,
  120324. configurable: true
  120325. });
  120326. /**
  120327. * Adds a pipeline to the manager
  120328. * @param renderPipeline The pipeline to add
  120329. */
  120330. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  120331. this._renderPipelines[renderPipeline._name] = renderPipeline;
  120332. };
  120333. /**
  120334. * Attaches a camera to the pipeline
  120335. * @param renderPipelineName The name of the pipeline to attach to
  120336. * @param cameras the camera to attach
  120337. * @param unique if the camera can be attached multiple times to the pipeline
  120338. */
  120339. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  120340. if (unique === void 0) { unique = false; }
  120341. var renderPipeline = this._renderPipelines[renderPipelineName];
  120342. if (!renderPipeline) {
  120343. return;
  120344. }
  120345. renderPipeline._attachCameras(cameras, unique);
  120346. };
  120347. /**
  120348. * Detaches a camera from the pipeline
  120349. * @param renderPipelineName The name of the pipeline to detach from
  120350. * @param cameras the camera to detach
  120351. */
  120352. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  120353. var renderPipeline = this._renderPipelines[renderPipelineName];
  120354. if (!renderPipeline) {
  120355. return;
  120356. }
  120357. renderPipeline._detachCameras(cameras);
  120358. };
  120359. /**
  120360. * Enables an effect by name on a pipeline
  120361. * @param renderPipelineName the name of the pipeline to enable the effect in
  120362. * @param renderEffectName the name of the effect to enable
  120363. * @param cameras the cameras that the effect should be enabled on
  120364. */
  120365. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  120366. var renderPipeline = this._renderPipelines[renderPipelineName];
  120367. if (!renderPipeline) {
  120368. return;
  120369. }
  120370. renderPipeline._enableEffect(renderEffectName, cameras);
  120371. };
  120372. /**
  120373. * Disables an effect by name on a pipeline
  120374. * @param renderPipelineName the name of the pipeline to disable the effect in
  120375. * @param renderEffectName the name of the effect to disable
  120376. * @param cameras the cameras that the effect should be disabled on
  120377. */
  120378. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  120379. var renderPipeline = this._renderPipelines[renderPipelineName];
  120380. if (!renderPipeline) {
  120381. return;
  120382. }
  120383. renderPipeline._disableEffect(renderEffectName, cameras);
  120384. };
  120385. /**
  120386. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  120387. */
  120388. PostProcessRenderPipelineManager.prototype.update = function () {
  120389. for (var renderPipelineName in this._renderPipelines) {
  120390. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  120391. var pipeline = this._renderPipelines[renderPipelineName];
  120392. if (!pipeline.isSupported) {
  120393. pipeline.dispose();
  120394. delete this._renderPipelines[renderPipelineName];
  120395. }
  120396. else {
  120397. pipeline._update();
  120398. }
  120399. }
  120400. }
  120401. };
  120402. /** @hidden */
  120403. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  120404. for (var renderPipelineName in this._renderPipelines) {
  120405. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  120406. var pipeline = this._renderPipelines[renderPipelineName];
  120407. pipeline._rebuild();
  120408. }
  120409. }
  120410. };
  120411. /**
  120412. * Disposes of the manager and pipelines
  120413. */
  120414. PostProcessRenderPipelineManager.prototype.dispose = function () {
  120415. for (var renderPipelineName in this._renderPipelines) {
  120416. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  120417. var pipeline = this._renderPipelines[renderPipelineName];
  120418. pipeline.dispose();
  120419. }
  120420. }
  120421. };
  120422. return PostProcessRenderPipelineManager;
  120423. }());
  120424. /***/ }),
  120425. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  120426. /*!****************************************************************************************!*\
  120427. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  120428. \****************************************************************************************/
  120429. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  120430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120431. "use strict";
  120432. __webpack_require__.r(__webpack_exports__);
  120433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  120434. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  120435. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  120436. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  120437. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  120438. get: function () {
  120439. if (!this._postProcessRenderPipelineManager) {
  120440. // Register the G Buffer component to the scene.
  120441. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  120442. if (!component) {
  120443. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  120444. this._addComponent(component);
  120445. }
  120446. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  120447. }
  120448. return this._postProcessRenderPipelineManager;
  120449. },
  120450. enumerable: true,
  120451. configurable: true
  120452. });
  120453. /**
  120454. * Defines the Render Pipeline scene component responsible to rendering pipelines
  120455. */
  120456. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  120457. /**
  120458. * Creates a new instance of the component for the given scene
  120459. * @param scene Defines the scene to register the component in
  120460. */
  120461. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  120462. /**
  120463. * The component name helpfull to identify the component in the list of scene components.
  120464. */
  120465. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  120466. this.scene = scene;
  120467. }
  120468. /**
  120469. * Registers the component in a given scene
  120470. */
  120471. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  120472. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  120473. };
  120474. /**
  120475. * Rebuilds the elements related to this component in case of
  120476. * context lost for instance.
  120477. */
  120478. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  120479. if (this.scene._postProcessRenderPipelineManager) {
  120480. this.scene._postProcessRenderPipelineManager._rebuild();
  120481. }
  120482. };
  120483. /**
  120484. * Disposes the component and the associated ressources
  120485. */
  120486. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  120487. if (this.scene._postProcessRenderPipelineManager) {
  120488. this.scene._postProcessRenderPipelineManager.dispose();
  120489. }
  120490. };
  120491. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  120492. if (this.scene._postProcessRenderPipelineManager) {
  120493. this.scene._postProcessRenderPipelineManager.update();
  120494. }
  120495. };
  120496. return PostProcessRenderPipelineManagerSceneComponent;
  120497. }());
  120498. /***/ }),
  120499. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  120500. /*!**********************************************!*\
  120501. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  120502. \**********************************************/
  120503. /*! exports provided: AnaglyphPostProcess */
  120504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120505. "use strict";
  120506. __webpack_require__.r(__webpack_exports__);
  120507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  120508. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120509. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120510. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  120511. /**
  120512. * Postprocess used to generate anaglyphic rendering
  120513. */
  120514. var AnaglyphPostProcess = /** @class */ (function (_super) {
  120515. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  120516. /**
  120517. * Creates a new AnaglyphPostProcess
  120518. * @param name defines postprocess name
  120519. * @param options defines creation options or target ratio scale
  120520. * @param rigCameras defines cameras using this postprocess
  120521. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  120522. * @param engine defines hosting engine
  120523. * @param reusable defines if the postprocess will be reused multiple times per frame
  120524. */
  120525. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  120526. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  120527. _this._passedProcess = rigCameras[0]._rigPostProcess;
  120528. _this.onApplyObservable.add(function (effect) {
  120529. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  120530. });
  120531. return _this;
  120532. }
  120533. return AnaglyphPostProcess;
  120534. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  120535. /***/ }),
  120536. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  120537. /*!***************************************************!*\
  120538. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  120539. \***************************************************/
  120540. /*! exports provided: BlackAndWhitePostProcess */
  120541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120542. "use strict";
  120543. __webpack_require__.r(__webpack_exports__);
  120544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  120545. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120546. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120547. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  120548. /**
  120549. * Post process used to render in black and white
  120550. */
  120551. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  120552. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  120553. /**
  120554. * Creates a black and white post process
  120555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  120556. * @param name The name of the effect.
  120557. * @param options The required width/height ratio to downsize to before computing the render pass.
  120558. * @param camera The camera to apply the render pass to.
  120559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120560. * @param engine The engine which the post process will be applied. (default: current engine)
  120561. * @param reusable If the post process can be reused on the same frame. (default: false)
  120562. */
  120563. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  120564. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  120565. /**
  120566. * Linear about to convert he result to black and white (default: 1)
  120567. */
  120568. _this.degree = 1;
  120569. _this.onApplyObservable.add(function (effect) {
  120570. effect.setFloat("degree", _this.degree);
  120571. });
  120572. return _this;
  120573. }
  120574. return BlackAndWhitePostProcess;
  120575. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  120576. /***/ }),
  120577. /***/ "./PostProcesses/bloomEffect.ts":
  120578. /*!**************************************!*\
  120579. !*** ./PostProcesses/bloomEffect.ts ***!
  120580. \**************************************/
  120581. /*! exports provided: BloomEffect */
  120582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120583. "use strict";
  120584. __webpack_require__.r(__webpack_exports__);
  120585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  120586. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120587. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120588. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  120589. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  120590. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  120591. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120592. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120593. /**
  120594. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  120595. */
  120596. var BloomEffect = /** @class */ (function (_super) {
  120597. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  120598. /**
  120599. * Creates a new instance of @see BloomEffect
  120600. * @param scene The scene the effect belongs to.
  120601. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120602. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120603. * @param bloomWeight The the strength of bloom.
  120604. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120605. * @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)
  120606. */
  120607. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  120608. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  120609. if (blockCompilation === void 0) { blockCompilation = false; }
  120610. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  120611. return _this._effects;
  120612. }, true) || this;
  120613. _this.bloomScale = bloomScale;
  120614. /**
  120615. * @hidden Internal
  120616. */
  120617. _this._effects = [];
  120618. _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);
  120619. _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);
  120620. _this._blurX.alwaysForcePOT = true;
  120621. _this._blurX.autoClear = false;
  120622. _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);
  120623. _this._blurY.alwaysForcePOT = true;
  120624. _this._blurY.autoClear = false;
  120625. _this.kernel = bloomKernel;
  120626. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  120627. _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);
  120628. _this._merge.autoClear = false;
  120629. _this._effects.push(_this._merge);
  120630. return _this;
  120631. }
  120632. Object.defineProperty(BloomEffect.prototype, "threshold", {
  120633. /**
  120634. * The luminance threshold to find bright areas of the image to bloom.
  120635. */
  120636. get: function () {
  120637. return this._downscale.threshold;
  120638. },
  120639. set: function (value) {
  120640. this._downscale.threshold = value;
  120641. },
  120642. enumerable: true,
  120643. configurable: true
  120644. });
  120645. Object.defineProperty(BloomEffect.prototype, "weight", {
  120646. /**
  120647. * The strength of the bloom.
  120648. */
  120649. get: function () {
  120650. return this._merge.weight;
  120651. },
  120652. set: function (value) {
  120653. this._merge.weight = value;
  120654. },
  120655. enumerable: true,
  120656. configurable: true
  120657. });
  120658. Object.defineProperty(BloomEffect.prototype, "kernel", {
  120659. /**
  120660. * Specifies the size of the bloom blur kernel, relative to the final output size
  120661. */
  120662. get: function () {
  120663. return this._blurX.kernel / this.bloomScale;
  120664. },
  120665. set: function (value) {
  120666. this._blurX.kernel = value * this.bloomScale;
  120667. this._blurY.kernel = value * this.bloomScale;
  120668. },
  120669. enumerable: true,
  120670. configurable: true
  120671. });
  120672. /**
  120673. * Disposes each of the internal effects for a given camera.
  120674. * @param camera The camera to dispose the effect on.
  120675. */
  120676. BloomEffect.prototype.disposeEffects = function (camera) {
  120677. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  120678. this._effects[effectIndex].dispose(camera);
  120679. }
  120680. };
  120681. /**
  120682. * @hidden Internal
  120683. */
  120684. BloomEffect.prototype._updateEffects = function () {
  120685. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  120686. this._effects[effectIndex].updateEffect();
  120687. }
  120688. };
  120689. /**
  120690. * Internal
  120691. * @returns if all the contained post processes are ready.
  120692. * @hidden
  120693. */
  120694. BloomEffect.prototype._isReady = function () {
  120695. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  120696. if (!this._effects[effectIndex].isReady()) {
  120697. return false;
  120698. }
  120699. }
  120700. return true;
  120701. };
  120702. return BloomEffect;
  120703. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  120704. /***/ }),
  120705. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  120706. /*!************************************************!*\
  120707. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  120708. \************************************************/
  120709. /*! exports provided: BloomMergePostProcess */
  120710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120711. "use strict";
  120712. __webpack_require__.r(__webpack_exports__);
  120713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  120714. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120715. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120716. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120717. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  120718. /**
  120719. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120720. */
  120721. var BloomMergePostProcess = /** @class */ (function (_super) {
  120722. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  120723. /**
  120724. * Creates a new instance of @see BloomMergePostProcess
  120725. * @param name The name of the effect.
  120726. * @param originalFromInput Post process which's input will be used for the merge.
  120727. * @param blurred Blurred highlights post process which's output will be used.
  120728. * @param weight Weight of the bloom to be added to the original input.
  120729. * @param options The required width/height ratio to downsize to before computing the render pass.
  120730. * @param camera The camera to apply the render pass to.
  120731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120732. * @param engine The engine which the post process will be applied. (default: current engine)
  120733. * @param reusable If the post process can be reused on the same frame. (default: false)
  120734. * @param textureType Type of textures used when performing the post process. (default: 0)
  120735. * @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)
  120736. */
  120737. function BloomMergePostProcess(name, originalFromInput, blurred,
  120738. /** Weight of the bloom to be added to the original input. */
  120739. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  120740. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120741. if (blockCompilation === void 0) { blockCompilation = false; }
  120742. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  120743. _this.weight = weight;
  120744. _this.onApplyObservable.add(function (effect) {
  120745. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  120746. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  120747. effect.setFloat("bloomWeight", _this.weight);
  120748. });
  120749. if (!blockCompilation) {
  120750. _this.updateEffect();
  120751. }
  120752. return _this;
  120753. }
  120754. return BloomMergePostProcess;
  120755. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  120756. /***/ }),
  120757. /***/ "./PostProcesses/blurPostProcess.ts":
  120758. /*!******************************************!*\
  120759. !*** ./PostProcesses/blurPostProcess.ts ***!
  120760. \******************************************/
  120761. /*! exports provided: BlurPostProcess */
  120762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120763. "use strict";
  120764. __webpack_require__.r(__webpack_exports__);
  120765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  120766. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120767. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120768. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120769. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120770. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  120771. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  120772. /**
  120773. * The Blur Post Process which blurs an image based on a kernel and direction.
  120774. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  120775. */
  120776. var BlurPostProcess = /** @class */ (function (_super) {
  120777. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  120778. /**
  120779. * Creates a new instance BlurPostProcess
  120780. * @param name The name of the effect.
  120781. * @param direction The direction in which to blur the image.
  120782. * @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.
  120783. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  120784. * @param camera The camera to apply the render pass to.
  120785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120786. * @param engine The engine which the post process will be applied. (default: current engine)
  120787. * @param reusable If the post process can be reused on the same frame. (default: false)
  120788. * @param textureType Type of textures used when performing the post process. (default: 0)
  120789. * @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)
  120790. */
  120791. function BlurPostProcess(name,
  120792. /** The direction in which to blur the image. */
  120793. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  120794. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  120795. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120796. if (defines === void 0) { defines = ""; }
  120797. if (blockCompilation === void 0) { blockCompilation = false; }
  120798. 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;
  120799. _this.direction = direction;
  120800. _this.blockCompilation = blockCompilation;
  120801. _this._packedFloat = false;
  120802. _this._staticDefines = "";
  120803. _this._staticDefines = defines;
  120804. _this.onApplyObservable.add(function (effect) {
  120805. if (_this._outputTexture) {
  120806. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  120807. }
  120808. else {
  120809. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  120810. }
  120811. });
  120812. _this.kernel = kernel;
  120813. return _this;
  120814. }
  120815. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  120816. /**
  120817. * Gets the length in pixels of the blur sample region
  120818. */
  120819. get: function () {
  120820. return this._idealKernel;
  120821. },
  120822. /**
  120823. * Sets the length in pixels of the blur sample region
  120824. */
  120825. set: function (v) {
  120826. if (this._idealKernel === v) {
  120827. return;
  120828. }
  120829. v = Math.max(v, 1);
  120830. this._idealKernel = v;
  120831. this._kernel = this._nearestBestKernel(v);
  120832. if (!this.blockCompilation) {
  120833. this._updateParameters();
  120834. }
  120835. },
  120836. enumerable: true,
  120837. configurable: true
  120838. });
  120839. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  120840. /**
  120841. * Gets wether or not the blur is unpacking/repacking floats
  120842. */
  120843. get: function () {
  120844. return this._packedFloat;
  120845. },
  120846. /**
  120847. * Sets wether or not the blur needs to unpack/repack floats
  120848. */
  120849. set: function (v) {
  120850. if (this._packedFloat === v) {
  120851. return;
  120852. }
  120853. this._packedFloat = v;
  120854. if (!this.blockCompilation) {
  120855. this._updateParameters();
  120856. }
  120857. },
  120858. enumerable: true,
  120859. configurable: true
  120860. });
  120861. /**
  120862. * Updates the effect with the current post process compile time values and recompiles the shader.
  120863. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120864. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120865. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120866. * @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
  120867. * @param onCompiled Called when the shader has been compiled.
  120868. * @param onError Called if there is an error when compiling a shader.
  120869. */
  120870. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  120871. if (defines === void 0) { defines = null; }
  120872. if (uniforms === void 0) { uniforms = null; }
  120873. if (samplers === void 0) { samplers = null; }
  120874. this._updateParameters(onCompiled, onError);
  120875. };
  120876. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  120877. // Generate sampling offsets and weights
  120878. var N = this._kernel;
  120879. var centerIndex = (N - 1) / 2;
  120880. // Generate Gaussian sampling weights over kernel
  120881. var offsets = [];
  120882. var weights = [];
  120883. var totalWeight = 0;
  120884. for (var i = 0; i < N; i++) {
  120885. var u = i / (N - 1);
  120886. var w = this._gaussianWeight(u * 2.0 - 1);
  120887. offsets[i] = (i - centerIndex);
  120888. weights[i] = w;
  120889. totalWeight += w;
  120890. }
  120891. // Normalize weights
  120892. for (var i = 0; i < weights.length; i++) {
  120893. weights[i] /= totalWeight;
  120894. }
  120895. // Optimize: combine samples to take advantage of hardware linear sampling
  120896. // Walk from left to center, combining pairs (symmetrically)
  120897. var linearSamplingWeights = [];
  120898. var linearSamplingOffsets = [];
  120899. var linearSamplingMap = [];
  120900. for (var i = 0; i <= centerIndex; i += 2) {
  120901. var j = Math.min(i + 1, Math.floor(centerIndex));
  120902. var singleCenterSample = i === j;
  120903. if (singleCenterSample) {
  120904. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  120905. }
  120906. else {
  120907. var sharedCell = j === centerIndex;
  120908. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  120909. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  120910. if (offsetLinear === 0) {
  120911. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  120912. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  120913. }
  120914. else {
  120915. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  120916. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  120917. }
  120918. }
  120919. }
  120920. for (var i = 0; i < linearSamplingMap.length; i++) {
  120921. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  120922. linearSamplingWeights[i] = linearSamplingMap[i].w;
  120923. }
  120924. // Replace with optimized
  120925. offsets = linearSamplingOffsets;
  120926. weights = linearSamplingWeights;
  120927. // Generate shaders
  120928. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  120929. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  120930. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  120931. var defines = "";
  120932. defines += this._staticDefines;
  120933. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  120934. if (this._staticDefines.indexOf("DOF") != -1) {
  120935. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  120936. varyingCount--;
  120937. }
  120938. for (var i = 0; i < varyingCount; i++) {
  120939. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  120940. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  120941. }
  120942. var depCount = 0;
  120943. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  120944. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  120945. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  120946. depCount++;
  120947. }
  120948. if (this.packedFloat) {
  120949. defines += "#define PACKEDFLOAT 1";
  120950. }
  120951. this.blockCompilation = false;
  120952. _super.prototype.updateEffect.call(this, defines, null, null, {
  120953. varyingCount: varyingCount,
  120954. depCount: depCount
  120955. }, onCompiled, onError);
  120956. };
  120957. /**
  120958. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  120959. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  120960. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  120961. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  120962. * The gaps between physical kernels are compensated for in the weighting of the samples
  120963. * @param idealKernel Ideal blur kernel.
  120964. * @return Nearest best kernel.
  120965. */
  120966. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  120967. var v = Math.round(idealKernel);
  120968. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  120969. var k = _a[_i];
  120970. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  120971. return Math.max(k, 3);
  120972. }
  120973. }
  120974. return Math.max(v, 3);
  120975. };
  120976. /**
  120977. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  120978. * @param x The point on the Gaussian distribution to sample.
  120979. * @return the value of the Gaussian function at x.
  120980. */
  120981. BlurPostProcess.prototype._gaussianWeight = function (x) {
  120982. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  120983. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  120984. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  120985. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  120986. // truncated at around 1.3% of peak strength.
  120987. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  120988. var sigma = (1 / 3);
  120989. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  120990. var exponent = -((x * x) / (2.0 * sigma * sigma));
  120991. var weight = (1.0 / denominator) * Math.exp(exponent);
  120992. return weight;
  120993. };
  120994. /**
  120995. * Generates a string that can be used as a floating point number in GLSL.
  120996. * @param x Value to print.
  120997. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  120998. * @return GLSL float string.
  120999. */
  121000. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  121001. if (decimalFigures === void 0) { decimalFigures = 8; }
  121002. return x.toFixed(decimalFigures).replace(/0+$/, '');
  121003. };
  121004. return BlurPostProcess;
  121005. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121006. /***/ }),
  121007. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  121008. /*!*********************************************************!*\
  121009. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  121010. \*********************************************************/
  121011. /*! exports provided: ChromaticAberrationPostProcess */
  121012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121013. "use strict";
  121014. __webpack_require__.r(__webpack_exports__);
  121015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  121016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121017. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121018. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121019. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121020. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  121021. /**
  121022. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  121023. */
  121024. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  121025. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  121026. /**
  121027. * Creates a new instance ChromaticAberrationPostProcess
  121028. * @param name The name of the effect.
  121029. * @param screenWidth The width of the screen to apply the effect on.
  121030. * @param screenHeight The height of the screen to apply the effect on.
  121031. * @param options The required width/height ratio to downsize to before computing the render pass.
  121032. * @param camera The camera to apply the render pass to.
  121033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121034. * @param engine The engine which the post process will be applied. (default: current engine)
  121035. * @param reusable If the post process can be reused on the same frame. (default: false)
  121036. * @param textureType Type of textures used when performing the post process. (default: 0)
  121037. * @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)
  121038. */
  121039. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121040. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121041. if (blockCompilation === void 0) { blockCompilation = false; }
  121042. 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;
  121043. /**
  121044. * The amount of seperation of rgb channels (default: 30)
  121045. */
  121046. _this.aberrationAmount = 30;
  121047. /**
  121048. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  121049. */
  121050. _this.radialIntensity = 0;
  121051. /**
  121052. * 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))
  121053. */
  121054. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  121055. /**
  121056. * 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))
  121057. */
  121058. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  121059. _this.onApplyObservable.add(function (effect) {
  121060. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  121061. effect.setFloat('screen_width', screenWidth);
  121062. effect.setFloat('screen_height', screenHeight);
  121063. effect.setFloat('radialIntensity', _this.radialIntensity);
  121064. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  121065. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  121066. });
  121067. return _this;
  121068. }
  121069. return ChromaticAberrationPostProcess;
  121070. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  121071. /***/ }),
  121072. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  121073. /*!*******************************************************!*\
  121074. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  121075. \*******************************************************/
  121076. /*! exports provided: CircleOfConfusionPostProcess */
  121077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121078. "use strict";
  121079. __webpack_require__.r(__webpack_exports__);
  121080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  121081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121082. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121083. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  121084. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121085. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  121086. /**
  121087. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  121088. */
  121089. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  121090. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  121091. /**
  121092. * Creates a new instance CircleOfConfusionPostProcess
  121093. * @param name The name of the effect.
  121094. * @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.
  121095. * @param options The required width/height ratio to downsize to before computing the render pass.
  121096. * @param camera The camera to apply the render pass to.
  121097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121098. * @param engine The engine which the post process will be applied. (default: current engine)
  121099. * @param reusable If the post process can be reused on the same frame. (default: false)
  121100. * @param textureType Type of textures used when performing the post process. (default: 0)
  121101. * @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)
  121102. */
  121103. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121104. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121105. if (blockCompilation === void 0) { blockCompilation = false; }
  121106. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  121107. /**
  121108. * 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.
  121109. */
  121110. _this.lensSize = 50;
  121111. /**
  121112. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121113. */
  121114. _this.fStop = 1.4;
  121115. /**
  121116. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121117. */
  121118. _this.focusDistance = 2000;
  121119. /**
  121120. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  121121. */
  121122. _this.focalLength = 50;
  121123. _this._depthTexture = null;
  121124. _this._depthTexture = depthTexture;
  121125. _this.onApplyObservable.add(function (effect) {
  121126. if (!_this._depthTexture) {
  121127. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  121128. return;
  121129. }
  121130. effect.setTexture("depthSampler", _this._depthTexture);
  121131. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  121132. var aperture = _this.lensSize / _this.fStop;
  121133. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  121134. effect.setFloat('focusDistance', _this.focusDistance);
  121135. effect.setFloat('cocPrecalculation', cocPrecalculation);
  121136. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  121137. });
  121138. return _this;
  121139. }
  121140. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  121141. /**
  121142. * 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.
  121143. */
  121144. set: function (value) {
  121145. this._depthTexture = value;
  121146. },
  121147. enumerable: true,
  121148. configurable: true
  121149. });
  121150. return CircleOfConfusionPostProcess;
  121151. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121152. /***/ }),
  121153. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  121154. /*!*****************************************************!*\
  121155. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  121156. \*****************************************************/
  121157. /*! exports provided: ColorCorrectionPostProcess */
  121158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121159. "use strict";
  121160. __webpack_require__.r(__webpack_exports__);
  121161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  121162. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121163. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121164. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121165. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  121166. /**
  121167. *
  121168. * This post-process allows the modification of rendered colors by using
  121169. * a 'look-up table' (LUT). This effect is also called Color Grading.
  121170. *
  121171. * The object needs to be provided an url to a texture containing the color
  121172. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  121173. * Use an image editing software to tweak the LUT to match your needs.
  121174. *
  121175. * For an example of a color LUT, see here:
  121176. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  121177. * For explanations on color grading, see here:
  121178. * @see http://udn.epicgames.com/Three/ColorGrading.html
  121179. *
  121180. */
  121181. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  121182. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  121183. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  121184. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  121185. _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);
  121186. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  121187. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  121188. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  121189. _this.onApply = function (effect) {
  121190. effect.setTexture("colorTable", _this._colorTableTexture);
  121191. };
  121192. return _this;
  121193. }
  121194. return ColorCorrectionPostProcess;
  121195. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121196. /***/ }),
  121197. /***/ "./PostProcesses/convolutionPostProcess.ts":
  121198. /*!*************************************************!*\
  121199. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  121200. \*************************************************/
  121201. /*! exports provided: ConvolutionPostProcess */
  121202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121203. "use strict";
  121204. __webpack_require__.r(__webpack_exports__);
  121205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  121206. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121207. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121208. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121209. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  121210. /**
  121211. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  121212. * input texture to perform effects such as edge detection or sharpening
  121213. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121214. */
  121215. var ConvolutionPostProcess = /** @class */ (function (_super) {
  121216. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  121217. /**
  121218. * Creates a new instance ConvolutionPostProcess
  121219. * @param name The name of the effect.
  121220. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  121221. * @param options The required width/height ratio to downsize to before computing the render pass.
  121222. * @param camera The camera to apply the render pass to.
  121223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121224. * @param engine The engine which the post process will be applied. (default: current engine)
  121225. * @param reusable If the post process can be reused on the same frame. (default: false)
  121226. * @param textureType Type of textures used when performing the post process. (default: 0)
  121227. */
  121228. function ConvolutionPostProcess(name,
  121229. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  121230. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  121231. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121232. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  121233. _this.kernel = kernel;
  121234. _this.onApply = function (effect) {
  121235. effect.setFloat2("screenSize", _this.width, _this.height);
  121236. effect.setArray("kernel", _this.kernel);
  121237. };
  121238. return _this;
  121239. }
  121240. // Statics
  121241. /**
  121242. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121243. */
  121244. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  121245. /**
  121246. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121247. */
  121248. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  121249. /**
  121250. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121251. */
  121252. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  121253. /**
  121254. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121255. */
  121256. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  121257. /**
  121258. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121259. */
  121260. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  121261. /**
  121262. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121263. */
  121264. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  121265. return ConvolutionPostProcess;
  121266. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121267. /***/ }),
  121268. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  121269. /*!******************************************************!*\
  121270. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  121271. \******************************************************/
  121272. /*! exports provided: DepthOfFieldBlurPostProcess */
  121273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121274. "use strict";
  121275. __webpack_require__.r(__webpack_exports__);
  121276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  121277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121278. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121279. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  121280. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121281. /**
  121282. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  121283. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  121284. * based on samples that have a large difference in distance than the center pixel.
  121285. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121286. */
  121287. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  121288. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  121289. /**
  121290. * Creates a new instance CircleOfConfusionPostProcess
  121291. * @param name The name of the effect.
  121292. * @param scene The scene the effect belongs to.
  121293. * @param direction The direction the blur should be applied.
  121294. * @param kernel The size of the kernel used to blur.
  121295. * @param options The required width/height ratio to downsize to before computing the render pass.
  121296. * @param camera The camera to apply the render pass to.
  121297. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  121298. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  121299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121300. * @param engine The engine which the post process will be applied. (default: current engine)
  121301. * @param reusable If the post process can be reused on the same frame. (default: false)
  121302. * @param textureType Type of textures used when performing the post process. (default: 0)
  121303. * @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)
  121304. */
  121305. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  121306. if (imageToBlur === void 0) { imageToBlur = null; }
  121307. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  121308. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121309. if (blockCompilation === void 0) { blockCompilation = false; }
  121310. 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;
  121311. _this.direction = direction;
  121312. _this.onApplyObservable.add(function (effect) {
  121313. if (imageToBlur != null) {
  121314. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  121315. }
  121316. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  121317. if (scene.activeCamera) {
  121318. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  121319. }
  121320. });
  121321. return _this;
  121322. }
  121323. return DepthOfFieldBlurPostProcess;
  121324. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  121325. /***/ }),
  121326. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  121327. /*!*********************************************!*\
  121328. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  121329. \*********************************************/
  121330. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  121331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121332. "use strict";
  121333. __webpack_require__.r(__webpack_exports__);
  121334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  121335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  121336. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121337. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121338. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121339. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  121340. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  121341. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  121342. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  121343. /**
  121344. * Specifies the level of max blur that should be applied when using the depth of field effect
  121345. */
  121346. var DepthOfFieldEffectBlurLevel;
  121347. (function (DepthOfFieldEffectBlurLevel) {
  121348. /**
  121349. * Subtle blur
  121350. */
  121351. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  121352. /**
  121353. * Medium blur
  121354. */
  121355. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  121356. /**
  121357. * Large blur
  121358. */
  121359. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  121360. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  121361. /**
  121362. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  121363. */
  121364. var DepthOfFieldEffect = /** @class */ (function (_super) {
  121365. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  121366. /**
  121367. * Creates a new instance DepthOfFieldEffect
  121368. * @param scene The scene the effect belongs to.
  121369. * @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.
  121370. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121371. * @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)
  121372. */
  121373. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  121374. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  121375. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  121376. if (blockCompilation === void 0) { blockCompilation = false; }
  121377. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  121378. return _this._effects;
  121379. }, true) || this;
  121380. /**
  121381. * @hidden Internal post processes in depth of field effect
  121382. */
  121383. _this._effects = [];
  121384. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  121385. _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);
  121386. // 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)
  121387. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  121388. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121389. _this._depthOfFieldBlurY = [];
  121390. _this._depthOfFieldBlurX = [];
  121391. var blurCount = 1;
  121392. var kernelSize = 15;
  121393. switch (blurLevel) {
  121394. case DepthOfFieldEffectBlurLevel.High: {
  121395. blurCount = 3;
  121396. kernelSize = 51;
  121397. break;
  121398. }
  121399. case DepthOfFieldEffectBlurLevel.Medium: {
  121400. blurCount = 2;
  121401. kernelSize = 31;
  121402. break;
  121403. }
  121404. default: {
  121405. kernelSize = 15;
  121406. blurCount = 1;
  121407. break;
  121408. }
  121409. }
  121410. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  121411. var ratio = 1.0;
  121412. for (var i = 0; i < blurCount; i++) {
  121413. 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);
  121414. blurY.autoClear = false;
  121415. ratio = 0.75 / Math.pow(2, i);
  121416. 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);
  121417. blurX.autoClear = false;
  121418. _this._depthOfFieldBlurY.push(blurY);
  121419. _this._depthOfFieldBlurX.push(blurX);
  121420. }
  121421. // Set all post processes on the effect.
  121422. _this._effects = [_this._circleOfConfusion];
  121423. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  121424. _this._effects.push(_this._depthOfFieldBlurY[i]);
  121425. _this._effects.push(_this._depthOfFieldBlurX[i]);
  121426. }
  121427. // Merge blurred images with original image based on circleOfConfusion
  121428. _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);
  121429. _this._dofMerge.autoClear = false;
  121430. _this._effects.push(_this._dofMerge);
  121431. return _this;
  121432. }
  121433. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  121434. get: function () {
  121435. return this._circleOfConfusion.focalLength;
  121436. },
  121437. /**
  121438. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  121439. */
  121440. set: function (value) {
  121441. this._circleOfConfusion.focalLength = value;
  121442. },
  121443. enumerable: true,
  121444. configurable: true
  121445. });
  121446. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  121447. get: function () {
  121448. return this._circleOfConfusion.fStop;
  121449. },
  121450. /**
  121451. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121452. */
  121453. set: function (value) {
  121454. this._circleOfConfusion.fStop = value;
  121455. },
  121456. enumerable: true,
  121457. configurable: true
  121458. });
  121459. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  121460. get: function () {
  121461. return this._circleOfConfusion.focusDistance;
  121462. },
  121463. /**
  121464. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121465. */
  121466. set: function (value) {
  121467. this._circleOfConfusion.focusDistance = value;
  121468. },
  121469. enumerable: true,
  121470. configurable: true
  121471. });
  121472. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  121473. get: function () {
  121474. return this._circleOfConfusion.lensSize;
  121475. },
  121476. /**
  121477. * 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.
  121478. */
  121479. set: function (value) {
  121480. this._circleOfConfusion.lensSize = value;
  121481. },
  121482. enumerable: true,
  121483. configurable: true
  121484. });
  121485. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  121486. /**
  121487. * 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.
  121488. */
  121489. set: function (value) {
  121490. this._circleOfConfusion.depthTexture = value;
  121491. },
  121492. enumerable: true,
  121493. configurable: true
  121494. });
  121495. /**
  121496. * Disposes each of the internal effects for a given camera.
  121497. * @param camera The camera to dispose the effect on.
  121498. */
  121499. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  121500. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121501. this._effects[effectIndex].dispose(camera);
  121502. }
  121503. };
  121504. /**
  121505. * @hidden Internal
  121506. */
  121507. DepthOfFieldEffect.prototype._updateEffects = function () {
  121508. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121509. this._effects[effectIndex].updateEffect();
  121510. }
  121511. };
  121512. /**
  121513. * Internal
  121514. * @returns if all the contained post processes are ready.
  121515. * @hidden
  121516. */
  121517. DepthOfFieldEffect.prototype._isReady = function () {
  121518. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121519. if (!this._effects[effectIndex].isReady()) {
  121520. return false;
  121521. }
  121522. }
  121523. return true;
  121524. };
  121525. return DepthOfFieldEffect;
  121526. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  121527. /***/ }),
  121528. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  121529. /*!*******************************************************!*\
  121530. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  121531. \*******************************************************/
  121532. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  121533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121534. "use strict";
  121535. __webpack_require__.r(__webpack_exports__);
  121536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  121537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  121538. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121539. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121540. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121541. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  121542. /**
  121543. * Options to be set when merging outputs from the default pipeline.
  121544. */
  121545. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  121546. function DepthOfFieldMergePostProcessOptions() {
  121547. }
  121548. return DepthOfFieldMergePostProcessOptions;
  121549. }());
  121550. /**
  121551. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121552. */
  121553. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  121554. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  121555. /**
  121556. * Creates a new instance of DepthOfFieldMergePostProcess
  121557. * @param name The name of the effect.
  121558. * @param originalFromInput Post process which's input will be used for the merge.
  121559. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  121560. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  121561. * @param options The required width/height ratio to downsize to before computing the render pass.
  121562. * @param camera The camera to apply the render pass to.
  121563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121564. * @param engine The engine which the post process will be applied. (default: current engine)
  121565. * @param reusable If the post process can be reused on the same frame. (default: false)
  121566. * @param textureType Type of textures used when performing the post process. (default: 0)
  121567. * @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)
  121568. */
  121569. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121570. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121571. if (blockCompilation === void 0) { blockCompilation = false; }
  121572. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  121573. _this.blurSteps = blurSteps;
  121574. _this.onApplyObservable.add(function (effect) {
  121575. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  121576. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  121577. blurSteps.forEach(function (step, index) {
  121578. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  121579. });
  121580. });
  121581. if (!blockCompilation) {
  121582. _this.updateEffect();
  121583. }
  121584. return _this;
  121585. }
  121586. /**
  121587. * Updates the effect with the current post process compile time values and recompiles the shader.
  121588. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121589. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121590. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121591. * @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
  121592. * @param onCompiled Called when the shader has been compiled.
  121593. * @param onError Called if there is an error when compiling a shader.
  121594. */
  121595. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  121596. if (defines === void 0) { defines = null; }
  121597. if (uniforms === void 0) { uniforms = null; }
  121598. if (samplers === void 0) { samplers = null; }
  121599. if (!defines) {
  121600. defines = "";
  121601. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  121602. }
  121603. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  121604. };
  121605. return DepthOfFieldMergePostProcess;
  121606. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121607. /***/ }),
  121608. /***/ "./PostProcesses/displayPassPostProcess.ts":
  121609. /*!*************************************************!*\
  121610. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  121611. \*************************************************/
  121612. /*! exports provided: DisplayPassPostProcess */
  121613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121614. "use strict";
  121615. __webpack_require__.r(__webpack_exports__);
  121616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  121617. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121618. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121619. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  121620. /**
  121621. * DisplayPassPostProcess which produces an output the same as it's input
  121622. */
  121623. var DisplayPassPostProcess = /** @class */ (function (_super) {
  121624. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  121625. /**
  121626. * Creates the DisplayPassPostProcess
  121627. * @param name The name of the effect.
  121628. * @param options The required width/height ratio to downsize to before computing the render pass.
  121629. * @param camera The camera to apply the render pass to.
  121630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121631. * @param engine The engine which the post process will be applied. (default: current engine)
  121632. * @param reusable If the post process can be reused on the same frame. (default: false)
  121633. */
  121634. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  121635. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  121636. }
  121637. return DisplayPassPostProcess;
  121638. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121639. /***/ }),
  121640. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  121641. /*!*******************************************************!*\
  121642. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  121643. \*******************************************************/
  121644. /*! exports provided: ExtractHighlightsPostProcess */
  121645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121646. "use strict";
  121647. __webpack_require__.r(__webpack_exports__);
  121648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  121649. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121650. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121651. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121652. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121653. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  121654. /**
  121655. * 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.
  121656. */
  121657. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  121658. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  121659. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121660. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121661. if (blockCompilation === void 0) { blockCompilation = false; }
  121662. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  121663. /**
  121664. * The luminance threshold, pixels below this value will be set to black.
  121665. */
  121666. _this.threshold = 0.9;
  121667. /** @hidden */
  121668. _this._exposure = 1;
  121669. /**
  121670. * Post process which has the input texture to be used when performing highlight extraction
  121671. * @hidden
  121672. */
  121673. _this._inputPostProcess = null;
  121674. _this.onApplyObservable.add(function (effect) {
  121675. if (_this._inputPostProcess) {
  121676. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  121677. }
  121678. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  121679. effect.setFloat('exposure', _this._exposure);
  121680. });
  121681. return _this;
  121682. }
  121683. return ExtractHighlightsPostProcess;
  121684. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121685. /***/ }),
  121686. /***/ "./PostProcesses/filterPostProcess.ts":
  121687. /*!********************************************!*\
  121688. !*** ./PostProcesses/filterPostProcess.ts ***!
  121689. \********************************************/
  121690. /*! exports provided: FilterPostProcess */
  121691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121692. "use strict";
  121693. __webpack_require__.r(__webpack_exports__);
  121694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  121695. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121696. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121697. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  121698. /**
  121699. * Applies a kernel filter to the image
  121700. */
  121701. var FilterPostProcess = /** @class */ (function (_super) {
  121702. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  121703. /**
  121704. *
  121705. * @param name The name of the effect.
  121706. * @param kernelMatrix The matrix to be applied to the image
  121707. * @param options The required width/height ratio to downsize to before computing the render pass.
  121708. * @param camera The camera to apply the render pass to.
  121709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121710. * @param engine The engine which the post process will be applied. (default: current engine)
  121711. * @param reusable If the post process can be reused on the same frame. (default: false)
  121712. */
  121713. function FilterPostProcess(name,
  121714. /** The matrix to be applied to the image */
  121715. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  121716. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  121717. _this.kernelMatrix = kernelMatrix;
  121718. _this.onApply = function (effect) {
  121719. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  121720. };
  121721. return _this;
  121722. }
  121723. return FilterPostProcess;
  121724. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121725. /***/ }),
  121726. /***/ "./PostProcesses/fxaaPostProcess.ts":
  121727. /*!******************************************!*\
  121728. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  121729. \******************************************/
  121730. /*! exports provided: FxaaPostProcess */
  121731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121732. "use strict";
  121733. __webpack_require__.r(__webpack_exports__);
  121734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  121735. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121736. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121737. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121738. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121739. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  121740. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  121741. /**
  121742. * Fxaa post process
  121743. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  121744. */
  121745. var FxaaPostProcess = /** @class */ (function (_super) {
  121746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  121747. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  121748. if (camera === void 0) { camera = null; }
  121749. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121750. 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;
  121751. var defines = _this._getDefines();
  121752. _this.updateEffect(defines);
  121753. _this.onApplyObservable.add(function (effect) {
  121754. var texelSize = _this.texelSize;
  121755. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  121756. });
  121757. return _this;
  121758. }
  121759. FxaaPostProcess.prototype._getDefines = function () {
  121760. var engine = this.getEngine();
  121761. if (!engine) {
  121762. return null;
  121763. }
  121764. var glInfo = engine.getGlInfo();
  121765. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  121766. return "#define MALI 1\n";
  121767. }
  121768. return null;
  121769. };
  121770. return FxaaPostProcess;
  121771. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  121772. /***/ }),
  121773. /***/ "./PostProcesses/grainPostProcess.ts":
  121774. /*!*******************************************!*\
  121775. !*** ./PostProcesses/grainPostProcess.ts ***!
  121776. \*******************************************/
  121777. /*! exports provided: GrainPostProcess */
  121778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121779. "use strict";
  121780. __webpack_require__.r(__webpack_exports__);
  121781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  121782. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121783. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121784. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121785. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  121786. /**
  121787. * The GrainPostProcess adds noise to the image at mid luminance levels
  121788. */
  121789. var GrainPostProcess = /** @class */ (function (_super) {
  121790. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  121791. /**
  121792. * Creates a new instance of @see GrainPostProcess
  121793. * @param name The name of the effect.
  121794. * @param options The required width/height ratio to downsize to before computing the render pass.
  121795. * @param camera The camera to apply the render pass to.
  121796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121797. * @param engine The engine which the post process will be applied. (default: current engine)
  121798. * @param reusable If the post process can be reused on the same frame. (default: false)
  121799. * @param textureType Type of textures used when performing the post process. (default: 0)
  121800. * @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)
  121801. */
  121802. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121803. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121804. if (blockCompilation === void 0) { blockCompilation = false; }
  121805. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  121806. /**
  121807. * The intensity of the grain added (default: 30)
  121808. */
  121809. _this.intensity = 30;
  121810. /**
  121811. * If the grain should be randomized on every frame
  121812. */
  121813. _this.animated = false;
  121814. _this.onApplyObservable.add(function (effect) {
  121815. effect.setFloat('intensity', _this.intensity);
  121816. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  121817. });
  121818. return _this;
  121819. }
  121820. return GrainPostProcess;
  121821. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121822. /***/ }),
  121823. /***/ "./PostProcesses/highlightsPostProcess.ts":
  121824. /*!************************************************!*\
  121825. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  121826. \************************************************/
  121827. /*! exports provided: HighlightsPostProcess */
  121828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121829. "use strict";
  121830. __webpack_require__.r(__webpack_exports__);
  121831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  121832. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121833. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121834. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121835. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  121836. /**
  121837. * Extracts highlights from the image
  121838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121839. */
  121840. var HighlightsPostProcess = /** @class */ (function (_super) {
  121841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  121842. /**
  121843. * Extracts highlights from the image
  121844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121845. * @param name The name of the effect.
  121846. * @param options The required width/height ratio to downsize to before computing the render pass.
  121847. * @param camera The camera to apply the render pass to.
  121848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121849. * @param engine The engine which the post process will be applied. (default: current engine)
  121850. * @param reusable If the post process can be reused on the same frame. (default: false)
  121851. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  121852. */
  121853. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  121854. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121855. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  121856. }
  121857. return HighlightsPostProcess;
  121858. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121859. /***/ }),
  121860. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  121861. /*!*****************************************************!*\
  121862. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  121863. \*****************************************************/
  121864. /*! exports provided: ImageProcessingPostProcess */
  121865. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121866. "use strict";
  121867. __webpack_require__.r(__webpack_exports__);
  121868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  121869. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121870. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  121871. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  121872. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121873. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  121874. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121875. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  121876. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  121877. /**
  121878. * ImageProcessingPostProcess
  121879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  121880. */
  121881. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  121882. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  121883. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  121884. if (camera === void 0) { camera = null; }
  121885. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121886. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  121887. _this._fromLinearSpace = true;
  121888. /**
  121889. * Defines cache preventing GC.
  121890. */
  121891. _this._defines = {
  121892. IMAGEPROCESSING: false,
  121893. VIGNETTE: false,
  121894. VIGNETTEBLENDMODEMULTIPLY: false,
  121895. VIGNETTEBLENDMODEOPAQUE: false,
  121896. TONEMAPPING: false,
  121897. TONEMAPPING_ACES: false,
  121898. CONTRAST: false,
  121899. COLORCURVES: false,
  121900. COLORGRADING: false,
  121901. COLORGRADING3D: false,
  121902. FROMLINEARSPACE: false,
  121903. SAMPLER3DGREENDEPTH: false,
  121904. SAMPLER3DBGRMAP: false,
  121905. IMAGEPROCESSINGPOSTPROCESS: false,
  121906. EXPOSURE: false,
  121907. };
  121908. // Setup the configuration as forced by the constructor. This would then not force the
  121909. // scene materials output in linear space and let untouched the default forward pass.
  121910. if (imageProcessingConfiguration) {
  121911. imageProcessingConfiguration.applyByPostProcess = true;
  121912. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  121913. // This will cause the shader to be compiled
  121914. _this.fromLinearSpace = false;
  121915. }
  121916. // Setup the default processing configuration to the scene.
  121917. else {
  121918. _this._attachImageProcessingConfiguration(null, true);
  121919. _this.imageProcessingConfiguration.applyByPostProcess = true;
  121920. }
  121921. _this.onApply = function (effect) {
  121922. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  121923. };
  121924. return _this;
  121925. }
  121926. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  121927. /**
  121928. * Gets the image processing configuration used either in this material.
  121929. */
  121930. get: function () {
  121931. return this._imageProcessingConfiguration;
  121932. },
  121933. /**
  121934. * Sets the Default image processing configuration used either in the this material.
  121935. *
  121936. * If sets to null, the scene one is in use.
  121937. */
  121938. set: function (value) {
  121939. this._attachImageProcessingConfiguration(value);
  121940. },
  121941. enumerable: true,
  121942. configurable: true
  121943. });
  121944. /**
  121945. * Attaches a new image processing configuration to the PBR Material.
  121946. * @param configuration
  121947. */
  121948. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  121949. var _this = this;
  121950. if (doNotBuild === void 0) { doNotBuild = false; }
  121951. if (configuration === this._imageProcessingConfiguration) {
  121952. return;
  121953. }
  121954. // Detaches observer.
  121955. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  121956. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  121957. }
  121958. // Pick the scene configuration if needed.
  121959. if (!configuration) {
  121960. var scene = null;
  121961. var engine = this.getEngine();
  121962. var camera = this.getCamera();
  121963. if (camera) {
  121964. scene = camera.getScene();
  121965. }
  121966. else if (engine && engine.scenes) {
  121967. var scenes = engine.scenes;
  121968. scene = scenes[scenes.length - 1];
  121969. }
  121970. else {
  121971. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  121972. }
  121973. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  121974. }
  121975. else {
  121976. this._imageProcessingConfiguration = configuration;
  121977. }
  121978. // Attaches observer.
  121979. if (this._imageProcessingConfiguration) {
  121980. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  121981. _this._updateParameters();
  121982. });
  121983. }
  121984. // Ensure the effect will be rebuilt.
  121985. if (!doNotBuild) {
  121986. this._updateParameters();
  121987. }
  121988. };
  121989. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  121990. /**
  121991. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  121992. */
  121993. get: function () {
  121994. return this.imageProcessingConfiguration.colorCurves;
  121995. },
  121996. /**
  121997. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  121998. */
  121999. set: function (value) {
  122000. this.imageProcessingConfiguration.colorCurves = value;
  122001. },
  122002. enumerable: true,
  122003. configurable: true
  122004. });
  122005. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  122006. /**
  122007. * Gets wether the color curves effect is enabled.
  122008. */
  122009. get: function () {
  122010. return this.imageProcessingConfiguration.colorCurvesEnabled;
  122011. },
  122012. /**
  122013. * Sets wether the color curves effect is enabled.
  122014. */
  122015. set: function (value) {
  122016. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  122017. },
  122018. enumerable: true,
  122019. configurable: true
  122020. });
  122021. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  122022. /**
  122023. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122024. */
  122025. get: function () {
  122026. return this.imageProcessingConfiguration.colorGradingTexture;
  122027. },
  122028. /**
  122029. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122030. */
  122031. set: function (value) {
  122032. this.imageProcessingConfiguration.colorGradingTexture = value;
  122033. },
  122034. enumerable: true,
  122035. configurable: true
  122036. });
  122037. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  122038. /**
  122039. * Gets wether the color grading effect is enabled.
  122040. */
  122041. get: function () {
  122042. return this.imageProcessingConfiguration.colorGradingEnabled;
  122043. },
  122044. /**
  122045. * Gets wether the color grading effect is enabled.
  122046. */
  122047. set: function (value) {
  122048. this.imageProcessingConfiguration.colorGradingEnabled = value;
  122049. },
  122050. enumerable: true,
  122051. configurable: true
  122052. });
  122053. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  122054. /**
  122055. * Gets exposure used in the effect.
  122056. */
  122057. get: function () {
  122058. return this.imageProcessingConfiguration.exposure;
  122059. },
  122060. /**
  122061. * Sets exposure used in the effect.
  122062. */
  122063. set: function (value) {
  122064. this.imageProcessingConfiguration.exposure = value;
  122065. },
  122066. enumerable: true,
  122067. configurable: true
  122068. });
  122069. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  122070. /**
  122071. * Gets wether tonemapping is enabled or not.
  122072. */
  122073. get: function () {
  122074. return this._imageProcessingConfiguration.toneMappingEnabled;
  122075. },
  122076. /**
  122077. * Sets wether tonemapping is enabled or not
  122078. */
  122079. set: function (value) {
  122080. this._imageProcessingConfiguration.toneMappingEnabled = value;
  122081. },
  122082. enumerable: true,
  122083. configurable: true
  122084. });
  122085. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  122086. /**
  122087. * Gets the type of tone mapping effect.
  122088. */
  122089. get: function () {
  122090. return this._imageProcessingConfiguration.toneMappingType;
  122091. },
  122092. /**
  122093. * Sets the type of tone mapping effect.
  122094. */
  122095. set: function (value) {
  122096. this._imageProcessingConfiguration.toneMappingType = value;
  122097. },
  122098. enumerable: true,
  122099. configurable: true
  122100. });
  122101. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  122102. /**
  122103. * Gets contrast used in the effect.
  122104. */
  122105. get: function () {
  122106. return this.imageProcessingConfiguration.contrast;
  122107. },
  122108. /**
  122109. * Sets contrast used in the effect.
  122110. */
  122111. set: function (value) {
  122112. this.imageProcessingConfiguration.contrast = value;
  122113. },
  122114. enumerable: true,
  122115. configurable: true
  122116. });
  122117. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  122118. /**
  122119. * Gets Vignette stretch size.
  122120. */
  122121. get: function () {
  122122. return this.imageProcessingConfiguration.vignetteStretch;
  122123. },
  122124. /**
  122125. * Sets Vignette stretch size.
  122126. */
  122127. set: function (value) {
  122128. this.imageProcessingConfiguration.vignetteStretch = value;
  122129. },
  122130. enumerable: true,
  122131. configurable: true
  122132. });
  122133. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  122134. /**
  122135. * Gets Vignette centre X Offset.
  122136. */
  122137. get: function () {
  122138. return this.imageProcessingConfiguration.vignetteCentreX;
  122139. },
  122140. /**
  122141. * Sets Vignette centre X Offset.
  122142. */
  122143. set: function (value) {
  122144. this.imageProcessingConfiguration.vignetteCentreX = value;
  122145. },
  122146. enumerable: true,
  122147. configurable: true
  122148. });
  122149. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  122150. /**
  122151. * Gets Vignette centre Y Offset.
  122152. */
  122153. get: function () {
  122154. return this.imageProcessingConfiguration.vignetteCentreY;
  122155. },
  122156. /**
  122157. * Sets Vignette centre Y Offset.
  122158. */
  122159. set: function (value) {
  122160. this.imageProcessingConfiguration.vignetteCentreY = value;
  122161. },
  122162. enumerable: true,
  122163. configurable: true
  122164. });
  122165. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  122166. /**
  122167. * Gets Vignette weight or intensity of the vignette effect.
  122168. */
  122169. get: function () {
  122170. return this.imageProcessingConfiguration.vignetteWeight;
  122171. },
  122172. /**
  122173. * Sets Vignette weight or intensity of the vignette effect.
  122174. */
  122175. set: function (value) {
  122176. this.imageProcessingConfiguration.vignetteWeight = value;
  122177. },
  122178. enumerable: true,
  122179. configurable: true
  122180. });
  122181. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  122182. /**
  122183. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122184. * if vignetteEnabled is set to true.
  122185. */
  122186. get: function () {
  122187. return this.imageProcessingConfiguration.vignetteColor;
  122188. },
  122189. /**
  122190. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122191. * if vignetteEnabled is set to true.
  122192. */
  122193. set: function (value) {
  122194. this.imageProcessingConfiguration.vignetteColor = value;
  122195. },
  122196. enumerable: true,
  122197. configurable: true
  122198. });
  122199. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  122200. /**
  122201. * Gets Camera field of view used by the Vignette effect.
  122202. */
  122203. get: function () {
  122204. return this.imageProcessingConfiguration.vignetteCameraFov;
  122205. },
  122206. /**
  122207. * Sets Camera field of view used by the Vignette effect.
  122208. */
  122209. set: function (value) {
  122210. this.imageProcessingConfiguration.vignetteCameraFov = value;
  122211. },
  122212. enumerable: true,
  122213. configurable: true
  122214. });
  122215. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  122216. /**
  122217. * Gets the vignette blend mode allowing different kind of effect.
  122218. */
  122219. get: function () {
  122220. return this.imageProcessingConfiguration.vignetteBlendMode;
  122221. },
  122222. /**
  122223. * Sets the vignette blend mode allowing different kind of effect.
  122224. */
  122225. set: function (value) {
  122226. this.imageProcessingConfiguration.vignetteBlendMode = value;
  122227. },
  122228. enumerable: true,
  122229. configurable: true
  122230. });
  122231. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  122232. /**
  122233. * Gets wether the vignette effect is enabled.
  122234. */
  122235. get: function () {
  122236. return this.imageProcessingConfiguration.vignetteEnabled;
  122237. },
  122238. /**
  122239. * Sets wether the vignette effect is enabled.
  122240. */
  122241. set: function (value) {
  122242. this.imageProcessingConfiguration.vignetteEnabled = value;
  122243. },
  122244. enumerable: true,
  122245. configurable: true
  122246. });
  122247. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  122248. /**
  122249. * Gets wether the input of the processing is in Gamma or Linear Space.
  122250. */
  122251. get: function () {
  122252. return this._fromLinearSpace;
  122253. },
  122254. /**
  122255. * Sets wether the input of the processing is in Gamma or Linear Space.
  122256. */
  122257. set: function (value) {
  122258. if (this._fromLinearSpace === value) {
  122259. return;
  122260. }
  122261. this._fromLinearSpace = value;
  122262. this._updateParameters();
  122263. },
  122264. enumerable: true,
  122265. configurable: true
  122266. });
  122267. /**
  122268. * "ImageProcessingPostProcess"
  122269. * @returns "ImageProcessingPostProcess"
  122270. */
  122271. ImageProcessingPostProcess.prototype.getClassName = function () {
  122272. return "ImageProcessingPostProcess";
  122273. };
  122274. ImageProcessingPostProcess.prototype._updateParameters = function () {
  122275. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  122276. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  122277. var defines = "";
  122278. for (var define in this._defines) {
  122279. if (this._defines[define]) {
  122280. defines += "#define " + define + ";\r\n";
  122281. }
  122282. }
  122283. var samplers = ["textureSampler"];
  122284. var uniforms = ["scale"];
  122285. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  122286. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  122287. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  122288. }
  122289. this.updateEffect(defines, uniforms, samplers);
  122290. };
  122291. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  122292. _super.prototype.dispose.call(this, camera);
  122293. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  122294. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  122295. }
  122296. if (this._imageProcessingConfiguration) {
  122297. this.imageProcessingConfiguration.applyByPostProcess = false;
  122298. }
  122299. };
  122300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122302. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  122303. return ImageProcessingPostProcess;
  122304. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  122305. /***/ }),
  122306. /***/ "./PostProcesses/index.ts":
  122307. /*!********************************!*\
  122308. !*** ./PostProcesses/index.ts ***!
  122309. \********************************/
  122310. /*! 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 */
  122311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122312. "use strict";
  122313. __webpack_require__.r(__webpack_exports__);
  122314. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  122315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  122316. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  122317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  122318. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  122319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  122320. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  122321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  122322. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  122323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  122324. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  122325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  122326. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  122327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  122328. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  122329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  122330. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  122331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  122332. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  122333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  122334. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  122335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  122336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  122337. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  122338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  122339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  122340. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  122341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  122342. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  122343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  122344. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  122345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  122346. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  122347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  122348. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  122349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  122350. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  122351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  122352. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  122353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  122354. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  122355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  122356. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  122357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  122358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  122359. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  122361. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  122362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  122363. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  122364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  122365. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  122366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  122367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  122368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  122369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  122370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  122371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  122372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  122373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  122374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  122375. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  122376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  122377. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  122378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  122379. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  122380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  122381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  122382. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  122383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  122384. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  122385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  122386. /***/ }),
  122387. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  122388. /*!************************************************!*\
  122389. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  122390. \************************************************/
  122391. /*! exports provided: MotionBlurPostProcess */
  122392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122393. "use strict";
  122394. __webpack_require__.r(__webpack_exports__);
  122395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  122396. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122397. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  122398. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122399. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122400. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122401. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  122402. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  122403. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  122404. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  122405. /**
  122406. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  122407. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  122408. * As an example, all you have to do is to create the post-process:
  122409. * var mb = new BABYLON.MotionBlurPostProcess(
  122410. * 'mb', // The name of the effect.
  122411. * scene, // The scene containing the objects to blur according to their velocity.
  122412. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  122413. * camera // The camera to apply the render pass to.
  122414. * );
  122415. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  122416. */
  122417. var MotionBlurPostProcess = /** @class */ (function (_super) {
  122418. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  122419. /**
  122420. * Creates a new instance MotionBlurPostProcess
  122421. * @param name The name of the effect.
  122422. * @param scene The scene containing the objects to blur according to their velocity.
  122423. * @param options The required width/height ratio to downsize to before computing the render pass.
  122424. * @param camera The camera to apply the render pass to.
  122425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122426. * @param engine The engine which the post process will be applied. (default: current engine)
  122427. * @param reusable If the post process can be reused on the same frame. (default: false)
  122428. * @param textureType Type of textures used when performing the post process. (default: 0)
  122429. * @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)
  122430. */
  122431. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122432. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122433. if (blockCompilation === void 0) { blockCompilation = false; }
  122434. 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;
  122435. /**
  122436. * Defines how much the image is blurred by the movement. Default value is equal to 1
  122437. */
  122438. _this.motionStrength = 1;
  122439. _this._motionBlurSamples = 32;
  122440. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  122441. if (!_this._geometryBufferRenderer) {
  122442. // Geometry buffer renderer is not supported. So, work as a passthrough.
  122443. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  122444. _this.updateEffect();
  122445. }
  122446. else {
  122447. // Geometry buffer renderer is supported.
  122448. _this._geometryBufferRenderer.enableVelocity = true;
  122449. _this.onApply = function (effect) {
  122450. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  122451. effect.setFloat("motionScale", scene.getAnimationRatio());
  122452. effect.setFloat("motionStrength", _this.motionStrength);
  122453. if (_this._geometryBufferRenderer) {
  122454. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  122455. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  122456. }
  122457. };
  122458. }
  122459. return _this;
  122460. }
  122461. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  122462. /**
  122463. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  122464. */
  122465. get: function () {
  122466. return this._motionBlurSamples;
  122467. },
  122468. /**
  122469. * Sets the number of iterations to be used for motion blur quality
  122470. */
  122471. set: function (samples) {
  122472. this._motionBlurSamples = samples;
  122473. if (this._geometryBufferRenderer) {
  122474. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  122475. }
  122476. },
  122477. enumerable: true,
  122478. configurable: true
  122479. });
  122480. /**
  122481. * Disposes the post process.
  122482. * @param camera The camera to dispose the post process on.
  122483. */
  122484. MotionBlurPostProcess.prototype.dispose = function (camera) {
  122485. if (this._geometryBufferRenderer) {
  122486. // Clear previous transformation matrices dictionary used to compute objects velocities
  122487. this._geometryBufferRenderer._previousTransformationMatrices = {};
  122488. }
  122489. _super.prototype.dispose.call(this, camera);
  122490. };
  122491. return MotionBlurPostProcess;
  122492. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  122493. /***/ }),
  122494. /***/ "./PostProcesses/passPostProcess.ts":
  122495. /*!******************************************!*\
  122496. !*** ./PostProcesses/passPostProcess.ts ***!
  122497. \******************************************/
  122498. /*! exports provided: PassPostProcess, PassCubePostProcess */
  122499. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122500. "use strict";
  122501. __webpack_require__.r(__webpack_exports__);
  122502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  122503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  122504. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122505. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122506. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122507. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  122508. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  122509. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  122510. /**
  122511. * PassPostProcess which produces an output the same as it's input
  122512. */
  122513. var PassPostProcess = /** @class */ (function (_super) {
  122514. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  122515. /**
  122516. * Creates the PassPostProcess
  122517. * @param name The name of the effect.
  122518. * @param options The required width/height ratio to downsize to before computing the render pass.
  122519. * @param camera The camera to apply the render pass to.
  122520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122521. * @param engine The engine which the post process will be applied. (default: current engine)
  122522. * @param reusable If the post process can be reused on the same frame. (default: false)
  122523. * @param textureType The type of texture to be used when performing the post processing.
  122524. * @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)
  122525. */
  122526. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122527. if (camera === void 0) { camera = null; }
  122528. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122529. if (blockCompilation === void 0) { blockCompilation = false; }
  122530. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  122531. }
  122532. return PassPostProcess;
  122533. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122534. /**
  122535. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122536. */
  122537. var PassCubePostProcess = /** @class */ (function (_super) {
  122538. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  122539. /**
  122540. * Creates the PassCubePostProcess
  122541. * @param name The name of the effect.
  122542. * @param options The required width/height ratio to downsize to before computing the render pass.
  122543. * @param camera The camera to apply the render pass to.
  122544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122545. * @param engine The engine which the post process will be applied. (default: current engine)
  122546. * @param reusable If the post process can be reused on the same frame. (default: false)
  122547. * @param textureType The type of texture to be used when performing the post processing.
  122548. * @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)
  122549. */
  122550. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122551. if (camera === void 0) { camera = null; }
  122552. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122553. if (blockCompilation === void 0) { blockCompilation = false; }
  122554. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  122555. _this._face = 0;
  122556. return _this;
  122557. }
  122558. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  122559. /**
  122560. * Gets or sets the cube face to display.
  122561. * * 0 is +X
  122562. * * 1 is -X
  122563. * * 2 is +Y
  122564. * * 3 is -Y
  122565. * * 4 is +Z
  122566. * * 5 is -Z
  122567. */
  122568. get: function () {
  122569. return this._face;
  122570. },
  122571. set: function (value) {
  122572. if (value < 0 || value > 5) {
  122573. return;
  122574. }
  122575. this._face = value;
  122576. switch (this._face) {
  122577. case 0:
  122578. this.updateEffect("#define POSITIVEX");
  122579. break;
  122580. case 1:
  122581. this.updateEffect("#define NEGATIVEX");
  122582. break;
  122583. case 2:
  122584. this.updateEffect("#define POSITIVEY");
  122585. break;
  122586. case 3:
  122587. this.updateEffect("#define NEGATIVEY");
  122588. break;
  122589. case 4:
  122590. this.updateEffect("#define POSITIVEZ");
  122591. break;
  122592. case 5:
  122593. this.updateEffect("#define NEGATIVEZ");
  122594. break;
  122595. }
  122596. },
  122597. enumerable: true,
  122598. configurable: true
  122599. });
  122600. return PassCubePostProcess;
  122601. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122602. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  122603. 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);
  122604. };
  122605. /***/ }),
  122606. /***/ "./PostProcesses/postProcess.ts":
  122607. /*!**************************************!*\
  122608. !*** ./PostProcesses/postProcess.ts ***!
  122609. \**************************************/
  122610. /*! exports provided: PostProcess */
  122611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122612. "use strict";
  122613. __webpack_require__.r(__webpack_exports__);
  122614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  122615. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  122616. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  122617. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  122618. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122619. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122620. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  122621. /**
  122622. * PostProcess can be used to apply a shader to a texture after it has been rendered
  122623. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122624. */
  122625. var PostProcess = /** @class */ (function () {
  122626. /**
  122627. * Creates a new instance PostProcess
  122628. * @param name The name of the PostProcess.
  122629. * @param fragmentUrl The url of the fragment shader to be used.
  122630. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  122631. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  122632. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  122633. * @param camera The camera to apply the render pass to.
  122634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122635. * @param engine The engine which the post process will be applied. (default: current engine)
  122636. * @param reusable If the post process can be reused on the same frame. (default: false)
  122637. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  122638. * @param textureType Type of textures used when performing the post process. (default: 0)
  122639. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  122640. * @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
  122641. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  122642. */
  122643. function PostProcess(
  122644. /** Name of the PostProcess. */
  122645. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  122646. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  122647. if (defines === void 0) { defines = null; }
  122648. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122649. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  122650. if (blockCompilation === void 0) { blockCompilation = false; }
  122651. this.name = name;
  122652. /**
  122653. * Width of the texture to apply the post process on
  122654. */
  122655. this.width = -1;
  122656. /**
  122657. * Height of the texture to apply the post process on
  122658. */
  122659. this.height = -1;
  122660. /**
  122661. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  122662. * @hidden
  122663. */
  122664. this._outputTexture = null;
  122665. /**
  122666. * If the buffer needs to be cleared before applying the post process. (default: true)
  122667. * Should be set to false if shader will overwrite all previous pixels.
  122668. */
  122669. this.autoClear = true;
  122670. /**
  122671. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  122672. */
  122673. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  122674. /**
  122675. * Animations to be used for the post processing
  122676. */
  122677. this.animations = new Array();
  122678. /**
  122679. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  122680. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  122681. */
  122682. this.enablePixelPerfectMode = false;
  122683. /**
  122684. * Force the postprocess to be applied without taking in account viewport
  122685. */
  122686. this.forceFullscreenViewport = true;
  122687. /**
  122688. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  122689. *
  122690. * | Value | Type | Description |
  122691. * | ----- | ----------------------------------- | ----------- |
  122692. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  122693. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  122694. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  122695. *
  122696. */
  122697. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  122698. /**
  122699. * Force textures to be a power of two (default: false)
  122700. */
  122701. this.alwaysForcePOT = false;
  122702. this._samples = 1;
  122703. /**
  122704. * Modify the scale of the post process to be the same as the viewport (default: false)
  122705. */
  122706. this.adaptScaleToCurrentViewport = false;
  122707. this._reusable = false;
  122708. /**
  122709. * Smart array of input and output textures for the post process.
  122710. * @hidden
  122711. */
  122712. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  122713. /**
  122714. * The index in _textures that corresponds to the output texture.
  122715. * @hidden
  122716. */
  122717. this._currentRenderTextureInd = 0;
  122718. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  122719. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  122720. // Events
  122721. /**
  122722. * An event triggered when the postprocess is activated.
  122723. */
  122724. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  122725. /**
  122726. * An event triggered when the postprocess changes its size.
  122727. */
  122728. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  122729. /**
  122730. * An event triggered when the postprocess applies its effect.
  122731. */
  122732. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  122733. /**
  122734. * An event triggered before rendering the postprocess
  122735. */
  122736. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  122737. /**
  122738. * An event triggered after rendering the postprocess
  122739. */
  122740. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  122741. if (camera != null) {
  122742. this._camera = camera;
  122743. this._scene = camera.getScene();
  122744. camera.attachPostProcess(this);
  122745. this._engine = this._scene.getEngine();
  122746. this._scene.postProcesses.push(this);
  122747. this.uniqueId = this._scene.getUniqueId();
  122748. }
  122749. else if (engine) {
  122750. this._engine = engine;
  122751. this._engine.postProcesses.push(this);
  122752. }
  122753. this._options = options;
  122754. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  122755. this._reusable = reusable || false;
  122756. this._textureType = textureType;
  122757. this._samplers = samplers || [];
  122758. this._samplers.push("textureSampler");
  122759. this._fragmentUrl = fragmentUrl;
  122760. this._vertexUrl = vertexUrl;
  122761. this._parameters = parameters || [];
  122762. this._parameters.push("scale");
  122763. this._indexParameters = indexParameters;
  122764. if (!blockCompilation) {
  122765. this.updateEffect(defines);
  122766. }
  122767. }
  122768. Object.defineProperty(PostProcess.prototype, "samples", {
  122769. /**
  122770. * Number of sample textures (default: 1)
  122771. */
  122772. get: function () {
  122773. return this._samples;
  122774. },
  122775. set: function (n) {
  122776. var _this = this;
  122777. this._samples = n;
  122778. this._textures.forEach(function (texture) {
  122779. if (texture.samples !== _this._samples) {
  122780. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  122781. }
  122782. });
  122783. },
  122784. enumerable: true,
  122785. configurable: true
  122786. });
  122787. /**
  122788. * Returns the fragment url or shader name used in the post process.
  122789. * @returns the fragment url or name in the shader store.
  122790. */
  122791. PostProcess.prototype.getEffectName = function () {
  122792. return this._fragmentUrl;
  122793. };
  122794. Object.defineProperty(PostProcess.prototype, "onActivate", {
  122795. /**
  122796. * A function that is added to the onActivateObservable
  122797. */
  122798. set: function (callback) {
  122799. if (this._onActivateObserver) {
  122800. this.onActivateObservable.remove(this._onActivateObserver);
  122801. }
  122802. if (callback) {
  122803. this._onActivateObserver = this.onActivateObservable.add(callback);
  122804. }
  122805. },
  122806. enumerable: true,
  122807. configurable: true
  122808. });
  122809. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  122810. /**
  122811. * A function that is added to the onSizeChangedObservable
  122812. */
  122813. set: function (callback) {
  122814. if (this._onSizeChangedObserver) {
  122815. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  122816. }
  122817. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  122818. },
  122819. enumerable: true,
  122820. configurable: true
  122821. });
  122822. Object.defineProperty(PostProcess.prototype, "onApply", {
  122823. /**
  122824. * A function that is added to the onApplyObservable
  122825. */
  122826. set: function (callback) {
  122827. if (this._onApplyObserver) {
  122828. this.onApplyObservable.remove(this._onApplyObserver);
  122829. }
  122830. this._onApplyObserver = this.onApplyObservable.add(callback);
  122831. },
  122832. enumerable: true,
  122833. configurable: true
  122834. });
  122835. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  122836. /**
  122837. * A function that is added to the onBeforeRenderObservable
  122838. */
  122839. set: function (callback) {
  122840. if (this._onBeforeRenderObserver) {
  122841. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  122842. }
  122843. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  122844. },
  122845. enumerable: true,
  122846. configurable: true
  122847. });
  122848. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  122849. /**
  122850. * A function that is added to the onAfterRenderObservable
  122851. */
  122852. set: function (callback) {
  122853. if (this._onAfterRenderObserver) {
  122854. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  122855. }
  122856. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  122857. },
  122858. enumerable: true,
  122859. configurable: true
  122860. });
  122861. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  122862. /**
  122863. * 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
  122864. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  122865. */
  122866. get: function () {
  122867. return this._textures.data[this._currentRenderTextureInd];
  122868. },
  122869. set: function (value) {
  122870. this._forcedOutputTexture = value;
  122871. },
  122872. enumerable: true,
  122873. configurable: true
  122874. });
  122875. /**
  122876. * Gets the camera which post process is applied to.
  122877. * @returns The camera the post process is applied to.
  122878. */
  122879. PostProcess.prototype.getCamera = function () {
  122880. return this._camera;
  122881. };
  122882. Object.defineProperty(PostProcess.prototype, "texelSize", {
  122883. /**
  122884. * Gets the texel size of the postprocess.
  122885. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  122886. */
  122887. get: function () {
  122888. if (this._shareOutputWithPostProcess) {
  122889. return this._shareOutputWithPostProcess.texelSize;
  122890. }
  122891. if (this._forcedOutputTexture) {
  122892. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  122893. }
  122894. return this._texelSize;
  122895. },
  122896. enumerable: true,
  122897. configurable: true
  122898. });
  122899. /**
  122900. * Gets a string idenfifying the name of the class
  122901. * @returns "PostProcess" string
  122902. */
  122903. PostProcess.prototype.getClassName = function () {
  122904. return "PostProcess";
  122905. };
  122906. /**
  122907. * Gets the engine which this post process belongs to.
  122908. * @returns The engine the post process was enabled with.
  122909. */
  122910. PostProcess.prototype.getEngine = function () {
  122911. return this._engine;
  122912. };
  122913. /**
  122914. * The effect that is created when initializing the post process.
  122915. * @returns The created effect corrisponding the the postprocess.
  122916. */
  122917. PostProcess.prototype.getEffect = function () {
  122918. return this._effect;
  122919. };
  122920. /**
  122921. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  122922. * @param postProcess The post process to share the output with.
  122923. * @returns This post process.
  122924. */
  122925. PostProcess.prototype.shareOutputWith = function (postProcess) {
  122926. this._disposeTextures();
  122927. this._shareOutputWithPostProcess = postProcess;
  122928. return this;
  122929. };
  122930. /**
  122931. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  122932. * This should be called if the post process that shares output with this post process is disabled/disposed.
  122933. */
  122934. PostProcess.prototype.useOwnOutput = function () {
  122935. if (this._textures.length == 0) {
  122936. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  122937. }
  122938. this._shareOutputWithPostProcess = null;
  122939. };
  122940. /**
  122941. * Updates the effect with the current post process compile time values and recompiles the shader.
  122942. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122943. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122944. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122945. * @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
  122946. * @param onCompiled Called when the shader has been compiled.
  122947. * @param onError Called if there is an error when compiling a shader.
  122948. */
  122949. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  122950. if (defines === void 0) { defines = null; }
  122951. if (uniforms === void 0) { uniforms = null; }
  122952. if (samplers === void 0) { samplers = null; }
  122953. 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);
  122954. };
  122955. /**
  122956. * The post process is reusable if it can be used multiple times within one frame.
  122957. * @returns If the post process is reusable
  122958. */
  122959. PostProcess.prototype.isReusable = function () {
  122960. return this._reusable;
  122961. };
  122962. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  122963. PostProcess.prototype.markTextureDirty = function () {
  122964. this.width = -1;
  122965. };
  122966. /**
  122967. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  122968. * 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.
  122969. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  122970. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  122971. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  122972. * @returns The target texture that was bound to be written to.
  122973. */
  122974. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  122975. var _this = this;
  122976. if (sourceTexture === void 0) { sourceTexture = null; }
  122977. camera = camera || this._camera;
  122978. var scene = camera.getScene();
  122979. var engine = scene.getEngine();
  122980. var maxSize = engine.getCaps().maxTextureSize;
  122981. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  122982. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  122983. // 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
  122984. var webVRCamera = camera.parent;
  122985. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  122986. requiredWidth /= 2;
  122987. }
  122988. var desiredWidth = (this._options.width || requiredWidth);
  122989. var desiredHeight = this._options.height || requiredHeight;
  122990. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  122991. if (this.adaptScaleToCurrentViewport) {
  122992. var currentViewport = engine.currentViewport;
  122993. if (currentViewport) {
  122994. desiredWidth *= currentViewport.width;
  122995. desiredHeight *= currentViewport.height;
  122996. }
  122997. }
  122998. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  122999. if (!this._options.width) {
  123000. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  123001. }
  123002. if (!this._options.height) {
  123003. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  123004. }
  123005. }
  123006. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  123007. if (this._textures.length > 0) {
  123008. for (var i = 0; i < this._textures.length; i++) {
  123009. this._engine._releaseTexture(this._textures.data[i]);
  123010. }
  123011. this._textures.reset();
  123012. }
  123013. this.width = desiredWidth;
  123014. this.height = desiredHeight;
  123015. var textureSize = { width: this.width, height: this.height };
  123016. var textureOptions = {
  123017. generateMipMaps: false,
  123018. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  123019. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  123020. samplingMode: this.renderTargetSamplingMode,
  123021. type: this._textureType
  123022. };
  123023. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  123024. if (this._reusable) {
  123025. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  123026. }
  123027. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  123028. this.onSizeChangedObservable.notifyObservers(this);
  123029. }
  123030. this._textures.forEach(function (texture) {
  123031. if (texture.samples !== _this.samples) {
  123032. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  123033. }
  123034. });
  123035. }
  123036. var target;
  123037. if (this._shareOutputWithPostProcess) {
  123038. target = this._shareOutputWithPostProcess.inputTexture;
  123039. }
  123040. else if (this._forcedOutputTexture) {
  123041. target = this._forcedOutputTexture;
  123042. this.width = this._forcedOutputTexture.width;
  123043. this.height = this._forcedOutputTexture.height;
  123044. }
  123045. else {
  123046. target = this.inputTexture;
  123047. }
  123048. // Bind the input of this post process to be used as the output of the previous post process.
  123049. if (this.enablePixelPerfectMode) {
  123050. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  123051. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  123052. }
  123053. else {
  123054. this._scaleRatio.copyFromFloats(1, 1);
  123055. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  123056. }
  123057. this.onActivateObservable.notifyObservers(camera);
  123058. // Clear
  123059. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  123060. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  123061. }
  123062. if (this._reusable) {
  123063. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  123064. }
  123065. return target;
  123066. };
  123067. Object.defineProperty(PostProcess.prototype, "isSupported", {
  123068. /**
  123069. * If the post process is supported.
  123070. */
  123071. get: function () {
  123072. return this._effect.isSupported;
  123073. },
  123074. enumerable: true,
  123075. configurable: true
  123076. });
  123077. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  123078. /**
  123079. * The aspect ratio of the output texture.
  123080. */
  123081. get: function () {
  123082. if (this._shareOutputWithPostProcess) {
  123083. return this._shareOutputWithPostProcess.aspectRatio;
  123084. }
  123085. if (this._forcedOutputTexture) {
  123086. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  123087. }
  123088. return this.width / this.height;
  123089. },
  123090. enumerable: true,
  123091. configurable: true
  123092. });
  123093. /**
  123094. * Get a value indicating if the post-process is ready to be used
  123095. * @returns true if the post-process is ready (shader is compiled)
  123096. */
  123097. PostProcess.prototype.isReady = function () {
  123098. return this._effect && this._effect.isReady();
  123099. };
  123100. /**
  123101. * Binds all textures and uniforms to the shader, this will be run on every pass.
  123102. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  123103. */
  123104. PostProcess.prototype.apply = function () {
  123105. // Check
  123106. if (!this._effect || !this._effect.isReady()) {
  123107. return null;
  123108. }
  123109. // States
  123110. this._engine.enableEffect(this._effect);
  123111. this._engine.setState(false);
  123112. this._engine.setDepthBuffer(false);
  123113. this._engine.setDepthWrite(false);
  123114. // Alpha
  123115. this._engine.setAlphaMode(this.alphaMode);
  123116. if (this.alphaConstants) {
  123117. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  123118. }
  123119. // Bind the output texture of the preivous post process as the input to this post process.
  123120. var source;
  123121. if (this._shareOutputWithPostProcess) {
  123122. source = this._shareOutputWithPostProcess.inputTexture;
  123123. }
  123124. else if (this._forcedOutputTexture) {
  123125. source = this._forcedOutputTexture;
  123126. }
  123127. else {
  123128. source = this.inputTexture;
  123129. }
  123130. this._effect._bindTexture("textureSampler", source);
  123131. // Parameters
  123132. this._effect.setVector2("scale", this._scaleRatio);
  123133. this.onApplyObservable.notifyObservers(this._effect);
  123134. return this._effect;
  123135. };
  123136. PostProcess.prototype._disposeTextures = function () {
  123137. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  123138. return;
  123139. }
  123140. if (this._textures.length > 0) {
  123141. for (var i = 0; i < this._textures.length; i++) {
  123142. this._engine._releaseTexture(this._textures.data[i]);
  123143. }
  123144. }
  123145. this._textures.dispose();
  123146. };
  123147. /**
  123148. * Disposes the post process.
  123149. * @param camera The camera to dispose the post process on.
  123150. */
  123151. PostProcess.prototype.dispose = function (camera) {
  123152. camera = camera || this._camera;
  123153. this._disposeTextures();
  123154. if (this._scene) {
  123155. var index_1 = this._scene.postProcesses.indexOf(this);
  123156. if (index_1 !== -1) {
  123157. this._scene.postProcesses.splice(index_1, 1);
  123158. }
  123159. }
  123160. else {
  123161. var index_2 = this._engine.postProcesses.indexOf(this);
  123162. if (index_2 !== -1) {
  123163. this._engine.postProcesses.splice(index_2, 1);
  123164. }
  123165. }
  123166. if (!camera) {
  123167. return;
  123168. }
  123169. camera.detachPostProcess(this);
  123170. var index = camera._postProcesses.indexOf(this);
  123171. if (index === 0 && camera._postProcesses.length > 0) {
  123172. var firstPostProcess = this._camera._getFirstPostProcess();
  123173. if (firstPostProcess) {
  123174. firstPostProcess.markTextureDirty();
  123175. }
  123176. }
  123177. this.onActivateObservable.clear();
  123178. this.onAfterRenderObservable.clear();
  123179. this.onApplyObservable.clear();
  123180. this.onBeforeRenderObservable.clear();
  123181. this.onSizeChangedObservable.clear();
  123182. };
  123183. return PostProcess;
  123184. }());
  123185. /***/ }),
  123186. /***/ "./PostProcesses/postProcessManager.ts":
  123187. /*!*********************************************!*\
  123188. !*** ./PostProcesses/postProcessManager.ts ***!
  123189. \*********************************************/
  123190. /*! exports provided: PostProcessManager */
  123191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123192. "use strict";
  123193. __webpack_require__.r(__webpack_exports__);
  123194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  123195. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  123196. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  123197. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123198. /**
  123199. * PostProcessManager is used to manage one or more post processes or post process pipelines
  123200. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123201. */
  123202. var PostProcessManager = /** @class */ (function () {
  123203. /**
  123204. * Creates a new instance PostProcess
  123205. * @param scene The scene that the post process is associated with.
  123206. */
  123207. function PostProcessManager(scene) {
  123208. this._vertexBuffers = {};
  123209. this._scene = scene;
  123210. }
  123211. PostProcessManager.prototype._prepareBuffers = function () {
  123212. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  123213. return;
  123214. }
  123215. // VBO
  123216. var vertices = [];
  123217. vertices.push(1, 1);
  123218. vertices.push(-1, 1);
  123219. vertices.push(-1, -1);
  123220. vertices.push(1, -1);
  123221. 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);
  123222. this._buildIndexBuffer();
  123223. };
  123224. PostProcessManager.prototype._buildIndexBuffer = function () {
  123225. // Indices
  123226. var indices = [];
  123227. indices.push(0);
  123228. indices.push(1);
  123229. indices.push(2);
  123230. indices.push(0);
  123231. indices.push(2);
  123232. indices.push(3);
  123233. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  123234. };
  123235. /**
  123236. * Rebuilds the vertex buffers of the manager.
  123237. * @hidden
  123238. */
  123239. PostProcessManager.prototype._rebuild = function () {
  123240. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  123241. if (!vb) {
  123242. return;
  123243. }
  123244. vb._rebuild();
  123245. this._buildIndexBuffer();
  123246. };
  123247. // Methods
  123248. /**
  123249. * Prepares a frame to be run through a post process.
  123250. * @param sourceTexture The input texture to the post procesess. (default: null)
  123251. * @param postProcesses An array of post processes to be run. (default: null)
  123252. * @returns True if the post processes were able to be run.
  123253. * @hidden
  123254. */
  123255. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  123256. if (sourceTexture === void 0) { sourceTexture = null; }
  123257. if (postProcesses === void 0) { postProcesses = null; }
  123258. var camera = this._scene.activeCamera;
  123259. if (!camera) {
  123260. return false;
  123261. }
  123262. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  123263. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  123264. return false;
  123265. }
  123266. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  123267. return true;
  123268. };
  123269. /**
  123270. * Manually render a set of post processes to a texture.
  123271. * @param postProcesses An array of post processes to be run.
  123272. * @param targetTexture The target texture to render to.
  123273. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  123274. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  123275. * @param lodLevel defines which lod of the texture to render to
  123276. */
  123277. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  123278. if (targetTexture === void 0) { targetTexture = null; }
  123279. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  123280. if (faceIndex === void 0) { faceIndex = 0; }
  123281. if (lodLevel === void 0) { lodLevel = 0; }
  123282. var engine = this._scene.getEngine();
  123283. for (var index = 0; index < postProcesses.length; index++) {
  123284. if (index < postProcesses.length - 1) {
  123285. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  123286. }
  123287. else {
  123288. if (targetTexture) {
  123289. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  123290. }
  123291. else {
  123292. engine.restoreDefaultFramebuffer();
  123293. }
  123294. }
  123295. var pp = postProcesses[index];
  123296. var effect = pp.apply();
  123297. if (effect) {
  123298. pp.onBeforeRenderObservable.notifyObservers(effect);
  123299. // VBOs
  123300. this._prepareBuffers();
  123301. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  123302. // Draw order
  123303. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  123304. pp.onAfterRenderObservable.notifyObservers(effect);
  123305. }
  123306. }
  123307. // Restore depth buffer
  123308. engine.setDepthBuffer(true);
  123309. engine.setDepthWrite(true);
  123310. };
  123311. /**
  123312. * Finalize the result of the output of the postprocesses.
  123313. * @param doNotPresent If true the result will not be displayed to the screen.
  123314. * @param targetTexture The target texture to render to.
  123315. * @param faceIndex The index of the face to bind the target texture to.
  123316. * @param postProcesses The array of post processes to render.
  123317. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  123318. * @hidden
  123319. */
  123320. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  123321. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  123322. var camera = this._scene.activeCamera;
  123323. if (!camera) {
  123324. return;
  123325. }
  123326. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  123327. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  123328. return;
  123329. }
  123330. var engine = this._scene.getEngine();
  123331. for (var index = 0, len = postProcesses.length; index < len; index++) {
  123332. var pp = postProcesses[index];
  123333. if (index < len - 1) {
  123334. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  123335. }
  123336. else {
  123337. if (targetTexture) {
  123338. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  123339. pp._outputTexture = targetTexture;
  123340. }
  123341. else {
  123342. engine.restoreDefaultFramebuffer();
  123343. pp._outputTexture = null;
  123344. }
  123345. }
  123346. if (doNotPresent) {
  123347. break;
  123348. }
  123349. var effect = pp.apply();
  123350. if (effect) {
  123351. pp.onBeforeRenderObservable.notifyObservers(effect);
  123352. // VBOs
  123353. this._prepareBuffers();
  123354. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  123355. // Draw order
  123356. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  123357. pp.onAfterRenderObservable.notifyObservers(effect);
  123358. }
  123359. }
  123360. // Restore states
  123361. engine.setDepthBuffer(true);
  123362. engine.setDepthWrite(true);
  123363. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  123364. };
  123365. /**
  123366. * Disposes of the post process manager.
  123367. */
  123368. PostProcessManager.prototype.dispose = function () {
  123369. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  123370. if (buffer) {
  123371. buffer.dispose();
  123372. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  123373. }
  123374. if (this._indexBuffer) {
  123375. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  123376. this._indexBuffer = null;
  123377. }
  123378. };
  123379. return PostProcessManager;
  123380. }());
  123381. /***/ }),
  123382. /***/ "./PostProcesses/refractionPostProcess.ts":
  123383. /*!************************************************!*\
  123384. !*** ./PostProcesses/refractionPostProcess.ts ***!
  123385. \************************************************/
  123386. /*! exports provided: RefractionPostProcess */
  123387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123388. "use strict";
  123389. __webpack_require__.r(__webpack_exports__);
  123390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  123391. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123392. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123393. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123394. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  123395. /**
  123396. * Post process which applies a refractin texture
  123397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123398. */
  123399. var RefractionPostProcess = /** @class */ (function (_super) {
  123400. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  123401. /**
  123402. * Initializes the RefractionPostProcess
  123403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123404. * @param name The name of the effect.
  123405. * @param refractionTextureUrl Url of the refraction texture to use
  123406. * @param color the base color of the refraction (used to taint the rendering)
  123407. * @param depth simulated refraction depth
  123408. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  123409. * @param camera The camera to apply the render pass to.
  123410. * @param options The required width/height ratio to downsize to before computing the render pass.
  123411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123412. * @param engine The engine which the post process will be applied. (default: current engine)
  123413. * @param reusable If the post process can be reused on the same frame. (default: false)
  123414. */
  123415. function RefractionPostProcess(name, refractionTextureUrl,
  123416. /** the base color of the refraction (used to taint the rendering) */
  123417. color,
  123418. /** simulated refraction depth */
  123419. depth,
  123420. /** the coefficient of the base color (0 to remove base color tainting) */
  123421. colorLevel, options, camera, samplingMode, engine, reusable) {
  123422. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  123423. _this.color = color;
  123424. _this.depth = depth;
  123425. _this.colorLevel = colorLevel;
  123426. _this._ownRefractionTexture = true;
  123427. _this.onActivateObservable.add(function (cam) {
  123428. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  123429. });
  123430. _this.onApplyObservable.add(function (effect) {
  123431. effect.setColor3("baseColor", _this.color);
  123432. effect.setFloat("depth", _this.depth);
  123433. effect.setFloat("colorLevel", _this.colorLevel);
  123434. effect.setTexture("refractionSampler", _this._refTexture);
  123435. });
  123436. return _this;
  123437. }
  123438. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  123439. /**
  123440. * Gets or sets the refraction texture
  123441. * Please note that you are responsible for disposing the texture if you set it manually
  123442. */
  123443. get: function () {
  123444. return this._refTexture;
  123445. },
  123446. set: function (value) {
  123447. if (this._refTexture && this._ownRefractionTexture) {
  123448. this._refTexture.dispose();
  123449. }
  123450. this._refTexture = value;
  123451. this._ownRefractionTexture = false;
  123452. },
  123453. enumerable: true,
  123454. configurable: true
  123455. });
  123456. // Methods
  123457. /**
  123458. * Disposes of the post process
  123459. * @param camera Camera to dispose post process on
  123460. */
  123461. RefractionPostProcess.prototype.dispose = function (camera) {
  123462. if (this._refTexture && this._ownRefractionTexture) {
  123463. this._refTexture.dispose();
  123464. this._refTexture = null;
  123465. }
  123466. _super.prototype.dispose.call(this, camera);
  123467. };
  123468. return RefractionPostProcess;
  123469. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123470. /***/ }),
  123471. /***/ "./PostProcesses/sharpenPostProcess.ts":
  123472. /*!*********************************************!*\
  123473. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  123474. \*********************************************/
  123475. /*! exports provided: SharpenPostProcess */
  123476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123477. "use strict";
  123478. __webpack_require__.r(__webpack_exports__);
  123479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  123480. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123481. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123482. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123483. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  123484. /**
  123485. * The SharpenPostProcess applies a sharpen kernel to every pixel
  123486. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123487. */
  123488. var SharpenPostProcess = /** @class */ (function (_super) {
  123489. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  123490. /**
  123491. * Creates a new instance ConvolutionPostProcess
  123492. * @param name The name of the effect.
  123493. * @param options The required width/height ratio to downsize to before computing the render pass.
  123494. * @param camera The camera to apply the render pass to.
  123495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123496. * @param engine The engine which the post process will be applied. (default: current engine)
  123497. * @param reusable If the post process can be reused on the same frame. (default: false)
  123498. * @param textureType Type of textures used when performing the post process. (default: 0)
  123499. * @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)
  123500. */
  123501. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123502. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123503. if (blockCompilation === void 0) { blockCompilation = false; }
  123504. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123505. /**
  123506. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  123507. */
  123508. _this.colorAmount = 1.0;
  123509. /**
  123510. * How much sharpness should be applied (default: 0.3)
  123511. */
  123512. _this.edgeAmount = 0.3;
  123513. _this.onApply = function (effect) {
  123514. effect.setFloat2("screenSize", _this.width, _this.height);
  123515. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  123516. };
  123517. return _this;
  123518. }
  123519. return SharpenPostProcess;
  123520. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123521. /***/ }),
  123522. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  123523. /*!***********************************************************!*\
  123524. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  123525. \***********************************************************/
  123526. /*! exports provided: StereoscopicInterlacePostProcess */
  123527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123528. "use strict";
  123529. __webpack_require__.r(__webpack_exports__);
  123530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  123531. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123532. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123533. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123534. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  123535. /**
  123536. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  123537. */
  123538. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  123539. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  123540. /**
  123541. * Initializes a StereoscopicInterlacePostProcess
  123542. * @param name The name of the effect.
  123543. * @param rigCameras The rig cameras to be appled to the post process
  123544. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  123545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123546. * @param engine The engine which the post process will be applied. (default: current engine)
  123547. * @param reusable If the post process can be reused on the same frame. (default: false)
  123548. */
  123549. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  123550. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  123551. _this._passedProcess = rigCameras[0]._rigPostProcess;
  123552. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  123553. _this.onSizeChangedObservable.add(function () {
  123554. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  123555. });
  123556. _this.onApplyObservable.add(function (effect) {
  123557. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  123558. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  123559. });
  123560. return _this;
  123561. }
  123562. return StereoscopicInterlacePostProcess;
  123563. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123564. /***/ }),
  123565. /***/ "./PostProcesses/tonemapPostProcess.ts":
  123566. /*!*********************************************!*\
  123567. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  123568. \*********************************************/
  123569. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  123570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123571. "use strict";
  123572. __webpack_require__.r(__webpack_exports__);
  123573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  123574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  123575. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123576. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123577. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123578. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  123579. /** Defines operator used for tonemapping */
  123580. var TonemappingOperator;
  123581. (function (TonemappingOperator) {
  123582. /** Hable */
  123583. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  123584. /** Reinhard */
  123585. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  123586. /** HejiDawson */
  123587. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  123588. /** Photographic */
  123589. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  123590. })(TonemappingOperator || (TonemappingOperator = {}));
  123591. /**
  123592. * Defines a post process to apply tone mapping
  123593. */
  123594. var TonemapPostProcess = /** @class */ (function (_super) {
  123595. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  123596. /**
  123597. * Creates a new TonemapPostProcess
  123598. * @param name defines the name of the postprocess
  123599. * @param _operator defines the operator to use
  123600. * @param exposureAdjustment defines the required exposure adjustement
  123601. * @param camera defines the camera to use (can be null)
  123602. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  123603. * @param engine defines the hosting engine (can be ignore if camera is set)
  123604. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123605. */
  123606. function TonemapPostProcess(name, _operator,
  123607. /** Defines the required exposure adjustement */
  123608. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  123609. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  123610. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123611. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  123612. _this._operator = _operator;
  123613. _this.exposureAdjustment = exposureAdjustment;
  123614. var defines = "#define ";
  123615. if (_this._operator === TonemappingOperator.Hable) {
  123616. defines += "HABLE_TONEMAPPING";
  123617. }
  123618. else if (_this._operator === TonemappingOperator.Reinhard) {
  123619. defines += "REINHARD_TONEMAPPING";
  123620. }
  123621. else if (_this._operator === TonemappingOperator.HejiDawson) {
  123622. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  123623. }
  123624. else if (_this._operator === TonemappingOperator.Photographic) {
  123625. defines += "PHOTOGRAPHIC_TONEMAPPING";
  123626. }
  123627. //sadly a second call to create the effect.
  123628. _this.updateEffect(defines);
  123629. _this.onApply = function (effect) {
  123630. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  123631. };
  123632. return _this;
  123633. }
  123634. return TonemapPostProcess;
  123635. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123636. /***/ }),
  123637. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  123638. /*!***************************************************************!*\
  123639. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  123640. \***************************************************************/
  123641. /*! exports provided: VolumetricLightScatteringPostProcess */
  123642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123643. "use strict";
  123644. __webpack_require__.r(__webpack_exports__);
  123645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  123646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123647. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  123648. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  123649. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123650. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  123651. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  123652. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  123653. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  123654. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  123655. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123656. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  123657. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123658. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123659. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  123660. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  123661. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  123662. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  123663. /**
  123664. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  123665. */
  123666. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  123667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  123668. /**
  123669. * @constructor
  123670. * @param name The post-process name
  123671. * @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)
  123672. * @param camera The camera that the post-process will be attached to
  123673. * @param mesh The mesh used to create the light scattering
  123674. * @param samples The post-process quality, default 100
  123675. * @param samplingModeThe post-process filtering mode
  123676. * @param engine The babylon engine
  123677. * @param reusable If the post-process is reusable
  123678. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  123679. */
  123680. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  123681. if (samples === void 0) { samples = 100; }
  123682. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  123683. 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;
  123684. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  123685. /**
  123686. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  123687. */
  123688. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  123689. /**
  123690. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  123691. */
  123692. _this.useCustomMeshPosition = false;
  123693. /**
  123694. * If the post-process should inverse the light scattering direction
  123695. */
  123696. _this.invert = true;
  123697. /**
  123698. * Array containing the excluded meshes not rendered in the internal pass
  123699. */
  123700. _this.excludedMeshes = new Array();
  123701. /**
  123702. * Controls the overall intensity of the post-process
  123703. */
  123704. _this.exposure = 0.3;
  123705. /**
  123706. * Dissipates each sample's contribution in range [0, 1]
  123707. */
  123708. _this.decay = 0.96815;
  123709. /**
  123710. * Controls the overall intensity of each sample
  123711. */
  123712. _this.weight = 0.58767;
  123713. /**
  123714. * Controls the density of each sample
  123715. */
  123716. _this.density = 0.926;
  123717. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  123718. engine = scene.getEngine();
  123719. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  123720. // Configure mesh
  123721. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  123722. // Configure
  123723. _this._createPass(scene, ratio.passRatio || ratio);
  123724. _this.onActivate = function (camera) {
  123725. if (!_this.isSupported) {
  123726. _this.dispose(camera);
  123727. }
  123728. _this.onActivate = null;
  123729. };
  123730. _this.onApplyObservable.add(function (effect) {
  123731. _this._updateMeshScreenCoordinates(scene);
  123732. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  123733. effect.setFloat("exposure", _this.exposure);
  123734. effect.setFloat("decay", _this.decay);
  123735. effect.setFloat("weight", _this.weight);
  123736. effect.setFloat("density", _this.density);
  123737. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  123738. });
  123739. return _this;
  123740. }
  123741. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  123742. /**
  123743. * @hidden
  123744. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  123745. */
  123746. get: function () {
  123747. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  123748. return false;
  123749. },
  123750. set: function (useDiffuseColor) {
  123751. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  123752. },
  123753. enumerable: true,
  123754. configurable: true
  123755. });
  123756. /**
  123757. * Returns the string "VolumetricLightScatteringPostProcess"
  123758. * @returns "VolumetricLightScatteringPostProcess"
  123759. */
  123760. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  123761. return "VolumetricLightScatteringPostProcess";
  123762. };
  123763. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  123764. var mesh = subMesh.getMesh();
  123765. // Render this.mesh as default
  123766. if (mesh === this.mesh && mesh.material) {
  123767. return mesh.material.isReady(mesh);
  123768. }
  123769. var defines = [];
  123770. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  123771. var material = subMesh.getMaterial();
  123772. // Alpha test
  123773. if (material) {
  123774. if (material.needAlphaTesting()) {
  123775. defines.push("#define ALPHATEST");
  123776. }
  123777. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  123778. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  123779. defines.push("#define UV1");
  123780. }
  123781. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  123782. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  123783. defines.push("#define UV2");
  123784. }
  123785. }
  123786. // Bones
  123787. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  123788. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  123789. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  123790. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  123791. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  123792. }
  123793. else {
  123794. defines.push("#define NUM_BONE_INFLUENCERS 0");
  123795. }
  123796. // Instances
  123797. if (useInstances) {
  123798. defines.push("#define INSTANCES");
  123799. attribs.push("world0");
  123800. attribs.push("world1");
  123801. attribs.push("world2");
  123802. attribs.push("world3");
  123803. }
  123804. // Get correct effect
  123805. var join = defines.join("\n");
  123806. if (this._cachedDefines !== join) {
  123807. this._cachedDefines = join;
  123808. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  123809. }
  123810. return this._volumetricLightScatteringPass.isReady();
  123811. };
  123812. /**
  123813. * Sets the new light position for light scattering effect
  123814. * @param position The new custom light position
  123815. */
  123816. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  123817. this.customMeshPosition = position;
  123818. };
  123819. /**
  123820. * Returns the light position for light scattering effect
  123821. * @return Vector3 The custom light position
  123822. */
  123823. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  123824. return this.customMeshPosition;
  123825. };
  123826. /**
  123827. * Disposes the internal assets and detaches the post-process from the camera
  123828. */
  123829. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  123830. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  123831. if (rttIndex !== -1) {
  123832. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  123833. }
  123834. this._volumetricLightScatteringRTT.dispose();
  123835. _super.prototype.dispose.call(this, camera);
  123836. };
  123837. /**
  123838. * Returns the render target texture used by the post-process
  123839. * @return the render target texture used by the post-process
  123840. */
  123841. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  123842. return this._volumetricLightScatteringRTT;
  123843. };
  123844. // Private methods
  123845. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  123846. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  123847. return true;
  123848. }
  123849. return false;
  123850. };
  123851. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  123852. var _this = this;
  123853. var engine = scene.getEngine();
  123854. 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);
  123855. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  123856. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  123857. this._volumetricLightScatteringRTT.renderList = null;
  123858. this._volumetricLightScatteringRTT.renderParticles = false;
  123859. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  123860. var camera = this.getCamera();
  123861. if (camera) {
  123862. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  123863. }
  123864. else {
  123865. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  123866. }
  123867. // Custom render function for submeshes
  123868. var renderSubMesh = function (subMesh) {
  123869. var mesh = subMesh.getRenderingMesh();
  123870. if (_this._meshExcluded(mesh)) {
  123871. return;
  123872. }
  123873. var material = subMesh.getMaterial();
  123874. if (!material) {
  123875. return;
  123876. }
  123877. var scene = mesh.getScene();
  123878. var engine = scene.getEngine();
  123879. // Culling
  123880. engine.setState(material.backFaceCulling);
  123881. // Managing instances
  123882. var batch = mesh._getInstancesRenderList(subMesh._id);
  123883. if (batch.mustReturn) {
  123884. return;
  123885. }
  123886. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  123887. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  123888. var effect = _this._volumetricLightScatteringPass;
  123889. if (mesh === _this.mesh) {
  123890. if (subMesh.effect) {
  123891. effect = subMesh.effect;
  123892. }
  123893. else {
  123894. effect = material.getEffect();
  123895. }
  123896. }
  123897. engine.enableEffect(effect);
  123898. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  123899. if (mesh === _this.mesh) {
  123900. material.bind(mesh.getWorldMatrix(), mesh);
  123901. }
  123902. else {
  123903. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  123904. // Alpha test
  123905. if (material && material.needAlphaTesting()) {
  123906. var alphaTexture = material.getAlphaTestTexture();
  123907. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  123908. if (alphaTexture) {
  123909. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  123910. }
  123911. }
  123912. // Bones
  123913. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  123914. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  123915. }
  123916. }
  123917. // Draw
  123918. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  123919. }
  123920. };
  123921. // Render target texture callbacks
  123922. var savedSceneClearColor;
  123923. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  123924. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  123925. savedSceneClearColor = scene.clearColor;
  123926. scene.clearColor = sceneClearColor;
  123927. });
  123928. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  123929. scene.clearColor = savedSceneClearColor;
  123930. });
  123931. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  123932. var engine = scene.getEngine();
  123933. var index;
  123934. if (depthOnlySubMeshes.length) {
  123935. engine.setColorWrite(false);
  123936. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  123937. renderSubMesh(depthOnlySubMeshes.data[index]);
  123938. }
  123939. engine.setColorWrite(true);
  123940. }
  123941. for (index = 0; index < opaqueSubMeshes.length; index++) {
  123942. renderSubMesh(opaqueSubMeshes.data[index]);
  123943. }
  123944. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  123945. renderSubMesh(alphaTestSubMeshes.data[index]);
  123946. }
  123947. if (transparentSubMeshes.length) {
  123948. // Sort sub meshes
  123949. for (index = 0; index < transparentSubMeshes.length; index++) {
  123950. var submesh = transparentSubMeshes.data[index];
  123951. var boundingInfo = submesh.getBoundingInfo();
  123952. if (boundingInfo && scene.activeCamera) {
  123953. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  123954. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  123955. }
  123956. }
  123957. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  123958. sortedArray.sort(function (a, b) {
  123959. // Alpha index first
  123960. if (a._alphaIndex > b._alphaIndex) {
  123961. return 1;
  123962. }
  123963. if (a._alphaIndex < b._alphaIndex) {
  123964. return -1;
  123965. }
  123966. // Then distance to camera
  123967. if (a._distanceToCamera < b._distanceToCamera) {
  123968. return 1;
  123969. }
  123970. if (a._distanceToCamera > b._distanceToCamera) {
  123971. return -1;
  123972. }
  123973. return 0;
  123974. });
  123975. // Render sub meshes
  123976. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  123977. for (index = 0; index < sortedArray.length; index++) {
  123978. renderSubMesh(sortedArray[index]);
  123979. }
  123980. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  123981. }
  123982. };
  123983. };
  123984. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  123985. var transform = scene.getTransformMatrix();
  123986. var meshPosition;
  123987. if (this.useCustomMeshPosition) {
  123988. meshPosition = this.customMeshPosition;
  123989. }
  123990. else if (this.attachedNode) {
  123991. meshPosition = this.attachedNode.position;
  123992. }
  123993. else {
  123994. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  123995. }
  123996. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  123997. this._screenCoordinates.x = pos.x / this._viewPort.width;
  123998. this._screenCoordinates.y = pos.y / this._viewPort.height;
  123999. if (this.invert) {
  124000. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  124001. }
  124002. };
  124003. // Static methods
  124004. /**
  124005. * Creates a default mesh for the Volumeric Light Scattering post-process
  124006. * @param name The mesh name
  124007. * @param scene The scene where to create the mesh
  124008. * @return the default mesh
  124009. */
  124010. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  124011. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  124012. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  124013. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  124014. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  124015. mesh.material = material;
  124016. return mesh;
  124017. };
  124018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  124020. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  124021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124023. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  124024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124026. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  124027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  124029. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  124030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124032. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  124033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124035. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  124036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124038. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  124039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124041. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  124042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124044. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  124045. return VolumetricLightScatteringPostProcess;
  124046. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  124047. /***/ }),
  124048. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  124049. /*!************************************************************!*\
  124050. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  124051. \************************************************************/
  124052. /*! exports provided: VRDistortionCorrectionPostProcess */
  124053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124054. "use strict";
  124055. __webpack_require__.r(__webpack_exports__);
  124056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  124057. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124058. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124059. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124060. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124061. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  124062. /**
  124063. * VRDistortionCorrectionPostProcess used for mobile VR
  124064. */
  124065. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  124066. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  124067. /**
  124068. * Initializes the VRDistortionCorrectionPostProcess
  124069. * @param name The name of the effect.
  124070. * @param camera The camera to apply the render pass to.
  124071. * @param isRightEye If this is for the right eye distortion
  124072. * @param vrMetrics All the required metrics for the VR camera
  124073. */
  124074. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  124075. var _this = _super.call(this, name, "vrDistortionCorrection", [
  124076. 'LensCenter',
  124077. 'Scale',
  124078. 'ScaleIn',
  124079. 'HmdWarpParam'
  124080. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  124081. _this._isRightEye = isRightEye;
  124082. _this._distortionFactors = vrMetrics.distortionK;
  124083. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  124084. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  124085. _this.adaptScaleToCurrentViewport = true;
  124086. _this.onSizeChangedObservable.add(function () {
  124087. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  124088. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  124089. _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);
  124090. });
  124091. _this.onApplyObservable.add(function (effect) {
  124092. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  124093. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  124094. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  124095. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  124096. });
  124097. return _this;
  124098. }
  124099. return VRDistortionCorrectionPostProcess;
  124100. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124101. /***/ }),
  124102. /***/ "./Probes/index.ts":
  124103. /*!*************************!*\
  124104. !*** ./Probes/index.ts ***!
  124105. \*************************/
  124106. /*! exports provided: ReflectionProbe */
  124107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124108. "use strict";
  124109. __webpack_require__.r(__webpack_exports__);
  124110. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  124111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  124112. /***/ }),
  124113. /***/ "./Probes/reflectionProbe.ts":
  124114. /*!***********************************!*\
  124115. !*** ./Probes/reflectionProbe.ts ***!
  124116. \***********************************/
  124117. /*! exports provided: ReflectionProbe */
  124118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124119. "use strict";
  124120. __webpack_require__.r(__webpack_exports__);
  124121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  124122. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124123. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  124124. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  124125. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124126. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  124127. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124128. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  124129. if (!this.reflectionProbes) {
  124130. return -1;
  124131. }
  124132. var index = this.reflectionProbes.indexOf(toRemove);
  124133. if (index !== -1) {
  124134. this.reflectionProbes.splice(index, 1);
  124135. }
  124136. return index;
  124137. };
  124138. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  124139. if (!this.reflectionProbes) {
  124140. this.reflectionProbes = [];
  124141. }
  124142. this.reflectionProbes.push(newReflectionProbe);
  124143. };
  124144. /**
  124145. * Class used to generate realtime reflection / refraction cube textures
  124146. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124147. */
  124148. var ReflectionProbe = /** @class */ (function () {
  124149. /**
  124150. * Creates a new reflection probe
  124151. * @param name defines the name of the probe
  124152. * @param size defines the texture resolution (for each face)
  124153. * @param scene defines the hosting scene
  124154. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124155. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124156. */
  124157. function ReflectionProbe(
  124158. /** defines the name of the probe */
  124159. name, size, scene, generateMipMaps, useFloat) {
  124160. if (generateMipMaps === void 0) { generateMipMaps = true; }
  124161. if (useFloat === void 0) { useFloat = false; }
  124162. var _this = this;
  124163. this.name = name;
  124164. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  124165. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124166. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124167. this._invertYAxis = false;
  124168. /** Gets or sets probe position (center of the cube map) */
  124169. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124170. this._scene = scene;
  124171. // Create the scene field if not exist.
  124172. if (!this._scene.reflectionProbes) {
  124173. this._scene.reflectionProbes = new Array();
  124174. }
  124175. this._scene.reflectionProbes.push(this);
  124176. 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);
  124177. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  124178. switch (faceIndex) {
  124179. case 0:
  124180. _this._add.copyFromFloats(1, 0, 0);
  124181. break;
  124182. case 1:
  124183. _this._add.copyFromFloats(-1, 0, 0);
  124184. break;
  124185. case 2:
  124186. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  124187. break;
  124188. case 3:
  124189. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  124190. break;
  124191. case 4:
  124192. _this._add.copyFromFloats(0, 0, 1);
  124193. break;
  124194. case 5:
  124195. _this._add.copyFromFloats(0, 0, -1);
  124196. break;
  124197. }
  124198. if (_this._attachedMesh) {
  124199. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  124200. }
  124201. _this.position.addToRef(_this._add, _this._target);
  124202. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  124203. if (scene.activeCamera) {
  124204. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  124205. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  124206. }
  124207. scene._forcedViewPosition = _this.position;
  124208. });
  124209. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  124210. scene._forcedViewPosition = null;
  124211. scene.updateTransformMatrix(true);
  124212. });
  124213. }
  124214. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  124215. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124216. get: function () {
  124217. return this._renderTargetTexture.samples;
  124218. },
  124219. set: function (value) {
  124220. this._renderTargetTexture.samples = value;
  124221. },
  124222. enumerable: true,
  124223. configurable: true
  124224. });
  124225. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  124226. /** Gets or sets the refresh rate to use (on every frame by default) */
  124227. get: function () {
  124228. return this._renderTargetTexture.refreshRate;
  124229. },
  124230. set: function (value) {
  124231. this._renderTargetTexture.refreshRate = value;
  124232. },
  124233. enumerable: true,
  124234. configurable: true
  124235. });
  124236. /**
  124237. * Gets the hosting scene
  124238. * @returns a Scene
  124239. */
  124240. ReflectionProbe.prototype.getScene = function () {
  124241. return this._scene;
  124242. };
  124243. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  124244. /** Gets the internal CubeTexture used to render to */
  124245. get: function () {
  124246. return this._renderTargetTexture;
  124247. },
  124248. enumerable: true,
  124249. configurable: true
  124250. });
  124251. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  124252. /** Gets the list of meshes to render */
  124253. get: function () {
  124254. return this._renderTargetTexture.renderList;
  124255. },
  124256. enumerable: true,
  124257. configurable: true
  124258. });
  124259. /**
  124260. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124261. * @param mesh defines the mesh to attach to
  124262. */
  124263. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  124264. this._attachedMesh = mesh;
  124265. };
  124266. /**
  124267. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124268. * @param renderingGroupId The rendering group id corresponding to its index
  124269. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124270. */
  124271. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  124272. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  124273. };
  124274. /**
  124275. * Clean all associated resources
  124276. */
  124277. ReflectionProbe.prototype.dispose = function () {
  124278. var index = this._scene.reflectionProbes.indexOf(this);
  124279. if (index !== -1) {
  124280. // Remove from the scene if found
  124281. this._scene.reflectionProbes.splice(index, 1);
  124282. }
  124283. if (this._renderTargetTexture) {
  124284. this._renderTargetTexture.dispose();
  124285. this._renderTargetTexture = null;
  124286. }
  124287. };
  124288. /**
  124289. * Converts the reflection probe information to a readable string for debug purpose.
  124290. * @param fullDetails Supports for multiple levels of logging within scene loading
  124291. * @returns the human readable reflection probe info
  124292. */
  124293. ReflectionProbe.prototype.toString = function (fullDetails) {
  124294. var ret = "Name: " + this.name;
  124295. if (fullDetails) {
  124296. ret += ", position: " + this.position.toString();
  124297. if (this._attachedMesh) {
  124298. ret += ", attached mesh: " + this._attachedMesh.name;
  124299. }
  124300. }
  124301. return ret;
  124302. };
  124303. /**
  124304. * Get the class name of the relfection probe.
  124305. * @returns "ReflectionProbe"
  124306. */
  124307. ReflectionProbe.prototype.getClassName = function () {
  124308. return "ReflectionProbe";
  124309. };
  124310. /**
  124311. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124312. * @returns The JSON representation of the texture
  124313. */
  124314. ReflectionProbe.prototype.serialize = function () {
  124315. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  124316. serializationObject.isReflectionProbe = true;
  124317. return serializationObject;
  124318. };
  124319. /**
  124320. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124321. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124322. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124323. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124324. * @returns The parsed reflection probe if successful
  124325. */
  124326. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  124327. var reflectionProbe = null;
  124328. if (scene.reflectionProbes) {
  124329. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  124330. var rp = scene.reflectionProbes[index];
  124331. if (rp.name === parsedReflectionProbe.name) {
  124332. reflectionProbe = rp;
  124333. break;
  124334. }
  124335. }
  124336. }
  124337. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  124338. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  124339. if (parsedReflectionProbe._attachedMesh) {
  124340. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  124341. }
  124342. return reflectionProbe;
  124343. };
  124344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  124346. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  124347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  124349. ], ReflectionProbe.prototype, "position", void 0);
  124350. return ReflectionProbe;
  124351. }());
  124352. /***/ }),
  124353. /***/ "./Rendering/boundingBoxRenderer.ts":
  124354. /*!******************************************!*\
  124355. !*** ./Rendering/boundingBoxRenderer.ts ***!
  124356. \******************************************/
  124357. /*! exports provided: BoundingBoxRenderer */
  124358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124359. "use strict";
  124360. __webpack_require__.r(__webpack_exports__);
  124361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  124362. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124363. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124364. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  124365. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  124366. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124367. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  124368. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124369. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124370. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  124371. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  124372. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  124373. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  124374. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  124375. get: function () {
  124376. return this._forceShowBoundingBoxes || false;
  124377. },
  124378. set: function (value) {
  124379. this._forceShowBoundingBoxes = value;
  124380. // Lazyly creates a BB renderer if needed.
  124381. if (value) {
  124382. this.getBoundingBoxRenderer();
  124383. }
  124384. },
  124385. enumerable: true,
  124386. configurable: true
  124387. });
  124388. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  124389. if (!this._boundingBoxRenderer) {
  124390. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  124391. }
  124392. return this._boundingBoxRenderer;
  124393. };
  124394. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  124395. get: function () {
  124396. return this._showBoundingBox || false;
  124397. },
  124398. set: function (value) {
  124399. this._showBoundingBox = value;
  124400. // Lazyly creates a BB renderer if needed.
  124401. if (value) {
  124402. this.getScene().getBoundingBoxRenderer();
  124403. }
  124404. },
  124405. enumerable: true,
  124406. configurable: true
  124407. });
  124408. /**
  124409. * Component responsible of rendering the bounding box of the meshes in a scene.
  124410. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  124411. */
  124412. var BoundingBoxRenderer = /** @class */ (function () {
  124413. /**
  124414. * Instantiates a new bounding box renderer in a scene.
  124415. * @param scene the scene the renderer renders in
  124416. */
  124417. function BoundingBoxRenderer(scene) {
  124418. /**
  124419. * The component name helpfull to identify the component in the list of scene components.
  124420. */
  124421. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  124422. /**
  124423. * Color of the bounding box lines placed in front of an object
  124424. */
  124425. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  124426. /**
  124427. * Color of the bounding box lines placed behind an object
  124428. */
  124429. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  124430. /**
  124431. * Defines if the renderer should show the back lines or not
  124432. */
  124433. this.showBackLines = true;
  124434. /**
  124435. * @hidden
  124436. */
  124437. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  124438. this._vertexBuffers = {};
  124439. this.scene = scene;
  124440. scene._addComponent(this);
  124441. }
  124442. /**
  124443. * Registers the component in a given scene
  124444. */
  124445. BoundingBoxRenderer.prototype.register = function () {
  124446. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  124447. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  124448. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  124449. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  124450. };
  124451. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  124452. if (mesh.showSubMeshesBoundingBox) {
  124453. var boundingInfo = subMesh.getBoundingInfo();
  124454. if (boundingInfo !== null && boundingInfo !== undefined) {
  124455. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  124456. this.renderList.push(boundingInfo.boundingBox);
  124457. }
  124458. }
  124459. };
  124460. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  124461. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  124462. var boundingInfo = sourceMesh.getBoundingInfo();
  124463. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  124464. this.renderList.push(boundingInfo.boundingBox);
  124465. }
  124466. };
  124467. BoundingBoxRenderer.prototype._prepareRessources = function () {
  124468. if (this._colorShader) {
  124469. return;
  124470. }
  124471. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  124472. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  124473. uniforms: ["world", "viewProjection", "color"]
  124474. });
  124475. var engine = this.scene.getEngine();
  124476. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  124477. 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);
  124478. this._createIndexBuffer();
  124479. };
  124480. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  124481. var engine = this.scene.getEngine();
  124482. 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]);
  124483. };
  124484. /**
  124485. * Rebuilds the elements related to this component in case of
  124486. * context lost for instance.
  124487. */
  124488. BoundingBoxRenderer.prototype.rebuild = function () {
  124489. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  124490. if (vb) {
  124491. vb._rebuild();
  124492. }
  124493. this._createIndexBuffer();
  124494. };
  124495. /**
  124496. * @hidden
  124497. */
  124498. BoundingBoxRenderer.prototype.reset = function () {
  124499. this.renderList.reset();
  124500. };
  124501. /**
  124502. * Render the bounding boxes of a specific rendering group
  124503. * @param renderingGroupId defines the rendering group to render
  124504. */
  124505. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  124506. if (this.renderList.length === 0) {
  124507. return;
  124508. }
  124509. this._prepareRessources();
  124510. if (!this._colorShader.isReady()) {
  124511. return;
  124512. }
  124513. var engine = this.scene.getEngine();
  124514. engine.setDepthWrite(false);
  124515. this._colorShader._preBind();
  124516. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  124517. var boundingBox = this.renderList.data[boundingBoxIndex];
  124518. if (boundingBox._tag !== renderingGroupId) {
  124519. continue;
  124520. }
  124521. var min = boundingBox.minimum;
  124522. var max = boundingBox.maximum;
  124523. var diff = max.subtract(min);
  124524. var median = min.add(diff.scale(0.5));
  124525. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  124526. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  124527. .multiply(boundingBox.getWorldMatrix());
  124528. // VBOs
  124529. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  124530. if (this.showBackLines) {
  124531. // Back
  124532. engine.setDepthFunctionToGreaterOrEqual();
  124533. this.scene.resetCachedMaterial();
  124534. this._colorShader.setColor4("color", this.backColor.toColor4());
  124535. this._colorShader.bind(worldMatrix);
  124536. // Draw order
  124537. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  124538. }
  124539. // Front
  124540. engine.setDepthFunctionToLess();
  124541. this.scene.resetCachedMaterial();
  124542. this._colorShader.setColor4("color", this.frontColor.toColor4());
  124543. this._colorShader.bind(worldMatrix);
  124544. // Draw order
  124545. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  124546. }
  124547. this._colorShader.unbind();
  124548. engine.setDepthFunctionToLessOrEqual();
  124549. engine.setDepthWrite(true);
  124550. };
  124551. /**
  124552. * In case of occlusion queries, we can render the occlusion bounding box through this method
  124553. * @param mesh Define the mesh to render the occlusion bounding box for
  124554. */
  124555. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  124556. this._prepareRessources();
  124557. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  124558. return;
  124559. }
  124560. var engine = this.scene.getEngine();
  124561. engine.setDepthWrite(false);
  124562. engine.setColorWrite(false);
  124563. this._colorShader._preBind();
  124564. var boundingBox = mesh._boundingInfo.boundingBox;
  124565. var min = boundingBox.minimum;
  124566. var max = boundingBox.maximum;
  124567. var diff = max.subtract(min);
  124568. var median = min.add(diff.scale(0.5));
  124569. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  124570. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  124571. .multiply(boundingBox.getWorldMatrix());
  124572. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  124573. engine.setDepthFunctionToLess();
  124574. this.scene.resetCachedMaterial();
  124575. this._colorShader.bind(worldMatrix);
  124576. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  124577. this._colorShader.unbind();
  124578. engine.setDepthFunctionToLessOrEqual();
  124579. engine.setDepthWrite(true);
  124580. engine.setColorWrite(true);
  124581. };
  124582. /**
  124583. * Dispose and release the resources attached to this renderer.
  124584. */
  124585. BoundingBoxRenderer.prototype.dispose = function () {
  124586. if (!this._colorShader) {
  124587. return;
  124588. }
  124589. this.renderList.dispose();
  124590. this._colorShader.dispose();
  124591. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  124592. if (buffer) {
  124593. buffer.dispose();
  124594. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  124595. }
  124596. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  124597. };
  124598. return BoundingBoxRenderer;
  124599. }());
  124600. /***/ }),
  124601. /***/ "./Rendering/depthRenderer.ts":
  124602. /*!************************************!*\
  124603. !*** ./Rendering/depthRenderer.ts ***!
  124604. \************************************/
  124605. /*! exports provided: DepthRenderer */
  124606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124607. "use strict";
  124608. __webpack_require__.r(__webpack_exports__);
  124609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  124610. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124611. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124612. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124613. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  124614. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124615. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124616. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  124617. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  124618. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  124619. /**
  124620. * This represents a depth renderer in Babylon.
  124621. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  124622. */
  124623. var DepthRenderer = /** @class */ (function () {
  124624. /**
  124625. * Instantiates a depth renderer
  124626. * @param scene The scene the renderer belongs to
  124627. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  124628. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  124629. */
  124630. function DepthRenderer(scene, type, camera) {
  124631. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  124632. if (camera === void 0) { camera = null; }
  124633. var _this = this;
  124634. /**
  124635. * Specifiess that the depth renderer will only be used within
  124636. * the camera it is created for.
  124637. * This can help forcing its rendering during the camera processing.
  124638. */
  124639. this.useOnlyInActiveCamera = false;
  124640. this._scene = scene;
  124641. DepthRenderer._SceneComponentInitialization(this._scene);
  124642. this._camera = camera;
  124643. var engine = scene.getEngine();
  124644. // Render target
  124645. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  124646. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  124647. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  124648. this._depthMap.refreshRate = 1;
  124649. this._depthMap.renderParticles = false;
  124650. this._depthMap.renderList = null;
  124651. // Camera to get depth map from to support multiple concurrent cameras
  124652. this._depthMap.activeCamera = this._camera;
  124653. this._depthMap.ignoreCameraViewport = true;
  124654. this._depthMap.useCameraPostProcesses = false;
  124655. // set default depth value to 1.0 (far away)
  124656. this._depthMap.onClearObservable.add(function (engine) {
  124657. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  124658. });
  124659. // Custom render function
  124660. var renderSubMesh = function (subMesh) {
  124661. var mesh = subMesh.getRenderingMesh();
  124662. var scene = _this._scene;
  124663. var engine = scene.getEngine();
  124664. var material = subMesh.getMaterial();
  124665. if (!material) {
  124666. return;
  124667. }
  124668. // Culling and reverse (right handed system)
  124669. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  124670. // Managing instances
  124671. var batch = mesh._getInstancesRenderList(subMesh._id);
  124672. if (batch.mustReturn) {
  124673. return;
  124674. }
  124675. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  124676. var camera = _this._camera || scene.activeCamera;
  124677. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  124678. engine.enableEffect(_this._effect);
  124679. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  124680. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  124681. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  124682. // Alpha test
  124683. if (material && material.needAlphaTesting()) {
  124684. var alphaTexture = material.getAlphaTestTexture();
  124685. if (alphaTexture) {
  124686. _this._effect.setTexture("diffuseSampler", alphaTexture);
  124687. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  124688. }
  124689. }
  124690. // Bones
  124691. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  124692. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  124693. }
  124694. // Draw
  124695. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  124696. }
  124697. };
  124698. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  124699. var index;
  124700. if (depthOnlySubMeshes.length) {
  124701. engine.setColorWrite(false);
  124702. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  124703. renderSubMesh(depthOnlySubMeshes.data[index]);
  124704. }
  124705. engine.setColorWrite(true);
  124706. }
  124707. for (index = 0; index < opaqueSubMeshes.length; index++) {
  124708. renderSubMesh(opaqueSubMeshes.data[index]);
  124709. }
  124710. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  124711. renderSubMesh(alphaTestSubMeshes.data[index]);
  124712. }
  124713. };
  124714. }
  124715. /**
  124716. * Creates the depth rendering effect and checks if the effect is ready.
  124717. * @param subMesh The submesh to be used to render the depth map of
  124718. * @param useInstances If multiple world instances should be used
  124719. * @returns if the depth renderer is ready to render the depth map
  124720. */
  124721. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  124722. var material = subMesh.getMaterial();
  124723. if (material.disableDepthWrite) {
  124724. return false;
  124725. }
  124726. var defines = [];
  124727. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  124728. var mesh = subMesh.getMesh();
  124729. // Alpha test
  124730. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  124731. defines.push("#define ALPHATEST");
  124732. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  124733. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  124734. defines.push("#define UV1");
  124735. }
  124736. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  124737. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  124738. defines.push("#define UV2");
  124739. }
  124740. }
  124741. // Bones
  124742. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  124743. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  124744. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  124745. if (mesh.numBoneInfluencers > 4) {
  124746. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  124747. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  124748. }
  124749. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  124750. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  124751. }
  124752. else {
  124753. defines.push("#define NUM_BONE_INFLUENCERS 0");
  124754. }
  124755. // Instances
  124756. if (useInstances) {
  124757. defines.push("#define INSTANCES");
  124758. attribs.push("world0");
  124759. attribs.push("world1");
  124760. attribs.push("world2");
  124761. attribs.push("world3");
  124762. }
  124763. // Get correct effect
  124764. var join = defines.join("\n");
  124765. if (this._cachedDefines !== join) {
  124766. this._cachedDefines = join;
  124767. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  124768. }
  124769. return this._effect.isReady();
  124770. };
  124771. /**
  124772. * Gets the texture which the depth map will be written to.
  124773. * @returns The depth map texture
  124774. */
  124775. DepthRenderer.prototype.getDepthMap = function () {
  124776. return this._depthMap;
  124777. };
  124778. /**
  124779. * Disposes of the depth renderer.
  124780. */
  124781. DepthRenderer.prototype.dispose = function () {
  124782. this._depthMap.dispose();
  124783. };
  124784. /** @hidden */
  124785. DepthRenderer._SceneComponentInitialization = function (_) {
  124786. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  124787. };
  124788. return DepthRenderer;
  124789. }());
  124790. /***/ }),
  124791. /***/ "./Rendering/depthRendererSceneComponent.ts":
  124792. /*!**************************************************!*\
  124793. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  124794. \**************************************************/
  124795. /*! exports provided: DepthRendererSceneComponent */
  124796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124797. "use strict";
  124798. __webpack_require__.r(__webpack_exports__);
  124799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  124800. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124801. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  124802. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124803. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124804. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  124805. camera = camera || this.activeCamera;
  124806. if (!camera) {
  124807. throw "No camera available to enable depth renderer";
  124808. }
  124809. if (!this._depthRenderer) {
  124810. this._depthRenderer = {};
  124811. }
  124812. if (!this._depthRenderer[camera.id]) {
  124813. var textureType = 0;
  124814. if (this.getEngine().getCaps().textureHalfFloatRender) {
  124815. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  124816. }
  124817. else if (this.getEngine().getCaps().textureFloatRender) {
  124818. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  124819. }
  124820. else {
  124821. throw "Depth renderer does not support int texture type";
  124822. }
  124823. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  124824. }
  124825. return this._depthRenderer[camera.id];
  124826. };
  124827. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  124828. camera = camera || this.activeCamera;
  124829. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  124830. return;
  124831. }
  124832. this._depthRenderer[camera.id].dispose();
  124833. delete this._depthRenderer[camera.id];
  124834. };
  124835. /**
  124836. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  124837. * in several rendering techniques.
  124838. */
  124839. var DepthRendererSceneComponent = /** @class */ (function () {
  124840. /**
  124841. * Creates a new instance of the component for the given scene
  124842. * @param scene Defines the scene to register the component in
  124843. */
  124844. function DepthRendererSceneComponent(scene) {
  124845. /**
  124846. * The component name helpfull to identify the component in the list of scene components.
  124847. */
  124848. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  124849. this.scene = scene;
  124850. }
  124851. /**
  124852. * Registers the component in a given scene
  124853. */
  124854. DepthRendererSceneComponent.prototype.register = function () {
  124855. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  124856. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  124857. };
  124858. /**
  124859. * Rebuilds the elements related to this component in case of
  124860. * context lost for instance.
  124861. */
  124862. DepthRendererSceneComponent.prototype.rebuild = function () {
  124863. // Nothing to do for this component
  124864. };
  124865. /**
  124866. * Disposes the component and the associated ressources
  124867. */
  124868. DepthRendererSceneComponent.prototype.dispose = function () {
  124869. for (var key in this.scene._depthRenderer) {
  124870. this.scene._depthRenderer[key].dispose();
  124871. }
  124872. };
  124873. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  124874. if (this.scene._depthRenderer) {
  124875. for (var key in this.scene._depthRenderer) {
  124876. var depthRenderer = this.scene._depthRenderer[key];
  124877. if (!depthRenderer.useOnlyInActiveCamera) {
  124878. renderTargets.push(depthRenderer.getDepthMap());
  124879. }
  124880. }
  124881. }
  124882. };
  124883. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  124884. if (this.scene._depthRenderer) {
  124885. for (var key in this.scene._depthRenderer) {
  124886. var depthRenderer = this.scene._depthRenderer[key];
  124887. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  124888. renderTargets.push(depthRenderer.getDepthMap());
  124889. }
  124890. }
  124891. }
  124892. };
  124893. return DepthRendererSceneComponent;
  124894. }());
  124895. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  124896. // Register the G Buffer component to the scene.
  124897. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  124898. if (!component) {
  124899. component = new DepthRendererSceneComponent(scene);
  124900. scene._addComponent(component);
  124901. }
  124902. };
  124903. /***/ }),
  124904. /***/ "./Rendering/edgesRenderer.ts":
  124905. /*!************************************!*\
  124906. !*** ./Rendering/edgesRenderer.ts ***!
  124907. \************************************/
  124908. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  124909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124910. "use strict";
  124911. __webpack_require__.r(__webpack_exports__);
  124912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  124913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  124914. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124915. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124916. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  124917. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  124918. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124919. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124920. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  124921. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  124922. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124923. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  124924. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  124925. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  124926. if (this._edgesRenderer) {
  124927. this._edgesRenderer.dispose();
  124928. this._edgesRenderer = null;
  124929. }
  124930. return this;
  124931. };
  124932. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  124933. if (epsilon === void 0) { epsilon = 0.95; }
  124934. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  124935. this.disableEdgesRendering();
  124936. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  124937. return this;
  124938. };
  124939. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  124940. get: function () {
  124941. return this._edgesRenderer;
  124942. },
  124943. enumerable: true,
  124944. configurable: true
  124945. });
  124946. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  124947. if (epsilon === void 0) { epsilon = 0.95; }
  124948. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  124949. this.disableEdgesRendering();
  124950. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  124951. return this;
  124952. };
  124953. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  124954. if (epsilon === void 0) { epsilon = 0.95; }
  124955. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  124956. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  124957. return this;
  124958. };
  124959. /**
  124960. * FaceAdjacencies Helper class to generate edges
  124961. */
  124962. var FaceAdjacencies = /** @class */ (function () {
  124963. function FaceAdjacencies() {
  124964. this.edges = new Array();
  124965. this.edgesConnectedCount = 0;
  124966. }
  124967. return FaceAdjacencies;
  124968. }());
  124969. /**
  124970. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  124971. */
  124972. var EdgesRenderer = /** @class */ (function () {
  124973. /**
  124974. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  124975. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  124976. * @param source Mesh used to create edges
  124977. * @param epsilon sum of angles in adjacency to check for edge
  124978. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  124979. * @param generateEdgesLines - should generate Lines or only prepare resources.
  124980. */
  124981. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  124982. if (epsilon === void 0) { epsilon = 0.95; }
  124983. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  124984. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  124985. var _this = this;
  124986. /**
  124987. * Define the size of the edges with an orthographic camera
  124988. */
  124989. this.edgesWidthScalerForOrthographic = 1000.0;
  124990. /**
  124991. * Define the size of the edges with a perspective camera
  124992. */
  124993. this.edgesWidthScalerForPerspective = 50.0;
  124994. this._linesPositions = new Array();
  124995. this._linesNormals = new Array();
  124996. this._linesIndices = new Array();
  124997. this._buffers = {};
  124998. this._checkVerticesInsteadOfIndices = false;
  124999. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  125000. this.isEnabled = true;
  125001. this._source = source;
  125002. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  125003. this._epsilon = epsilon;
  125004. this._prepareRessources();
  125005. if (generateEdgesLines) {
  125006. this._generateEdgesLines();
  125007. }
  125008. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  125009. _this._rebuild();
  125010. });
  125011. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  125012. _this.dispose();
  125013. });
  125014. }
  125015. EdgesRenderer.prototype._prepareRessources = function () {
  125016. if (this._lineShader) {
  125017. return;
  125018. }
  125019. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  125020. attributes: ["position", "normal"],
  125021. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  125022. });
  125023. this._lineShader.disableDepthWrite = true;
  125024. this._lineShader.backFaceCulling = false;
  125025. };
  125026. /** @hidden */
  125027. EdgesRenderer.prototype._rebuild = function () {
  125028. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125029. if (buffer) {
  125030. buffer._rebuild();
  125031. }
  125032. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  125033. if (buffer) {
  125034. buffer._rebuild();
  125035. }
  125036. var scene = this._source.getScene();
  125037. var engine = scene.getEngine();
  125038. this._ib = engine.createIndexBuffer(this._linesIndices);
  125039. };
  125040. /**
  125041. * Releases the required resources for the edges renderer
  125042. */
  125043. EdgesRenderer.prototype.dispose = function () {
  125044. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  125045. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  125046. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125047. if (buffer) {
  125048. buffer.dispose();
  125049. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  125050. }
  125051. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  125052. if (buffer) {
  125053. buffer.dispose();
  125054. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  125055. }
  125056. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  125057. this._lineShader.dispose();
  125058. };
  125059. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  125060. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  125061. return 0;
  125062. }
  125063. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  125064. return 1;
  125065. }
  125066. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  125067. return 2;
  125068. }
  125069. return -1;
  125070. };
  125071. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  125072. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  125073. return 0;
  125074. }
  125075. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  125076. return 1;
  125077. }
  125078. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  125079. return 2;
  125080. }
  125081. return -1;
  125082. };
  125083. /**
  125084. * Checks if the pair of p0 and p1 is en edge
  125085. * @param faceIndex
  125086. * @param edge
  125087. * @param faceNormals
  125088. * @param p0
  125089. * @param p1
  125090. * @private
  125091. */
  125092. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  125093. var needToCreateLine;
  125094. if (edge === undefined) {
  125095. needToCreateLine = true;
  125096. }
  125097. else {
  125098. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  125099. needToCreateLine = dotProduct < this._epsilon;
  125100. }
  125101. if (needToCreateLine) {
  125102. this.createLine(p0, p1, this._linesPositions.length / 3);
  125103. }
  125104. };
  125105. /**
  125106. * push line into the position, normal and index buffer
  125107. * @protected
  125108. */
  125109. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  125110. // Positions
  125111. 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);
  125112. // Normals
  125113. 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);
  125114. // Indices
  125115. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  125116. };
  125117. /**
  125118. * Generates lines edges from adjacencjes
  125119. * @private
  125120. */
  125121. EdgesRenderer.prototype._generateEdgesLines = function () {
  125122. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  125123. var indices = this._source.getIndices();
  125124. if (!indices || !positions) {
  125125. return;
  125126. }
  125127. // First let's find adjacencies
  125128. var adjacencies = new Array();
  125129. var faceNormals = new Array();
  125130. var index;
  125131. var faceAdjacencies;
  125132. // Prepare faces
  125133. for (index = 0; index < indices.length; index += 3) {
  125134. faceAdjacencies = new FaceAdjacencies();
  125135. var p0Index = indices[index];
  125136. var p1Index = indices[index + 1];
  125137. var p2Index = indices[index + 2];
  125138. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  125139. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  125140. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  125141. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  125142. faceNormal.normalize();
  125143. faceNormals.push(faceNormal);
  125144. adjacencies.push(faceAdjacencies);
  125145. }
  125146. // Scan
  125147. for (index = 0; index < adjacencies.length; index++) {
  125148. faceAdjacencies = adjacencies[index];
  125149. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  125150. var otherFaceAdjacencies = adjacencies[otherIndex];
  125151. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  125152. break;
  125153. }
  125154. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  125155. continue;
  125156. }
  125157. var otherP0 = indices[otherIndex * 3];
  125158. var otherP1 = indices[otherIndex * 3 + 1];
  125159. var otherP2 = indices[otherIndex * 3 + 2];
  125160. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  125161. var otherEdgeIndex = 0;
  125162. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  125163. continue;
  125164. }
  125165. switch (edgeIndex) {
  125166. case 0:
  125167. if (this._checkVerticesInsteadOfIndices) {
  125168. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  125169. }
  125170. else {
  125171. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  125172. }
  125173. break;
  125174. case 1:
  125175. if (this._checkVerticesInsteadOfIndices) {
  125176. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  125177. }
  125178. else {
  125179. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  125180. }
  125181. break;
  125182. case 2:
  125183. if (this._checkVerticesInsteadOfIndices) {
  125184. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  125185. }
  125186. else {
  125187. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  125188. }
  125189. break;
  125190. }
  125191. if (otherEdgeIndex === -1) {
  125192. continue;
  125193. }
  125194. faceAdjacencies.edges[edgeIndex] = otherIndex;
  125195. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  125196. faceAdjacencies.edgesConnectedCount++;
  125197. otherFaceAdjacencies.edgesConnectedCount++;
  125198. if (faceAdjacencies.edgesConnectedCount === 3) {
  125199. break;
  125200. }
  125201. }
  125202. }
  125203. }
  125204. // Create lines
  125205. for (index = 0; index < adjacencies.length; index++) {
  125206. // 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
  125207. var current = adjacencies[index];
  125208. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  125209. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  125210. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  125211. }
  125212. // Merge into a single mesh
  125213. var engine = this._source.getScene().getEngine();
  125214. 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);
  125215. 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);
  125216. this._ib = engine.createIndexBuffer(this._linesIndices);
  125217. this._indicesCount = this._linesIndices.length;
  125218. };
  125219. /**
  125220. * Checks wether or not the edges renderer is ready to render.
  125221. * @return true if ready, otherwise false.
  125222. */
  125223. EdgesRenderer.prototype.isReady = function () {
  125224. return this._lineShader.isReady();
  125225. };
  125226. /**
  125227. * Renders the edges of the attached mesh,
  125228. */
  125229. EdgesRenderer.prototype.render = function () {
  125230. var scene = this._source.getScene();
  125231. if (!this.isReady() || !scene.activeCamera) {
  125232. return;
  125233. }
  125234. var engine = scene.getEngine();
  125235. this._lineShader._preBind();
  125236. if (this._source.edgesColor.a !== 1) {
  125237. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  125238. }
  125239. else {
  125240. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  125241. }
  125242. // VBOs
  125243. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  125244. scene.resetCachedMaterial();
  125245. this._lineShader.setColor4("color", this._source.edgesColor);
  125246. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  125247. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  125248. }
  125249. else {
  125250. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  125251. }
  125252. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  125253. this._lineShader.bind(this._source.getWorldMatrix());
  125254. // Draw order
  125255. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  125256. this._lineShader.unbind();
  125257. };
  125258. return EdgesRenderer;
  125259. }());
  125260. /**
  125261. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  125262. */
  125263. var LineEdgesRenderer = /** @class */ (function (_super) {
  125264. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  125265. /**
  125266. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  125267. * @param source LineMesh used to generate edges
  125268. * @param epsilon not important (specified angle for edge detection)
  125269. * @param checkVerticesInsteadOfIndices not important for LineMesh
  125270. */
  125271. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  125272. if (epsilon === void 0) { epsilon = 0.95; }
  125273. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  125274. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  125275. _this._generateEdgesLines();
  125276. return _this;
  125277. }
  125278. /**
  125279. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  125280. */
  125281. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  125282. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  125283. var indices = this._source.getIndices();
  125284. if (!indices || !positions) {
  125285. return;
  125286. }
  125287. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  125288. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  125289. var len = indices.length - 1;
  125290. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  125291. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  125292. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  125293. this.createLine(p0, p1, offset);
  125294. }
  125295. // Merge into a single mesh
  125296. var engine = this._source.getScene().getEngine();
  125297. 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);
  125298. 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);
  125299. this._ib = engine.createIndexBuffer(this._linesIndices);
  125300. this._indicesCount = this._linesIndices.length;
  125301. };
  125302. return LineEdgesRenderer;
  125303. }(EdgesRenderer));
  125304. /***/ }),
  125305. /***/ "./Rendering/geometryBufferRenderer.ts":
  125306. /*!*********************************************!*\
  125307. !*** ./Rendering/geometryBufferRenderer.ts ***!
  125308. \*********************************************/
  125309. /*! exports provided: GeometryBufferRenderer */
  125310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125311. "use strict";
  125312. __webpack_require__.r(__webpack_exports__);
  125313. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  125314. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125315. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125316. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125317. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125318. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  125319. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125320. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  125321. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  125322. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  125323. /**
  125324. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  125325. */
  125326. var GeometryBufferRenderer = /** @class */ (function () {
  125327. /**
  125328. * Creates a new G Buffer for the scene
  125329. * @param scene The scene the buffer belongs to
  125330. * @param ratio How big is the buffer related to the main canvas.
  125331. */
  125332. function GeometryBufferRenderer(scene, ratio) {
  125333. if (ratio === void 0) { ratio = 1; }
  125334. /**
  125335. * Dictionary used to store the previous transformation matrices of each rendered mesh
  125336. * in order to compute objects velocities when enableVelocity is set to "true"
  125337. * @hidden
  125338. */
  125339. this._previousTransformationMatrices = {};
  125340. this._enablePosition = false;
  125341. this._enableVelocity = false;
  125342. this._positionIndex = -1;
  125343. this._velocityIndex = -1;
  125344. this._scene = scene;
  125345. this._ratio = ratio;
  125346. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  125347. // Render target
  125348. this._createRenderTargets();
  125349. }
  125350. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  125351. /**
  125352. * Set the render list (meshes to be rendered) used in the G buffer.
  125353. */
  125354. set: function (meshes) {
  125355. this._multiRenderTarget.renderList = meshes;
  125356. },
  125357. enumerable: true,
  125358. configurable: true
  125359. });
  125360. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  125361. /**
  125362. * Gets wether or not G buffer are supported by the running hardware.
  125363. * This requires draw buffer supports
  125364. */
  125365. get: function () {
  125366. return this._multiRenderTarget.isSupported;
  125367. },
  125368. enumerable: true,
  125369. configurable: true
  125370. });
  125371. /**
  125372. * Returns the index of the given texture type in the G-Buffer textures array
  125373. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  125374. * @returns the index of the given texture type in the G-Buffer textures array
  125375. */
  125376. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  125377. switch (textureType) {
  125378. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  125379. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  125380. default: return -1;
  125381. }
  125382. };
  125383. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  125384. /**
  125385. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  125386. */
  125387. get: function () {
  125388. return this._enablePosition;
  125389. },
  125390. /**
  125391. * Sets whether or not objects positions are enabled for the G buffer.
  125392. */
  125393. set: function (enable) {
  125394. this._enablePosition = enable;
  125395. this.dispose();
  125396. this._createRenderTargets();
  125397. },
  125398. enumerable: true,
  125399. configurable: true
  125400. });
  125401. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  125402. /**
  125403. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  125404. */
  125405. get: function () {
  125406. return this._enableVelocity;
  125407. },
  125408. /**
  125409. * Sets wether or not objects velocities are enabled for the G buffer.
  125410. */
  125411. set: function (enable) {
  125412. this._enableVelocity = enable;
  125413. this.dispose();
  125414. this._createRenderTargets();
  125415. },
  125416. enumerable: true,
  125417. configurable: true
  125418. });
  125419. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  125420. /**
  125421. * Gets the scene associated with the buffer.
  125422. */
  125423. get: function () {
  125424. return this._scene;
  125425. },
  125426. enumerable: true,
  125427. configurable: true
  125428. });
  125429. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  125430. /**
  125431. * Gets the ratio used by the buffer during its creation.
  125432. * How big is the buffer related to the main canvas.
  125433. */
  125434. get: function () {
  125435. return this._ratio;
  125436. },
  125437. enumerable: true,
  125438. configurable: true
  125439. });
  125440. /**
  125441. * Checks wether everything is ready to render a submesh to the G buffer.
  125442. * @param subMesh the submesh to check readiness for
  125443. * @param useInstances is the mesh drawn using instance or not
  125444. * @returns true if ready otherwise false
  125445. */
  125446. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  125447. var material = subMesh.getMaterial();
  125448. if (material && material.disableDepthWrite) {
  125449. return false;
  125450. }
  125451. var defines = [];
  125452. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  125453. var mesh = subMesh.getMesh();
  125454. // Alpha test
  125455. if (material && material.needAlphaTesting()) {
  125456. defines.push("#define ALPHATEST");
  125457. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  125458. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  125459. defines.push("#define UV1");
  125460. }
  125461. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  125462. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  125463. defines.push("#define UV2");
  125464. }
  125465. }
  125466. // Buffers
  125467. if (this._enablePosition) {
  125468. defines.push("#define POSITION");
  125469. defines.push("#define POSITION_INDEX " + this._positionIndex);
  125470. }
  125471. if (this._enableVelocity) {
  125472. defines.push("#define VELOCITY");
  125473. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  125474. }
  125475. // Bones
  125476. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  125477. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  125478. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  125479. if (mesh.numBoneInfluencers > 4) {
  125480. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  125481. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  125482. }
  125483. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  125484. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  125485. }
  125486. else {
  125487. defines.push("#define NUM_BONE_INFLUENCERS 0");
  125488. }
  125489. // Instances
  125490. if (useInstances) {
  125491. defines.push("#define INSTANCES");
  125492. attribs.push("world0");
  125493. attribs.push("world1");
  125494. attribs.push("world2");
  125495. attribs.push("world3");
  125496. }
  125497. // Setup textures count
  125498. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  125499. // Get correct effect
  125500. var join = defines.join("\n");
  125501. if (this._cachedDefines !== join) {
  125502. this._cachedDefines = join;
  125503. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  125504. }
  125505. return this._effect.isReady();
  125506. };
  125507. /**
  125508. * Gets the current underlying G Buffer.
  125509. * @returns the buffer
  125510. */
  125511. GeometryBufferRenderer.prototype.getGBuffer = function () {
  125512. return this._multiRenderTarget;
  125513. };
  125514. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  125515. /**
  125516. * Gets the number of samples used to render the buffer (anti aliasing).
  125517. */
  125518. get: function () {
  125519. return this._multiRenderTarget.samples;
  125520. },
  125521. /**
  125522. * Sets the number of samples used to render the buffer (anti aliasing).
  125523. */
  125524. set: function (value) {
  125525. this._multiRenderTarget.samples = value;
  125526. },
  125527. enumerable: true,
  125528. configurable: true
  125529. });
  125530. /**
  125531. * Disposes the renderer and frees up associated resources.
  125532. */
  125533. GeometryBufferRenderer.prototype.dispose = function () {
  125534. this.getGBuffer().dispose();
  125535. };
  125536. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  125537. var _this = this;
  125538. var engine = this._scene.getEngine();
  125539. var count = 2;
  125540. if (this._enablePosition) {
  125541. this._positionIndex = count;
  125542. count++;
  125543. }
  125544. if (this._enableVelocity) {
  125545. this._velocityIndex = count;
  125546. count++;
  125547. }
  125548. 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 });
  125549. if (!this.isSupported) {
  125550. return;
  125551. }
  125552. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  125553. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  125554. this._multiRenderTarget.refreshRate = 1;
  125555. this._multiRenderTarget.renderParticles = false;
  125556. this._multiRenderTarget.renderList = null;
  125557. // set default depth value to 1.0 (far away)
  125558. this._multiRenderTarget.onClearObservable.add(function (engine) {
  125559. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  125560. });
  125561. // Custom render function
  125562. var renderSubMesh = function (subMesh) {
  125563. var mesh = subMesh.getRenderingMesh();
  125564. var scene = _this._scene;
  125565. var engine = scene.getEngine();
  125566. var material = subMesh.getMaterial();
  125567. if (!material) {
  125568. return;
  125569. }
  125570. // Velocity
  125571. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  125572. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  125573. }
  125574. // Culling
  125575. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  125576. // Managing instances
  125577. var batch = mesh._getInstancesRenderList(subMesh._id);
  125578. if (batch.mustReturn) {
  125579. return;
  125580. }
  125581. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  125582. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  125583. engine.enableEffect(_this._effect);
  125584. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  125585. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  125586. _this._effect.setMatrix("view", scene.getViewMatrix());
  125587. // Alpha test
  125588. if (material && material.needAlphaTesting()) {
  125589. var alphaTexture = material.getAlphaTestTexture();
  125590. if (alphaTexture) {
  125591. _this._effect.setTexture("diffuseSampler", alphaTexture);
  125592. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  125593. }
  125594. }
  125595. // Bones
  125596. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  125597. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  125598. }
  125599. // Velocity
  125600. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  125601. // Draw
  125602. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  125603. }
  125604. // Velocity
  125605. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  125606. };
  125607. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  125608. var index;
  125609. if (depthOnlySubMeshes.length) {
  125610. engine.setColorWrite(false);
  125611. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  125612. renderSubMesh(depthOnlySubMeshes.data[index]);
  125613. }
  125614. engine.setColorWrite(true);
  125615. }
  125616. for (index = 0; index < opaqueSubMeshes.length; index++) {
  125617. renderSubMesh(opaqueSubMeshes.data[index]);
  125618. }
  125619. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  125620. renderSubMesh(alphaTestSubMeshes.data[index]);
  125621. }
  125622. };
  125623. };
  125624. /**
  125625. * Constant used to retrieve the position texture index in the G-Buffer textures array
  125626. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  125627. */
  125628. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  125629. /**
  125630. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  125631. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  125632. */
  125633. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  125634. /** @hidden */
  125635. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  125636. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  125637. };
  125638. return GeometryBufferRenderer;
  125639. }());
  125640. /***/ }),
  125641. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  125642. /*!***********************************************************!*\
  125643. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  125644. \***********************************************************/
  125645. /*! exports provided: GeometryBufferRendererSceneComponent */
  125646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125647. "use strict";
  125648. __webpack_require__.r(__webpack_exports__);
  125649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  125650. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125651. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125652. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  125653. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  125654. get: function () {
  125655. this._geometryBufferRenderer;
  125656. },
  125657. set: function (value) {
  125658. if (value && value.isSupported) {
  125659. this._geometryBufferRenderer = value;
  125660. }
  125661. },
  125662. enumerable: true,
  125663. configurable: true
  125664. });
  125665. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  125666. if (ratio === void 0) { ratio = 1; }
  125667. if (this._geometryBufferRenderer) {
  125668. return this._geometryBufferRenderer;
  125669. }
  125670. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  125671. if (!this._geometryBufferRenderer.isSupported) {
  125672. this._geometryBufferRenderer = null;
  125673. }
  125674. return this._geometryBufferRenderer;
  125675. };
  125676. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  125677. if (!this._geometryBufferRenderer) {
  125678. return;
  125679. }
  125680. this._geometryBufferRenderer.dispose();
  125681. this._geometryBufferRenderer = null;
  125682. };
  125683. /**
  125684. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  125685. * in several rendering techniques.
  125686. */
  125687. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  125688. /**
  125689. * Creates a new instance of the component for the given scene
  125690. * @param scene Defines the scene to register the component in
  125691. */
  125692. function GeometryBufferRendererSceneComponent(scene) {
  125693. /**
  125694. * The component name helpful to identify the component in the list of scene components.
  125695. */
  125696. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  125697. this.scene = scene;
  125698. }
  125699. /**
  125700. * Registers the component in a given scene
  125701. */
  125702. GeometryBufferRendererSceneComponent.prototype.register = function () {
  125703. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  125704. };
  125705. /**
  125706. * Rebuilds the elements related to this component in case of
  125707. * context lost for instance.
  125708. */
  125709. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  125710. // Nothing to do for this component
  125711. };
  125712. /**
  125713. * Disposes the component and the associated ressources
  125714. */
  125715. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  125716. // Nothing to do for this component
  125717. };
  125718. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  125719. if (this.scene._geometryBufferRenderer) {
  125720. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  125721. }
  125722. };
  125723. return GeometryBufferRendererSceneComponent;
  125724. }());
  125725. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  125726. // Register the G Buffer component to the scene.
  125727. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  125728. if (!component) {
  125729. component = new GeometryBufferRendererSceneComponent(scene);
  125730. scene._addComponent(component);
  125731. }
  125732. };
  125733. /***/ }),
  125734. /***/ "./Rendering/index.ts":
  125735. /*!****************************!*\
  125736. !*** ./Rendering/index.ts ***!
  125737. \****************************/
  125738. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  125739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125740. "use strict";
  125741. __webpack_require__.r(__webpack_exports__);
  125742. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  125743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  125744. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  125745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  125746. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  125747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  125748. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  125749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  125750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  125751. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  125752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  125753. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  125754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  125755. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  125756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  125757. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  125758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  125759. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  125760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  125761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  125762. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  125763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  125764. /***/ }),
  125765. /***/ "./Rendering/outlineRenderer.ts":
  125766. /*!**************************************!*\
  125767. !*** ./Rendering/outlineRenderer.ts ***!
  125768. \**************************************/
  125769. /*! exports provided: OutlineRenderer */
  125770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125771. "use strict";
  125772. __webpack_require__.r(__webpack_exports__);
  125773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  125774. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125775. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  125776. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125777. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125778. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125779. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125780. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  125781. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  125782. /**
  125783. * Gets the outline renderer associated with the scene
  125784. * @returns a OutlineRenderer
  125785. */
  125786. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  125787. if (!this._outlineRenderer) {
  125788. this._outlineRenderer = new OutlineRenderer(this);
  125789. }
  125790. return this._outlineRenderer;
  125791. };
  125792. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  125793. get: function () {
  125794. return this._renderOutline;
  125795. },
  125796. set: function (value) {
  125797. if (value) {
  125798. // Lazy Load the component.
  125799. this.getScene().getOutlineRenderer();
  125800. }
  125801. this._renderOutline = value;
  125802. },
  125803. enumerable: true,
  125804. configurable: true
  125805. });
  125806. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  125807. get: function () {
  125808. return this._renderOverlay;
  125809. },
  125810. set: function (value) {
  125811. if (value) {
  125812. // Lazy Load the component.
  125813. this.getScene().getOutlineRenderer();
  125814. }
  125815. this._renderOverlay = value;
  125816. },
  125817. enumerable: true,
  125818. configurable: true
  125819. });
  125820. /**
  125821. * This class is responsible to draw bothe outline/overlay of meshes.
  125822. * It should not be used directly but through the available method on mesh.
  125823. */
  125824. var OutlineRenderer = /** @class */ (function () {
  125825. /**
  125826. * Instantiates a new outline renderer. (There could be only one per scene).
  125827. * @param scene Defines the scene it belongs to
  125828. */
  125829. function OutlineRenderer(scene) {
  125830. /**
  125831. * The name of the component. Each component must have a unique name.
  125832. */
  125833. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  125834. /**
  125835. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  125836. */
  125837. this.zOffset = 1;
  125838. this.scene = scene;
  125839. this._engine = scene.getEngine();
  125840. this.scene._addComponent(this);
  125841. }
  125842. /**
  125843. * Register the component to one instance of a scene.
  125844. */
  125845. OutlineRenderer.prototype.register = function () {
  125846. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  125847. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  125848. };
  125849. /**
  125850. * Rebuilds the elements related to this component in case of
  125851. * context lost for instance.
  125852. */
  125853. OutlineRenderer.prototype.rebuild = function () {
  125854. // Nothing to do here.
  125855. };
  125856. /**
  125857. * Disposes the component and the associated ressources.
  125858. */
  125859. OutlineRenderer.prototype.dispose = function () {
  125860. // Nothing to do here.
  125861. };
  125862. /**
  125863. * Renders the outline in the canvas.
  125864. * @param subMesh Defines the sumesh to render
  125865. * @param batch Defines the batch of meshes in case of instances
  125866. * @param useOverlay Defines if the rendering is for the overlay or the outline
  125867. */
  125868. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  125869. var _this = this;
  125870. if (useOverlay === void 0) { useOverlay = false; }
  125871. var scene = this.scene;
  125872. var engine = scene.getEngine();
  125873. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  125874. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  125875. return;
  125876. }
  125877. var mesh = subMesh.getRenderingMesh();
  125878. var material = subMesh.getMaterial();
  125879. if (!material || !scene.activeCamera) {
  125880. return;
  125881. }
  125882. engine.enableEffect(this._effect);
  125883. // Logarithmic depth
  125884. if (material.useLogarithmicDepth) {
  125885. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  125886. }
  125887. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  125888. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  125889. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  125890. // Bones
  125891. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  125892. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  125893. }
  125894. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  125895. // Alpha test
  125896. if (material && material.needAlphaTesting()) {
  125897. var alphaTexture = material.getAlphaTestTexture();
  125898. if (alphaTexture) {
  125899. this._effect.setTexture("diffuseSampler", alphaTexture);
  125900. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  125901. }
  125902. }
  125903. engine.setZOffset(-this.zOffset);
  125904. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  125905. engine.setZOffset(0);
  125906. };
  125907. /**
  125908. * Returns whether or not the outline renderer is ready for a given submesh.
  125909. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  125910. * @param subMesh Defines the submesh to check readyness for
  125911. * @param useInstances Defines wheter wee are trying to render instances or not
  125912. * @returns true if ready otherwise false
  125913. */
  125914. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  125915. var defines = [];
  125916. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  125917. var mesh = subMesh.getMesh();
  125918. var material = subMesh.getMaterial();
  125919. if (material) {
  125920. // Alpha test
  125921. if (material.needAlphaTesting()) {
  125922. defines.push("#define ALPHATEST");
  125923. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  125924. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  125925. defines.push("#define UV1");
  125926. }
  125927. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  125928. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  125929. defines.push("#define UV2");
  125930. }
  125931. }
  125932. //Logarithmic depth
  125933. if (material.useLogarithmicDepth) {
  125934. defines.push("#define LOGARITHMICDEPTH");
  125935. }
  125936. }
  125937. // Bones
  125938. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  125939. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  125940. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  125941. if (mesh.numBoneInfluencers > 4) {
  125942. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  125943. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  125944. }
  125945. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  125946. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  125947. }
  125948. else {
  125949. defines.push("#define NUM_BONE_INFLUENCERS 0");
  125950. }
  125951. // Instances
  125952. if (useInstances) {
  125953. defines.push("#define INSTANCES");
  125954. attribs.push("world0");
  125955. attribs.push("world1");
  125956. attribs.push("world2");
  125957. attribs.push("world3");
  125958. }
  125959. // Get correct effect
  125960. var join = defines.join("\n");
  125961. if (this._cachedDefines !== join) {
  125962. this._cachedDefines = join;
  125963. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  125964. }
  125965. return this._effect.isReady();
  125966. };
  125967. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  125968. // Outline - step 1
  125969. this._savedDepthWrite = this._engine.getDepthWrite();
  125970. if (mesh.renderOutline) {
  125971. var material = subMesh.getMaterial();
  125972. if (material && material.needAlphaBlending) {
  125973. this._engine.cacheStencilState();
  125974. // Draw only to stencil buffer for the original mesh
  125975. // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
  125976. this._engine.setDepthWrite(false);
  125977. this._engine.setColorWrite(false);
  125978. this._engine.setStencilBuffer(true);
  125979. this._engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].REPLACE);
  125980. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALWAYS);
  125981. this._engine.setStencilMask(OutlineRenderer._StencilReference);
  125982. this._engine.setStencilFunctionReference(OutlineRenderer._StencilReference);
  125983. this.render(subMesh, batch, /* This sets offset to 0 */ true);
  125984. this._engine.setColorWrite(true);
  125985. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].NOTEQUAL);
  125986. }
  125987. // Draw the outline using the above stencil if needed to avoid drawing within the mesh
  125988. this._engine.setDepthWrite(false);
  125989. this.render(subMesh, batch);
  125990. this._engine.setDepthWrite(this._savedDepthWrite);
  125991. if (material && material.needAlphaBlending) {
  125992. this._engine.restoreStencilState();
  125993. }
  125994. }
  125995. };
  125996. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  125997. // Outline - step 2
  125998. if (mesh.renderOutline && this._savedDepthWrite) {
  125999. this._engine.setDepthWrite(true);
  126000. this._engine.setColorWrite(false);
  126001. this.render(subMesh, batch);
  126002. this._engine.setColorWrite(true);
  126003. }
  126004. // Overlay
  126005. if (mesh.renderOverlay) {
  126006. var currentMode = this._engine.getAlphaMode();
  126007. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  126008. this.render(subMesh, batch, true);
  126009. this._engine.setAlphaMode(currentMode);
  126010. }
  126011. };
  126012. /**
  126013. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126014. */
  126015. OutlineRenderer._StencilReference = 0x04;
  126016. return OutlineRenderer;
  126017. }());
  126018. /***/ }),
  126019. /***/ "./Rendering/renderingGroup.ts":
  126020. /*!*************************************!*\
  126021. !*** ./Rendering/renderingGroup.ts ***!
  126022. \*************************************/
  126023. /*! exports provided: RenderingGroup */
  126024. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126025. "use strict";
  126026. __webpack_require__.r(__webpack_exports__);
  126027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  126028. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  126029. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126030. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126031. /**
  126032. * This represents the object necessary to create a rendering group.
  126033. * This is exclusively used and created by the rendering manager.
  126034. * To modify the behavior, you use the available helpers in your scene or meshes.
  126035. * @hidden
  126036. */
  126037. var RenderingGroup = /** @class */ (function () {
  126038. /**
  126039. * Creates a new rendering group.
  126040. * @param index The rendering group index
  126041. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  126042. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  126043. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  126044. */
  126045. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  126046. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  126047. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  126048. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  126049. this.index = index;
  126050. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126051. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126052. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126053. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126054. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126055. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  126056. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  126057. this._scene = scene;
  126058. this.opaqueSortCompareFn = opaqueSortCompareFn;
  126059. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  126060. this.transparentSortCompareFn = transparentSortCompareFn;
  126061. }
  126062. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  126063. /**
  126064. * Set the opaque sort comparison function.
  126065. * If null the sub meshes will be render in the order they were created
  126066. */
  126067. set: function (value) {
  126068. this._opaqueSortCompareFn = value;
  126069. if (value) {
  126070. this._renderOpaque = this.renderOpaqueSorted;
  126071. }
  126072. else {
  126073. this._renderOpaque = RenderingGroup.renderUnsorted;
  126074. }
  126075. },
  126076. enumerable: true,
  126077. configurable: true
  126078. });
  126079. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  126080. /**
  126081. * Set the alpha test sort comparison function.
  126082. * If null the sub meshes will be render in the order they were created
  126083. */
  126084. set: function (value) {
  126085. this._alphaTestSortCompareFn = value;
  126086. if (value) {
  126087. this._renderAlphaTest = this.renderAlphaTestSorted;
  126088. }
  126089. else {
  126090. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  126091. }
  126092. },
  126093. enumerable: true,
  126094. configurable: true
  126095. });
  126096. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  126097. /**
  126098. * Set the transparent sort comparison function.
  126099. * If null the sub meshes will be render in the order they were created
  126100. */
  126101. set: function (value) {
  126102. if (value) {
  126103. this._transparentSortCompareFn = value;
  126104. }
  126105. else {
  126106. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  126107. }
  126108. this._renderTransparent = this.renderTransparentSorted;
  126109. },
  126110. enumerable: true,
  126111. configurable: true
  126112. });
  126113. /**
  126114. * Render all the sub meshes contained in the group.
  126115. * @param customRenderFunction Used to override the default render behaviour of the group.
  126116. * @returns true if rendered some submeshes.
  126117. */
  126118. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  126119. if (customRenderFunction) {
  126120. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  126121. return;
  126122. }
  126123. var engine = this._scene.getEngine();
  126124. // Depth only
  126125. if (this._depthOnlySubMeshes.length !== 0) {
  126126. engine.setColorWrite(false);
  126127. this._renderAlphaTest(this._depthOnlySubMeshes);
  126128. engine.setColorWrite(true);
  126129. }
  126130. // Opaque
  126131. if (this._opaqueSubMeshes.length !== 0) {
  126132. this._renderOpaque(this._opaqueSubMeshes);
  126133. }
  126134. // Alpha test
  126135. if (this._alphaTestSubMeshes.length !== 0) {
  126136. this._renderAlphaTest(this._alphaTestSubMeshes);
  126137. }
  126138. var stencilState = engine.getStencilBuffer();
  126139. engine.setStencilBuffer(false);
  126140. // Sprites
  126141. if (renderSprites) {
  126142. this._renderSprites();
  126143. }
  126144. // Particles
  126145. if (renderParticles) {
  126146. this._renderParticles(activeMeshes);
  126147. }
  126148. if (this.onBeforeTransparentRendering) {
  126149. this.onBeforeTransparentRendering();
  126150. }
  126151. // Transparent
  126152. if (this._transparentSubMeshes.length !== 0) {
  126153. this._renderTransparent(this._transparentSubMeshes);
  126154. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  126155. }
  126156. // Set back stencil to false in case it changes before the edge renderer.
  126157. engine.setStencilBuffer(false);
  126158. // Edges
  126159. if (this._edgesRenderers.length) {
  126160. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  126161. this._edgesRenderers.data[edgesRendererIndex].render();
  126162. }
  126163. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  126164. }
  126165. // Restore Stencil state.
  126166. engine.setStencilBuffer(stencilState);
  126167. };
  126168. /**
  126169. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  126170. * @param subMeshes The submeshes to render
  126171. */
  126172. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  126173. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  126174. };
  126175. /**
  126176. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  126177. * @param subMeshes The submeshes to render
  126178. */
  126179. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  126180. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  126181. };
  126182. /**
  126183. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  126184. * @param subMeshes The submeshes to render
  126185. */
  126186. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  126187. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  126188. };
  126189. /**
  126190. * Renders the submeshes in a specified order.
  126191. * @param subMeshes The submeshes to sort before render
  126192. * @param sortCompareFn The comparison function use to sort
  126193. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  126194. * @param transparent Specifies to activate blending if true
  126195. */
  126196. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  126197. var subIndex = 0;
  126198. var subMesh;
  126199. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  126200. for (; subIndex < subMeshes.length; subIndex++) {
  126201. subMesh = subMeshes.data[subIndex];
  126202. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  126203. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  126204. }
  126205. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  126206. if (sortCompareFn) {
  126207. sortedArray.sort(sortCompareFn);
  126208. }
  126209. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  126210. subMesh = sortedArray[subIndex];
  126211. if (transparent) {
  126212. var material = subMesh.getMaterial();
  126213. if (material && material.needDepthPrePass) {
  126214. var engine = material.getScene().getEngine();
  126215. engine.setColorWrite(false);
  126216. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  126217. subMesh.render(false);
  126218. engine.setColorWrite(true);
  126219. }
  126220. }
  126221. subMesh.render(transparent);
  126222. }
  126223. };
  126224. /**
  126225. * Renders the submeshes in the order they were dispatched (no sort applied).
  126226. * @param subMeshes The submeshes to render
  126227. */
  126228. RenderingGroup.renderUnsorted = function (subMeshes) {
  126229. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  126230. var submesh = subMeshes.data[subIndex];
  126231. submesh.render(false);
  126232. }
  126233. };
  126234. /**
  126235. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  126236. * are rendered back to front if in the same alpha index.
  126237. *
  126238. * @param a The first submesh
  126239. * @param b The second submesh
  126240. * @returns The result of the comparison
  126241. */
  126242. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  126243. // Alpha index first
  126244. if (a._alphaIndex > b._alphaIndex) {
  126245. return 1;
  126246. }
  126247. if (a._alphaIndex < b._alphaIndex) {
  126248. return -1;
  126249. }
  126250. // Then distance to camera
  126251. return RenderingGroup.backToFrontSortCompare(a, b);
  126252. };
  126253. /**
  126254. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  126255. * are rendered back to front.
  126256. *
  126257. * @param a The first submesh
  126258. * @param b The second submesh
  126259. * @returns The result of the comparison
  126260. */
  126261. RenderingGroup.backToFrontSortCompare = function (a, b) {
  126262. // Then distance to camera
  126263. if (a._distanceToCamera < b._distanceToCamera) {
  126264. return 1;
  126265. }
  126266. if (a._distanceToCamera > b._distanceToCamera) {
  126267. return -1;
  126268. }
  126269. return 0;
  126270. };
  126271. /**
  126272. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  126273. * are rendered front to back (prevent overdraw).
  126274. *
  126275. * @param a The first submesh
  126276. * @param b The second submesh
  126277. * @returns The result of the comparison
  126278. */
  126279. RenderingGroup.frontToBackSortCompare = function (a, b) {
  126280. // Then distance to camera
  126281. if (a._distanceToCamera < b._distanceToCamera) {
  126282. return -1;
  126283. }
  126284. if (a._distanceToCamera > b._distanceToCamera) {
  126285. return 1;
  126286. }
  126287. return 0;
  126288. };
  126289. /**
  126290. * Resets the different lists of submeshes to prepare a new frame.
  126291. */
  126292. RenderingGroup.prototype.prepare = function () {
  126293. this._opaqueSubMeshes.reset();
  126294. this._transparentSubMeshes.reset();
  126295. this._alphaTestSubMeshes.reset();
  126296. this._depthOnlySubMeshes.reset();
  126297. this._particleSystems.reset();
  126298. this._spriteManagers.reset();
  126299. this._edgesRenderers.reset();
  126300. };
  126301. RenderingGroup.prototype.dispose = function () {
  126302. this._opaqueSubMeshes.dispose();
  126303. this._transparentSubMeshes.dispose();
  126304. this._alphaTestSubMeshes.dispose();
  126305. this._depthOnlySubMeshes.dispose();
  126306. this._particleSystems.dispose();
  126307. this._spriteManagers.dispose();
  126308. this._edgesRenderers.dispose();
  126309. };
  126310. /**
  126311. * Inserts the submesh in its correct queue depending on its material.
  126312. * @param subMesh The submesh to dispatch
  126313. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  126314. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  126315. */
  126316. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  126317. // Get mesh and materials if not provided
  126318. if (mesh === undefined) {
  126319. mesh = subMesh.getMesh();
  126320. }
  126321. if (material === undefined) {
  126322. material = subMesh.getMaterial();
  126323. }
  126324. if (material === null || material === undefined) {
  126325. return;
  126326. }
  126327. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  126328. this._transparentSubMeshes.push(subMesh);
  126329. }
  126330. else if (material.needAlphaTesting()) { // Alpha test
  126331. if (material.needDepthPrePass) {
  126332. this._depthOnlySubMeshes.push(subMesh);
  126333. }
  126334. this._alphaTestSubMeshes.push(subMesh);
  126335. }
  126336. else {
  126337. if (material.needDepthPrePass) {
  126338. this._depthOnlySubMeshes.push(subMesh);
  126339. }
  126340. this._opaqueSubMeshes.push(subMesh); // Opaque
  126341. }
  126342. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  126343. this._edgesRenderers.push(mesh._edgesRenderer);
  126344. }
  126345. };
  126346. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  126347. this._spriteManagers.push(spriteManager);
  126348. };
  126349. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  126350. this._particleSystems.push(particleSystem);
  126351. };
  126352. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  126353. if (this._particleSystems.length === 0) {
  126354. return;
  126355. }
  126356. // Particles
  126357. var activeCamera = this._scene.activeCamera;
  126358. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  126359. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  126360. var particleSystem = this._particleSystems.data[particleIndex];
  126361. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  126362. continue;
  126363. }
  126364. var emitter = particleSystem.emitter;
  126365. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  126366. this._scene._activeParticles.addCount(particleSystem.render(), false);
  126367. }
  126368. }
  126369. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  126370. };
  126371. RenderingGroup.prototype._renderSprites = function () {
  126372. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  126373. return;
  126374. }
  126375. // Sprites
  126376. var activeCamera = this._scene.activeCamera;
  126377. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  126378. for (var id = 0; id < this._spriteManagers.length; id++) {
  126379. var spriteManager = this._spriteManagers.data[id];
  126380. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  126381. spriteManager.render();
  126382. }
  126383. }
  126384. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  126385. };
  126386. return RenderingGroup;
  126387. }());
  126388. /***/ }),
  126389. /***/ "./Rendering/renderingManager.ts":
  126390. /*!***************************************!*\
  126391. !*** ./Rendering/renderingManager.ts ***!
  126392. \***************************************/
  126393. /*! exports provided: RenderingGroupInfo, RenderingManager */
  126394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126395. "use strict";
  126396. __webpack_require__.r(__webpack_exports__);
  126397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  126398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  126399. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  126400. /**
  126401. * This class is used by the onRenderingGroupObservable
  126402. */
  126403. var RenderingGroupInfo = /** @class */ (function () {
  126404. function RenderingGroupInfo() {
  126405. }
  126406. return RenderingGroupInfo;
  126407. }());
  126408. /**
  126409. * This is the manager responsible of all the rendering for meshes sprites and particles.
  126410. * It is enable to manage the different groups as well as the different necessary sort functions.
  126411. * This should not be used directly aside of the few static configurations
  126412. */
  126413. var RenderingManager = /** @class */ (function () {
  126414. /**
  126415. * Instantiates a new rendering group for a particular scene
  126416. * @param scene Defines the scene the groups belongs to
  126417. */
  126418. function RenderingManager(scene) {
  126419. /**
  126420. * @hidden
  126421. */
  126422. this._useSceneAutoClearSetup = false;
  126423. this._renderingGroups = new Array();
  126424. this._autoClearDepthStencil = {};
  126425. this._customOpaqueSortCompareFn = {};
  126426. this._customAlphaTestSortCompareFn = {};
  126427. this._customTransparentSortCompareFn = {};
  126428. this._renderingGroupInfo = new RenderingGroupInfo();
  126429. this._scene = scene;
  126430. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  126431. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  126432. }
  126433. }
  126434. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  126435. if (depth === void 0) { depth = true; }
  126436. if (stencil === void 0) { stencil = true; }
  126437. if (this._depthStencilBufferAlreadyCleaned) {
  126438. return;
  126439. }
  126440. this._scene.getEngine().clear(null, false, depth, stencil);
  126441. this._depthStencilBufferAlreadyCleaned = true;
  126442. };
  126443. /**
  126444. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  126445. * @hidden
  126446. */
  126447. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  126448. // Update the observable context (not null as it only goes away on dispose)
  126449. var info = this._renderingGroupInfo;
  126450. info.scene = this._scene;
  126451. info.camera = this._scene.activeCamera;
  126452. // Dispatch sprites
  126453. if (this._scene.spriteManagers && renderSprites) {
  126454. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  126455. var manager = this._scene.spriteManagers[index];
  126456. this.dispatchSprites(manager);
  126457. }
  126458. }
  126459. // Render
  126460. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  126461. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  126462. var renderingGroup = this._renderingGroups[index];
  126463. if (!renderingGroup) {
  126464. continue;
  126465. }
  126466. var renderingGroupMask = Math.pow(2, index);
  126467. info.renderingGroupId = index;
  126468. // Before Observable
  126469. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  126470. // Clear depth/stencil if needed
  126471. if (RenderingManager.AUTOCLEAR) {
  126472. var autoClear = this._useSceneAutoClearSetup ?
  126473. this._scene.getAutoClearDepthStencilSetup(index) :
  126474. this._autoClearDepthStencil[index];
  126475. if (autoClear && autoClear.autoClear) {
  126476. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  126477. }
  126478. }
  126479. // Render
  126480. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  126481. var step = _a[_i];
  126482. step.action(index);
  126483. }
  126484. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  126485. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  126486. var step = _c[_b];
  126487. step.action(index);
  126488. }
  126489. // After Observable
  126490. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  126491. }
  126492. };
  126493. /**
  126494. * Resets the different information of the group to prepare a new frame
  126495. * @hidden
  126496. */
  126497. RenderingManager.prototype.reset = function () {
  126498. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  126499. var renderingGroup = this._renderingGroups[index];
  126500. if (renderingGroup) {
  126501. renderingGroup.prepare();
  126502. }
  126503. }
  126504. };
  126505. /**
  126506. * Dispose and release the group and its associated resources.
  126507. * @hidden
  126508. */
  126509. RenderingManager.prototype.dispose = function () {
  126510. this.freeRenderingGroups();
  126511. this._renderingGroups.length = 0;
  126512. this._renderingGroupInfo = null;
  126513. };
  126514. /**
  126515. * Clear the info related to rendering groups preventing retention points during dispose.
  126516. */
  126517. RenderingManager.prototype.freeRenderingGroups = function () {
  126518. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  126519. var renderingGroup = this._renderingGroups[index];
  126520. if (renderingGroup) {
  126521. renderingGroup.dispose();
  126522. }
  126523. }
  126524. };
  126525. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  126526. if (this._renderingGroups[renderingGroupId] === undefined) {
  126527. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  126528. }
  126529. };
  126530. /**
  126531. * Add a sprite manager to the rendering manager in order to render it this frame.
  126532. * @param spriteManager Define the sprite manager to render
  126533. */
  126534. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  126535. var renderingGroupId = spriteManager.renderingGroupId || 0;
  126536. this._prepareRenderingGroup(renderingGroupId);
  126537. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  126538. };
  126539. /**
  126540. * Add a particle system to the rendering manager in order to render it this frame.
  126541. * @param particleSystem Define the particle system to render
  126542. */
  126543. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  126544. var renderingGroupId = particleSystem.renderingGroupId || 0;
  126545. this._prepareRenderingGroup(renderingGroupId);
  126546. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  126547. };
  126548. /**
  126549. * Add a submesh to the manager in order to render it this frame
  126550. * @param subMesh The submesh to dispatch
  126551. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  126552. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  126553. */
  126554. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  126555. if (mesh === undefined) {
  126556. mesh = subMesh.getMesh();
  126557. }
  126558. var renderingGroupId = mesh.renderingGroupId || 0;
  126559. this._prepareRenderingGroup(renderingGroupId);
  126560. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  126561. };
  126562. /**
  126563. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  126564. * This allowed control for front to back rendering or reversly depending of the special needs.
  126565. *
  126566. * @param renderingGroupId The rendering group id corresponding to its index
  126567. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  126568. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  126569. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  126570. */
  126571. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  126572. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  126573. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  126574. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  126575. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  126576. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  126577. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  126578. if (this._renderingGroups[renderingGroupId]) {
  126579. var group = this._renderingGroups[renderingGroupId];
  126580. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  126581. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  126582. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  126583. }
  126584. };
  126585. /**
  126586. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  126587. *
  126588. * @param renderingGroupId The rendering group id corresponding to its index
  126589. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126590. * @param depth Automatically clears depth between groups if true and autoClear is true.
  126591. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  126592. */
  126593. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  126594. if (depth === void 0) { depth = true; }
  126595. if (stencil === void 0) { stencil = true; }
  126596. this._autoClearDepthStencil[renderingGroupId] = {
  126597. autoClear: autoClearDepthStencil,
  126598. depth: depth,
  126599. stencil: stencil
  126600. };
  126601. };
  126602. /**
  126603. * Gets the current auto clear configuration for one rendering group of the rendering
  126604. * manager.
  126605. * @param index the rendering group index to get the information for
  126606. * @returns The auto clear setup for the requested rendering group
  126607. */
  126608. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  126609. return this._autoClearDepthStencil[index];
  126610. };
  126611. /**
  126612. * The max id used for rendering groups (not included)
  126613. */
  126614. RenderingManager.MAX_RENDERINGGROUPS = 4;
  126615. /**
  126616. * The min id used for rendering groups (included)
  126617. */
  126618. RenderingManager.MIN_RENDERINGGROUPS = 0;
  126619. /**
  126620. * Used to globally prevent autoclearing scenes.
  126621. */
  126622. RenderingManager.AUTOCLEAR = true;
  126623. return RenderingManager;
  126624. }());
  126625. /***/ }),
  126626. /***/ "./Rendering/utilityLayerRenderer.ts":
  126627. /*!*******************************************!*\
  126628. !*** ./Rendering/utilityLayerRenderer.ts ***!
  126629. \*******************************************/
  126630. /*! exports provided: UtilityLayerRenderer */
  126631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126632. "use strict";
  126633. __webpack_require__.r(__webpack_exports__);
  126634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  126635. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126636. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  126637. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  126638. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  126639. /**
  126640. * Renders a layer on top of an existing scene
  126641. */
  126642. var UtilityLayerRenderer = /** @class */ (function () {
  126643. /**
  126644. * Instantiates a UtilityLayerRenderer
  126645. * @param originalScene the original scene that will be rendered on top of
  126646. * @param handleEvents boolean indicating if the utility layer should handle events
  126647. */
  126648. function UtilityLayerRenderer(
  126649. /** the original scene that will be rendered on top of */
  126650. originalScene, handleEvents) {
  126651. if (handleEvents === void 0) { handleEvents = true; }
  126652. var _this = this;
  126653. this.originalScene = originalScene;
  126654. this._pointerCaptures = {};
  126655. this._lastPointerEvents = {};
  126656. /**
  126657. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  126658. */
  126659. this.pickUtilitySceneFirst = true;
  126660. /**
  126661. * If the utility layer should automatically be rendered on top of existing scene
  126662. */
  126663. this.shouldRender = true;
  126664. /**
  126665. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  126666. */
  126667. this.onlyCheckPointerDownEvents = true;
  126668. /**
  126669. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  126670. */
  126671. this.processAllEvents = false;
  126672. /**
  126673. * Observable raised when the pointer move from the utility layer scene to the main scene
  126674. */
  126675. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  126676. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  126677. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  126678. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  126679. this.utilityLayerScene._allowPostProcessClearColor = false;
  126680. originalScene.getEngine().scenes.pop();
  126681. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  126682. this.utilityLayerScene.detachControl();
  126683. if (handleEvents) {
  126684. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  126685. if (!_this.utilityLayerScene.activeCamera) {
  126686. return;
  126687. }
  126688. if (!_this.processAllEvents) {
  126689. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  126690. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  126691. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  126692. return;
  126693. }
  126694. }
  126695. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  126696. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  126697. var pointerEvent = (prePointerInfo.event);
  126698. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  126699. _this._pointerCaptures[pointerEvent.pointerId] = false;
  126700. return;
  126701. }
  126702. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  126703. if (!prePointerInfo.ray && utilityScenePick) {
  126704. prePointerInfo.ray = utilityScenePick.ray;
  126705. }
  126706. // always fire the prepointer oversvable
  126707. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  126708. // allow every non pointer down event to flow to the utility layer
  126709. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  126710. if (!prePointerInfo.skipOnPointerObservable) {
  126711. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  126712. }
  126713. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  126714. _this._pointerCaptures[pointerEvent.pointerId] = false;
  126715. }
  126716. return;
  126717. }
  126718. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  126719. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  126720. if (utilityScenePick && utilityScenePick.hit) {
  126721. if (!prePointerInfo.skipOnPointerObservable) {
  126722. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  126723. }
  126724. prePointerInfo.skipOnPointerObservable = true;
  126725. }
  126726. }
  126727. else {
  126728. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  126729. var pointerEvent_1 = (prePointerInfo.event);
  126730. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  126731. if (originalScenePick && utilityScenePick) {
  126732. // No pick in utility scene
  126733. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  126734. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  126735. // We touched an utility mesh present in the main scene
  126736. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  126737. prePointerInfo.skipOnPointerObservable = true;
  126738. }
  126739. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  126740. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  126741. }
  126742. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  126743. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  126744. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  126745. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  126746. }
  126747. }
  126748. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  126749. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  126750. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  126751. // If a previous utility layer set this, do not unset this
  126752. if (!prePointerInfo.skipOnPointerObservable) {
  126753. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  126754. }
  126755. }
  126756. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  126757. // We have a pick in both scenes but main is closer than utility
  126758. // We touched an utility mesh present in the main scene
  126759. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  126760. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  126761. prePointerInfo.skipOnPointerObservable = true;
  126762. }
  126763. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  126764. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  126765. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  126766. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  126767. }
  126768. }
  126769. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  126770. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  126771. }
  126772. }
  126773. }
  126774. });
  126775. // As a newly added utility layer will be rendered over the screen last, it's pointer events should be processed first
  126776. if (this._originalPointerObserver) {
  126777. originalScene.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver);
  126778. }
  126779. }
  126780. // Render directly on top of existing scene without clearing
  126781. this.utilityLayerScene.autoClear = false;
  126782. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  126783. if (_this.shouldRender) {
  126784. _this.render();
  126785. }
  126786. });
  126787. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  126788. _this.dispose();
  126789. });
  126790. this._updateCamera();
  126791. }
  126792. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  126793. /**
  126794. * 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)
  126795. */
  126796. get: function () {
  126797. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  126798. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  126799. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  126800. UtilityLayerRenderer._DefaultUtilityLayer = null;
  126801. });
  126802. }
  126803. return UtilityLayerRenderer._DefaultUtilityLayer;
  126804. },
  126805. enumerable: true,
  126806. configurable: true
  126807. });
  126808. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  126809. /**
  126810. * 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)
  126811. */
  126812. get: function () {
  126813. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  126814. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  126815. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  126816. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  126817. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  126818. });
  126819. }
  126820. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  126821. },
  126822. enumerable: true,
  126823. configurable: true
  126824. });
  126825. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  126826. if (!prePointerInfo.skipOnPointerObservable) {
  126827. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  126828. this._lastPointerEvents[pointerEvent.pointerId] = true;
  126829. }
  126830. };
  126831. /**
  126832. * Renders the utility layers scene on top of the original scene
  126833. */
  126834. UtilityLayerRenderer.prototype.render = function () {
  126835. this._updateCamera();
  126836. if (this.utilityLayerScene.activeCamera) {
  126837. // Set the camera's scene to utility layers scene
  126838. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  126839. var camera = this.utilityLayerScene.activeCamera;
  126840. camera._scene = this.utilityLayerScene;
  126841. if (camera.leftCamera) {
  126842. camera.leftCamera._scene = this.utilityLayerScene;
  126843. }
  126844. if (camera.rightCamera) {
  126845. camera.rightCamera._scene = this.utilityLayerScene;
  126846. }
  126847. this.utilityLayerScene.render(false);
  126848. // Reset camera's scene back to original
  126849. camera._scene = oldScene;
  126850. if (camera.leftCamera) {
  126851. camera.leftCamera._scene = oldScene;
  126852. }
  126853. if (camera.rightCamera) {
  126854. camera.rightCamera._scene = oldScene;
  126855. }
  126856. }
  126857. };
  126858. /**
  126859. * Disposes of the renderer
  126860. */
  126861. UtilityLayerRenderer.prototype.dispose = function () {
  126862. this.onPointerOutObservable.clear();
  126863. if (this._afterRenderObserver) {
  126864. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  126865. }
  126866. if (this._sceneDisposeObserver) {
  126867. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  126868. }
  126869. if (this._originalPointerObserver) {
  126870. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  126871. }
  126872. this.utilityLayerScene.dispose();
  126873. };
  126874. UtilityLayerRenderer.prototype._updateCamera = function () {
  126875. if (this.originalScene.activeCameras.length > 1) {
  126876. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  126877. }
  126878. else {
  126879. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  126880. }
  126881. };
  126882. UtilityLayerRenderer._DefaultUtilityLayer = null;
  126883. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  126884. return UtilityLayerRenderer;
  126885. }());
  126886. /***/ }),
  126887. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  126888. /*!*****************************************************************!*\
  126889. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  126890. \*****************************************************************/
  126891. /*! exports provided: backgroundFragmentDeclaration */
  126892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126893. "use strict";
  126894. __webpack_require__.r(__webpack_exports__);
  126895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  126896. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  126897. var name = 'backgroundFragmentDeclaration';
  126898. 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";
  126899. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  126900. /** @hidden */
  126901. var backgroundFragmentDeclaration = { name: name, shader: shader };
  126902. /***/ }),
  126903. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  126904. /*!************************************************************!*\
  126905. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  126906. \************************************************************/
  126907. /*! exports provided: backgroundUboDeclaration */
  126908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126909. "use strict";
  126910. __webpack_require__.r(__webpack_exports__);
  126911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  126912. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  126913. var name = 'backgroundUboDeclaration';
  126914. 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};";
  126915. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  126916. /** @hidden */
  126917. var backgroundUboDeclaration = { name: name, shader: shader };
  126918. /***/ }),
  126919. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  126920. /*!***************************************************************!*\
  126921. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  126922. \***************************************************************/
  126923. /*! exports provided: backgroundVertexDeclaration */
  126924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126925. "use strict";
  126926. __webpack_require__.r(__webpack_exports__);
  126927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  126928. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  126929. var name = 'backgroundVertexDeclaration';
  126930. 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";
  126931. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  126932. /** @hidden */
  126933. var backgroundVertexDeclaration = { name: name, shader: shader };
  126934. /***/ }),
  126935. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  126936. /*!****************************************************!*\
  126937. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  126938. \****************************************************/
  126939. /*! exports provided: bonesDeclaration */
  126940. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126941. "use strict";
  126942. __webpack_require__.r(__webpack_exports__);
  126943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  126944. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  126945. var name = 'bonesDeclaration';
  126946. 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";
  126947. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  126948. /** @hidden */
  126949. var bonesDeclaration = { name: name, shader: shader };
  126950. /***/ }),
  126951. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  126952. /*!***********************************************!*\
  126953. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  126954. \***********************************************/
  126955. /*! exports provided: bonesVertex */
  126956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126957. "use strict";
  126958. __webpack_require__.r(__webpack_exports__);
  126959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  126960. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  126961. var name = 'bonesVertex';
  126962. 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";
  126963. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  126964. /** @hidden */
  126965. var bonesVertex = { name: name, shader: shader };
  126966. /***/ }),
  126967. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  126968. /*!************************************************!*\
  126969. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  126970. \************************************************/
  126971. /*! exports provided: bumpFragment */
  126972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126973. "use strict";
  126974. __webpack_require__.r(__webpack_exports__);
  126975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  126976. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  126977. var name = 'bumpFragment';
  126978. var shader = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else\nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,vec2(1.,1.));\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif";
  126979. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  126980. /** @hidden */
  126981. var bumpFragment = { name: name, shader: shader };
  126982. /***/ }),
  126983. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  126984. /*!*********************************************************!*\
  126985. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  126986. \*********************************************************/
  126987. /*! exports provided: bumpFragmentFunctions */
  126988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126989. "use strict";
  126990. __webpack_require__.r(__webpack_exports__);
  126991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  126992. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  126993. var name = 'bumpFragmentFunctions';
  126994. var shader = "#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv,sampler2D textureSampler,float scale)\n{\nvec3 map=texture2D(textureSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=tangentSpaceParams.x;\nbitangent*=tangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\n#endif\n#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nreturn perturbNormal(cotangentFrame,uv,bumpSampler,vBumpInfos.y);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\nreturn cotangent_frame(normal,p,uv,vTangentSpaceParams);\n}\n#endif\n#if defined(BUMP) && defined(PARALLAX)\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif";
  126995. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  126996. /** @hidden */
  126997. var bumpFragmentFunctions = { name: name, shader: shader };
  126998. /***/ }),
  126999. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  127000. /*!**********************************************!*\
  127001. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  127002. \**********************************************/
  127003. /*! exports provided: bumpVertex */
  127004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127005. "use strict";
  127006. __webpack_require__.r(__webpack_exports__);
  127007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  127008. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127009. var name = 'bumpVertex';
  127010. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";
  127011. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127012. /** @hidden */
  127013. var bumpVertex = { name: name, shader: shader };
  127014. /***/ }),
  127015. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  127016. /*!*********************************************************!*\
  127017. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  127018. \*********************************************************/
  127019. /*! exports provided: bumpVertexDeclaration */
  127020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127021. "use strict";
  127022. __webpack_require__.r(__webpack_exports__);
  127023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  127024. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127025. var name = 'bumpVertexDeclaration';
  127026. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  127027. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127028. /** @hidden */
  127029. var bumpVertexDeclaration = { name: name, shader: shader };
  127030. /***/ }),
  127031. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  127032. /*!*****************************************************!*\
  127033. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  127034. \*****************************************************/
  127035. /*! exports provided: clipPlaneFragment */
  127036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127037. "use strict";
  127038. __webpack_require__.r(__webpack_exports__);
  127039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  127040. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127041. var name = 'clipPlaneFragment';
  127042. 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";
  127043. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127044. /** @hidden */
  127045. var clipPlaneFragment = { name: name, shader: shader };
  127046. /***/ }),
  127047. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  127048. /*!****************************************************************!*\
  127049. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  127050. \****************************************************************/
  127051. /*! exports provided: clipPlaneFragmentDeclaration */
  127052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127053. "use strict";
  127054. __webpack_require__.r(__webpack_exports__);
  127055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  127056. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127057. var name = 'clipPlaneFragmentDeclaration';
  127058. 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";
  127059. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127060. /** @hidden */
  127061. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  127062. /***/ }),
  127063. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  127064. /*!*****************************************************************!*\
  127065. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  127066. \*****************************************************************/
  127067. /*! exports provided: clipPlaneFragmentDeclaration2 */
  127068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127069. "use strict";
  127070. __webpack_require__.r(__webpack_exports__);
  127071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  127072. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127073. var name = 'clipPlaneFragmentDeclaration2';
  127074. 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";
  127075. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127076. /** @hidden */
  127077. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  127078. /***/ }),
  127079. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  127080. /*!***************************************************!*\
  127081. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  127082. \***************************************************/
  127083. /*! exports provided: clipPlaneVertex */
  127084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127085. "use strict";
  127086. __webpack_require__.r(__webpack_exports__);
  127087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  127088. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127089. var name = 'clipPlaneVertex';
  127090. 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";
  127091. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127092. /** @hidden */
  127093. var clipPlaneVertex = { name: name, shader: shader };
  127094. /***/ }),
  127095. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  127096. /*!**************************************************************!*\
  127097. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  127098. \**************************************************************/
  127099. /*! exports provided: clipPlaneVertexDeclaration */
  127100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127101. "use strict";
  127102. __webpack_require__.r(__webpack_exports__);
  127103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  127104. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127105. var name = 'clipPlaneVertexDeclaration';
  127106. 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";
  127107. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127108. /** @hidden */
  127109. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  127110. /***/ }),
  127111. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  127112. /*!***************************************************************!*\
  127113. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  127114. \***************************************************************/
  127115. /*! exports provided: clipPlaneVertexDeclaration2 */
  127116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127117. "use strict";
  127118. __webpack_require__.r(__webpack_exports__);
  127119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  127120. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127121. var name = 'clipPlaneVertexDeclaration2';
  127122. 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";
  127123. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127124. /** @hidden */
  127125. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  127126. /***/ }),
  127127. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  127128. /*!**************************************************************!*\
  127129. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  127130. \**************************************************************/
  127131. /*! exports provided: defaultFragmentDeclaration */
  127132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127133. "use strict";
  127134. __webpack_require__.r(__webpack_exports__);
  127135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  127136. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127137. var name = 'defaultFragmentDeclaration';
  127138. 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";
  127139. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127140. /** @hidden */
  127141. var defaultFragmentDeclaration = { name: name, shader: shader };
  127142. /***/ }),
  127143. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  127144. /*!*********************************************************!*\
  127145. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  127146. \*********************************************************/
  127147. /*! exports provided: defaultUboDeclaration */
  127148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127149. "use strict";
  127150. __webpack_require__.r(__webpack_exports__);
  127151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  127152. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127153. var name = 'defaultUboDeclaration';
  127154. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};\n";
  127155. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127156. /** @hidden */
  127157. var defaultUboDeclaration = { name: name, shader: shader };
  127158. /***/ }),
  127159. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  127160. /*!************************************************************!*\
  127161. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  127162. \************************************************************/
  127163. /*! exports provided: defaultVertexDeclaration */
  127164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127165. "use strict";
  127166. __webpack_require__.r(__webpack_exports__);
  127167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  127168. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127169. var name = 'defaultVertexDeclaration';
  127170. 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";
  127171. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127172. /** @hidden */
  127173. var defaultVertexDeclaration = { name: name, shader: shader };
  127174. /***/ }),
  127175. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  127176. /*!************************************************!*\
  127177. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  127178. \************************************************/
  127179. /*! exports provided: depthPrePass */
  127180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127181. "use strict";
  127182. __webpack_require__.r(__webpack_exports__);
  127183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  127184. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127185. var name = 'depthPrePass';
  127186. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  127187. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127188. /** @hidden */
  127189. var depthPrePass = { name: name, shader: shader };
  127190. /***/ }),
  127191. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  127192. /*!***********************************************!*\
  127193. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  127194. \***********************************************/
  127195. /*! exports provided: fogFragment */
  127196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127197. "use strict";
  127198. __webpack_require__.r(__webpack_exports__);
  127199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  127200. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127201. var name = 'fogFragment';
  127202. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  127203. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127204. /** @hidden */
  127205. var fogFragment = { name: name, shader: shader };
  127206. /***/ }),
  127207. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  127208. /*!**********************************************************!*\
  127209. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  127210. \**********************************************************/
  127211. /*! exports provided: fogFragmentDeclaration */
  127212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127213. "use strict";
  127214. __webpack_require__.r(__webpack_exports__);
  127215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  127216. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127217. var name = 'fogFragmentDeclaration';
  127218. 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";
  127219. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127220. /** @hidden */
  127221. var fogFragmentDeclaration = { name: name, shader: shader };
  127222. /***/ }),
  127223. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  127224. /*!*********************************************!*\
  127225. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  127226. \*********************************************/
  127227. /*! exports provided: fogVertex */
  127228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127229. "use strict";
  127230. __webpack_require__.r(__webpack_exports__);
  127231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  127232. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127233. var name = 'fogVertex';
  127234. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  127235. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127236. /** @hidden */
  127237. var fogVertex = { name: name, shader: shader };
  127238. /***/ }),
  127239. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  127240. /*!********************************************************!*\
  127241. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  127242. \********************************************************/
  127243. /*! exports provided: fogVertexDeclaration */
  127244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127245. "use strict";
  127246. __webpack_require__.r(__webpack_exports__);
  127247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  127248. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127249. var name = 'fogVertexDeclaration';
  127250. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  127251. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127252. /** @hidden */
  127253. var fogVertexDeclaration = { name: name, shader: shader };
  127254. /***/ }),
  127255. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  127256. /*!***************************************************!*\
  127257. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  127258. \***************************************************/
  127259. /*! exports provided: fresnelFunction */
  127260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127261. "use strict";
  127262. __webpack_require__.r(__webpack_exports__);
  127263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  127264. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127265. var name = 'fresnelFunction';
  127266. 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";
  127267. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127268. /** @hidden */
  127269. var fresnelFunction = { name: name, shader: shader };
  127270. /***/ }),
  127271. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  127272. /*!******************************************************!*\
  127273. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  127274. \******************************************************/
  127275. /*! exports provided: harmonicsFunctions */
  127276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127277. "use strict";
  127278. __webpack_require__.r(__webpack_exports__);
  127279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  127280. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127281. var name = 'harmonicsFunctions';
  127282. 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";
  127283. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127284. /** @hidden */
  127285. var harmonicsFunctions = { name: name, shader: shader };
  127286. /***/ }),
  127287. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  127288. /*!***************************************************!*\
  127289. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  127290. \***************************************************/
  127291. /*! exports provided: helperFunctions */
  127292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127293. "use strict";
  127294. __webpack_require__.r(__webpack_exports__);
  127295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  127296. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127297. var name = 'helperFunctions';
  127298. var shader = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";
  127299. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127300. /** @hidden */
  127301. var helperFunctions = { name: name, shader: shader };
  127302. /***/ }),
  127303. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  127304. /*!**************************************************************!*\
  127305. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  127306. \**************************************************************/
  127307. /*! exports provided: imageProcessingDeclaration */
  127308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127309. "use strict";
  127310. __webpack_require__.r(__webpack_exports__);
  127311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  127312. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127313. var name = 'imageProcessingDeclaration';
  127314. 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";
  127315. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127316. /** @hidden */
  127317. var imageProcessingDeclaration = { name: name, shader: shader };
  127318. /***/ }),
  127319. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  127320. /*!************************************************************!*\
  127321. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  127322. \************************************************************/
  127323. /*! exports provided: imageProcessingFunctions */
  127324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127325. "use strict";
  127326. __webpack_require__.r(__webpack_exports__);
  127327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  127328. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127329. var name = 'imageProcessingFunctions';
  127330. var shader = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=saturate(color);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=saturate(result.rgb);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  127331. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127332. /** @hidden */
  127333. var imageProcessingFunctions = { name: name, shader: shader };
  127334. /***/ }),
  127335. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  127336. /*!********************************************************!*\
  127337. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  127338. \********************************************************/
  127339. /*! exports provided: instancesDeclaration */
  127340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127341. "use strict";
  127342. __webpack_require__.r(__webpack_exports__);
  127343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  127344. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127345. var name = 'instancesDeclaration';
  127346. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  127347. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127348. /** @hidden */
  127349. var instancesDeclaration = { name: name, shader: shader };
  127350. /***/ }),
  127351. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  127352. /*!***************************************************!*\
  127353. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  127354. \***************************************************/
  127355. /*! exports provided: instancesVertex */
  127356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127357. "use strict";
  127358. __webpack_require__.r(__webpack_exports__);
  127359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  127360. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127361. var name = 'instancesVertex';
  127362. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  127363. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127364. /** @hidden */
  127365. var instancesVertex = { name: name, shader: shader };
  127366. /***/ }),
  127367. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  127368. /*!******************************************************!*\
  127369. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  127370. \******************************************************/
  127371. /*! exports provided: kernelBlurFragment */
  127372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127373. "use strict";
  127374. __webpack_require__.r(__webpack_exports__);
  127375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  127376. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127377. var name = 'kernelBlurFragment';
  127378. 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";
  127379. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127380. /** @hidden */
  127381. var kernelBlurFragment = { name: name, shader: shader };
  127382. /***/ }),
  127383. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  127384. /*!*******************************************************!*\
  127385. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  127386. \*******************************************************/
  127387. /*! exports provided: kernelBlurFragment2 */
  127388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127389. "use strict";
  127390. __webpack_require__.r(__webpack_exports__);
  127391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  127392. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127393. var name = 'kernelBlurFragment2';
  127394. 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";
  127395. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127396. /** @hidden */
  127397. var kernelBlurFragment2 = { name: name, shader: shader };
  127398. /***/ }),
  127399. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  127400. /*!****************************************************************!*\
  127401. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  127402. \****************************************************************/
  127403. /*! exports provided: kernelBlurVaryingDeclaration */
  127404. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127405. "use strict";
  127406. __webpack_require__.r(__webpack_exports__);
  127407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  127408. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127409. var name = 'kernelBlurVaryingDeclaration';
  127410. var shader = "varying vec2 sampleCoord{X};";
  127411. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127412. /** @hidden */
  127413. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  127414. /***/ }),
  127415. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  127416. /*!****************************************************!*\
  127417. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  127418. \****************************************************/
  127419. /*! exports provided: kernelBlurVertex */
  127420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127421. "use strict";
  127422. __webpack_require__.r(__webpack_exports__);
  127423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  127424. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127425. var name = 'kernelBlurVertex';
  127426. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  127427. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127428. /** @hidden */
  127429. var kernelBlurVertex = { name: name, shader: shader };
  127430. /***/ }),
  127431. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  127432. /*!*************************************************!*\
  127433. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  127434. \*************************************************/
  127435. /*! exports provided: lightFragment */
  127436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127437. "use strict";
  127438. __webpack_require__.r(__webpack_exports__);
  127439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  127440. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127441. var name = 'lightFragment';
  127442. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicTangent,anisotropicBitangent,anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\n\npreInfo.roughness=sheenIntensity;\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearCoatRoughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearCoatNormalW,clearCoatAARoughnessFactors.x,clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearCoatNdotVRefract,preInfo.L,clearCoatNormalW,clearCoatColor,clearCoatThickness,clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif";
  127443. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127444. /** @hidden */
  127445. var lightFragment = { name: name, shader: shader };
  127446. /***/ }),
  127447. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  127448. /*!************************************************************!*\
  127449. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  127450. \************************************************************/
  127451. /*! exports provided: lightFragmentDeclaration */
  127452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127453. "use strict";
  127454. __webpack_require__.r(__webpack_exports__);
  127455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  127456. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127457. var name = 'lightFragmentDeclaration';
  127458. 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";
  127459. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127460. /** @hidden */
  127461. var lightFragmentDeclaration = { name: name, shader: shader };
  127462. /***/ }),
  127463. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  127464. /*!*******************************************************!*\
  127465. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  127466. \*******************************************************/
  127467. /*! exports provided: lightUboDeclaration */
  127468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127469. "use strict";
  127470. __webpack_require__.r(__webpack_exports__);
  127471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  127472. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127473. var name = 'lightUboDeclaration';
  127474. 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";
  127475. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127476. /** @hidden */
  127477. var lightUboDeclaration = { name: name, shader: shader };
  127478. /***/ }),
  127479. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  127480. /*!***********************************************************!*\
  127481. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  127482. \***********************************************************/
  127483. /*! exports provided: lightsFragmentFunctions */
  127484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127485. "use strict";
  127486. __webpack_require__.r(__webpack_exports__);
  127487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  127488. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127489. var name = 'lightsFragmentFunctions';
  127490. 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}";
  127491. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127492. /** @hidden */
  127493. var lightsFragmentFunctions = { name: name, shader: shader };
  127494. /***/ }),
  127495. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  127496. /*!*******************************************************!*\
  127497. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  127498. \*******************************************************/
  127499. /*! exports provided: logDepthDeclaration */
  127500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127501. "use strict";
  127502. __webpack_require__.r(__webpack_exports__);
  127503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  127504. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127505. var name = 'logDepthDeclaration';
  127506. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  127507. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127508. /** @hidden */
  127509. var logDepthDeclaration = { name: name, shader: shader };
  127510. /***/ }),
  127511. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  127512. /*!****************************************************!*\
  127513. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  127514. \****************************************************/
  127515. /*! exports provided: logDepthFragment */
  127516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127517. "use strict";
  127518. __webpack_require__.r(__webpack_exports__);
  127519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  127520. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127521. var name = 'logDepthFragment';
  127522. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  127523. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127524. /** @hidden */
  127525. var logDepthFragment = { name: name, shader: shader };
  127526. /***/ }),
  127527. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  127528. /*!**************************************************!*\
  127529. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  127530. \**************************************************/
  127531. /*! exports provided: logDepthVertex */
  127532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127533. "use strict";
  127534. __webpack_require__.r(__webpack_exports__);
  127535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  127536. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127537. var name = 'logDepthVertex';
  127538. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  127539. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127540. /** @hidden */
  127541. var logDepthVertex = { name: name, shader: shader };
  127542. /***/ }),
  127543. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  127544. /*!******************************************************!*\
  127545. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  127546. \******************************************************/
  127547. /*! exports provided: morphTargetsVertex */
  127548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127549. "use strict";
  127550. __webpack_require__.r(__webpack_exports__);
  127551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  127552. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127553. var name = 'morphTargetsVertex';
  127554. 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";
  127555. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127556. /** @hidden */
  127557. var morphTargetsVertex = { name: name, shader: shader };
  127558. /***/ }),
  127559. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  127560. /*!*****************************************************************!*\
  127561. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  127562. \*****************************************************************/
  127563. /*! exports provided: morphTargetsVertexDeclaration */
  127564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127565. "use strict";
  127566. __webpack_require__.r(__webpack_exports__);
  127567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  127568. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127569. var name = 'morphTargetsVertexDeclaration';
  127570. 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";
  127571. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127572. /** @hidden */
  127573. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  127574. /***/ }),
  127575. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  127576. /*!***********************************************************************!*\
  127577. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  127578. \***********************************************************************/
  127579. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  127580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127581. "use strict";
  127582. __webpack_require__.r(__webpack_exports__);
  127583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  127584. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127585. var name = 'morphTargetsVertexGlobalDeclaration';
  127586. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  127587. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127588. /** @hidden */
  127589. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  127590. /***/ }),
  127591. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  127592. /*!**********************************************************!*\
  127593. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  127594. \**********************************************************/
  127595. /*! exports provided: mrtFragmentDeclaration */
  127596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127597. "use strict";
  127598. __webpack_require__.r(__webpack_exports__);
  127599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  127600. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127601. var name = 'mrtFragmentDeclaration';
  127602. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  127603. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127604. /** @hidden */
  127605. var mrtFragmentDeclaration = { name: name, shader: shader };
  127606. /***/ }),
  127607. /***/ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts":
  127608. /*!****************************************************!*\
  127609. !*** ./Shaders/ShadersInclude/pbrBRDFFunctions.ts ***!
  127610. \****************************************************/
  127611. /*! exports provided: pbrBRDFFunctions */
  127612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127613. "use strict";
  127614. __webpack_require__.r(__webpack_exports__);
  127615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrBRDFFunctions", function() { return pbrBRDFFunctions; });
  127616. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127617. var name = 'pbrBRDFFunctions';
  127618. var shader = "\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,vec2 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec2 getBRDFLookup(float NdotV,float perceptualRoughness,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec2 brdfLookup=texture2D(brdfSampler,UV).xy;\nreturn brdfLookup;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,vec2 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(REFLECTION)\n\nvec2 getCharlieSheenAnalyticalBRDFLookup_RomainGuy(float NoV,float roughness) {\nconst vec3 c0=vec3(0.95,1250.0,0.0095);\nconst vec4 c1=vec4(0.04,0.2,0.3,0.2);\nfloat a=1.0-NoV;\nfloat b=1.0-roughness;\nfloat n=pow(c1.x+a,64.0);\nfloat e=b-c0.x;\nfloat g=exp2(-(e*e)*c0.y);\nfloat f=b+c1.y;\nfloat a2=a*a;\nfloat a3=a2*a;\nfloat c=n*g+c1.z*(a+c1.w)*roughness+f*f*a3*a3*a2;\nfloat r=min(c,18.0);\nreturn vec2(r,r*c0.z);\n}\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,float NdotV,float sheenAlphaG) {\nvec2 environmentSheenBrdf=getCharlieSheenAnalyticalBRDFLookup_RomainGuy(NdotV,sheenAlphaG);\nvec3 reflectance=reflectance0*environmentSheenBrdf.x+environmentSheenBrdf.y;\nreturn reflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\n\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n";
  127619. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127620. /** @hidden */
  127621. var pbrBRDFFunctions = { name: name, shader: shader };
  127622. /***/ }),
  127623. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  127624. /*!********************************************!*\
  127625. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  127626. \********************************************/
  127627. /*! exports provided: pbrDebug */
  127628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127629. "use strict";
  127630. __webpack_require__.r(__webpack_exports__);
  127631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  127632. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127633. var name = 'pbrDebug';
  127634. var shader = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w<vDebugMode.x) {\nreturn;\n}\n\n#if DEBUGMODE == 1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 3 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 4 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 5\n\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE == 7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\n\ngl_FragColor.rgb=clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n\n#elif DEBUGMODE == 20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE == 21 && defined(AMBIENT)\ngl_FragColor.rgb=ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE == 22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE == 23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=clearCoatMapData.rgb;\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearCoatTintMapData.rgb;\n#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenMapData.rgb;\n#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropyMapData.rgb;\n\n#elif DEBUGMODE == 40 && defined(REFRACTION)\n\ngl_FragColor.rgb=environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=environmentClearCoatRadiance;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 54 && defined(REFLECTION)\ngl_FragColor.rgb=environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 65 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 66 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n\n#elif DEBUGMODE == 70 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 71 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 72 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 73 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 74 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 75 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 76 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 77\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#endif";
  127635. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127636. /** @hidden */
  127637. var pbrDebug = { name: name, shader: shader };
  127638. /***/ }),
  127639. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts":
  127640. /*!*********************************************************************!*\
  127641. !*** ./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts ***!
  127642. \*********************************************************************/
  127643. /*! exports provided: pbrDirectLightingFalloffFunctions */
  127644. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127645. "use strict";
  127646. __webpack_require__.r(__webpack_exports__);
  127647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFalloffFunctions", function() { return pbrDirectLightingFalloffFunctions; });
  127648. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127649. var name = 'pbrDirectLightingFalloffFunctions';
  127650. var shader = "float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";
  127651. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127652. /** @hidden */
  127653. var pbrDirectLightingFalloffFunctions = { name: name, shader: shader };
  127654. /***/ }),
  127655. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts":
  127656. /*!**************************************************************!*\
  127657. !*** ./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts ***!
  127658. \**************************************************************/
  127659. /*! exports provided: pbrDirectLightingFunctions */
  127660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127661. "use strict";
  127662. __webpack_require__.r(__webpack_exports__);
  127663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFunctions", function() { return pbrDirectLightingFunctions; });
  127664. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127665. var name = 'pbrDirectLightingFunctions';
  127666. var shader = "#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat visibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat visibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat visibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*visibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nfloat sheenTerm=distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
  127667. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127668. /** @hidden */
  127669. var pbrDirectLightingFunctions = { name: name, shader: shader };
  127670. /***/ }),
  127671. /***/ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts":
  127672. /*!*******************************************************************!*\
  127673. !*** ./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts ***!
  127674. \*******************************************************************/
  127675. /*! exports provided: pbrDirectLightingSetupFunctions */
  127676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127677. "use strict";
  127678. __webpack_require__.r(__webpack_exports__);
  127679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingSetupFunctions", function() { return pbrDirectLightingSetupFunctions; });
  127680. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127681. var name = 'pbrDirectLightingSetupFunctions';
  127682. var shader = "\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.NdotL=saturateEps(dot(N,result.L));\nresult.VdotH=saturate(dot(V,result.H));\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.NdotL=saturateEps(dot(N,result.L));\nresult.VdotH=saturate(dot(V,result.H));\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";
  127683. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127684. /** @hidden */
  127685. var pbrDirectLightingSetupFunctions = { name: name, shader: shader };
  127686. /***/ }),
  127687. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  127688. /*!**********************************************************!*\
  127689. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  127690. \**********************************************************/
  127691. /*! exports provided: pbrFragmentDeclaration */
  127692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127693. "use strict";
  127694. __webpack_require__.r(__webpack_exports__);
  127695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  127696. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127697. var name = 'pbrFragmentDeclaration';
  127698. 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\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif";
  127699. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127700. /** @hidden */
  127701. var pbrFragmentDeclaration = { name: name, shader: shader };
  127702. /***/ }),
  127703. /***/ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts":
  127704. /*!***************************************************************!*\
  127705. !*** ./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts ***!
  127706. \***************************************************************/
  127707. /*! exports provided: pbrFragmentExtraDeclaration */
  127708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127709. "use strict";
  127710. __webpack_require__.r(__webpack_exports__);
  127711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentExtraDeclaration", function() { return pbrFragmentExtraDeclaration; });
  127712. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127713. var name = 'pbrFragmentExtraDeclaration';
  127714. var shader = "uniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif";
  127715. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127716. /** @hidden */
  127717. var pbrFragmentExtraDeclaration = { name: name, shader: shader };
  127718. /***/ }),
  127719. /***/ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts":
  127720. /*!******************************************************************!*\
  127721. !*** ./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts ***!
  127722. \******************************************************************/
  127723. /*! exports provided: pbrFragmentSamplersDeclaration */
  127724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127725. "use strict";
  127726. __webpack_require__.r(__webpack_exports__);
  127727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentSamplersDeclaration", function() { return pbrFragmentSamplersDeclaration; });
  127728. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127729. var name = 'pbrFragmentSamplersDeclaration';
  127730. var shader = "#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef 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#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif";
  127731. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127732. /** @hidden */
  127733. var pbrFragmentSamplersDeclaration = { name: name, shader: shader };
  127734. /***/ }),
  127735. /***/ "./Shaders/ShadersInclude/pbrHelperFunctions.ts":
  127736. /*!******************************************************!*\
  127737. !*** ./Shaders/ShadersInclude/pbrHelperFunctions.ts ***!
  127738. \******************************************************/
  127739. /*! exports provided: pbrHelperFunctions */
  127740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127741. "use strict";
  127742. __webpack_require__.r(__webpack_exports__);
  127743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrHelperFunctions", function() { return pbrHelperFunctions; });
  127744. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127745. var name = 'pbrHelperFunctions';
  127746. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n#endif\n#ifdef CLEARCOAT\n\n\n\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn exp(alpha*-(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n\n\n\n\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif";
  127747. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127748. /** @hidden */
  127749. var pbrHelperFunctions = { name: name, shader: shader };
  127750. /***/ }),
  127751. /***/ "./Shaders/ShadersInclude/pbrIBLFunctions.ts":
  127752. /*!***************************************************!*\
  127753. !*** ./Shaders/ShadersInclude/pbrIBLFunctions.ts ***!
  127754. \***************************************************/
  127755. /*! exports provided: pbrIBLFunctions */
  127756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127757. "use strict";
  127758. __webpack_require__.r(__webpack_exports__);
  127759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrIBLFunctions", function() { return pbrIBLFunctions; });
  127760. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127761. var name = 'pbrIBLFunctions';
  127762. var shader = "#if defined(REFLECTION) || defined(REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(LODINREFRACTIONALPHA)\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";
  127763. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127764. /** @hidden */
  127765. var pbrIBLFunctions = { name: name, shader: shader };
  127766. /***/ }),
  127767. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  127768. /*!*****************************************************!*\
  127769. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  127770. \*****************************************************/
  127771. /*! exports provided: pbrUboDeclaration */
  127772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127773. "use strict";
  127774. __webpack_require__.r(__webpack_exports__);
  127775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  127776. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127777. var name = 'pbrUboDeclaration';
  127778. 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;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  127779. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127780. /** @hidden */
  127781. var pbrUboDeclaration = { name: name, shader: shader };
  127782. /***/ }),
  127783. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  127784. /*!********************************************************!*\
  127785. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  127786. \********************************************************/
  127787. /*! exports provided: pbrVertexDeclaration */
  127788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127789. "use strict";
  127790. __webpack_require__.r(__webpack_exports__);
  127791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  127792. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127793. var name = 'pbrVertexDeclaration';
  127794. 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\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n";
  127795. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127796. /** @hidden */
  127797. var pbrVertexDeclaration = { name: name, shader: shader };
  127798. /***/ }),
  127799. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  127800. /*!****************************************************!*\
  127801. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  127802. \****************************************************/
  127803. /*! exports provided: pointCloudVertex */
  127804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127805. "use strict";
  127806. __webpack_require__.r(__webpack_exports__);
  127807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  127808. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127809. var name = 'pointCloudVertex';
  127810. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  127811. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127812. /** @hidden */
  127813. var pointCloudVertex = { name: name, shader: shader };
  127814. /***/ }),
  127815. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  127816. /*!******************************************************!*\
  127817. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  127818. \******************************************************/
  127819. /*! exports provided: reflectionFunction */
  127820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127821. "use strict";
  127822. __webpack_require__.r(__webpack_exports__);
  127823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  127824. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127825. var name = 'reflectionFunction';
  127826. 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}";
  127827. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127828. /** @hidden */
  127829. var reflectionFunction = { name: name, shader: shader };
  127830. /***/ }),
  127831. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  127832. /*!************************************************************!*\
  127833. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  127834. \************************************************************/
  127835. /*! exports provided: shadowsFragmentFunctions */
  127836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127837. "use strict";
  127838. __webpack_require__.r(__webpack_exports__);
  127839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  127840. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127841. var name = 'shadowsFragmentFunctions';
  127842. var shader = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n";
  127843. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127844. /** @hidden */
  127845. var shadowsFragmentFunctions = { name: name, shader: shader };
  127846. /***/ }),
  127847. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  127848. /*!*************************************************!*\
  127849. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  127850. \*************************************************/
  127851. /*! exports provided: shadowsVertex */
  127852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127853. "use strict";
  127854. __webpack_require__.r(__webpack_exports__);
  127855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  127856. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127857. var name = 'shadowsVertex';
  127858. 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";
  127859. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127860. /** @hidden */
  127861. var shadowsVertex = { name: name, shader: shader };
  127862. /***/ }),
  127863. /***/ "./Shaders/anaglyph.fragment.ts":
  127864. /*!**************************************!*\
  127865. !*** ./Shaders/anaglyph.fragment.ts ***!
  127866. \**************************************/
  127867. /*! exports provided: anaglyphPixelShader */
  127868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127869. "use strict";
  127870. __webpack_require__.r(__webpack_exports__);
  127871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  127872. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127873. var name = 'anaglyphPixelShader';
  127874. 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}";
  127875. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127876. /** @hidden */
  127877. var anaglyphPixelShader = { name: name, shader: shader };
  127878. /***/ }),
  127879. /***/ "./Shaders/background.fragment.ts":
  127880. /*!****************************************!*\
  127881. !*** ./Shaders/background.fragment.ts ***!
  127882. \****************************************/
  127883. /*! exports provided: backgroundPixelShader */
  127884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127885. "use strict";
  127886. __webpack_require__.r(__webpack_exports__);
  127887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  127888. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127889. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  127890. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  127891. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  127892. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  127893. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  127894. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  127895. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  127896. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  127897. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  127898. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  127899. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  127900. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  127901. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  127902. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  127903. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  127904. var name = 'backgroundPixelShader';
  127905. var shader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n";
  127906. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127907. /** @hidden */
  127908. var backgroundPixelShader = { name: name, shader: shader };
  127909. /***/ }),
  127910. /***/ "./Shaders/background.vertex.ts":
  127911. /*!**************************************!*\
  127912. !*** ./Shaders/background.vertex.ts ***!
  127913. \**************************************/
  127914. /*! exports provided: backgroundVertexShader */
  127915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127916. "use strict";
  127917. __webpack_require__.r(__webpack_exports__);
  127918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  127919. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127920. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  127921. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  127922. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  127923. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  127924. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  127925. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  127926. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  127927. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  127928. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  127929. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  127930. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  127931. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  127932. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  127933. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  127934. var name = 'backgroundVertexShader';
  127935. 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";
  127936. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127937. /** @hidden */
  127938. var backgroundVertexShader = { name: name, shader: shader };
  127939. /***/ }),
  127940. /***/ "./Shaders/blackAndWhite.fragment.ts":
  127941. /*!*******************************************!*\
  127942. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  127943. \*******************************************/
  127944. /*! exports provided: blackAndWhitePixelShader */
  127945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127946. "use strict";
  127947. __webpack_require__.r(__webpack_exports__);
  127948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  127949. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127950. var name = 'blackAndWhitePixelShader';
  127951. 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}";
  127952. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127953. /** @hidden */
  127954. var blackAndWhitePixelShader = { name: name, shader: shader };
  127955. /***/ }),
  127956. /***/ "./Shaders/bloomMerge.fragment.ts":
  127957. /*!****************************************!*\
  127958. !*** ./Shaders/bloomMerge.fragment.ts ***!
  127959. \****************************************/
  127960. /*! exports provided: bloomMergePixelShader */
  127961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127962. "use strict";
  127963. __webpack_require__.r(__webpack_exports__);
  127964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  127965. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127966. var name = 'bloomMergePixelShader';
  127967. 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";
  127968. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127969. /** @hidden */
  127970. var bloomMergePixelShader = { name: name, shader: shader };
  127971. /***/ }),
  127972. /***/ "./Shaders/chromaticAberration.fragment.ts":
  127973. /*!*************************************************!*\
  127974. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  127975. \*************************************************/
  127976. /*! exports provided: chromaticAberrationPixelShader */
  127977. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127978. "use strict";
  127979. __webpack_require__.r(__webpack_exports__);
  127980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  127981. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127982. var name = 'chromaticAberrationPixelShader';
  127983. 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}";
  127984. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127985. /** @hidden */
  127986. var chromaticAberrationPixelShader = { name: name, shader: shader };
  127987. /***/ }),
  127988. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  127989. /*!***********************************************!*\
  127990. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  127991. \***********************************************/
  127992. /*! exports provided: circleOfConfusionPixelShader */
  127993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127994. "use strict";
  127995. __webpack_require__.r(__webpack_exports__);
  127996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  127997. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127998. var name = 'circleOfConfusionPixelShader';
  127999. 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";
  128000. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128001. /** @hidden */
  128002. var circleOfConfusionPixelShader = { name: name, shader: shader };
  128003. /***/ }),
  128004. /***/ "./Shaders/color.fragment.ts":
  128005. /*!***********************************!*\
  128006. !*** ./Shaders/color.fragment.ts ***!
  128007. \***********************************/
  128008. /*! exports provided: colorPixelShader */
  128009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128010. "use strict";
  128011. __webpack_require__.r(__webpack_exports__);
  128012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  128013. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128014. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  128015. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128016. var name = 'colorPixelShader';
  128017. var shader = "#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include<clipPlaneFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";
  128018. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128019. /** @hidden */
  128020. var colorPixelShader = { name: name, shader: shader };
  128021. /***/ }),
  128022. /***/ "./Shaders/color.vertex.ts":
  128023. /*!*********************************!*\
  128024. !*** ./Shaders/color.vertex.ts ***!
  128025. \*********************************/
  128026. /*! exports provided: colorVertexShader */
  128027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128028. "use strict";
  128029. __webpack_require__.r(__webpack_exports__);
  128030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  128031. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128032. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128033. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  128034. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128035. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128036. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128037. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128038. var name = 'colorVertexShader';
  128039. var shader = "\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<clipPlaneVertexDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\n#include<clipPlaneVertex>\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";
  128040. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128041. /** @hidden */
  128042. var colorVertexShader = { name: name, shader: shader };
  128043. /***/ }),
  128044. /***/ "./Shaders/colorCorrection.fragment.ts":
  128045. /*!*********************************************!*\
  128046. !*** ./Shaders/colorCorrection.fragment.ts ***!
  128047. \*********************************************/
  128048. /*! exports provided: colorCorrectionPixelShader */
  128049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128050. "use strict";
  128051. __webpack_require__.r(__webpack_exports__);
  128052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  128053. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128054. var name = 'colorCorrectionPixelShader';
  128055. 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}";
  128056. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128057. /** @hidden */
  128058. var colorCorrectionPixelShader = { name: name, shader: shader };
  128059. /***/ }),
  128060. /***/ "./Shaders/convolution.fragment.ts":
  128061. /*!*****************************************!*\
  128062. !*** ./Shaders/convolution.fragment.ts ***!
  128063. \*****************************************/
  128064. /*! exports provided: convolutionPixelShader */
  128065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128066. "use strict";
  128067. __webpack_require__.r(__webpack_exports__);
  128068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  128069. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128070. var name = 'convolutionPixelShader';
  128071. 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}";
  128072. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128073. /** @hidden */
  128074. var convolutionPixelShader = { name: name, shader: shader };
  128075. /***/ }),
  128076. /***/ "./Shaders/default.fragment.ts":
  128077. /*!*************************************!*\
  128078. !*** ./Shaders/default.fragment.ts ***!
  128079. \*************************************/
  128080. /*! exports provided: defaultPixelShader */
  128081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128082. "use strict";
  128083. __webpack_require__.r(__webpack_exports__);
  128084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  128085. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128086. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  128087. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  128088. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128089. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128090. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128091. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  128092. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  128093. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  128094. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  128095. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128096. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128097. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  128098. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  128099. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  128100. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  128101. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128102. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  128103. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  128104. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  128105. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  128106. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  128107. var name = 'defaultPixelShader';
  128108. 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";
  128109. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128110. /** @hidden */
  128111. var defaultPixelShader = { name: name, shader: shader };
  128112. /***/ }),
  128113. /***/ "./Shaders/default.vertex.ts":
  128114. /*!***********************************!*\
  128115. !*** ./Shaders/default.vertex.ts ***!
  128116. \***********************************/
  128117. /*! exports provided: defaultVertexShader */
  128118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128119. "use strict";
  128120. __webpack_require__.r(__webpack_exports__);
  128121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  128122. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128123. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  128124. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  128125. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128126. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128127. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128128. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  128129. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  128130. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  128131. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128132. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128133. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  128134. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  128135. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  128136. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  128137. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128138. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128139. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  128140. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128141. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  128142. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  128143. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  128144. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  128145. var name = 'defaultVertexShader';
  128146. 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";
  128147. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128148. /** @hidden */
  128149. var defaultVertexShader = { name: name, shader: shader };
  128150. /***/ }),
  128151. /***/ "./Shaders/depth.fragment.ts":
  128152. /*!***********************************!*\
  128153. !*** ./Shaders/depth.fragment.ts ***!
  128154. \***********************************/
  128155. /*! exports provided: depthPixelShader */
  128156. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128157. "use strict";
  128158. __webpack_require__.r(__webpack_exports__);
  128159. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  128160. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128161. var name = 'depthPixelShader';
  128162. 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}";
  128163. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128164. /** @hidden */
  128165. var depthPixelShader = { name: name, shader: shader };
  128166. /***/ }),
  128167. /***/ "./Shaders/depth.vertex.ts":
  128168. /*!*********************************!*\
  128169. !*** ./Shaders/depth.vertex.ts ***!
  128170. \*********************************/
  128171. /*! exports provided: depthVertexShader */
  128172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128173. "use strict";
  128174. __webpack_require__.r(__webpack_exports__);
  128175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  128176. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128177. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128178. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128179. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128180. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128181. var name = 'depthVertexShader';
  128182. 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}";
  128183. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128184. /** @hidden */
  128185. var depthVertexShader = { name: name, shader: shader };
  128186. /***/ }),
  128187. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  128188. /*!******************************************!*\
  128189. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  128190. \******************************************/
  128191. /*! exports provided: depthBoxBlurPixelShader */
  128192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128193. "use strict";
  128194. __webpack_require__.r(__webpack_exports__);
  128195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  128196. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128197. var name = 'depthBoxBlurPixelShader';
  128198. 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}";
  128199. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128200. /** @hidden */
  128201. var depthBoxBlurPixelShader = { name: name, shader: shader };
  128202. /***/ }),
  128203. /***/ "./Shaders/depthOfField.fragment.ts":
  128204. /*!******************************************!*\
  128205. !*** ./Shaders/depthOfField.fragment.ts ***!
  128206. \******************************************/
  128207. /*! exports provided: depthOfFieldPixelShader */
  128208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128209. "use strict";
  128210. __webpack_require__.r(__webpack_exports__);
  128211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  128212. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128213. var name = 'depthOfFieldPixelShader';
  128214. 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";
  128215. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128216. /** @hidden */
  128217. var depthOfFieldPixelShader = { name: name, shader: shader };
  128218. /***/ }),
  128219. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  128220. /*!***********************************************!*\
  128221. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  128222. \***********************************************/
  128223. /*! exports provided: depthOfFieldMergePixelShader */
  128224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128225. "use strict";
  128226. __webpack_require__.r(__webpack_exports__);
  128227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  128228. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128229. var name = 'depthOfFieldMergePixelShader';
  128230. 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";
  128231. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128232. /** @hidden */
  128233. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  128234. /***/ }),
  128235. /***/ "./Shaders/displayPass.fragment.ts":
  128236. /*!*****************************************!*\
  128237. !*** ./Shaders/displayPass.fragment.ts ***!
  128238. \*****************************************/
  128239. /*! exports provided: displayPassPixelShader */
  128240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128241. "use strict";
  128242. __webpack_require__.r(__webpack_exports__);
  128243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  128244. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128245. var name = 'displayPassPixelShader';
  128246. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  128247. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128248. /** @hidden */
  128249. var displayPassPixelShader = { name: name, shader: shader };
  128250. /***/ }),
  128251. /***/ "./Shaders/extractHighlights.fragment.ts":
  128252. /*!***********************************************!*\
  128253. !*** ./Shaders/extractHighlights.fragment.ts ***!
  128254. \***********************************************/
  128255. /*! exports provided: extractHighlightsPixelShader */
  128256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128257. "use strict";
  128258. __webpack_require__.r(__webpack_exports__);
  128259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  128260. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128261. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128262. var name = 'extractHighlightsPixelShader';
  128263. 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}";
  128264. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128265. /** @hidden */
  128266. var extractHighlightsPixelShader = { name: name, shader: shader };
  128267. /***/ }),
  128268. /***/ "./Shaders/filter.fragment.ts":
  128269. /*!************************************!*\
  128270. !*** ./Shaders/filter.fragment.ts ***!
  128271. \************************************/
  128272. /*! exports provided: filterPixelShader */
  128273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128274. "use strict";
  128275. __webpack_require__.r(__webpack_exports__);
  128276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  128277. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128278. var name = 'filterPixelShader';
  128279. 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}";
  128280. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128281. /** @hidden */
  128282. var filterPixelShader = { name: name, shader: shader };
  128283. /***/ }),
  128284. /***/ "./Shaders/fxaa.fragment.ts":
  128285. /*!**********************************!*\
  128286. !*** ./Shaders/fxaa.fragment.ts ***!
  128287. \**********************************/
  128288. /*! exports provided: fxaaPixelShader */
  128289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128290. "use strict";
  128291. __webpack_require__.r(__webpack_exports__);
  128292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  128293. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128294. var name = 'fxaaPixelShader';
  128295. 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}";
  128296. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128297. /** @hidden */
  128298. var fxaaPixelShader = { name: name, shader: shader };
  128299. /***/ }),
  128300. /***/ "./Shaders/fxaa.vertex.ts":
  128301. /*!********************************!*\
  128302. !*** ./Shaders/fxaa.vertex.ts ***!
  128303. \********************************/
  128304. /*! exports provided: fxaaVertexShader */
  128305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128306. "use strict";
  128307. __webpack_require__.r(__webpack_exports__);
  128308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  128309. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128310. var name = 'fxaaVertexShader';
  128311. 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}";
  128312. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128313. /** @hidden */
  128314. var fxaaVertexShader = { name: name, shader: shader };
  128315. /***/ }),
  128316. /***/ "./Shaders/geometry.fragment.ts":
  128317. /*!**************************************!*\
  128318. !*** ./Shaders/geometry.fragment.ts ***!
  128319. \**************************************/
  128320. /*! exports provided: geometryPixelShader */
  128321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128322. "use strict";
  128323. __webpack_require__.r(__webpack_exports__);
  128324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  128325. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128326. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  128327. var name = 'geometryPixelShader';
  128328. 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}";
  128329. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128330. /** @hidden */
  128331. var geometryPixelShader = { name: name, shader: shader };
  128332. /***/ }),
  128333. /***/ "./Shaders/geometry.vertex.ts":
  128334. /*!************************************!*\
  128335. !*** ./Shaders/geometry.vertex.ts ***!
  128336. \************************************/
  128337. /*! exports provided: geometryVertexShader */
  128338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128339. "use strict";
  128340. __webpack_require__.r(__webpack_exports__);
  128341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  128342. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128343. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128344. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128345. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128346. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128347. var name = 'geometryVertexShader';
  128348. 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}";
  128349. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128350. /** @hidden */
  128351. var geometryVertexShader = { name: name, shader: shader };
  128352. /***/ }),
  128353. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  128354. /*!*************************************************!*\
  128355. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  128356. \*************************************************/
  128357. /*! exports provided: glowBlurPostProcessPixelShader */
  128358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128359. "use strict";
  128360. __webpack_require__.r(__webpack_exports__);
  128361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  128362. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128363. var name = 'glowBlurPostProcessPixelShader';
  128364. 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}";
  128365. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128366. /** @hidden */
  128367. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  128368. /***/ }),
  128369. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  128370. /*!***********************************************!*\
  128371. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  128372. \***********************************************/
  128373. /*! exports provided: glowMapGenerationPixelShader */
  128374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128375. "use strict";
  128376. __webpack_require__.r(__webpack_exports__);
  128377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  128378. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128379. var name = 'glowMapGenerationPixelShader';
  128380. 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}";
  128381. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128382. /** @hidden */
  128383. var glowMapGenerationPixelShader = { name: name, shader: shader };
  128384. /***/ }),
  128385. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  128386. /*!*********************************************!*\
  128387. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  128388. \*********************************************/
  128389. /*! exports provided: glowMapGenerationVertexShader */
  128390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128391. "use strict";
  128392. __webpack_require__.r(__webpack_exports__);
  128393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  128394. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128395. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128396. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  128397. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  128398. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128399. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  128400. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128401. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128402. var name = 'glowMapGenerationVertexShader';
  128403. 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}";
  128404. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128405. /** @hidden */
  128406. var glowMapGenerationVertexShader = { name: name, shader: shader };
  128407. /***/ }),
  128408. /***/ "./Shaders/glowMapMerge.fragment.ts":
  128409. /*!******************************************!*\
  128410. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  128411. \******************************************/
  128412. /*! exports provided: glowMapMergePixelShader */
  128413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128414. "use strict";
  128415. __webpack_require__.r(__webpack_exports__);
  128416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  128417. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128418. var name = 'glowMapMergePixelShader';
  128419. 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}";
  128420. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128421. /** @hidden */
  128422. var glowMapMergePixelShader = { name: name, shader: shader };
  128423. /***/ }),
  128424. /***/ "./Shaders/glowMapMerge.vertex.ts":
  128425. /*!****************************************!*\
  128426. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  128427. \****************************************/
  128428. /*! exports provided: glowMapMergeVertexShader */
  128429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128430. "use strict";
  128431. __webpack_require__.r(__webpack_exports__);
  128432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  128433. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128434. var name = 'glowMapMergeVertexShader';
  128435. 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}";
  128436. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128437. /** @hidden */
  128438. var glowMapMergeVertexShader = { name: name, shader: shader };
  128439. /***/ }),
  128440. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  128441. /*!************************************************!*\
  128442. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  128443. \************************************************/
  128444. /*! exports provided: gpuRenderParticlesPixelShader */
  128445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128446. "use strict";
  128447. __webpack_require__.r(__webpack_exports__);
  128448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  128449. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128450. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  128451. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128452. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128453. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128454. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128455. var name = 'gpuRenderParticlesPixelShader';
  128456. 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";
  128457. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128458. /** @hidden */
  128459. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  128460. /***/ }),
  128461. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  128462. /*!**********************************************!*\
  128463. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  128464. \**********************************************/
  128465. /*! exports provided: gpuRenderParticlesVertexShader */
  128466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128467. "use strict";
  128468. __webpack_require__.r(__webpack_exports__);
  128469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  128470. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128471. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  128472. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128473. var name = 'gpuRenderParticlesVertexShader';
  128474. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\nuniform vec3 worldOffset;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn (position+worldOffset)+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn (position+worldOffset)+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=(position+worldOffset)-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=(position+worldOffset)-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  128475. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128476. /** @hidden */
  128477. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  128478. /***/ }),
  128479. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  128480. /*!************************************************!*\
  128481. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  128482. \************************************************/
  128483. /*! exports provided: gpuUpdateParticlesPixelShader */
  128484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128485. "use strict";
  128486. __webpack_require__.r(__webpack_exports__);
  128487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  128488. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128489. var name = 'gpuUpdateParticlesPixelShader';
  128490. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  128491. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128492. /** @hidden */
  128493. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  128494. /***/ }),
  128495. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  128496. /*!**********************************************!*\
  128497. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  128498. \**********************************************/
  128499. /*! exports provided: gpuUpdateParticlesVertexShader */
  128500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128501. "use strict";
  128502. __webpack_require__.r(__webpack_exports__);
  128503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  128504. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128505. var name = 'gpuUpdateParticlesVertexShader';
  128506. 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}";
  128507. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128508. /** @hidden */
  128509. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  128510. /***/ }),
  128511. /***/ "./Shaders/grain.fragment.ts":
  128512. /*!***********************************!*\
  128513. !*** ./Shaders/grain.fragment.ts ***!
  128514. \***********************************/
  128515. /*! exports provided: grainPixelShader */
  128516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128517. "use strict";
  128518. __webpack_require__.r(__webpack_exports__);
  128519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  128520. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128521. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128522. var name = 'grainPixelShader';
  128523. 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}";
  128524. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128525. /** @hidden */
  128526. var grainPixelShader = { name: name, shader: shader };
  128527. /***/ }),
  128528. /***/ "./Shaders/highlights.fragment.ts":
  128529. /*!****************************************!*\
  128530. !*** ./Shaders/highlights.fragment.ts ***!
  128531. \****************************************/
  128532. /*! exports provided: highlightsPixelShader */
  128533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128534. "use strict";
  128535. __webpack_require__.r(__webpack_exports__);
  128536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  128537. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128538. var name = 'highlightsPixelShader';
  128539. 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}";
  128540. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128541. /** @hidden */
  128542. var highlightsPixelShader = { name: name, shader: shader };
  128543. /***/ }),
  128544. /***/ "./Shaders/imageProcessing.fragment.ts":
  128545. /*!*********************************************!*\
  128546. !*** ./Shaders/imageProcessing.fragment.ts ***!
  128547. \*********************************************/
  128548. /*! exports provided: imageProcessingPixelShader */
  128549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128550. "use strict";
  128551. __webpack_require__.r(__webpack_exports__);
  128552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  128553. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128554. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128555. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128556. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128557. var name = 'imageProcessingPixelShader';
  128558. 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}";
  128559. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128560. /** @hidden */
  128561. var imageProcessingPixelShader = { name: name, shader: shader };
  128562. /***/ }),
  128563. /***/ "./Shaders/kernelBlur.fragment.ts":
  128564. /*!****************************************!*\
  128565. !*** ./Shaders/kernelBlur.fragment.ts ***!
  128566. \****************************************/
  128567. /*! exports provided: kernelBlurPixelShader */
  128568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128569. "use strict";
  128570. __webpack_require__.r(__webpack_exports__);
  128571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  128572. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128573. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  128574. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  128575. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  128576. var name = 'kernelBlurPixelShader';
  128577. 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}";
  128578. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128579. /** @hidden */
  128580. var kernelBlurPixelShader = { name: name, shader: shader };
  128581. /***/ }),
  128582. /***/ "./Shaders/kernelBlur.vertex.ts":
  128583. /*!**************************************!*\
  128584. !*** ./Shaders/kernelBlur.vertex.ts ***!
  128585. \**************************************/
  128586. /*! exports provided: kernelBlurVertexShader */
  128587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128588. "use strict";
  128589. __webpack_require__.r(__webpack_exports__);
  128590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  128591. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128592. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  128593. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  128594. var name = 'kernelBlurVertexShader';
  128595. 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}";
  128596. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128597. /** @hidden */
  128598. var kernelBlurVertexShader = { name: name, shader: shader };
  128599. /***/ }),
  128600. /***/ "./Shaders/layer.fragment.ts":
  128601. /*!***********************************!*\
  128602. !*** ./Shaders/layer.fragment.ts ***!
  128603. \***********************************/
  128604. /*! exports provided: layerPixelShader */
  128605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128606. "use strict";
  128607. __webpack_require__.r(__webpack_exports__);
  128608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  128609. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128610. var name = 'layerPixelShader';
  128611. 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}";
  128612. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128613. /** @hidden */
  128614. var layerPixelShader = { name: name, shader: shader };
  128615. /***/ }),
  128616. /***/ "./Shaders/layer.vertex.ts":
  128617. /*!*********************************!*\
  128618. !*** ./Shaders/layer.vertex.ts ***!
  128619. \*********************************/
  128620. /*! exports provided: layerVertexShader */
  128621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128622. "use strict";
  128623. __webpack_require__.r(__webpack_exports__);
  128624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  128625. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128626. var name = 'layerVertexShader';
  128627. 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}";
  128628. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128629. /** @hidden */
  128630. var layerVertexShader = { name: name, shader: shader };
  128631. /***/ }),
  128632. /***/ "./Shaders/lensFlare.fragment.ts":
  128633. /*!***************************************!*\
  128634. !*** ./Shaders/lensFlare.fragment.ts ***!
  128635. \***************************************/
  128636. /*! exports provided: lensFlarePixelShader */
  128637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128638. "use strict";
  128639. __webpack_require__.r(__webpack_exports__);
  128640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  128641. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128642. var name = 'lensFlarePixelShader';
  128643. 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}";
  128644. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128645. /** @hidden */
  128646. var lensFlarePixelShader = { name: name, shader: shader };
  128647. /***/ }),
  128648. /***/ "./Shaders/lensFlare.vertex.ts":
  128649. /*!*************************************!*\
  128650. !*** ./Shaders/lensFlare.vertex.ts ***!
  128651. \*************************************/
  128652. /*! exports provided: lensFlareVertexShader */
  128653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128654. "use strict";
  128655. __webpack_require__.r(__webpack_exports__);
  128656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  128657. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128658. var name = 'lensFlareVertexShader';
  128659. 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}";
  128660. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128661. /** @hidden */
  128662. var lensFlareVertexShader = { name: name, shader: shader };
  128663. /***/ }),
  128664. /***/ "./Shaders/lensHighlights.fragment.ts":
  128665. /*!********************************************!*\
  128666. !*** ./Shaders/lensHighlights.fragment.ts ***!
  128667. \********************************************/
  128668. /*! exports provided: lensHighlightsPixelShader */
  128669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128670. "use strict";
  128671. __webpack_require__.r(__webpack_exports__);
  128672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  128673. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128674. var name = 'lensHighlightsPixelShader';
  128675. 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}";
  128676. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128677. /** @hidden */
  128678. var lensHighlightsPixelShader = { name: name, shader: shader };
  128679. /***/ }),
  128680. /***/ "./Shaders/line.fragment.ts":
  128681. /*!**********************************!*\
  128682. !*** ./Shaders/line.fragment.ts ***!
  128683. \**********************************/
  128684. /*! exports provided: linePixelShader */
  128685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128686. "use strict";
  128687. __webpack_require__.r(__webpack_exports__);
  128688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  128689. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128690. var name = 'linePixelShader';
  128691. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  128692. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128693. /** @hidden */
  128694. var linePixelShader = { name: name, shader: shader };
  128695. /***/ }),
  128696. /***/ "./Shaders/line.vertex.ts":
  128697. /*!********************************!*\
  128698. !*** ./Shaders/line.vertex.ts ***!
  128699. \********************************/
  128700. /*! exports provided: lineVertexShader */
  128701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128702. "use strict";
  128703. __webpack_require__.r(__webpack_exports__);
  128704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  128705. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128706. var name = 'lineVertexShader';
  128707. 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}";
  128708. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128709. /** @hidden */
  128710. var lineVertexShader = { name: name, shader: shader };
  128711. /***/ }),
  128712. /***/ "./Shaders/motionBlur.fragment.ts":
  128713. /*!****************************************!*\
  128714. !*** ./Shaders/motionBlur.fragment.ts ***!
  128715. \****************************************/
  128716. /*! exports provided: motionBlurPixelShader */
  128717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128718. "use strict";
  128719. __webpack_require__.r(__webpack_exports__);
  128720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  128721. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128722. var name = 'motionBlurPixelShader';
  128723. 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";
  128724. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128725. /** @hidden */
  128726. var motionBlurPixelShader = { name: name, shader: shader };
  128727. /***/ }),
  128728. /***/ "./Shaders/noise.fragment.ts":
  128729. /*!***********************************!*\
  128730. !*** ./Shaders/noise.fragment.ts ***!
  128731. \***********************************/
  128732. /*! exports provided: noisePixelShader */
  128733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128734. "use strict";
  128735. __webpack_require__.r(__webpack_exports__);
  128736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  128737. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128738. var name = 'noisePixelShader';
  128739. 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";
  128740. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128741. /** @hidden */
  128742. var noisePixelShader = { name: name, shader: shader };
  128743. /***/ }),
  128744. /***/ "./Shaders/outline.fragment.ts":
  128745. /*!*************************************!*\
  128746. !*** ./Shaders/outline.fragment.ts ***!
  128747. \*************************************/
  128748. /*! exports provided: outlinePixelShader */
  128749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128750. "use strict";
  128751. __webpack_require__.r(__webpack_exports__);
  128752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  128753. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128754. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  128755. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  128756. var name = 'outlinePixelShader';
  128757. 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}";
  128758. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128759. /** @hidden */
  128760. var outlinePixelShader = { name: name, shader: shader };
  128761. /***/ }),
  128762. /***/ "./Shaders/outline.vertex.ts":
  128763. /*!***********************************!*\
  128764. !*** ./Shaders/outline.vertex.ts ***!
  128765. \***********************************/
  128766. /*! exports provided: outlineVertexShader */
  128767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128768. "use strict";
  128769. __webpack_require__.r(__webpack_exports__);
  128770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  128771. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128772. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128773. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128774. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  128775. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128776. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128777. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  128778. var name = 'outlineVertexShader';
  128779. 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";
  128780. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128781. /** @hidden */
  128782. var outlineVertexShader = { name: name, shader: shader };
  128783. /***/ }),
  128784. /***/ "./Shaders/particles.fragment.ts":
  128785. /*!***************************************!*\
  128786. !*** ./Shaders/particles.fragment.ts ***!
  128787. \***************************************/
  128788. /*! exports provided: particlesPixelShader */
  128789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128790. "use strict";
  128791. __webpack_require__.r(__webpack_exports__);
  128792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  128793. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128794. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  128795. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128796. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128797. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128798. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128799. var name = 'particlesPixelShader';
  128800. 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}";
  128801. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128802. /** @hidden */
  128803. var particlesPixelShader = { name: name, shader: shader };
  128804. /***/ }),
  128805. /***/ "./Shaders/particles.vertex.ts":
  128806. /*!*************************************!*\
  128807. !*** ./Shaders/particles.vertex.ts ***!
  128808. \*************************************/
  128809. /*! exports provided: particlesVertexShader */
  128810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128811. "use strict";
  128812. __webpack_require__.r(__webpack_exports__);
  128813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  128814. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128815. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  128816. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128817. var name = 'particlesVertexShader';
  128818. 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}";
  128819. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128820. /** @hidden */
  128821. var particlesVertexShader = { name: name, shader: shader };
  128822. /***/ }),
  128823. /***/ "./Shaders/pass.fragment.ts":
  128824. /*!**********************************!*\
  128825. !*** ./Shaders/pass.fragment.ts ***!
  128826. \**********************************/
  128827. /*! exports provided: passPixelShader */
  128828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128829. "use strict";
  128830. __webpack_require__.r(__webpack_exports__);
  128831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  128832. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128833. var name = 'passPixelShader';
  128834. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  128835. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128836. /** @hidden */
  128837. var passPixelShader = { name: name, shader: shader };
  128838. /***/ }),
  128839. /***/ "./Shaders/passCube.fragment.ts":
  128840. /*!**************************************!*\
  128841. !*** ./Shaders/passCube.fragment.ts ***!
  128842. \**************************************/
  128843. /*! exports provided: passCubePixelShader */
  128844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128845. "use strict";
  128846. __webpack_require__.r(__webpack_exports__);
  128847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  128848. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128849. var name = 'passCubePixelShader';
  128850. 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}";
  128851. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128852. /** @hidden */
  128853. var passCubePixelShader = { name: name, shader: shader };
  128854. /***/ }),
  128855. /***/ "./Shaders/pbr.fragment.ts":
  128856. /*!*********************************!*\
  128857. !*** ./Shaders/pbr.fragment.ts ***!
  128858. \*********************************/
  128859. /*! exports provided: pbrPixelShader */
  128860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128861. "use strict";
  128862. __webpack_require__.r(__webpack_exports__);
  128863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  128864. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128865. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  128866. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  128867. /* harmony import */ var _ShadersInclude_pbrFragmentExtraDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentExtraDeclaration */ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts");
  128868. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128869. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128870. /* harmony import */ var _ShadersInclude_pbrFragmentSamplersDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentSamplersDeclaration */ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts");
  128871. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128872. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  128873. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  128874. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  128875. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128876. /* harmony import */ var _ShadersInclude_pbrHelperFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrHelperFunctions */ "./Shaders/ShadersInclude/pbrHelperFunctions.ts");
  128877. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128878. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  128879. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  128880. /* harmony import */ var _ShadersInclude_pbrDirectLightingSetupFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingSetupFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts");
  128881. /* harmony import */ var _ShadersInclude_pbrDirectLightingFalloffFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFalloffFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts");
  128882. /* harmony import */ var _ShadersInclude_pbrBRDFFunctions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/pbrBRDFFunctions */ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts");
  128883. /* harmony import */ var _ShadersInclude_pbrDirectLightingFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts");
  128884. /* harmony import */ var _ShadersInclude_pbrIBLFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/pbrIBLFunctions */ "./Shaders/ShadersInclude/pbrIBLFunctions.ts");
  128885. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  128886. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  128887. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128888. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  128889. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  128890. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  128891. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  128892. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  128893. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  128894. var name = 'pbrPixelShader';
  128895. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#include<__decl__pbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<pbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n\n#include<helperFunctions>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n\nvoid main(void) {\n#include<clipPlaneFragment>\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#ifdef CLEARCOAT\n\nvec3 clearCoatNormalW=normalW;\n#endif\n#include<bumpFragment>\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\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\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n#ifdef REFLECTANCE\n\n\n\n\n\nsurfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\n\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=saturate(microSurface);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\n\nfloat NdotV=absEps(NdotVUnclamped);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\n\nalphaG+=AARoughnessFactors.y;\n#endif\n#ifdef ANISOTROPIC\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\nvec3 anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef 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);\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=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef 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.);\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\n#ifdef SHEEN\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset)*vSheenInfos.y;\nsheenIntensity*=sheenMapData.a;\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow5(1.0-sheenIntensity);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\n\nsurfaceAlbedo.rgb*=sheenFactor;\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\nsheenColor.rgb*=toLinearSpace(sheenMapData.rgb);\n#endif\nfloat sheenRoughness=roughness;\n\nsheenColor*=sheenIntensity;\nspecularEnvironmentR0*=(1.0-sheenIntensity);\n#endif\n\n#if defined(REFLECTION)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\n\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\n\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG,NdotVUnclamped);\n#else\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nsheenReflectionLOD=sheenReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nenvironmentSheenRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,sheenReflectionLOD);\n#else\nfloat lodSheenReflectionNormalized=saturate(sheenReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodSheenReflectionNormalizedDoubled=lodSheenReflectionNormalized*2.0;\nvec4 environmentSheenMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodSheenReflectionNormalizedDoubled<1.0){\nenvironmentSheenRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSheenMid,\nlodSheenReflectionNormalizedDoubled\n);\n}else{\nenvironmentSheenRadiance=mix(\nenvironmentSheenMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodSheenReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentSheenRadiance.rgb=fromRGBD(environmentSheenRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentSheenRadiance.rgb=toLinearSpace(environmentSheenRadiance.rgb);\n#endif\n\nenvironmentSheenRadiance.rgb*=vReflectionInfos.x;\nenvironmentSheenRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#ifdef CLEARCOAT\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\nclearCoatIntensity*=clearCoatMapData.x;\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\nclearCoatThickness*=clearCoatTintMapData.a;\n#endif\nclearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\n#endif\n\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\nspecularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset).xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBN,vClearCoatBumpUV+uvOffset,clearCoatBumpSampler,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\n\nvec2 clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\n\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\n\nclearCoatAlphaG+=clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG,clearCoatNdotVUnclamped);\n#else\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nclearCoatReflectionLOD=clearCoatReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nfloat requestedClearCoatReflectionLOD=clearCoatReflectionLOD;\nenvironmentClearCoatRadiance=sampleReflectionLod(reflectionSampler,clearCoatReflectionCoords,requestedClearCoatReflectionLOD);\n#else\nfloat lodClearCoatReflectionNormalized=saturate(clearCoatReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodClearCoatReflectionNormalizedDoubled=lodClearCoatReflectionNormalized*2.0;\nvec4 environmentClearCoatMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodClearCoatReflectionNormalizedDoubled<1.0){\nenvironmentClearCoatRadiance=mix(\nsampleReflection(reflectionSamplerHigh,clearCoatReflectionCoords),\nenvironmentClearCoatMid,\nlodClearCoatReflectionNormalizedDoubled\n);\n}else{\nenvironmentClearCoatRadiance=mix(\nenvironmentClearCoatMid,\nsampleReflection(reflectionSamplerLow,clearCoatReflectionCoords),\nlodClearCoatReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentClearCoatRadiance.rgb=fromRGBD(environmentClearCoatRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentClearCoatRadiance.rgb=toLinearSpace(environmentClearCoatRadiance.rgb);\n#endif\n#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\n\nfloat clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\nvec3 absorption=vec3(0.);\n#endif\n\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#if defined(ENVIRONMENTBRDF)\n\nvec2 environmentBrdf=getBRDFLookup(NdotV,roughness,environmentBrdfSampler);\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(specularEnvironmentR0,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#if defined(SHEEN) && defined(REFLECTION)\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,NdotV,sheenAlphaG);\n#ifdef RADIANCEOCCLUSION\nsheenEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nsheenEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness,environmentBrdfSampler);\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatAbsorption(clearCoatNdotVRefract,clearCoatNdotVRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#ifdef REFLECTION\nenvironmentIrradiance*=absorption;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=absorption;\n#endif\nspecularEnvironmentReflectance*=absorption;\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef 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=saturate(maxChannel*mixedAlbedo);\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#ifndef METALLICWORKFLOW\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\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#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=energyConservationFactor;\n#endif\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#ifdef CLEARCOAT_TINT\nfinalRefraction*=absorption;\n#endif\n#endif\n#endif\n\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\n\n\n\n#endif\n#ifdef REFLECTION\nvec3 finalSheenRadiance=environmentSheenRadiance.rgb;\nfinalSheenRadiance*=sheenEnvironmentReflectance;\n\nvec3 finalSheenRadianceScaled=finalSheenRadiance*vLightingIntensity.z;\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n#endif\n\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 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(\nvAmbientColor*ambientOcclusionColor +\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef CLEARCOAT\n\n\nfinalClearCoatScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#ifdef CLEARCOAT\n\n\nfinalClearCoatRadianceScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenRadianceScaled +\n#endif\n#endif\n#ifdef 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#include<pbrDebug>\n}\n";
  128896. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128897. /** @hidden */
  128898. var pbrPixelShader = { name: name, shader: shader };
  128899. /***/ }),
  128900. /***/ "./Shaders/pbr.vertex.ts":
  128901. /*!*******************************!*\
  128902. !*** ./Shaders/pbr.vertex.ts ***!
  128903. \*******************************/
  128904. /*! exports provided: pbrVertexShader */
  128905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128906. "use strict";
  128907. __webpack_require__.r(__webpack_exports__);
  128908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  128909. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128910. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  128911. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  128912. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128913. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128914. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  128915. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  128916. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  128917. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  128918. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  128919. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128920. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128921. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  128922. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  128923. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  128924. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  128925. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  128926. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  128927. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  128928. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  128929. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  128930. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  128931. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  128932. var name = 'pbrVertexShader';
  128933. 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#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nvarying vec2 vSheenUV;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nvarying vec2 vAnisotropyUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\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);\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nif (vClearCoatInfos.x == 0.)\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nif (vClearCoatBumpInfos.x == 0.)\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nif (vClearCoatTintInfos.x == 0.)\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nif (vSheenInfos.x == 0.)\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nif (vAnisotropyInfos.x == 0.)\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n\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}";
  128934. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128935. /** @hidden */
  128936. var pbrVertexShader = { name: name, shader: shader };
  128937. /***/ }),
  128938. /***/ "./Shaders/postprocess.vertex.ts":
  128939. /*!***************************************!*\
  128940. !*** ./Shaders/postprocess.vertex.ts ***!
  128941. \***************************************/
  128942. /*! exports provided: postprocessVertexShader */
  128943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128944. "use strict";
  128945. __webpack_require__.r(__webpack_exports__);
  128946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  128947. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128948. var name = 'postprocessVertexShader';
  128949. 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}";
  128950. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128951. /** @hidden */
  128952. var postprocessVertexShader = { name: name, shader: shader };
  128953. /***/ }),
  128954. /***/ "./Shaders/procedural.vertex.ts":
  128955. /*!**************************************!*\
  128956. !*** ./Shaders/procedural.vertex.ts ***!
  128957. \**************************************/
  128958. /*! exports provided: proceduralVertexShader */
  128959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128960. "use strict";
  128961. __webpack_require__.r(__webpack_exports__);
  128962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  128963. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128964. var name = 'proceduralVertexShader';
  128965. 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}";
  128966. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128967. /** @hidden */
  128968. var proceduralVertexShader = { name: name, shader: shader };
  128969. /***/ }),
  128970. /***/ "./Shaders/refraction.fragment.ts":
  128971. /*!****************************************!*\
  128972. !*** ./Shaders/refraction.fragment.ts ***!
  128973. \****************************************/
  128974. /*! exports provided: refractionPixelShader */
  128975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128976. "use strict";
  128977. __webpack_require__.r(__webpack_exports__);
  128978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  128979. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128980. var name = 'refractionPixelShader';
  128981. 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}";
  128982. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128983. /** @hidden */
  128984. var refractionPixelShader = { name: name, shader: shader };
  128985. /***/ }),
  128986. /***/ "./Shaders/rgbdDecode.fragment.ts":
  128987. /*!****************************************!*\
  128988. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  128989. \****************************************/
  128990. /*! exports provided: rgbdDecodePixelShader */
  128991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128992. "use strict";
  128993. __webpack_require__.r(__webpack_exports__);
  128994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  128995. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128996. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128997. var name = 'rgbdDecodePixelShader';
  128998. 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}";
  128999. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129000. /** @hidden */
  129001. var rgbdDecodePixelShader = { name: name, shader: shader };
  129002. /***/ }),
  129003. /***/ "./Shaders/rgbdEncode.fragment.ts":
  129004. /*!****************************************!*\
  129005. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  129006. \****************************************/
  129007. /*! exports provided: rgbdEncodePixelShader */
  129008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129009. "use strict";
  129010. __webpack_require__.r(__webpack_exports__);
  129011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  129012. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129013. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129014. var name = 'rgbdEncodePixelShader';
  129015. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  129016. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129017. /** @hidden */
  129018. var rgbdEncodePixelShader = { name: name, shader: shader };
  129019. /***/ }),
  129020. /***/ "./Shaders/shadowMap.fragment.ts":
  129021. /*!***************************************!*\
  129022. !*** ./Shaders/shadowMap.fragment.ts ***!
  129023. \***************************************/
  129024. /*! exports provided: shadowMapPixelShader */
  129025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129026. "use strict";
  129027. __webpack_require__.r(__webpack_exports__);
  129028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  129029. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129030. var name = 'shadowMapPixelShader';
  129031. 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}";
  129032. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129033. /** @hidden */
  129034. var shadowMapPixelShader = { name: name, shader: shader };
  129035. /***/ }),
  129036. /***/ "./Shaders/shadowMap.vertex.ts":
  129037. /*!*************************************!*\
  129038. !*** ./Shaders/shadowMap.vertex.ts ***!
  129039. \*************************************/
  129040. /*! exports provided: shadowMapVertexShader */
  129041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129042. "use strict";
  129043. __webpack_require__.r(__webpack_exports__);
  129044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  129045. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129046. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129047. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  129048. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  129049. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129050. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129051. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  129052. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129053. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129054. var name = 'shadowMapVertexShader';
  129055. 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}";
  129056. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129057. /** @hidden */
  129058. var shadowMapVertexShader = { name: name, shader: shader };
  129059. /***/ }),
  129060. /***/ "./Shaders/sharpen.fragment.ts":
  129061. /*!*************************************!*\
  129062. !*** ./Shaders/sharpen.fragment.ts ***!
  129063. \*************************************/
  129064. /*! exports provided: sharpenPixelShader */
  129065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129066. "use strict";
  129067. __webpack_require__.r(__webpack_exports__);
  129068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  129069. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129070. var name = 'sharpenPixelShader';
  129071. 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}";
  129072. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129073. /** @hidden */
  129074. var sharpenPixelShader = { name: name, shader: shader };
  129075. /***/ }),
  129076. /***/ "./Shaders/sprites.fragment.ts":
  129077. /*!*************************************!*\
  129078. !*** ./Shaders/sprites.fragment.ts ***!
  129079. \*************************************/
  129080. /*! exports provided: spritesPixelShader */
  129081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129082. "use strict";
  129083. __webpack_require__.r(__webpack_exports__);
  129084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  129085. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129086. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  129087. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  129088. var name = 'spritesPixelShader';
  129089. 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}";
  129090. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129091. /** @hidden */
  129092. var spritesPixelShader = { name: name, shader: shader };
  129093. /***/ }),
  129094. /***/ "./Shaders/sprites.vertex.ts":
  129095. /*!***********************************!*\
  129096. !*** ./Shaders/sprites.vertex.ts ***!
  129097. \***********************************/
  129098. /*! exports provided: spritesVertexShader */
  129099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129100. "use strict";
  129101. __webpack_require__.r(__webpack_exports__);
  129102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  129103. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129104. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129105. var name = 'spritesVertexShader';
  129106. 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}";
  129107. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129108. /** @hidden */
  129109. var spritesVertexShader = { name: name, shader: shader };
  129110. /***/ }),
  129111. /***/ "./Shaders/ssao.fragment.ts":
  129112. /*!**********************************!*\
  129113. !*** ./Shaders/ssao.fragment.ts ***!
  129114. \**********************************/
  129115. /*! exports provided: ssaoPixelShader */
  129116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129117. "use strict";
  129118. __webpack_require__.r(__webpack_exports__);
  129119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  129120. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129121. var name = 'ssaoPixelShader';
  129122. 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";
  129123. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129124. /** @hidden */
  129125. var ssaoPixelShader = { name: name, shader: shader };
  129126. /***/ }),
  129127. /***/ "./Shaders/ssao2.fragment.ts":
  129128. /*!***********************************!*\
  129129. !*** ./Shaders/ssao2.fragment.ts ***!
  129130. \***********************************/
  129131. /*! exports provided: ssao2PixelShader */
  129132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129133. "use strict";
  129134. __webpack_require__.r(__webpack_exports__);
  129135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  129136. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129137. var name = 'ssao2PixelShader';
  129138. 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";
  129139. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129140. /** @hidden */
  129141. var ssao2PixelShader = { name: name, shader: shader };
  129142. /***/ }),
  129143. /***/ "./Shaders/ssaoCombine.fragment.ts":
  129144. /*!*****************************************!*\
  129145. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  129146. \*****************************************/
  129147. /*! exports provided: ssaoCombinePixelShader */
  129148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129149. "use strict";
  129150. __webpack_require__.r(__webpack_exports__);
  129151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  129152. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129153. var name = 'ssaoCombinePixelShader';
  129154. 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";
  129155. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129156. /** @hidden */
  129157. var ssaoCombinePixelShader = { name: name, shader: shader };
  129158. /***/ }),
  129159. /***/ "./Shaders/standard.fragment.ts":
  129160. /*!**************************************!*\
  129161. !*** ./Shaders/standard.fragment.ts ***!
  129162. \**************************************/
  129163. /*! exports provided: standardPixelShader */
  129164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129165. "use strict";
  129166. __webpack_require__.r(__webpack_exports__);
  129167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  129168. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129169. var name = 'standardPixelShader';
  129170. 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";
  129171. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129172. /** @hidden */
  129173. var standardPixelShader = { name: name, shader: shader };
  129174. /***/ }),
  129175. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  129176. /*!***************************************************!*\
  129177. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  129178. \***************************************************/
  129179. /*! exports provided: stereoscopicInterlacePixelShader */
  129180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129181. "use strict";
  129182. __webpack_require__.r(__webpack_exports__);
  129183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  129184. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129185. var name = 'stereoscopicInterlacePixelShader';
  129186. 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}";
  129187. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129188. /** @hidden */
  129189. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  129190. /***/ }),
  129191. /***/ "./Shaders/tonemap.fragment.ts":
  129192. /*!*************************************!*\
  129193. !*** ./Shaders/tonemap.fragment.ts ***!
  129194. \*************************************/
  129195. /*! exports provided: tonemapPixelShader */
  129196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129197. "use strict";
  129198. __webpack_require__.r(__webpack_exports__);
  129199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  129200. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129201. var name = 'tonemapPixelShader';
  129202. 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}";
  129203. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129204. /** @hidden */
  129205. var tonemapPixelShader = { name: name, shader: shader };
  129206. /***/ }),
  129207. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  129208. /*!*******************************************************!*\
  129209. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  129210. \*******************************************************/
  129211. /*! exports provided: volumetricLightScatteringPixelShader */
  129212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129213. "use strict";
  129214. __webpack_require__.r(__webpack_exports__);
  129215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  129216. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129217. var name = 'volumetricLightScatteringPixelShader';
  129218. 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";
  129219. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129220. /** @hidden */
  129221. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  129222. /***/ }),
  129223. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  129224. /*!***********************************************************!*\
  129225. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  129226. \***********************************************************/
  129227. /*! exports provided: volumetricLightScatteringPassPixelShader */
  129228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129229. "use strict";
  129230. __webpack_require__.r(__webpack_exports__);
  129231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  129232. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129233. var name = 'volumetricLightScatteringPassPixelShader';
  129234. 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";
  129235. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129236. /** @hidden */
  129237. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  129238. /***/ }),
  129239. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  129240. /*!****************************************************!*\
  129241. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  129242. \****************************************************/
  129243. /*! exports provided: vrDistortionCorrectionPixelShader */
  129244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129245. "use strict";
  129246. __webpack_require__.r(__webpack_exports__);
  129247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  129248. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129249. var name = 'vrDistortionCorrectionPixelShader';
  129250. 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}";
  129251. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129252. /** @hidden */
  129253. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  129254. /***/ }),
  129255. /***/ "./Sprites/index.ts":
  129256. /*!**************************!*\
  129257. !*** ./Sprites/index.ts ***!
  129258. \**************************/
  129259. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  129260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129261. "use strict";
  129262. __webpack_require__.r(__webpack_exports__);
  129263. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  129264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  129265. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  129266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  129267. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  129268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  129269. /***/ }),
  129270. /***/ "./Sprites/sprite.ts":
  129271. /*!***************************!*\
  129272. !*** ./Sprites/sprite.ts ***!
  129273. \***************************/
  129274. /*! exports provided: Sprite */
  129275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129276. "use strict";
  129277. __webpack_require__.r(__webpack_exports__);
  129278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  129279. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  129280. /**
  129281. * Class used to represent a sprite
  129282. * @see http://doc.babylonjs.com/babylon101/sprites
  129283. */
  129284. var Sprite = /** @class */ (function () {
  129285. /**
  129286. * Creates a new Sprite
  129287. * @param name defines the name
  129288. * @param manager defines the manager
  129289. */
  129290. function Sprite(
  129291. /** defines the name */
  129292. name, manager) {
  129293. this.name = name;
  129294. /** Gets or sets the main color */
  129295. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  129296. /** Gets or sets the width */
  129297. this.width = 1.0;
  129298. /** Gets or sets the height */
  129299. this.height = 1.0;
  129300. /** Gets or sets rotation angle */
  129301. this.angle = 0;
  129302. /** Gets or sets the cell index in the sprite sheet */
  129303. this.cellIndex = 0;
  129304. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  129305. this.invertU = 0;
  129306. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  129307. this.invertV = 0;
  129308. /** Gets the list of attached animations */
  129309. this.animations = new Array();
  129310. /** Gets or sets a boolean indicating if the sprite can be picked */
  129311. this.isPickable = false;
  129312. this._animationStarted = false;
  129313. this._loopAnimation = false;
  129314. this._fromIndex = 0;
  129315. this._toIndex = 0;
  129316. this._delay = 0;
  129317. this._direction = 1;
  129318. this._time = 0;
  129319. /**
  129320. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  129321. */
  129322. this.isVisible = true;
  129323. this._manager = manager;
  129324. this._manager.sprites.push(this);
  129325. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  129326. }
  129327. Object.defineProperty(Sprite.prototype, "size", {
  129328. /**
  129329. * Gets or sets the sprite size
  129330. */
  129331. get: function () {
  129332. return this.width;
  129333. },
  129334. set: function (value) {
  129335. this.width = value;
  129336. this.height = value;
  129337. },
  129338. enumerable: true,
  129339. configurable: true
  129340. });
  129341. /**
  129342. * Starts an animation
  129343. * @param from defines the initial key
  129344. * @param to defines the end key
  129345. * @param loop defines if the animation must loop
  129346. * @param delay defines the start delay (in ms)
  129347. * @param onAnimationEnd defines a callback to call when animation ends
  129348. */
  129349. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  129350. this._fromIndex = from;
  129351. this._toIndex = to;
  129352. this._loopAnimation = loop;
  129353. this._delay = delay;
  129354. this._animationStarted = true;
  129355. this._direction = from < to ? 1 : -1;
  129356. this.cellIndex = from;
  129357. this._time = 0;
  129358. this._onAnimationEnd = onAnimationEnd;
  129359. };
  129360. /** Stops current animation (if any) */
  129361. Sprite.prototype.stopAnimation = function () {
  129362. this._animationStarted = false;
  129363. };
  129364. /** @hidden */
  129365. Sprite.prototype._animate = function (deltaTime) {
  129366. if (!this._animationStarted) {
  129367. return;
  129368. }
  129369. this._time += deltaTime;
  129370. if (this._time > this._delay) {
  129371. this._time = this._time % this._delay;
  129372. this.cellIndex += this._direction;
  129373. if (this.cellIndex > this._toIndex) {
  129374. if (this._loopAnimation) {
  129375. this.cellIndex = this._fromIndex;
  129376. }
  129377. else {
  129378. this.cellIndex = this._toIndex;
  129379. this._animationStarted = false;
  129380. if (this._onAnimationEnd) {
  129381. this._onAnimationEnd();
  129382. }
  129383. if (this.disposeWhenFinishedAnimating) {
  129384. this.dispose();
  129385. }
  129386. }
  129387. }
  129388. }
  129389. };
  129390. /** Release associated resources */
  129391. Sprite.prototype.dispose = function () {
  129392. for (var i = 0; i < this._manager.sprites.length; i++) {
  129393. if (this._manager.sprites[i] == this) {
  129394. this._manager.sprites.splice(i, 1);
  129395. }
  129396. }
  129397. };
  129398. return Sprite;
  129399. }());
  129400. /***/ }),
  129401. /***/ "./Sprites/spriteManager.ts":
  129402. /*!**********************************!*\
  129403. !*** ./Sprites/spriteManager.ts ***!
  129404. \**********************************/
  129405. /*! exports provided: SpriteManager */
  129406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129407. "use strict";
  129408. __webpack_require__.r(__webpack_exports__);
  129409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  129410. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  129411. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  129412. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  129413. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  129414. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  129415. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  129416. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  129417. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  129418. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  129419. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  129420. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  129421. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  129422. /**
  129423. * Class used to manage multiple sprites on the same spritesheet
  129424. * @see http://doc.babylonjs.com/babylon101/sprites
  129425. */
  129426. var SpriteManager = /** @class */ (function () {
  129427. /**
  129428. * Creates a new sprite manager
  129429. * @param name defines the manager's name
  129430. * @param imgUrl defines the sprite sheet url
  129431. * @param capacity defines the maximum allowed number of sprites
  129432. * @param cellSize defines the size of a sprite cell
  129433. * @param scene defines the hosting scene
  129434. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129435. * @param samplingMode defines the smapling mode to use with spritesheet
  129436. */
  129437. function SpriteManager(
  129438. /** defines the manager's name */
  129439. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  129440. if (epsilon === void 0) { epsilon = 0.01; }
  129441. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  129442. this.name = name;
  129443. /** Gets the list of sprites */
  129444. this.sprites = new Array();
  129445. /** Gets or sets the rendering group id (0 by default) */
  129446. this.renderingGroupId = 0;
  129447. /** Gets or sets camera layer mask */
  129448. this.layerMask = 0x0FFFFFFF;
  129449. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  129450. this.fogEnabled = true;
  129451. /** Gets or sets a boolean indicating if the sprites are pickable */
  129452. this.isPickable = false;
  129453. /**
  129454. * An event triggered when the manager is disposed.
  129455. */
  129456. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  129457. this._vertexBuffers = {};
  129458. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  129459. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  129460. }
  129461. this._capacity = capacity;
  129462. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  129463. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  129464. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  129465. if (cellSize.width && cellSize.height) {
  129466. this.cellWidth = cellSize.width;
  129467. this.cellHeight = cellSize.height;
  129468. }
  129469. else if (cellSize !== undefined) {
  129470. this.cellWidth = cellSize;
  129471. this.cellHeight = cellSize;
  129472. }
  129473. else {
  129474. return;
  129475. }
  129476. this._epsilon = epsilon;
  129477. this._scene = scene;
  129478. this._scene.spriteManagers.push(this);
  129479. var indices = [];
  129480. var index = 0;
  129481. for (var count = 0; count < capacity; count++) {
  129482. indices.push(index);
  129483. indices.push(index + 1);
  129484. indices.push(index + 2);
  129485. indices.push(index);
  129486. indices.push(index + 2);
  129487. indices.push(index + 3);
  129488. index += 4;
  129489. }
  129490. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  129491. // VBO
  129492. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  129493. this._vertexData = new Float32Array(capacity * 16 * 4);
  129494. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  129495. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  129496. var options = this._buffer.createVertexBuffer("options", 4, 4);
  129497. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  129498. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  129499. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  129500. this._vertexBuffers["options"] = options;
  129501. this._vertexBuffers["cellInfo"] = cellInfo;
  129502. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  129503. // Effects
  129504. 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"], "");
  129505. 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");
  129506. }
  129507. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  129508. /**
  129509. * Callback called when the manager is disposed
  129510. */
  129511. set: function (callback) {
  129512. if (this._onDisposeObserver) {
  129513. this.onDisposeObservable.remove(this._onDisposeObserver);
  129514. }
  129515. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  129516. },
  129517. enumerable: true,
  129518. configurable: true
  129519. });
  129520. Object.defineProperty(SpriteManager.prototype, "texture", {
  129521. /**
  129522. * Gets or sets the spritesheet texture
  129523. */
  129524. get: function () {
  129525. return this._spriteTexture;
  129526. },
  129527. set: function (value) {
  129528. this._spriteTexture = value;
  129529. },
  129530. enumerable: true,
  129531. configurable: true
  129532. });
  129533. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  129534. var arrayOffset = index * 16;
  129535. if (offsetX === 0) {
  129536. offsetX = this._epsilon;
  129537. }
  129538. else if (offsetX === 1) {
  129539. offsetX = 1 - this._epsilon;
  129540. }
  129541. if (offsetY === 0) {
  129542. offsetY = this._epsilon;
  129543. }
  129544. else if (offsetY === 1) {
  129545. offsetY = 1 - this._epsilon;
  129546. }
  129547. this._vertexData[arrayOffset] = sprite.position.x;
  129548. this._vertexData[arrayOffset + 1] = sprite.position.y;
  129549. this._vertexData[arrayOffset + 2] = sprite.position.z;
  129550. this._vertexData[arrayOffset + 3] = sprite.angle;
  129551. this._vertexData[arrayOffset + 4] = sprite.width;
  129552. this._vertexData[arrayOffset + 5] = sprite.height;
  129553. this._vertexData[arrayOffset + 6] = offsetX;
  129554. this._vertexData[arrayOffset + 7] = offsetY;
  129555. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  129556. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  129557. var offset = (sprite.cellIndex / rowSize) >> 0;
  129558. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  129559. this._vertexData[arrayOffset + 11] = offset;
  129560. // Color
  129561. this._vertexData[arrayOffset + 12] = sprite.color.r;
  129562. this._vertexData[arrayOffset + 13] = sprite.color.g;
  129563. this._vertexData[arrayOffset + 14] = sprite.color.b;
  129564. this._vertexData[arrayOffset + 15] = sprite.color.a;
  129565. };
  129566. /**
  129567. * Intersects the sprites with a ray
  129568. * @param ray defines the ray to intersect with
  129569. * @param camera defines the current active camera
  129570. * @param predicate defines a predicate used to select candidate sprites
  129571. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  129572. * @returns null if no hit or a PickingInfo
  129573. */
  129574. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  129575. var count = Math.min(this._capacity, this.sprites.length);
  129576. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  129577. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  129578. var distance = Number.MAX_VALUE;
  129579. var currentSprite = null;
  129580. var pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  129581. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  129582. var cameraView = camera.getViewMatrix();
  129583. for (var index = 0; index < count; index++) {
  129584. var sprite = this.sprites[index];
  129585. if (!sprite) {
  129586. continue;
  129587. }
  129588. if (predicate) {
  129589. if (!predicate(sprite)) {
  129590. continue;
  129591. }
  129592. }
  129593. else if (!sprite.isPickable) {
  129594. continue;
  129595. }
  129596. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  129597. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  129598. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  129599. if (ray.intersectsBoxMinMax(min, max)) {
  129600. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  129601. if (distance > currentDistance) {
  129602. distance = currentDistance;
  129603. currentSprite = sprite;
  129604. if (fastCheck) {
  129605. break;
  129606. }
  129607. }
  129608. }
  129609. }
  129610. if (currentSprite) {
  129611. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  129612. cameraView.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  129613. result.hit = true;
  129614. result.pickedSprite = currentSprite;
  129615. result.distance = distance;
  129616. // Get picked point
  129617. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  129618. direction.copyFrom(ray.direction);
  129619. direction.normalize();
  129620. direction.scaleInPlace(distance);
  129621. ray.origin.addToRef(direction, pickedPoint);
  129622. result.pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(pickedPoint, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  129623. return result;
  129624. }
  129625. return null;
  129626. };
  129627. /**
  129628. * Render all child sprites
  129629. */
  129630. SpriteManager.prototype.render = function () {
  129631. // Check
  129632. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  129633. || !this._spriteTexture.isReady() || !this.sprites.length) {
  129634. return;
  129635. }
  129636. var engine = this._scene.getEngine();
  129637. var baseSize = this._spriteTexture.getBaseSize();
  129638. // Sprites
  129639. var deltaTime = engine.getDeltaTime();
  129640. var max = Math.min(this._capacity, this.sprites.length);
  129641. var rowSize = baseSize.width / this.cellWidth;
  129642. var offset = 0;
  129643. var noSprite = true;
  129644. for (var index = 0; index < max; index++) {
  129645. var sprite = this.sprites[index];
  129646. if (!sprite || !sprite.isVisible) {
  129647. continue;
  129648. }
  129649. noSprite = false;
  129650. sprite._animate(deltaTime);
  129651. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  129652. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  129653. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  129654. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  129655. }
  129656. if (noSprite) {
  129657. return;
  129658. }
  129659. this._buffer.update(this._vertexData);
  129660. // Render
  129661. var effect = this._effectBase;
  129662. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  129663. effect = this._effectFog;
  129664. }
  129665. engine.enableEffect(effect);
  129666. var viewMatrix = this._scene.getViewMatrix();
  129667. effect.setTexture("diffuseSampler", this._spriteTexture);
  129668. effect.setMatrix("view", viewMatrix);
  129669. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  129670. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  129671. // Fog
  129672. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  129673. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  129674. effect.setColor3("vFogColor", this._scene.fogColor);
  129675. }
  129676. // VBOs
  129677. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  129678. // Draw order
  129679. engine.setDepthFunctionToLessOrEqual();
  129680. effect.setBool("alphaTest", true);
  129681. engine.setColorWrite(false);
  129682. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  129683. engine.setColorWrite(true);
  129684. effect.setBool("alphaTest", false);
  129685. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  129686. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  129687. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  129688. };
  129689. /**
  129690. * Release associated resources
  129691. */
  129692. SpriteManager.prototype.dispose = function () {
  129693. if (this._buffer) {
  129694. this._buffer.dispose();
  129695. this._buffer = null;
  129696. }
  129697. if (this._indexBuffer) {
  129698. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  129699. this._indexBuffer = null;
  129700. }
  129701. if (this._spriteTexture) {
  129702. this._spriteTexture.dispose();
  129703. this._spriteTexture = null;
  129704. }
  129705. // Remove from scene
  129706. var index = this._scene.spriteManagers.indexOf(this);
  129707. this._scene.spriteManagers.splice(index, 1);
  129708. // Callback
  129709. this.onDisposeObservable.notifyObservers(this);
  129710. this.onDisposeObservable.clear();
  129711. };
  129712. return SpriteManager;
  129713. }());
  129714. /***/ }),
  129715. /***/ "./Sprites/spriteSceneComponent.ts":
  129716. /*!*****************************************!*\
  129717. !*** ./Sprites/spriteSceneComponent.ts ***!
  129718. \*****************************************/
  129719. /*! exports provided: SpriteSceneComponent */
  129720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129721. "use strict";
  129722. __webpack_require__.r(__webpack_exports__);
  129723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  129724. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  129725. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  129726. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  129727. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  129728. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  129729. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  129730. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  129731. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  129732. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  129733. return null;
  129734. }
  129735. var pickingInfo = null;
  129736. if (!camera) {
  129737. if (!this.activeCamera) {
  129738. return null;
  129739. }
  129740. camera = this.activeCamera;
  129741. }
  129742. if (this.spriteManagers.length > 0) {
  129743. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  129744. var spriteManager = this.spriteManagers[spriteIndex];
  129745. if (!spriteManager.isPickable) {
  129746. continue;
  129747. }
  129748. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  129749. if (!result || !result.hit) {
  129750. continue;
  129751. }
  129752. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  129753. continue;
  129754. }
  129755. pickingInfo = result;
  129756. if (fastCheck) {
  129757. break;
  129758. }
  129759. }
  129760. }
  129761. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  129762. };
  129763. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  129764. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  129765. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  129766. };
  129767. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  129768. if (!this._tempSpritePickingRay) {
  129769. return null;
  129770. }
  129771. if (!camera) {
  129772. if (!this.activeCamera) {
  129773. return null;
  129774. }
  129775. camera = this.activeCamera;
  129776. }
  129777. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  129778. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  129779. };
  129780. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  129781. if (this._pointerOverSprite === sprite) {
  129782. return;
  129783. }
  129784. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  129785. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  129786. }
  129787. this._pointerOverSprite = sprite;
  129788. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  129789. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  129790. }
  129791. };
  129792. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  129793. return this._pointerOverSprite;
  129794. };
  129795. /**
  129796. * Defines the sprite scene component responsible to manage sprites
  129797. * in a given scene.
  129798. */
  129799. var SpriteSceneComponent = /** @class */ (function () {
  129800. /**
  129801. * Creates a new instance of the component for the given scene
  129802. * @param scene Defines the scene to register the component in
  129803. */
  129804. function SpriteSceneComponent(scene) {
  129805. /**
  129806. * The component name helpfull to identify the component in the list of scene components.
  129807. */
  129808. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  129809. this.scene = scene;
  129810. this.scene.spriteManagers = new Array();
  129811. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  129812. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  129813. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  129814. this._spritePredicate = function (sprite) {
  129815. if (!sprite.actionManager) {
  129816. return false;
  129817. }
  129818. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  129819. };
  129820. }
  129821. /**
  129822. * Registers the component in a given scene
  129823. */
  129824. SpriteSceneComponent.prototype.register = function () {
  129825. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  129826. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  129827. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  129828. };
  129829. /**
  129830. * Rebuilds the elements related to this component in case of
  129831. * context lost for instance.
  129832. */
  129833. SpriteSceneComponent.prototype.rebuild = function () {
  129834. /** Nothing to do for sprites */
  129835. };
  129836. /**
  129837. * Disposes the component and the associated ressources.
  129838. */
  129839. SpriteSceneComponent.prototype.dispose = function () {
  129840. this.scene.onBeforeSpritesRenderingObservable.clear();
  129841. this.scene.onAfterSpritesRenderingObservable.clear();
  129842. var spriteManagers = this.scene.spriteManagers;
  129843. while (spriteManagers.length) {
  129844. spriteManagers[0].dispose();
  129845. }
  129846. };
  129847. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  129848. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  129849. if (result) {
  129850. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  129851. }
  129852. return result;
  129853. };
  129854. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  129855. var scene = this.scene;
  129856. if (isMeshPicked) {
  129857. scene.setPointerOverSprite(null);
  129858. }
  129859. else {
  129860. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  129861. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  129862. scene.setPointerOverSprite(pickResult.pickedSprite);
  129863. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  129864. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  129865. }
  129866. else {
  129867. canvas.style.cursor = scene.hoverCursor;
  129868. }
  129869. }
  129870. else {
  129871. scene.setPointerOverSprite(null);
  129872. }
  129873. }
  129874. return pickResult;
  129875. };
  129876. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  129877. var scene = this.scene;
  129878. scene._pickedDownSprite = null;
  129879. if (scene.spriteManagers.length > 0) {
  129880. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  129881. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  129882. if (pickResult.pickedSprite.actionManager) {
  129883. scene._pickedDownSprite = pickResult.pickedSprite;
  129884. switch (evt.button) {
  129885. case 0:
  129886. 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));
  129887. break;
  129888. case 1:
  129889. 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));
  129890. break;
  129891. case 2:
  129892. 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));
  129893. break;
  129894. }
  129895. if (pickResult.pickedSprite.actionManager) {
  129896. 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));
  129897. }
  129898. }
  129899. }
  129900. }
  129901. return pickResult;
  129902. };
  129903. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  129904. var scene = this.scene;
  129905. if (scene.spriteManagers.length > 0) {
  129906. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  129907. if (spritePickResult) {
  129908. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  129909. if (spritePickResult.pickedSprite.actionManager) {
  129910. 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));
  129911. if (spritePickResult.pickedSprite.actionManager) {
  129912. if (!this.scene._isPointerSwiping()) {
  129913. 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));
  129914. }
  129915. }
  129916. }
  129917. }
  129918. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  129919. 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));
  129920. }
  129921. }
  129922. }
  129923. return pickResult;
  129924. };
  129925. return SpriteSceneComponent;
  129926. }());
  129927. /***/ }),
  129928. /***/ "./States/alphaCullingState.ts":
  129929. /*!*************************************!*\
  129930. !*** ./States/alphaCullingState.ts ***!
  129931. \*************************************/
  129932. /*! exports provided: _AlphaState */
  129933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129934. "use strict";
  129935. __webpack_require__.r(__webpack_exports__);
  129936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  129937. /**
  129938. * @hidden
  129939. **/
  129940. var _AlphaState = /** @class */ (function () {
  129941. /**
  129942. * Initializes the state.
  129943. */
  129944. function _AlphaState() {
  129945. this._isAlphaBlendDirty = false;
  129946. this._isBlendFunctionParametersDirty = false;
  129947. this._isBlendEquationParametersDirty = false;
  129948. this._isBlendConstantsDirty = false;
  129949. this._alphaBlend = false;
  129950. this._blendFunctionParameters = new Array(4);
  129951. this._blendEquationParameters = new Array(2);
  129952. this._blendConstants = new Array(4);
  129953. this.reset();
  129954. }
  129955. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  129956. get: function () {
  129957. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  129958. },
  129959. enumerable: true,
  129960. configurable: true
  129961. });
  129962. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  129963. get: function () {
  129964. return this._alphaBlend;
  129965. },
  129966. set: function (value) {
  129967. if (this._alphaBlend === value) {
  129968. return;
  129969. }
  129970. this._alphaBlend = value;
  129971. this._isAlphaBlendDirty = true;
  129972. },
  129973. enumerable: true,
  129974. configurable: true
  129975. });
  129976. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  129977. if (this._blendConstants[0] === r &&
  129978. this._blendConstants[1] === g &&
  129979. this._blendConstants[2] === b &&
  129980. this._blendConstants[3] === a) {
  129981. return;
  129982. }
  129983. this._blendConstants[0] = r;
  129984. this._blendConstants[1] = g;
  129985. this._blendConstants[2] = b;
  129986. this._blendConstants[3] = a;
  129987. this._isBlendConstantsDirty = true;
  129988. };
  129989. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  129990. if (this._blendFunctionParameters[0] === value0 &&
  129991. this._blendFunctionParameters[1] === value1 &&
  129992. this._blendFunctionParameters[2] === value2 &&
  129993. this._blendFunctionParameters[3] === value3) {
  129994. return;
  129995. }
  129996. this._blendFunctionParameters[0] = value0;
  129997. this._blendFunctionParameters[1] = value1;
  129998. this._blendFunctionParameters[2] = value2;
  129999. this._blendFunctionParameters[3] = value3;
  130000. this._isBlendFunctionParametersDirty = true;
  130001. };
  130002. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  130003. if (this._blendEquationParameters[0] === rgb &&
  130004. this._blendEquationParameters[1] === alpha) {
  130005. return;
  130006. }
  130007. this._blendEquationParameters[0] = rgb;
  130008. this._blendEquationParameters[1] = alpha;
  130009. this._isBlendEquationParametersDirty = true;
  130010. };
  130011. _AlphaState.prototype.reset = function () {
  130012. this._alphaBlend = false;
  130013. this._blendFunctionParameters[0] = null;
  130014. this._blendFunctionParameters[1] = null;
  130015. this._blendFunctionParameters[2] = null;
  130016. this._blendFunctionParameters[3] = null;
  130017. this._blendEquationParameters[0] = null;
  130018. this._blendEquationParameters[1] = null;
  130019. this._blendConstants[0] = null;
  130020. this._blendConstants[1] = null;
  130021. this._blendConstants[2] = null;
  130022. this._blendConstants[3] = null;
  130023. this._isAlphaBlendDirty = true;
  130024. this._isBlendFunctionParametersDirty = false;
  130025. this._isBlendEquationParametersDirty = false;
  130026. this._isBlendConstantsDirty = false;
  130027. };
  130028. _AlphaState.prototype.apply = function (gl) {
  130029. if (!this.isDirty) {
  130030. return;
  130031. }
  130032. // Alpha blend
  130033. if (this._isAlphaBlendDirty) {
  130034. if (this._alphaBlend) {
  130035. gl.enable(gl.BLEND);
  130036. }
  130037. else {
  130038. gl.disable(gl.BLEND);
  130039. }
  130040. this._isAlphaBlendDirty = false;
  130041. }
  130042. // Alpha function
  130043. if (this._isBlendFunctionParametersDirty) {
  130044. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  130045. this._isBlendFunctionParametersDirty = false;
  130046. }
  130047. // Alpha equation
  130048. if (this._isBlendEquationParametersDirty) {
  130049. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  130050. this._isBlendEquationParametersDirty = false;
  130051. }
  130052. // Constants
  130053. if (this._isBlendConstantsDirty) {
  130054. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  130055. this._isBlendConstantsDirty = false;
  130056. }
  130057. };
  130058. return _AlphaState;
  130059. }());
  130060. /***/ }),
  130061. /***/ "./States/depthCullingState.ts":
  130062. /*!*************************************!*\
  130063. !*** ./States/depthCullingState.ts ***!
  130064. \*************************************/
  130065. /*! exports provided: _DepthCullingState */
  130066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130067. "use strict";
  130068. __webpack_require__.r(__webpack_exports__);
  130069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  130070. /**
  130071. * @hidden
  130072. **/
  130073. var _DepthCullingState = /** @class */ (function () {
  130074. /**
  130075. * Initializes the state.
  130076. */
  130077. function _DepthCullingState() {
  130078. this._isDepthTestDirty = false;
  130079. this._isDepthMaskDirty = false;
  130080. this._isDepthFuncDirty = false;
  130081. this._isCullFaceDirty = false;
  130082. this._isCullDirty = false;
  130083. this._isZOffsetDirty = false;
  130084. this._isFrontFaceDirty = false;
  130085. this.reset();
  130086. }
  130087. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  130088. get: function () {
  130089. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  130090. },
  130091. enumerable: true,
  130092. configurable: true
  130093. });
  130094. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  130095. get: function () {
  130096. return this._zOffset;
  130097. },
  130098. set: function (value) {
  130099. if (this._zOffset === value) {
  130100. return;
  130101. }
  130102. this._zOffset = value;
  130103. this._isZOffsetDirty = true;
  130104. },
  130105. enumerable: true,
  130106. configurable: true
  130107. });
  130108. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  130109. get: function () {
  130110. return this._cullFace;
  130111. },
  130112. set: function (value) {
  130113. if (this._cullFace === value) {
  130114. return;
  130115. }
  130116. this._cullFace = value;
  130117. this._isCullFaceDirty = true;
  130118. },
  130119. enumerable: true,
  130120. configurable: true
  130121. });
  130122. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  130123. get: function () {
  130124. return this._cull;
  130125. },
  130126. set: function (value) {
  130127. if (this._cull === value) {
  130128. return;
  130129. }
  130130. this._cull = value;
  130131. this._isCullDirty = true;
  130132. },
  130133. enumerable: true,
  130134. configurable: true
  130135. });
  130136. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  130137. get: function () {
  130138. return this._depthFunc;
  130139. },
  130140. set: function (value) {
  130141. if (this._depthFunc === value) {
  130142. return;
  130143. }
  130144. this._depthFunc = value;
  130145. this._isDepthFuncDirty = true;
  130146. },
  130147. enumerable: true,
  130148. configurable: true
  130149. });
  130150. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  130151. get: function () {
  130152. return this._depthMask;
  130153. },
  130154. set: function (value) {
  130155. if (this._depthMask === value) {
  130156. return;
  130157. }
  130158. this._depthMask = value;
  130159. this._isDepthMaskDirty = true;
  130160. },
  130161. enumerable: true,
  130162. configurable: true
  130163. });
  130164. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  130165. get: function () {
  130166. return this._depthTest;
  130167. },
  130168. set: function (value) {
  130169. if (this._depthTest === value) {
  130170. return;
  130171. }
  130172. this._depthTest = value;
  130173. this._isDepthTestDirty = true;
  130174. },
  130175. enumerable: true,
  130176. configurable: true
  130177. });
  130178. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  130179. get: function () {
  130180. return this._frontFace;
  130181. },
  130182. set: function (value) {
  130183. if (this._frontFace === value) {
  130184. return;
  130185. }
  130186. this._frontFace = value;
  130187. this._isFrontFaceDirty = true;
  130188. },
  130189. enumerable: true,
  130190. configurable: true
  130191. });
  130192. _DepthCullingState.prototype.reset = function () {
  130193. this._depthMask = true;
  130194. this._depthTest = true;
  130195. this._depthFunc = null;
  130196. this._cullFace = null;
  130197. this._cull = null;
  130198. this._zOffset = 0;
  130199. this._frontFace = null;
  130200. this._isDepthTestDirty = true;
  130201. this._isDepthMaskDirty = true;
  130202. this._isDepthFuncDirty = false;
  130203. this._isCullFaceDirty = false;
  130204. this._isCullDirty = false;
  130205. this._isZOffsetDirty = false;
  130206. this._isFrontFaceDirty = false;
  130207. };
  130208. _DepthCullingState.prototype.apply = function (gl) {
  130209. if (!this.isDirty) {
  130210. return;
  130211. }
  130212. // Cull
  130213. if (this._isCullDirty) {
  130214. if (this.cull) {
  130215. gl.enable(gl.CULL_FACE);
  130216. }
  130217. else {
  130218. gl.disable(gl.CULL_FACE);
  130219. }
  130220. this._isCullDirty = false;
  130221. }
  130222. // Cull face
  130223. if (this._isCullFaceDirty) {
  130224. gl.cullFace(this.cullFace);
  130225. this._isCullFaceDirty = false;
  130226. }
  130227. // Depth mask
  130228. if (this._isDepthMaskDirty) {
  130229. gl.depthMask(this.depthMask);
  130230. this._isDepthMaskDirty = false;
  130231. }
  130232. // Depth test
  130233. if (this._isDepthTestDirty) {
  130234. if (this.depthTest) {
  130235. gl.enable(gl.DEPTH_TEST);
  130236. }
  130237. else {
  130238. gl.disable(gl.DEPTH_TEST);
  130239. }
  130240. this._isDepthTestDirty = false;
  130241. }
  130242. // Depth func
  130243. if (this._isDepthFuncDirty) {
  130244. gl.depthFunc(this.depthFunc);
  130245. this._isDepthFuncDirty = false;
  130246. }
  130247. // zOffset
  130248. if (this._isZOffsetDirty) {
  130249. if (this.zOffset) {
  130250. gl.enable(gl.POLYGON_OFFSET_FILL);
  130251. gl.polygonOffset(this.zOffset, 0);
  130252. }
  130253. else {
  130254. gl.disable(gl.POLYGON_OFFSET_FILL);
  130255. }
  130256. this._isZOffsetDirty = false;
  130257. }
  130258. // Front face
  130259. if (this._isFrontFaceDirty) {
  130260. gl.frontFace(this.frontFace);
  130261. this._isFrontFaceDirty = false;
  130262. }
  130263. };
  130264. return _DepthCullingState;
  130265. }());
  130266. /***/ }),
  130267. /***/ "./States/index.ts":
  130268. /*!*************************!*\
  130269. !*** ./States/index.ts ***!
  130270. \*************************/
  130271. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  130272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130273. "use strict";
  130274. __webpack_require__.r(__webpack_exports__);
  130275. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  130276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  130277. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  130278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  130279. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  130280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  130281. /***/ }),
  130282. /***/ "./States/stencilState.ts":
  130283. /*!********************************!*\
  130284. !*** ./States/stencilState.ts ***!
  130285. \********************************/
  130286. /*! exports provided: _StencilState */
  130287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130288. "use strict";
  130289. __webpack_require__.r(__webpack_exports__);
  130290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  130291. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  130292. /**
  130293. * @hidden
  130294. **/
  130295. var _StencilState = /** @class */ (function () {
  130296. function _StencilState() {
  130297. this._isStencilTestDirty = false;
  130298. this._isStencilMaskDirty = false;
  130299. this._isStencilFuncDirty = false;
  130300. this._isStencilOpDirty = false;
  130301. this.reset();
  130302. }
  130303. Object.defineProperty(_StencilState.prototype, "isDirty", {
  130304. get: function () {
  130305. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  130306. },
  130307. enumerable: true,
  130308. configurable: true
  130309. });
  130310. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  130311. get: function () {
  130312. return this._stencilFunc;
  130313. },
  130314. set: function (value) {
  130315. if (this._stencilFunc === value) {
  130316. return;
  130317. }
  130318. this._stencilFunc = value;
  130319. this._isStencilFuncDirty = true;
  130320. },
  130321. enumerable: true,
  130322. configurable: true
  130323. });
  130324. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  130325. get: function () {
  130326. return this._stencilFuncRef;
  130327. },
  130328. set: function (value) {
  130329. if (this._stencilFuncRef === value) {
  130330. return;
  130331. }
  130332. this._stencilFuncRef = value;
  130333. this._isStencilFuncDirty = true;
  130334. },
  130335. enumerable: true,
  130336. configurable: true
  130337. });
  130338. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  130339. get: function () {
  130340. return this._stencilFuncMask;
  130341. },
  130342. set: function (value) {
  130343. if (this._stencilFuncMask === value) {
  130344. return;
  130345. }
  130346. this._stencilFuncMask = value;
  130347. this._isStencilFuncDirty = true;
  130348. },
  130349. enumerable: true,
  130350. configurable: true
  130351. });
  130352. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  130353. get: function () {
  130354. return this._stencilOpStencilFail;
  130355. },
  130356. set: function (value) {
  130357. if (this._stencilOpStencilFail === value) {
  130358. return;
  130359. }
  130360. this._stencilOpStencilFail = value;
  130361. this._isStencilOpDirty = true;
  130362. },
  130363. enumerable: true,
  130364. configurable: true
  130365. });
  130366. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  130367. get: function () {
  130368. return this._stencilOpDepthFail;
  130369. },
  130370. set: function (value) {
  130371. if (this._stencilOpDepthFail === value) {
  130372. return;
  130373. }
  130374. this._stencilOpDepthFail = value;
  130375. this._isStencilOpDirty = true;
  130376. },
  130377. enumerable: true,
  130378. configurable: true
  130379. });
  130380. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  130381. get: function () {
  130382. return this._stencilOpStencilDepthPass;
  130383. },
  130384. set: function (value) {
  130385. if (this._stencilOpStencilDepthPass === value) {
  130386. return;
  130387. }
  130388. this._stencilOpStencilDepthPass = value;
  130389. this._isStencilOpDirty = true;
  130390. },
  130391. enumerable: true,
  130392. configurable: true
  130393. });
  130394. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  130395. get: function () {
  130396. return this._stencilMask;
  130397. },
  130398. set: function (value) {
  130399. if (this._stencilMask === value) {
  130400. return;
  130401. }
  130402. this._stencilMask = value;
  130403. this._isStencilMaskDirty = true;
  130404. },
  130405. enumerable: true,
  130406. configurable: true
  130407. });
  130408. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  130409. get: function () {
  130410. return this._stencilTest;
  130411. },
  130412. set: function (value) {
  130413. if (this._stencilTest === value) {
  130414. return;
  130415. }
  130416. this._stencilTest = value;
  130417. this._isStencilTestDirty = true;
  130418. },
  130419. enumerable: true,
  130420. configurable: true
  130421. });
  130422. _StencilState.prototype.reset = function () {
  130423. this._stencilTest = false;
  130424. this._stencilMask = 0xFF;
  130425. this._stencilFunc = _StencilState.ALWAYS;
  130426. this._stencilFuncRef = 1;
  130427. this._stencilFuncMask = 0xFF;
  130428. this._stencilOpStencilFail = _StencilState.KEEP;
  130429. this._stencilOpDepthFail = _StencilState.KEEP;
  130430. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  130431. this._isStencilTestDirty = true;
  130432. this._isStencilMaskDirty = true;
  130433. this._isStencilFuncDirty = true;
  130434. this._isStencilOpDirty = true;
  130435. };
  130436. _StencilState.prototype.apply = function (gl) {
  130437. if (!this.isDirty) {
  130438. return;
  130439. }
  130440. // Stencil test
  130441. if (this._isStencilTestDirty) {
  130442. if (this.stencilTest) {
  130443. gl.enable(gl.STENCIL_TEST);
  130444. }
  130445. else {
  130446. gl.disable(gl.STENCIL_TEST);
  130447. }
  130448. this._isStencilTestDirty = false;
  130449. }
  130450. // Stencil mask
  130451. if (this._isStencilMaskDirty) {
  130452. gl.stencilMask(this.stencilMask);
  130453. this._isStencilMaskDirty = false;
  130454. }
  130455. // Stencil func
  130456. if (this._isStencilFuncDirty) {
  130457. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  130458. this._isStencilFuncDirty = false;
  130459. }
  130460. // Stencil op
  130461. if (this._isStencilOpDirty) {
  130462. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  130463. this._isStencilOpDirty = false;
  130464. }
  130465. };
  130466. /** 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 */
  130467. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  130468. /** Passed to stencilOperation to specify that stencil value must be kept */
  130469. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  130470. /** Passed to stencilOperation to specify that stencil value must be replaced */
  130471. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  130472. return _StencilState;
  130473. }());
  130474. /***/ }),
  130475. /***/ "./abstractScene.ts":
  130476. /*!**************************!*\
  130477. !*** ./abstractScene.ts ***!
  130478. \**************************/
  130479. /*! exports provided: AbstractScene */
  130480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130481. "use strict";
  130482. __webpack_require__.r(__webpack_exports__);
  130483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  130484. /**
  130485. * Base class of the scene acting as a container for the different elements composing a scene.
  130486. * This class is dynamically extended by the different components of the scene increasing
  130487. * flexibility and reducing coupling
  130488. */
  130489. var AbstractScene = /** @class */ (function () {
  130490. function AbstractScene() {
  130491. /**
  130492. * Gets the list of root nodes (ie. nodes with no parent)
  130493. */
  130494. this.rootNodes = new Array();
  130495. /** All of the cameras added to this scene
  130496. * @see http://doc.babylonjs.com/babylon101/cameras
  130497. */
  130498. this.cameras = new Array();
  130499. /**
  130500. * All of the lights added to this scene
  130501. * @see http://doc.babylonjs.com/babylon101/lights
  130502. */
  130503. this.lights = new Array();
  130504. /**
  130505. * All of the (abstract) meshes added to this scene
  130506. */
  130507. this.meshes = new Array();
  130508. /**
  130509. * The list of skeletons added to the scene
  130510. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  130511. */
  130512. this.skeletons = new Array();
  130513. /**
  130514. * All of the particle systems added to this scene
  130515. * @see http://doc.babylonjs.com/babylon101/particles
  130516. */
  130517. this.particleSystems = new Array();
  130518. /**
  130519. * Gets a list of Animations associated with the scene
  130520. */
  130521. this.animations = [];
  130522. /**
  130523. * All of the animation groups added to this scene
  130524. * @see http://doc.babylonjs.com/how_to/group
  130525. */
  130526. this.animationGroups = new Array();
  130527. /**
  130528. * All of the multi-materials added to this scene
  130529. * @see http://doc.babylonjs.com/how_to/multi_materials
  130530. */
  130531. this.multiMaterials = new Array();
  130532. /**
  130533. * All of the materials added to this scene
  130534. * In the context of a Scene, it is not supposed to be modified manually.
  130535. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  130536. * Note also that the order of the Material wihin the array is not significant and might change.
  130537. * @see http://doc.babylonjs.com/babylon101/materials
  130538. */
  130539. this.materials = new Array();
  130540. /**
  130541. * The list of morph target managers added to the scene
  130542. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  130543. */
  130544. this.morphTargetManagers = new Array();
  130545. /**
  130546. * The list of geometries used in the scene.
  130547. */
  130548. this.geometries = new Array();
  130549. /**
  130550. * All of the tranform nodes added to this scene
  130551. * In the context of a Scene, it is not supposed to be modified manually.
  130552. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  130553. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  130554. * @see http://doc.babylonjs.com/how_to/transformnode
  130555. */
  130556. this.transformNodes = new Array();
  130557. /**
  130558. * ActionManagers available on the scene.
  130559. */
  130560. this.actionManagers = new Array();
  130561. /**
  130562. * Textures to keep.
  130563. */
  130564. this.textures = new Array();
  130565. }
  130566. /**
  130567. * Adds a parser in the list of available ones
  130568. * @param name Defines the name of the parser
  130569. * @param parser Defines the parser to add
  130570. */
  130571. AbstractScene.AddParser = function (name, parser) {
  130572. this._BabylonFileParsers[name] = parser;
  130573. };
  130574. /**
  130575. * Gets a general parser from the list of avaialble ones
  130576. * @param name Defines the name of the parser
  130577. * @returns the requested parser or null
  130578. */
  130579. AbstractScene.GetParser = function (name) {
  130580. if (this._BabylonFileParsers[name]) {
  130581. return this._BabylonFileParsers[name];
  130582. }
  130583. return null;
  130584. };
  130585. /**
  130586. * Adds n individual parser in the list of available ones
  130587. * @param name Defines the name of the parser
  130588. * @param parser Defines the parser to add
  130589. */
  130590. AbstractScene.AddIndividualParser = function (name, parser) {
  130591. this._IndividualBabylonFileParsers[name] = parser;
  130592. };
  130593. /**
  130594. * Gets an individual parser from the list of avaialble ones
  130595. * @param name Defines the name of the parser
  130596. * @returns the requested parser or null
  130597. */
  130598. AbstractScene.GetIndividualParser = function (name) {
  130599. if (this._IndividualBabylonFileParsers[name]) {
  130600. return this._IndividualBabylonFileParsers[name];
  130601. }
  130602. return null;
  130603. };
  130604. /**
  130605. * Parser json data and populate both a scene and its associated container object
  130606. * @param jsonData Defines the data to parse
  130607. * @param scene Defines the scene to parse the data for
  130608. * @param container Defines the container attached to the parsing sequence
  130609. * @param rootUrl Defines the root url of the data
  130610. */
  130611. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  130612. for (var parserName in this._BabylonFileParsers) {
  130613. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  130614. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  130615. }
  130616. }
  130617. };
  130618. /**
  130619. * Stores the list of available parsers in the application.
  130620. */
  130621. AbstractScene._BabylonFileParsers = {};
  130622. /**
  130623. * Stores the list of available individual parsers in the application.
  130624. */
  130625. AbstractScene._IndividualBabylonFileParsers = {};
  130626. return AbstractScene;
  130627. }());
  130628. /***/ }),
  130629. /***/ "./assetContainer.ts":
  130630. /*!***************************!*\
  130631. !*** ./assetContainer.ts ***!
  130632. \***************************/
  130633. /*! exports provided: KeepAssets, AssetContainer */
  130634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130635. "use strict";
  130636. __webpack_require__.r(__webpack_exports__);
  130637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  130638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  130639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  130640. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  130641. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  130642. /**
  130643. * Set of assets to keep when moving a scene into an asset container.
  130644. */
  130645. var KeepAssets = /** @class */ (function (_super) {
  130646. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  130647. function KeepAssets() {
  130648. return _super !== null && _super.apply(this, arguments) || this;
  130649. }
  130650. return KeepAssets;
  130651. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  130652. /**
  130653. * Container with a set of assets that can be added or removed from a scene.
  130654. */
  130655. var AssetContainer = /** @class */ (function (_super) {
  130656. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  130657. /**
  130658. * Instantiates an AssetContainer.
  130659. * @param scene The scene the AssetContainer belongs to.
  130660. */
  130661. function AssetContainer(scene) {
  130662. var _this = _super.call(this) || this;
  130663. _this.scene = scene;
  130664. _this["sounds"] = [];
  130665. _this["effectLayers"] = [];
  130666. _this["layers"] = [];
  130667. _this["lensFlareSystems"] = [];
  130668. _this["proceduralTextures"] = [];
  130669. _this["reflectionProbes"] = [];
  130670. return _this;
  130671. }
  130672. /**
  130673. * Adds all the assets from the container to the scene.
  130674. */
  130675. AssetContainer.prototype.addAllToScene = function () {
  130676. var _this = this;
  130677. this.cameras.forEach(function (o) {
  130678. _this.scene.addCamera(o);
  130679. });
  130680. this.lights.forEach(function (o) {
  130681. _this.scene.addLight(o);
  130682. });
  130683. this.meshes.forEach(function (o) {
  130684. _this.scene.addMesh(o);
  130685. });
  130686. this.skeletons.forEach(function (o) {
  130687. _this.scene.addSkeleton(o);
  130688. });
  130689. this.animations.forEach(function (o) {
  130690. _this.scene.addAnimation(o);
  130691. });
  130692. this.animationGroups.forEach(function (o) {
  130693. _this.scene.addAnimationGroup(o);
  130694. });
  130695. this.multiMaterials.forEach(function (o) {
  130696. _this.scene.addMultiMaterial(o);
  130697. });
  130698. this.materials.forEach(function (o) {
  130699. _this.scene.addMaterial(o);
  130700. });
  130701. this.morphTargetManagers.forEach(function (o) {
  130702. _this.scene.addMorphTargetManager(o);
  130703. });
  130704. this.geometries.forEach(function (o) {
  130705. _this.scene.addGeometry(o);
  130706. });
  130707. this.transformNodes.forEach(function (o) {
  130708. _this.scene.addTransformNode(o);
  130709. });
  130710. this.actionManagers.forEach(function (o) {
  130711. _this.scene.addActionManager(o);
  130712. });
  130713. this.textures.forEach(function (o) {
  130714. _this.scene.addTexture(o);
  130715. });
  130716. this.reflectionProbes.forEach(function (o) {
  130717. _this.scene.addReflectionProbe(o);
  130718. });
  130719. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  130720. var component = _a[_i];
  130721. component.addFromContainer(this);
  130722. }
  130723. };
  130724. /**
  130725. * Removes all the assets in the container from the scene
  130726. */
  130727. AssetContainer.prototype.removeAllFromScene = function () {
  130728. var _this = this;
  130729. this.cameras.forEach(function (o) {
  130730. _this.scene.removeCamera(o);
  130731. });
  130732. this.lights.forEach(function (o) {
  130733. _this.scene.removeLight(o);
  130734. });
  130735. this.meshes.forEach(function (o) {
  130736. _this.scene.removeMesh(o);
  130737. });
  130738. this.skeletons.forEach(function (o) {
  130739. _this.scene.removeSkeleton(o);
  130740. });
  130741. this.animations.forEach(function (o) {
  130742. _this.scene.removeAnimation(o);
  130743. });
  130744. this.animationGroups.forEach(function (o) {
  130745. _this.scene.removeAnimationGroup(o);
  130746. });
  130747. this.multiMaterials.forEach(function (o) {
  130748. _this.scene.removeMultiMaterial(o);
  130749. });
  130750. this.materials.forEach(function (o) {
  130751. _this.scene.removeMaterial(o);
  130752. });
  130753. this.morphTargetManagers.forEach(function (o) {
  130754. _this.scene.removeMorphTargetManager(o);
  130755. });
  130756. this.geometries.forEach(function (o) {
  130757. _this.scene.removeGeometry(o);
  130758. });
  130759. this.transformNodes.forEach(function (o) {
  130760. _this.scene.removeTransformNode(o);
  130761. });
  130762. this.actionManagers.forEach(function (o) {
  130763. _this.scene.removeActionManager(o);
  130764. });
  130765. this.textures.forEach(function (o) {
  130766. _this.scene.removeTexture(o);
  130767. });
  130768. this.reflectionProbes.forEach(function (o) {
  130769. _this.scene.removeReflectionProbe(o);
  130770. });
  130771. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  130772. var component = _a[_i];
  130773. component.removeFromContainer(this);
  130774. }
  130775. };
  130776. /**
  130777. * Disposes all the assets in the container
  130778. */
  130779. AssetContainer.prototype.dispose = function () {
  130780. this.cameras.forEach(function (o) {
  130781. o.dispose();
  130782. });
  130783. this.lights.forEach(function (o) {
  130784. o.dispose();
  130785. });
  130786. this.meshes.forEach(function (o) {
  130787. o.dispose();
  130788. });
  130789. this.skeletons.forEach(function (o) {
  130790. o.dispose();
  130791. });
  130792. this.animationGroups.forEach(function (o) {
  130793. o.dispose();
  130794. });
  130795. this.multiMaterials.forEach(function (o) {
  130796. o.dispose();
  130797. });
  130798. this.materials.forEach(function (o) {
  130799. o.dispose();
  130800. });
  130801. this.geometries.forEach(function (o) {
  130802. o.dispose();
  130803. });
  130804. this.transformNodes.forEach(function (o) {
  130805. o.dispose();
  130806. });
  130807. this.actionManagers.forEach(function (o) {
  130808. o.dispose();
  130809. });
  130810. this.textures.forEach(function (o) {
  130811. o.dispose();
  130812. });
  130813. this.reflectionProbes.forEach(function (o) {
  130814. o.dispose();
  130815. });
  130816. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  130817. var component = _a[_i];
  130818. component.dispose();
  130819. }
  130820. };
  130821. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  130822. if (!sourceAssets) {
  130823. return;
  130824. }
  130825. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  130826. var asset = sourceAssets_1[_i];
  130827. var move = true;
  130828. if (keepAssets) {
  130829. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  130830. var keepAsset = keepAssets_1[_a];
  130831. if (asset === keepAsset) {
  130832. move = false;
  130833. break;
  130834. }
  130835. }
  130836. }
  130837. if (move) {
  130838. targetAssets.push(asset);
  130839. }
  130840. }
  130841. };
  130842. /**
  130843. * Removes all the assets contained in the scene and adds them to the container.
  130844. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  130845. */
  130846. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  130847. if (keepAssets === undefined) {
  130848. keepAssets = new KeepAssets();
  130849. }
  130850. for (var key in this) {
  130851. if (this.hasOwnProperty(key)) {
  130852. this[key] = this[key] || [];
  130853. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  130854. }
  130855. }
  130856. this.removeAllFromScene();
  130857. };
  130858. /**
  130859. * 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.
  130860. * @returns the root mesh
  130861. */
  130862. AssetContainer.prototype.createRootMesh = function () {
  130863. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  130864. this.meshes.forEach(function (m) {
  130865. if (!m.parent) {
  130866. rootMesh.addChild(m);
  130867. }
  130868. });
  130869. this.meshes.unshift(rootMesh);
  130870. return rootMesh;
  130871. };
  130872. return AssetContainer;
  130873. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  130874. /***/ }),
  130875. /***/ "./index.ts":
  130876. /*!******************!*\
  130877. !*** ./index.ts ***!
  130878. \******************/
  130879. /*! 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, 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, PBRBaseMaterial, PBRMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, DynamicTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, VideoTexture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, 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, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, CubeMapToSphericalPolynomialTools, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseSimpleMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, EquiRectangularCubeTexture, HDRCubeTexture, DummyInternalTextureTracker, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, HDRTools, PanoramaToCubeMapTools, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  130880. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130881. "use strict";
  130882. __webpack_require__.r(__webpack_exports__);
  130883. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  130884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  130885. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  130886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  130887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  130888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  130889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  130890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  130891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  130892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  130893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  130894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  130895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  130896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  130897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  130898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  130899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  130900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  130901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  130902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  130903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  130904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  130905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  130906. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  130907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  130908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  130909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  130910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  130911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  130912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  130913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  130914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  130915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  130916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  130917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  130918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  130919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  130920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  130921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  130922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  130923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  130924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  130925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  130926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  130927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  130928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  130929. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  130930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  130931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  130932. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  130933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  130934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  130935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  130936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  130937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  130938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  130939. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  130940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  130941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  130942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  130943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  130944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  130945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  130946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  130947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  130948. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  130949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  130950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  130951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  130952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  130953. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  130954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  130955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  130956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  130957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  130958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  130959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  130960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  130961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  130962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  130963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  130964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  130965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  130966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  130967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  130968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  130969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  130970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  130971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  130972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  130973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  130974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  130975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  130976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  130977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  130978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  130979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  130980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  130981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  130982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  130983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  130984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  130985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  130986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  130987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  130988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  130989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  130990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  130991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  130992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  130993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  130994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  130995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  130996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  130997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  130998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  130999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  131000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  131001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  131002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  131003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  131004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  131005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  131006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  131007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  131008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  131009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  131010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  131011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  131012. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  131013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  131014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  131015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  131016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  131017. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  131018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  131019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  131020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  131021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  131022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  131023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  131024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  131025. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  131026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  131027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  131028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  131029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  131030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  131031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  131032. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  131033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  131034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  131035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  131036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  131037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  131038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  131039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  131040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  131041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  131042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  131043. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  131044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  131045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  131046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  131047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  131048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  131049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  131050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  131051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  131052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  131053. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  131054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  131055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  131056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  131057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  131058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  131059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  131060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  131061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  131062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  131063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  131064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  131065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  131066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  131067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  131068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  131069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  131070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  131071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  131072. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  131073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  131074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  131075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  131076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  131077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  131078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  131079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  131080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  131081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  131082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  131083. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  131084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  131085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  131086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  131087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  131088. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  131089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  131090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  131091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  131092. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  131093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  131094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  131095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  131096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  131097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  131098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  131099. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  131100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  131101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  131102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  131103. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  131104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  131105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  131106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  131107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  131108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  131109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  131110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  131111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  131112. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  131113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  131114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  131115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  131116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  131117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  131118. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  131119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  131120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  131121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  131122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  131123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  131124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  131125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  131126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  131127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  131128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  131129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  131130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  131131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  131132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  131133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  131134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  131135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  131136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  131137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  131138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  131139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  131140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  131141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  131142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  131143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  131144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  131145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  131146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  131147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  131148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  131149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  131150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  131151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  131152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EquiRectangularCubeTexture"]; });
  131153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  131154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  131155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  131156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  131157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  131158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  131159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  131160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  131161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  131162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  131163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  131164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  131165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  131166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  131167. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  131168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  131169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  131170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  131171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  131172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  131173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  131174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  131175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  131176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  131177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  131178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  131179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  131180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  131181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  131182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  131183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  131184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  131185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  131186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  131187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  131188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  131189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  131190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  131191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  131192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  131193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  131194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  131195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  131196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  131197. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  131198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  131199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  131200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  131201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  131202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  131203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  131204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  131205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  131206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  131207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  131208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  131209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  131210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  131211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  131212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  131213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  131214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  131215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  131216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  131217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  131218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  131219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  131220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  131221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  131222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  131223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  131224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  131225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  131226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  131227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  131228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  131229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  131230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  131231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  131232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  131233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  131234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  131235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  131236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  131237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  131238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  131239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  131240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  131241. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  131242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  131243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  131244. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  131245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  131246. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  131247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  131248. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  131249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  131250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  131251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  131252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  131253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  131254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  131255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  131256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  131257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  131258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  131259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  131260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  131261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  131262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  131263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  131264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  131265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  131266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  131267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  131268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  131269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  131270. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  131271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  131272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  131273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  131274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEventOptions"]; });
  131275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEventOptions"]; });
  131276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEventOptions"]; });
  131277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  131278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  131279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  131280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  131281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  131282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  131283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  131284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  131285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  131286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  131287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  131288. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  131289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  131290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  131291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  131292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  131293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  131294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  131295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  131296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  131297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  131298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  131299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  131300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  131301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  131302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  131303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  131304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  131305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  131306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  131307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  131308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  131309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  131310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  131311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  131312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  131313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  131314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  131315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  131316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  131317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  131318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  131319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  131320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  131321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  131322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  131323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  131324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  131325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  131326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  131327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  131328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  131329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  131330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  131331. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  131332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  131333. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  131334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  131335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  131336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  131337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  131338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  131339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  131340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  131341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  131342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  131343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  131344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  131345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  131346. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  131347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  131348. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  131349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  131350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  131351. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  131352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  131353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  131354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  131355. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  131356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  131357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  131358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  131359. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  131360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  131361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  131362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  131363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  131364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  131365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  131366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  131367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  131368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  131369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  131370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  131371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  131372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  131373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  131374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  131375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  131376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  131377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  131378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  131379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  131380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  131381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  131382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  131383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  131384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  131385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMatrix"]; });
  131386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  131387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  131388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  131389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  131390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshExploder"]; });
  131391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  131392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  131393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  131394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  131395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  131396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  131397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  131398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  131399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  131400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  131401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  131402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  131403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  131404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  131405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  131406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  131407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  131408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  131409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  131410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  131411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  131412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  131413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  131414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  131415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  131416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  131417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  131418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  131419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  131420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  131421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  131422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  131423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  131424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  131425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  131426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  131427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  131428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  131429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  131430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  131431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  131432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  131433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  131434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  131435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  131436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  131437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  131438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  131439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  131440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WebRequest"]; });
  131441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["InspectableType"]; });
  131442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  131443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  131444. /***/ }),
  131445. /***/ "./node.ts":
  131446. /*!*****************!*\
  131447. !*** ./node.ts ***!
  131448. \*****************/
  131449. /*! exports provided: Node */
  131450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131451. "use strict";
  131452. __webpack_require__.r(__webpack_exports__);
  131453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  131454. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131455. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  131456. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  131457. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  131458. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  131459. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  131460. /**
  131461. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  131462. */
  131463. var Node = /** @class */ (function () {
  131464. /**
  131465. * Creates a new Node
  131466. * @param name the name and id to be given to this node
  131467. * @param scene the scene this node will be added to
  131468. * @param addToRootNodes the node will be added to scene.rootNodes
  131469. */
  131470. function Node(name, scene, addToRootNodes) {
  131471. if (scene === void 0) { scene = null; }
  131472. if (addToRootNodes === void 0) { addToRootNodes = true; }
  131473. /**
  131474. * Gets or sets a string used to store user defined state for the node
  131475. */
  131476. this.state = "";
  131477. /**
  131478. * Gets or sets an object used to store user defined information for the node
  131479. */
  131480. this.metadata = null;
  131481. /**
  131482. * For internal use only. Please do not use.
  131483. */
  131484. this.reservedDataStore = null;
  131485. /**
  131486. * Gets or sets a boolean used to define if the node must be serialized
  131487. */
  131488. this.doNotSerialize = false;
  131489. /** @hidden */
  131490. this._isDisposed = false;
  131491. /**
  131492. * Gets a list of Animations associated with the node
  131493. */
  131494. this.animations = new Array();
  131495. this._ranges = {};
  131496. this._isEnabled = true;
  131497. this._isParentEnabled = true;
  131498. this._isReady = true;
  131499. /** @hidden */
  131500. this._currentRenderId = -1;
  131501. this._parentRenderId = -1;
  131502. this._childRenderId = -1;
  131503. /** @hidden */
  131504. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  131505. /** @hidden */
  131506. this._worldMatrixDeterminant = 0;
  131507. /** @hidden */
  131508. this._sceneRootNodesIndex = -1;
  131509. this._animationPropertiesOverride = null;
  131510. /** @hidden */
  131511. this._isNode = true;
  131512. /**
  131513. * An event triggered when the mesh is disposed
  131514. */
  131515. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  131516. // Behaviors
  131517. this._behaviors = new Array();
  131518. this.name = name;
  131519. this.id = name;
  131520. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  131521. this.uniqueId = this._scene.getUniqueId();
  131522. this._initCache();
  131523. if (addToRootNodes) {
  131524. this.addToSceneRootNodes();
  131525. }
  131526. }
  131527. /**
  131528. * Add a new node constructor
  131529. * @param type defines the type name of the node to construct
  131530. * @param constructorFunc defines the constructor function
  131531. */
  131532. Node.AddNodeConstructor = function (type, constructorFunc) {
  131533. this._NodeConstructors[type] = constructorFunc;
  131534. };
  131535. /**
  131536. * Returns a node constructor based on type name
  131537. * @param type defines the type name
  131538. * @param name defines the new node name
  131539. * @param scene defines the hosting scene
  131540. * @param options defines optional options to transmit to constructors
  131541. * @returns the new constructor or null
  131542. */
  131543. Node.Construct = function (type, name, scene, options) {
  131544. var constructorFunc = this._NodeConstructors[type];
  131545. if (!constructorFunc) {
  131546. return null;
  131547. }
  131548. return constructorFunc(name, scene, options);
  131549. };
  131550. /**
  131551. * Gets a boolean indicating if the node has been disposed
  131552. * @returns true if the node was disposed
  131553. */
  131554. Node.prototype.isDisposed = function () {
  131555. return this._isDisposed;
  131556. };
  131557. Object.defineProperty(Node.prototype, "parent", {
  131558. get: function () {
  131559. return this._parentNode;
  131560. },
  131561. /**
  131562. * Gets or sets the parent of the node (without keeping the current position in the scene)
  131563. * @see https://doc.babylonjs.com/how_to/parenting
  131564. */
  131565. set: function (parent) {
  131566. if (this._parentNode === parent) {
  131567. return;
  131568. }
  131569. var previousParentNode = this._parentNode;
  131570. // Remove self from list of children of parent
  131571. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  131572. var index = this._parentNode._children.indexOf(this);
  131573. if (index !== -1) {
  131574. this._parentNode._children.splice(index, 1);
  131575. }
  131576. if (!parent && !this._isDisposed) {
  131577. this.addToSceneRootNodes();
  131578. }
  131579. }
  131580. // Store new parent
  131581. this._parentNode = parent;
  131582. // Add as child to new parent
  131583. if (this._parentNode) {
  131584. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  131585. this._parentNode._children = new Array();
  131586. }
  131587. this._parentNode._children.push(this);
  131588. if (!previousParentNode) {
  131589. this.removeFromSceneRootNodes();
  131590. }
  131591. }
  131592. // Enabled state
  131593. this._syncParentEnabledState();
  131594. },
  131595. enumerable: true,
  131596. configurable: true
  131597. });
  131598. Node.prototype.addToSceneRootNodes = function () {
  131599. if (this._sceneRootNodesIndex === -1) {
  131600. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  131601. this._scene.rootNodes.push(this);
  131602. }
  131603. };
  131604. Node.prototype.removeFromSceneRootNodes = function () {
  131605. if (this._sceneRootNodesIndex !== -1) {
  131606. var rootNodes = this._scene.rootNodes;
  131607. var lastIdx = rootNodes.length - 1;
  131608. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  131609. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  131610. this._scene.rootNodes.pop();
  131611. this._sceneRootNodesIndex = -1;
  131612. }
  131613. };
  131614. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  131615. /**
  131616. * Gets or sets the animation properties override
  131617. */
  131618. get: function () {
  131619. if (!this._animationPropertiesOverride) {
  131620. return this._scene.animationPropertiesOverride;
  131621. }
  131622. return this._animationPropertiesOverride;
  131623. },
  131624. set: function (value) {
  131625. this._animationPropertiesOverride = value;
  131626. },
  131627. enumerable: true,
  131628. configurable: true
  131629. });
  131630. /**
  131631. * Gets a string idenfifying the name of the class
  131632. * @returns "Node" string
  131633. */
  131634. Node.prototype.getClassName = function () {
  131635. return "Node";
  131636. };
  131637. Object.defineProperty(Node.prototype, "onDispose", {
  131638. /**
  131639. * Sets a callback that will be raised when the node will be disposed
  131640. */
  131641. set: function (callback) {
  131642. if (this._onDisposeObserver) {
  131643. this.onDisposeObservable.remove(this._onDisposeObserver);
  131644. }
  131645. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  131646. },
  131647. enumerable: true,
  131648. configurable: true
  131649. });
  131650. /**
  131651. * Gets the scene of the node
  131652. * @returns a scene
  131653. */
  131654. Node.prototype.getScene = function () {
  131655. return this._scene;
  131656. };
  131657. /**
  131658. * Gets the engine of the node
  131659. * @returns a Engine
  131660. */
  131661. Node.prototype.getEngine = function () {
  131662. return this._scene.getEngine();
  131663. };
  131664. /**
  131665. * Attach a behavior to the node
  131666. * @see http://doc.babylonjs.com/features/behaviour
  131667. * @param behavior defines the behavior to attach
  131668. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  131669. * @returns the current Node
  131670. */
  131671. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  131672. var _this = this;
  131673. if (attachImmediately === void 0) { attachImmediately = false; }
  131674. var index = this._behaviors.indexOf(behavior);
  131675. if (index !== -1) {
  131676. return this;
  131677. }
  131678. behavior.init();
  131679. if (this._scene.isLoading && !attachImmediately) {
  131680. // We defer the attach when the scene will be loaded
  131681. this._scene.onDataLoadedObservable.addOnce(function () {
  131682. behavior.attach(_this);
  131683. });
  131684. }
  131685. else {
  131686. behavior.attach(this);
  131687. }
  131688. this._behaviors.push(behavior);
  131689. return this;
  131690. };
  131691. /**
  131692. * Remove an attached behavior
  131693. * @see http://doc.babylonjs.com/features/behaviour
  131694. * @param behavior defines the behavior to attach
  131695. * @returns the current Node
  131696. */
  131697. Node.prototype.removeBehavior = function (behavior) {
  131698. var index = this._behaviors.indexOf(behavior);
  131699. if (index === -1) {
  131700. return this;
  131701. }
  131702. this._behaviors[index].detach();
  131703. this._behaviors.splice(index, 1);
  131704. return this;
  131705. };
  131706. Object.defineProperty(Node.prototype, "behaviors", {
  131707. /**
  131708. * Gets the list of attached behaviors
  131709. * @see http://doc.babylonjs.com/features/behaviour
  131710. */
  131711. get: function () {
  131712. return this._behaviors;
  131713. },
  131714. enumerable: true,
  131715. configurable: true
  131716. });
  131717. /**
  131718. * Gets an attached behavior by name
  131719. * @param name defines the name of the behavior to look for
  131720. * @see http://doc.babylonjs.com/features/behaviour
  131721. * @returns null if behavior was not found else the requested behavior
  131722. */
  131723. Node.prototype.getBehaviorByName = function (name) {
  131724. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  131725. var behavior = _a[_i];
  131726. if (behavior.name === name) {
  131727. return behavior;
  131728. }
  131729. }
  131730. return null;
  131731. };
  131732. /**
  131733. * Returns the latest update of the World matrix
  131734. * @returns a Matrix
  131735. */
  131736. Node.prototype.getWorldMatrix = function () {
  131737. if (this._currentRenderId !== this._scene.getRenderId()) {
  131738. this.computeWorldMatrix();
  131739. }
  131740. return this._worldMatrix;
  131741. };
  131742. /** @hidden */
  131743. Node.prototype._getWorldMatrixDeterminant = function () {
  131744. return this._worldMatrixDeterminant;
  131745. };
  131746. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  131747. /**
  131748. * Returns directly the latest state of the mesh World matrix.
  131749. * A Matrix is returned.
  131750. */
  131751. get: function () {
  131752. return this._worldMatrix;
  131753. },
  131754. enumerable: true,
  131755. configurable: true
  131756. });
  131757. // override it in derived class if you add new variables to the cache
  131758. // and call the parent class method
  131759. /** @hidden */
  131760. Node.prototype._initCache = function () {
  131761. this._cache = {};
  131762. this._cache.parent = undefined;
  131763. };
  131764. /** @hidden */
  131765. Node.prototype.updateCache = function (force) {
  131766. if (!force && this.isSynchronized()) {
  131767. return;
  131768. }
  131769. this._cache.parent = this.parent;
  131770. this._updateCache();
  131771. };
  131772. /** @hidden */
  131773. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  131774. if (initialCall === void 0) { initialCall = true; }
  131775. if (!this.parent) {
  131776. return null;
  131777. }
  131778. return this.parent._getActionManagerForTrigger(trigger, false);
  131779. };
  131780. // override it in derived class if you add new variables to the cache
  131781. // and call the parent class method if !ignoreParentClass
  131782. /** @hidden */
  131783. Node.prototype._updateCache = function (ignoreParentClass) {
  131784. };
  131785. // override it in derived class if you add new variables to the cache
  131786. /** @hidden */
  131787. Node.prototype._isSynchronized = function () {
  131788. return true;
  131789. };
  131790. /** @hidden */
  131791. Node.prototype._markSyncedWithParent = function () {
  131792. if (this._parentNode) {
  131793. this._parentRenderId = this._parentNode._childRenderId;
  131794. }
  131795. };
  131796. /** @hidden */
  131797. Node.prototype.isSynchronizedWithParent = function () {
  131798. if (!this._parentNode) {
  131799. return true;
  131800. }
  131801. if (this._parentRenderId !== this._parentNode._childRenderId) {
  131802. return false;
  131803. }
  131804. return this._parentNode.isSynchronized();
  131805. };
  131806. /** @hidden */
  131807. Node.prototype.isSynchronized = function () {
  131808. if (this._cache.parent != this._parentNode) {
  131809. this._cache.parent = this._parentNode;
  131810. return false;
  131811. }
  131812. if (this._parentNode && !this.isSynchronizedWithParent()) {
  131813. return false;
  131814. }
  131815. return this._isSynchronized();
  131816. };
  131817. /**
  131818. * Is this node ready to be used/rendered
  131819. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  131820. * @return true if the node is ready
  131821. */
  131822. Node.prototype.isReady = function (completeCheck) {
  131823. if (completeCheck === void 0) { completeCheck = false; }
  131824. return this._isReady;
  131825. };
  131826. /**
  131827. * Is this node enabled?
  131828. * 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
  131829. * @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
  131830. * @return whether this node (and its parent) is enabled
  131831. */
  131832. Node.prototype.isEnabled = function (checkAncestors) {
  131833. if (checkAncestors === void 0) { checkAncestors = true; }
  131834. if (checkAncestors === false) {
  131835. return this._isEnabled;
  131836. }
  131837. if (!this._isEnabled) {
  131838. return false;
  131839. }
  131840. return this._isParentEnabled;
  131841. };
  131842. /** @hidden */
  131843. Node.prototype._syncParentEnabledState = function () {
  131844. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  131845. if (this._children) {
  131846. this._children.forEach(function (c) {
  131847. c._syncParentEnabledState(); // Force children to update accordingly
  131848. });
  131849. }
  131850. };
  131851. /**
  131852. * Set the enabled state of this node
  131853. * @param value defines the new enabled state
  131854. */
  131855. Node.prototype.setEnabled = function (value) {
  131856. this._isEnabled = value;
  131857. this._syncParentEnabledState();
  131858. };
  131859. /**
  131860. * Is this node a descendant of the given node?
  131861. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  131862. * @param ancestor defines the parent node to inspect
  131863. * @returns a boolean indicating if this node is a descendant of the given node
  131864. */
  131865. Node.prototype.isDescendantOf = function (ancestor) {
  131866. if (this.parent) {
  131867. if (this.parent === ancestor) {
  131868. return true;
  131869. }
  131870. return this.parent.isDescendantOf(ancestor);
  131871. }
  131872. return false;
  131873. };
  131874. /** @hidden */
  131875. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  131876. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  131877. if (!this._children) {
  131878. return;
  131879. }
  131880. for (var index = 0; index < this._children.length; index++) {
  131881. var item = this._children[index];
  131882. if (!predicate || predicate(item)) {
  131883. results.push(item);
  131884. }
  131885. if (!directDescendantsOnly) {
  131886. item._getDescendants(results, false, predicate);
  131887. }
  131888. }
  131889. };
  131890. /**
  131891. * Will return all nodes that have this node as ascendant
  131892. * @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
  131893. * @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
  131894. * @return all children nodes of all types
  131895. */
  131896. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  131897. var results = new Array();
  131898. this._getDescendants(results, directDescendantsOnly, predicate);
  131899. return results;
  131900. };
  131901. /**
  131902. * Get all child-meshes of this node
  131903. * @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)
  131904. * @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
  131905. * @returns an array of AbstractMesh
  131906. */
  131907. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  131908. var results = [];
  131909. this._getDescendants(results, directDescendantsOnly, function (node) {
  131910. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  131911. });
  131912. return results;
  131913. };
  131914. /**
  131915. * Get all direct children of this node
  131916. * @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
  131917. * @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)
  131918. * @returns an array of Node
  131919. */
  131920. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  131921. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  131922. return this.getDescendants(directDescendantsOnly, predicate);
  131923. };
  131924. /** @hidden */
  131925. Node.prototype._setReady = function (state) {
  131926. if (state === this._isReady) {
  131927. return;
  131928. }
  131929. if (!state) {
  131930. this._isReady = false;
  131931. return;
  131932. }
  131933. if (this.onReady) {
  131934. this.onReady(this);
  131935. }
  131936. this._isReady = true;
  131937. };
  131938. /**
  131939. * Get an animation by name
  131940. * @param name defines the name of the animation to look for
  131941. * @returns null if not found else the requested animation
  131942. */
  131943. Node.prototype.getAnimationByName = function (name) {
  131944. for (var i = 0; i < this.animations.length; i++) {
  131945. var animation = this.animations[i];
  131946. if (animation.name === name) {
  131947. return animation;
  131948. }
  131949. }
  131950. return null;
  131951. };
  131952. /**
  131953. * Creates an animation range for this node
  131954. * @param name defines the name of the range
  131955. * @param from defines the starting key
  131956. * @param to defines the end key
  131957. */
  131958. Node.prototype.createAnimationRange = function (name, from, to) {
  131959. // check name not already in use
  131960. if (!this._ranges[name]) {
  131961. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  131962. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  131963. if (this.animations[i]) {
  131964. this.animations[i].createRange(name, from, to);
  131965. }
  131966. }
  131967. }
  131968. };
  131969. /**
  131970. * Delete a specific animation range
  131971. * @param name defines the name of the range to delete
  131972. * @param deleteFrames defines if animation frames from the range must be deleted as well
  131973. */
  131974. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  131975. if (deleteFrames === void 0) { deleteFrames = true; }
  131976. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  131977. if (this.animations[i]) {
  131978. this.animations[i].deleteRange(name, deleteFrames);
  131979. }
  131980. }
  131981. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  131982. };
  131983. /**
  131984. * Get an animation range by name
  131985. * @param name defines the name of the animation range to look for
  131986. * @returns null if not found else the requested animation range
  131987. */
  131988. Node.prototype.getAnimationRange = function (name) {
  131989. return this._ranges[name];
  131990. };
  131991. /**
  131992. * Gets the list of all animation ranges defined on this node
  131993. * @returns an array
  131994. */
  131995. Node.prototype.getAnimationRanges = function () {
  131996. var animationRanges = [];
  131997. var name;
  131998. for (name in this._ranges) {
  131999. animationRanges.push(this._ranges[name]);
  132000. }
  132001. return animationRanges;
  132002. };
  132003. /**
  132004. * Will start the animation sequence
  132005. * @param name defines the range frames for animation sequence
  132006. * @param loop defines if the animation should loop (false by default)
  132007. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  132008. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  132009. * @returns the object created for this animation. If range does not exist, it will return null
  132010. */
  132011. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  132012. var range = this.getAnimationRange(name);
  132013. if (!range) {
  132014. return null;
  132015. }
  132016. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  132017. };
  132018. /**
  132019. * Serialize animation ranges into a JSON compatible object
  132020. * @returns serialization object
  132021. */
  132022. Node.prototype.serializeAnimationRanges = function () {
  132023. var serializationRanges = [];
  132024. for (var name in this._ranges) {
  132025. var localRange = this._ranges[name];
  132026. if (!localRange) {
  132027. continue;
  132028. }
  132029. var range = {};
  132030. range.name = name;
  132031. range.from = localRange.from;
  132032. range.to = localRange.to;
  132033. serializationRanges.push(range);
  132034. }
  132035. return serializationRanges;
  132036. };
  132037. /**
  132038. * Computes the world matrix of the node
  132039. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  132040. * @returns the world matrix
  132041. */
  132042. Node.prototype.computeWorldMatrix = function (force) {
  132043. if (!this._worldMatrix) {
  132044. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  132045. }
  132046. return this._worldMatrix;
  132047. };
  132048. /**
  132049. * Releases resources associated with this node.
  132050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132052. */
  132053. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  132054. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  132055. this._isDisposed = true;
  132056. if (!doNotRecurse) {
  132057. var nodes = this.getDescendants(true);
  132058. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  132059. var node = nodes_1[_i];
  132060. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  132061. }
  132062. }
  132063. if (!this.parent) {
  132064. this.removeFromSceneRootNodes();
  132065. }
  132066. else {
  132067. this.parent = null;
  132068. }
  132069. // Callback
  132070. this.onDisposeObservable.notifyObservers(this);
  132071. this.onDisposeObservable.clear();
  132072. // Behaviors
  132073. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  132074. var behavior = _b[_a];
  132075. behavior.detach();
  132076. }
  132077. this._behaviors = [];
  132078. };
  132079. /**
  132080. * Parse animation range data from a serialization object and store them into a given node
  132081. * @param node defines where to store the animation ranges
  132082. * @param parsedNode defines the serialization object to read data from
  132083. * @param scene defines the hosting scene
  132084. */
  132085. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  132086. if (parsedNode.ranges) {
  132087. for (var index = 0; index < parsedNode.ranges.length; index++) {
  132088. var data = parsedNode.ranges[index];
  132089. node.createAnimationRange(data.name, data.from, data.to);
  132090. }
  132091. }
  132092. };
  132093. /** @hidden */
  132094. Node._AnimationRangeFactory = function (name, from, to) {
  132095. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  132096. };
  132097. Node._NodeConstructors = {};
  132098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132100. ], Node.prototype, "name", void 0);
  132101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132103. ], Node.prototype, "id", void 0);
  132104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132106. ], Node.prototype, "uniqueId", void 0);
  132107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132109. ], Node.prototype, "state", void 0);
  132110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  132111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  132112. ], Node.prototype, "metadata", void 0);
  132113. return Node;
  132114. }());
  132115. /***/ }),
  132116. /***/ "./scene.ts":
  132117. /*!******************!*\
  132118. !*** ./scene.ts ***!
  132119. \******************/
  132120. /*! exports provided: Scene */
  132121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132122. "use strict";
  132123. __webpack_require__.r(__webpack_exports__);
  132124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  132125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132126. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  132127. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  132128. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  132129. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  132130. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  132131. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  132132. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  132133. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  132134. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  132135. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  132136. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  132137. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  132138. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  132139. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  132140. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  132141. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  132142. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  132143. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  132144. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  132145. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  132146. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  132147. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  132148. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  132149. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  132150. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  132151. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  132152. /** @hidden */
  132153. var ClickInfo = /** @class */ (function () {
  132154. function ClickInfo() {
  132155. this._singleClick = false;
  132156. this._doubleClick = false;
  132157. this._hasSwiped = false;
  132158. this._ignore = false;
  132159. }
  132160. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  132161. get: function () {
  132162. return this._singleClick;
  132163. },
  132164. set: function (b) {
  132165. this._singleClick = b;
  132166. },
  132167. enumerable: true,
  132168. configurable: true
  132169. });
  132170. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  132171. get: function () {
  132172. return this._doubleClick;
  132173. },
  132174. set: function (b) {
  132175. this._doubleClick = b;
  132176. },
  132177. enumerable: true,
  132178. configurable: true
  132179. });
  132180. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  132181. get: function () {
  132182. return this._hasSwiped;
  132183. },
  132184. set: function (b) {
  132185. this._hasSwiped = b;
  132186. },
  132187. enumerable: true,
  132188. configurable: true
  132189. });
  132190. Object.defineProperty(ClickInfo.prototype, "ignore", {
  132191. get: function () {
  132192. return this._ignore;
  132193. },
  132194. set: function (b) {
  132195. this._ignore = b;
  132196. },
  132197. enumerable: true,
  132198. configurable: true
  132199. });
  132200. return ClickInfo;
  132201. }());
  132202. /**
  132203. * Represents a scene to be rendered by the engine.
  132204. * @see http://doc.babylonjs.com/features/scene
  132205. */
  132206. var Scene = /** @class */ (function (_super) {
  132207. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  132208. /**
  132209. * Creates a new Scene
  132210. * @param engine defines the engine to use to render this scene
  132211. * @param options defines the scene options
  132212. */
  132213. function Scene(engine, options) {
  132214. var _this = _super.call(this) || this;
  132215. // Members
  132216. /** @hidden */
  132217. _this._isScene = true;
  132218. /**
  132219. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  132220. */
  132221. _this.autoClear = true;
  132222. /**
  132223. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  132224. */
  132225. _this.autoClearDepthAndStencil = true;
  132226. /**
  132227. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  132228. */
  132229. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  132230. /**
  132231. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  132232. */
  132233. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  132234. _this._forceWireframe = false;
  132235. _this._forcePointsCloud = false;
  132236. /**
  132237. * Gets or sets a boolean indicating if animations are enabled
  132238. */
  132239. _this.animationsEnabled = true;
  132240. _this._animationPropertiesOverride = null;
  132241. /**
  132242. * Gets or sets a boolean indicating if a constant deltatime has to be used
  132243. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  132244. */
  132245. _this.useConstantAnimationDeltaTime = false;
  132246. /**
  132247. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  132248. * Please note that it requires to run a ray cast through the scene on every frame
  132249. */
  132250. _this.constantlyUpdateMeshUnderPointer = false;
  132251. /**
  132252. * Defines the HTML cursor to use when hovering over interactive elements
  132253. */
  132254. _this.hoverCursor = "pointer";
  132255. /**
  132256. * Defines the HTML default cursor to use (empty by default)
  132257. */
  132258. _this.defaultCursor = "";
  132259. /**
  132260. * This is used to call preventDefault() on pointer down
  132261. * in order to block unwanted artifacts like system double clicks
  132262. */
  132263. _this.preventDefaultOnPointerDown = true;
  132264. /**
  132265. * This is used to call preventDefault() on pointer up
  132266. * in order to block unwanted artifacts like system double clicks
  132267. */
  132268. _this.preventDefaultOnPointerUp = true;
  132269. // Metadata
  132270. /**
  132271. * Gets or sets user defined metadata
  132272. */
  132273. _this.metadata = null;
  132274. /**
  132275. * For internal use only. Please do not use.
  132276. */
  132277. _this.reservedDataStore = null;
  132278. /**
  132279. * Use this array to add regular expressions used to disable offline support for specific urls
  132280. */
  132281. _this.disableOfflineSupportExceptionRules = new Array();
  132282. /**
  132283. * An event triggered when the scene is disposed.
  132284. */
  132285. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132286. _this._onDisposeObserver = null;
  132287. /**
  132288. * An event triggered before rendering the scene (right after animations and physics)
  132289. */
  132290. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132291. _this._onBeforeRenderObserver = null;
  132292. /**
  132293. * An event triggered after rendering the scene
  132294. */
  132295. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132296. _this._onAfterRenderObserver = null;
  132297. /**
  132298. * An event triggered before animating the scene
  132299. */
  132300. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132301. /**
  132302. * An event triggered after animations processing
  132303. */
  132304. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132305. /**
  132306. * An event triggered before draw calls are ready to be sent
  132307. */
  132308. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132309. /**
  132310. * An event triggered after draw calls have been sent
  132311. */
  132312. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132313. /**
  132314. * An event triggered when the scene is ready
  132315. */
  132316. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132317. /**
  132318. * An event triggered before rendering a camera
  132319. */
  132320. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132321. _this._onBeforeCameraRenderObserver = null;
  132322. /**
  132323. * An event triggered after rendering a camera
  132324. */
  132325. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132326. _this._onAfterCameraRenderObserver = null;
  132327. /**
  132328. * An event triggered when active meshes evaluation is about to start
  132329. */
  132330. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132331. /**
  132332. * An event triggered when active meshes evaluation is done
  132333. */
  132334. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132335. /**
  132336. * An event triggered when particles rendering is about to start
  132337. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  132338. */
  132339. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132340. /**
  132341. * An event triggered when particles rendering is done
  132342. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  132343. */
  132344. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132345. /**
  132346. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  132347. */
  132348. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132349. /**
  132350. * An event triggered when a camera is created
  132351. */
  132352. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132353. /**
  132354. * An event triggered when a camera is removed
  132355. */
  132356. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132357. /**
  132358. * An event triggered when a light is created
  132359. */
  132360. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132361. /**
  132362. * An event triggered when a light is removed
  132363. */
  132364. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132365. /**
  132366. * An event triggered when a geometry is created
  132367. */
  132368. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132369. /**
  132370. * An event triggered when a geometry is removed
  132371. */
  132372. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132373. /**
  132374. * An event triggered when a transform node is created
  132375. */
  132376. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132377. /**
  132378. * An event triggered when a transform node is removed
  132379. */
  132380. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132381. /**
  132382. * An event triggered when a mesh is created
  132383. */
  132384. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132385. /**
  132386. * An event triggered when a mesh is removed
  132387. */
  132388. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132389. /**
  132390. * An event triggered when a skeleton is created
  132391. */
  132392. _this.onNewSkeletonAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132393. /**
  132394. * An event triggered when a skeleton is removed
  132395. */
  132396. _this.onSkeletonRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132397. /**
  132398. * An event triggered when a material is created
  132399. */
  132400. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132401. /**
  132402. * An event triggered when a material is removed
  132403. */
  132404. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132405. /**
  132406. * An event triggered when a texture is created
  132407. */
  132408. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132409. /**
  132410. * An event triggered when a texture is removed
  132411. */
  132412. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132413. /**
  132414. * An event triggered when render targets are about to be rendered
  132415. * Can happen multiple times per frame.
  132416. */
  132417. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132418. /**
  132419. * An event triggered when render targets were rendered.
  132420. * Can happen multiple times per frame.
  132421. */
  132422. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132423. /**
  132424. * An event triggered before calculating deterministic simulation step
  132425. */
  132426. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132427. /**
  132428. * An event triggered after calculating deterministic simulation step
  132429. */
  132430. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132431. /**
  132432. * An event triggered when the activeCamera property is updated
  132433. */
  132434. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132435. /**
  132436. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  132437. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  132438. * 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)
  132439. */
  132440. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132441. /**
  132442. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  132443. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  132444. * 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)
  132445. */
  132446. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132447. /**
  132448. * This Observable will when a mesh has been imported into the scene.
  132449. */
  132450. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132451. // Animations
  132452. /** @hidden */
  132453. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  132454. /**
  132455. * 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).
  132456. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  132457. */
  132458. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132459. /**
  132460. * Observable event triggered each time an input event is received from the rendering canvas
  132461. */
  132462. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132463. _this._meshPickProceed = false;
  132464. _this._currentPickResult = null;
  132465. _this._previousPickResult = null;
  132466. _this._totalPointersPressed = 0;
  132467. _this._doubleClickOccured = false;
  132468. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  132469. _this.cameraToUseForPointers = null;
  132470. _this._pointerX = 0;
  132471. _this._pointerY = 0;
  132472. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  132473. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  132474. _this._startingPointerTime = 0;
  132475. _this._previousStartingPointerTime = 0;
  132476. _this._pointerCaptures = {};
  132477. // Deterministic lockstep
  132478. _this._timeAccumulator = 0;
  132479. _this._currentStepId = 0;
  132480. _this._currentInternalStep = 0;
  132481. // Keyboard
  132482. /**
  132483. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  132484. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  132485. */
  132486. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132487. /**
  132488. * Observable event triggered each time an keyboard event is received from the hosting window
  132489. */
  132490. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132491. // Coordinates system
  132492. _this._useRightHandedSystem = false;
  132493. // Fog
  132494. _this._fogEnabled = true;
  132495. _this._fogMode = Scene.FOGMODE_NONE;
  132496. /**
  132497. * Gets or sets the fog color to use
  132498. * @see http://doc.babylonjs.com/babylon101/environment#fog
  132499. * (Default is Color3(0.2, 0.2, 0.3))
  132500. */
  132501. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  132502. /**
  132503. * Gets or sets the fog density to use
  132504. * @see http://doc.babylonjs.com/babylon101/environment#fog
  132505. * (Default is 0.1)
  132506. */
  132507. _this.fogDensity = 0.1;
  132508. /**
  132509. * Gets or sets the fog start distance to use
  132510. * @see http://doc.babylonjs.com/babylon101/environment#fog
  132511. * (Default is 0)
  132512. */
  132513. _this.fogStart = 0;
  132514. /**
  132515. * Gets or sets the fog end distance to use
  132516. * @see http://doc.babylonjs.com/babylon101/environment#fog
  132517. * (Default is 1000)
  132518. */
  132519. _this.fogEnd = 1000.0;
  132520. // Lights
  132521. _this._shadowsEnabled = true;
  132522. _this._lightsEnabled = true;
  132523. /** All of the active cameras added to this scene. */
  132524. _this.activeCameras = new Array();
  132525. // Textures
  132526. _this._texturesEnabled = true;
  132527. // Particles
  132528. /**
  132529. * Gets or sets a boolean indicating if particles are enabled on this scene
  132530. */
  132531. _this.particlesEnabled = true;
  132532. // Sprites
  132533. /**
  132534. * Gets or sets a boolean indicating if sprites are enabled on this scene
  132535. */
  132536. _this.spritesEnabled = true;
  132537. // Skeletons
  132538. _this._skeletonsEnabled = true;
  132539. // Lens flares
  132540. /**
  132541. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  132542. */
  132543. _this.lensFlaresEnabled = true;
  132544. // Collisions
  132545. /**
  132546. * Gets or sets a boolean indicating if collisions are enabled on this scene
  132547. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  132548. */
  132549. _this.collisionsEnabled = true;
  132550. /**
  132551. * Defines the gravity applied to this scene (used only for collisions)
  132552. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  132553. */
  132554. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  132555. // Postprocesses
  132556. /**
  132557. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  132558. */
  132559. _this.postProcessesEnabled = true;
  132560. /**
  132561. * The list of postprocesses added to the scene
  132562. */
  132563. _this.postProcesses = new Array();
  132564. // Customs render targets
  132565. /**
  132566. * Gets or sets a boolean indicating if render targets are enabled on this scene
  132567. */
  132568. _this.renderTargetsEnabled = true;
  132569. /**
  132570. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  132571. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  132572. */
  132573. _this.dumpNextRenderTargets = false;
  132574. /**
  132575. * The list of user defined render targets added to the scene
  132576. */
  132577. _this.customRenderTargets = new Array();
  132578. /**
  132579. * Gets the list of meshes imported to the scene through SceneLoader
  132580. */
  132581. _this.importedMeshesFiles = new Array();
  132582. // Probes
  132583. /**
  132584. * Gets or sets a boolean indicating if probes are enabled on this scene
  132585. */
  132586. _this.probesEnabled = true;
  132587. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  132588. // Procedural textures
  132589. /**
  132590. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  132591. */
  132592. _this.proceduralTexturesEnabled = true;
  132593. // Performance counters
  132594. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  132595. /** @hidden */
  132596. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  132597. /** @hidden */
  132598. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  132599. /** @hidden */
  132600. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  132601. /** @hidden */
  132602. _this._animationTime = 0;
  132603. /**
  132604. * Gets or sets a general scale for animation speed
  132605. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  132606. */
  132607. _this.animationTimeScale = 1;
  132608. _this._renderId = 0;
  132609. _this._frameId = 0;
  132610. _this._executeWhenReadyTimeoutId = -1;
  132611. _this._intermediateRendering = false;
  132612. _this._viewUpdateFlag = -1;
  132613. _this._projectionUpdateFlag = -1;
  132614. _this._alternateViewUpdateFlag = -1;
  132615. _this._alternateProjectionUpdateFlag = -1;
  132616. /** @hidden */
  132617. _this._toBeDisposed = new Array(256);
  132618. _this._activeRequests = new Array();
  132619. /** @hidden */
  132620. _this._pendingData = new Array();
  132621. _this._isDisposed = false;
  132622. /**
  132623. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  132624. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  132625. */
  132626. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  132627. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  132628. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  132629. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  132630. /** @hidden */
  132631. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  132632. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  132633. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  132634. /** @hidden */
  132635. _this._activeAnimatables = new Array();
  132636. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  132637. _this._useAlternateCameraConfiguration = false;
  132638. _this._alternateRendering = false;
  132639. _this._wheelEventName = "";
  132640. /**
  132641. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  132642. * This is useful if there are more lights that the maximum simulteanous authorized
  132643. */
  132644. _this.requireLightSorting = false;
  132645. /**
  132646. * @hidden
  132647. * Backing store of defined scene components.
  132648. */
  132649. _this._components = [];
  132650. /**
  132651. * @hidden
  132652. * Backing store of defined scene components.
  132653. */
  132654. _this._serializableComponents = [];
  132655. /**
  132656. * List of components to register on the next registration step.
  132657. */
  132658. _this._transientComponents = [];
  132659. /**
  132660. * @hidden
  132661. * Defines the actions happening before camera updates.
  132662. */
  132663. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132664. /**
  132665. * @hidden
  132666. * Defines the actions happening before clear the canvas.
  132667. */
  132668. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132669. /**
  132670. * @hidden
  132671. * Defines the actions when collecting render targets for the frame.
  132672. */
  132673. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132674. /**
  132675. * @hidden
  132676. * Defines the actions happening for one camera in the frame.
  132677. */
  132678. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132679. /**
  132680. * @hidden
  132681. * Defines the actions happening during the per mesh ready checks.
  132682. */
  132683. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132684. /**
  132685. * @hidden
  132686. * Defines the actions happening before evaluate active mesh checks.
  132687. */
  132688. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132689. /**
  132690. * @hidden
  132691. * Defines the actions happening during the evaluate sub mesh checks.
  132692. */
  132693. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132694. /**
  132695. * @hidden
  132696. * Defines the actions happening during the active mesh stage.
  132697. */
  132698. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132699. /**
  132700. * @hidden
  132701. * Defines the actions happening during the per camera render target step.
  132702. */
  132703. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132704. /**
  132705. * @hidden
  132706. * Defines the actions happening just before the active camera is drawing.
  132707. */
  132708. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132709. /**
  132710. * @hidden
  132711. * Defines the actions happening just before a render target is drawing.
  132712. */
  132713. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132714. /**
  132715. * @hidden
  132716. * Defines the actions happening just before a rendering group is drawing.
  132717. */
  132718. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132719. /**
  132720. * @hidden
  132721. * Defines the actions happening just before a mesh is drawing.
  132722. */
  132723. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132724. /**
  132725. * @hidden
  132726. * Defines the actions happening just after a mesh has been drawn.
  132727. */
  132728. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132729. /**
  132730. * @hidden
  132731. * Defines the actions happening just after a rendering group has been drawn.
  132732. */
  132733. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132734. /**
  132735. * @hidden
  132736. * Defines the actions happening just after the active camera has been drawn.
  132737. */
  132738. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132739. /**
  132740. * @hidden
  132741. * Defines the actions happening just after a render target has been drawn.
  132742. */
  132743. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132744. /**
  132745. * @hidden
  132746. * Defines the actions happening just after rendering all cameras and computing intersections.
  132747. */
  132748. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132749. /**
  132750. * @hidden
  132751. * Defines the actions happening when a pointer move event happens.
  132752. */
  132753. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132754. /**
  132755. * @hidden
  132756. * Defines the actions happening when a pointer down event happens.
  132757. */
  132758. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132759. /**
  132760. * @hidden
  132761. * Defines the actions happening when a pointer up event happens.
  132762. */
  132763. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  132764. /**
  132765. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  132766. */
  132767. _this.geometriesByUniqueId = null;
  132768. _this._defaultMeshCandidates = {
  132769. data: [],
  132770. length: 0
  132771. };
  132772. _this._defaultSubMeshCandidates = {
  132773. data: [],
  132774. length: 0
  132775. };
  132776. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  132777. _this._activeMeshesFrozen = false;
  132778. /** @hidden */
  132779. _this._allowPostProcessClearColor = true;
  132780. /**
  132781. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  132782. */
  132783. _this.getDeterministicFrameTime = function () {
  132784. return 1000.0 / 60.0; // frame time in ms
  132785. };
  132786. _this._blockMaterialDirtyMechanism = false;
  132787. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  132788. _this._engine.scenes.push(_this);
  132789. _this._uid = null;
  132790. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  132791. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  132792. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  132793. }
  132794. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  132795. _this.attachControl();
  132796. }
  132797. // Uniform Buffer
  132798. _this._createUbo();
  132799. // Default Image processing definition
  132800. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  132801. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  132802. }
  132803. _this.setDefaultCandidateProviders();
  132804. if (options && options.useGeometryUniqueIdsMap === true) {
  132805. _this.geometriesByUniqueId = {};
  132806. }
  132807. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  132808. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  132809. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  132810. return _this;
  132811. }
  132812. /**
  132813. * Factory used to create the default material.
  132814. * @param name The name of the material to create
  132815. * @param scene The scene to create the material for
  132816. * @returns The default material
  132817. */
  132818. Scene.DefaultMaterialFactory = function (scene) {
  132819. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  132820. };
  132821. /**
  132822. * Factory used to create the a collision coordinator.
  132823. * @returns The collision coordinator
  132824. */
  132825. Scene.CollisionCoordinatorFactory = function () {
  132826. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  132827. };
  132828. Object.defineProperty(Scene.prototype, "environmentTexture", {
  132829. /**
  132830. * Texture used in all pbr material as the reflection texture.
  132831. * As in the majority of the scene they are the same (exception for multi room and so on),
  132832. * this is easier to reference from here than from all the materials.
  132833. */
  132834. get: function () {
  132835. return this._environmentTexture;
  132836. },
  132837. /**
  132838. * Texture used in all pbr material as the reflection texture.
  132839. * As in the majority of the scene they are the same (exception for multi room and so on),
  132840. * this is easier to set here than in all the materials.
  132841. */
  132842. set: function (value) {
  132843. if (this._environmentTexture === value) {
  132844. return;
  132845. }
  132846. this._environmentTexture = value;
  132847. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  132848. },
  132849. enumerable: true,
  132850. configurable: true
  132851. });
  132852. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  132853. /**
  132854. * Default image processing configuration used either in the rendering
  132855. * Forward main pass or through the imageProcessingPostProcess if present.
  132856. * As in the majority of the scene they are the same (exception for multi camera),
  132857. * this is easier to reference from here than from all the materials and post process.
  132858. *
  132859. * No setter as we it is a shared configuration, you can set the values instead.
  132860. */
  132861. get: function () {
  132862. return this._imageProcessingConfiguration;
  132863. },
  132864. enumerable: true,
  132865. configurable: true
  132866. });
  132867. Object.defineProperty(Scene.prototype, "forceWireframe", {
  132868. get: function () {
  132869. return this._forceWireframe;
  132870. },
  132871. /**
  132872. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  132873. */
  132874. set: function (value) {
  132875. if (this._forceWireframe === value) {
  132876. return;
  132877. }
  132878. this._forceWireframe = value;
  132879. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  132880. },
  132881. enumerable: true,
  132882. configurable: true
  132883. });
  132884. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  132885. get: function () {
  132886. return this._forcePointsCloud;
  132887. },
  132888. /**
  132889. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  132890. */
  132891. set: function (value) {
  132892. if (this._forcePointsCloud === value) {
  132893. return;
  132894. }
  132895. this._forcePointsCloud = value;
  132896. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  132897. },
  132898. enumerable: true,
  132899. configurable: true
  132900. });
  132901. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  132902. /**
  132903. * Gets or sets the animation properties override
  132904. */
  132905. get: function () {
  132906. return this._animationPropertiesOverride;
  132907. },
  132908. set: function (value) {
  132909. this._animationPropertiesOverride = value;
  132910. },
  132911. enumerable: true,
  132912. configurable: true
  132913. });
  132914. Object.defineProperty(Scene.prototype, "onDispose", {
  132915. /** Sets a function to be executed when this scene is disposed. */
  132916. set: function (callback) {
  132917. if (this._onDisposeObserver) {
  132918. this.onDisposeObservable.remove(this._onDisposeObserver);
  132919. }
  132920. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  132921. },
  132922. enumerable: true,
  132923. configurable: true
  132924. });
  132925. Object.defineProperty(Scene.prototype, "beforeRender", {
  132926. /** Sets a function to be executed before rendering this scene */
  132927. set: function (callback) {
  132928. if (this._onBeforeRenderObserver) {
  132929. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  132930. }
  132931. if (callback) {
  132932. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  132933. }
  132934. },
  132935. enumerable: true,
  132936. configurable: true
  132937. });
  132938. Object.defineProperty(Scene.prototype, "afterRender", {
  132939. /** Sets a function to be executed after rendering this scene */
  132940. set: function (callback) {
  132941. if (this._onAfterRenderObserver) {
  132942. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  132943. }
  132944. if (callback) {
  132945. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  132946. }
  132947. },
  132948. enumerable: true,
  132949. configurable: true
  132950. });
  132951. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  132952. /** Sets a function to be executed before rendering a camera*/
  132953. set: function (callback) {
  132954. if (this._onBeforeCameraRenderObserver) {
  132955. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  132956. }
  132957. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  132958. },
  132959. enumerable: true,
  132960. configurable: true
  132961. });
  132962. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  132963. /** Sets a function to be executed after rendering a camera*/
  132964. set: function (callback) {
  132965. if (this._onAfterCameraRenderObserver) {
  132966. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  132967. }
  132968. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  132969. },
  132970. enumerable: true,
  132971. configurable: true
  132972. });
  132973. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  132974. /**
  132975. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  132976. */
  132977. get: function () {
  132978. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  132979. },
  132980. enumerable: true,
  132981. configurable: true
  132982. });
  132983. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  132984. get: function () {
  132985. return this._useRightHandedSystem;
  132986. },
  132987. /**
  132988. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  132989. */
  132990. set: function (value) {
  132991. if (this._useRightHandedSystem === value) {
  132992. return;
  132993. }
  132994. this._useRightHandedSystem = value;
  132995. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  132996. },
  132997. enumerable: true,
  132998. configurable: true
  132999. });
  133000. /**
  133001. * Sets the step Id used by deterministic lock step
  133002. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  133003. * @param newStepId defines the step Id
  133004. */
  133005. Scene.prototype.setStepId = function (newStepId) {
  133006. this._currentStepId = newStepId;
  133007. };
  133008. /**
  133009. * Gets the step Id used by deterministic lock step
  133010. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  133011. * @returns the step Id
  133012. */
  133013. Scene.prototype.getStepId = function () {
  133014. return this._currentStepId;
  133015. };
  133016. /**
  133017. * Gets the internal step used by deterministic lock step
  133018. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  133019. * @returns the internal step
  133020. */
  133021. Scene.prototype.getInternalStep = function () {
  133022. return this._currentInternalStep;
  133023. };
  133024. Object.defineProperty(Scene.prototype, "fogEnabled", {
  133025. get: function () {
  133026. return this._fogEnabled;
  133027. },
  133028. /**
  133029. * Gets or sets a boolean indicating if fog is enabled on this scene
  133030. * @see http://doc.babylonjs.com/babylon101/environment#fog
  133031. * (Default is true)
  133032. */
  133033. set: function (value) {
  133034. if (this._fogEnabled === value) {
  133035. return;
  133036. }
  133037. this._fogEnabled = value;
  133038. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  133039. },
  133040. enumerable: true,
  133041. configurable: true
  133042. });
  133043. Object.defineProperty(Scene.prototype, "fogMode", {
  133044. get: function () {
  133045. return this._fogMode;
  133046. },
  133047. /**
  133048. * Gets or sets the fog mode to use
  133049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  133050. * | mode | value |
  133051. * | --- | --- |
  133052. * | FOGMODE_NONE | 0 |
  133053. * | FOGMODE_EXP | 1 |
  133054. * | FOGMODE_EXP2 | 2 |
  133055. * | FOGMODE_LINEAR | 3 |
  133056. */
  133057. set: function (value) {
  133058. if (this._fogMode === value) {
  133059. return;
  133060. }
  133061. this._fogMode = value;
  133062. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  133063. },
  133064. enumerable: true,
  133065. configurable: true
  133066. });
  133067. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  133068. get: function () {
  133069. return this._shadowsEnabled;
  133070. },
  133071. /**
  133072. * Gets or sets a boolean indicating if shadows are enabled on this scene
  133073. */
  133074. set: function (value) {
  133075. if (this._shadowsEnabled === value) {
  133076. return;
  133077. }
  133078. this._shadowsEnabled = value;
  133079. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  133080. },
  133081. enumerable: true,
  133082. configurable: true
  133083. });
  133084. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  133085. get: function () {
  133086. return this._lightsEnabled;
  133087. },
  133088. /**
  133089. * Gets or sets a boolean indicating if lights are enabled on this scene
  133090. */
  133091. set: function (value) {
  133092. if (this._lightsEnabled === value) {
  133093. return;
  133094. }
  133095. this._lightsEnabled = value;
  133096. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  133097. },
  133098. enumerable: true,
  133099. configurable: true
  133100. });
  133101. Object.defineProperty(Scene.prototype, "activeCamera", {
  133102. /** Gets or sets the current active camera */
  133103. get: function () {
  133104. return this._activeCamera;
  133105. },
  133106. set: function (value) {
  133107. if (value === this._activeCamera) {
  133108. return;
  133109. }
  133110. this._activeCamera = value;
  133111. this.onActiveCameraChanged.notifyObservers(this);
  133112. },
  133113. enumerable: true,
  133114. configurable: true
  133115. });
  133116. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  133117. /** The default material used on meshes when no material is affected */
  133118. get: function () {
  133119. if (!this._defaultMaterial) {
  133120. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  133121. }
  133122. return this._defaultMaterial;
  133123. },
  133124. /** The default material used on meshes when no material is affected */
  133125. set: function (value) {
  133126. this._defaultMaterial = value;
  133127. },
  133128. enumerable: true,
  133129. configurable: true
  133130. });
  133131. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  133132. get: function () {
  133133. return this._texturesEnabled;
  133134. },
  133135. /**
  133136. * Gets or sets a boolean indicating if textures are enabled on this scene
  133137. */
  133138. set: function (value) {
  133139. if (this._texturesEnabled === value) {
  133140. return;
  133141. }
  133142. this._texturesEnabled = value;
  133143. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  133144. },
  133145. enumerable: true,
  133146. configurable: true
  133147. });
  133148. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  133149. get: function () {
  133150. return this._skeletonsEnabled;
  133151. },
  133152. /**
  133153. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  133154. */
  133155. set: function (value) {
  133156. if (this._skeletonsEnabled === value) {
  133157. return;
  133158. }
  133159. this._skeletonsEnabled = value;
  133160. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  133161. },
  133162. enumerable: true,
  133163. configurable: true
  133164. });
  133165. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  133166. /** @hidden */
  133167. get: function () {
  133168. if (!this._collisionCoordinator) {
  133169. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  133170. this._collisionCoordinator.init(this);
  133171. }
  133172. return this._collisionCoordinator;
  133173. },
  133174. enumerable: true,
  133175. configurable: true
  133176. });
  133177. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  133178. /** @hidden */
  133179. get: function () {
  133180. return this._alternateRendering;
  133181. },
  133182. enumerable: true,
  133183. configurable: true
  133184. });
  133185. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  133186. /**
  133187. * Gets the list of frustum planes (built from the active camera)
  133188. */
  133189. get: function () {
  133190. return this._frustumPlanes;
  133191. },
  133192. enumerable: true,
  133193. configurable: true
  133194. });
  133195. /**
  133196. * Registers the transient components if needed.
  133197. */
  133198. Scene.prototype._registerTransientComponents = function () {
  133199. // Register components that have been associated lately to the scene.
  133200. if (this._transientComponents.length > 0) {
  133201. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  133202. var component = _a[_i];
  133203. component.register();
  133204. }
  133205. this._transientComponents = [];
  133206. }
  133207. };
  133208. /**
  133209. * @hidden
  133210. * Add a component to the scene.
  133211. * Note that the ccomponent could be registered on th next frame if this is called after
  133212. * the register component stage.
  133213. * @param component Defines the component to add to the scene
  133214. */
  133215. Scene.prototype._addComponent = function (component) {
  133216. this._components.push(component);
  133217. this._transientComponents.push(component);
  133218. var serializableComponent = component;
  133219. if (serializableComponent.addFromContainer) {
  133220. this._serializableComponents.push(serializableComponent);
  133221. }
  133222. };
  133223. /**
  133224. * @hidden
  133225. * Gets a component from the scene.
  133226. * @param name defines the name of the component to retrieve
  133227. * @returns the component or null if not present
  133228. */
  133229. Scene.prototype._getComponent = function (name) {
  133230. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  133231. var component = _a[_i];
  133232. if (component.name === name) {
  133233. return component;
  133234. }
  133235. }
  133236. return null;
  133237. };
  133238. /**
  133239. * @hidden
  133240. */
  133241. Scene.prototype._getDefaultMeshCandidates = function () {
  133242. this._defaultMeshCandidates.data = this.meshes;
  133243. this._defaultMeshCandidates.length = this.meshes.length;
  133244. return this._defaultMeshCandidates;
  133245. };
  133246. /**
  133247. * @hidden
  133248. */
  133249. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  133250. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  133251. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  133252. return this._defaultSubMeshCandidates;
  133253. };
  133254. /**
  133255. * Sets the default candidate providers for the scene.
  133256. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  133257. * and getCollidingSubMeshCandidates to their default function
  133258. */
  133259. Scene.prototype.setDefaultCandidateProviders = function () {
  133260. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  133261. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  133262. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  133263. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  133264. };
  133265. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  133266. /**
  133267. * Gets the mesh that is currently under the pointer
  133268. */
  133269. get: function () {
  133270. return this._pointerOverMesh;
  133271. },
  133272. enumerable: true,
  133273. configurable: true
  133274. });
  133275. Object.defineProperty(Scene.prototype, "pointerX", {
  133276. /**
  133277. * Gets or sets the current on-screen X position of the pointer
  133278. */
  133279. get: function () {
  133280. return this._pointerX;
  133281. },
  133282. set: function (value) {
  133283. this._pointerX = value;
  133284. },
  133285. enumerable: true,
  133286. configurable: true
  133287. });
  133288. Object.defineProperty(Scene.prototype, "pointerY", {
  133289. /**
  133290. * Gets or sets the current on-screen Y position of the pointer
  133291. */
  133292. get: function () {
  133293. return this._pointerY;
  133294. },
  133295. set: function (value) {
  133296. this._pointerY = value;
  133297. },
  133298. enumerable: true,
  133299. configurable: true
  133300. });
  133301. /**
  133302. * Gets the cached material (ie. the latest rendered one)
  133303. * @returns the cached material
  133304. */
  133305. Scene.prototype.getCachedMaterial = function () {
  133306. return this._cachedMaterial;
  133307. };
  133308. /**
  133309. * Gets the cached effect (ie. the latest rendered one)
  133310. * @returns the cached effect
  133311. */
  133312. Scene.prototype.getCachedEffect = function () {
  133313. return this._cachedEffect;
  133314. };
  133315. /**
  133316. * Gets the cached visibility state (ie. the latest rendered one)
  133317. * @returns the cached visibility state
  133318. */
  133319. Scene.prototype.getCachedVisibility = function () {
  133320. return this._cachedVisibility;
  133321. };
  133322. /**
  133323. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  133324. * @param material defines the current material
  133325. * @param effect defines the current effect
  133326. * @param visibility defines the current visibility state
  133327. * @returns true if one parameter is not cached
  133328. */
  133329. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  133330. if (visibility === void 0) { visibility = 1; }
  133331. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  133332. };
  133333. /**
  133334. * Gets the engine associated with the scene
  133335. * @returns an Engine
  133336. */
  133337. Scene.prototype.getEngine = function () {
  133338. return this._engine;
  133339. };
  133340. /**
  133341. * Gets the total number of vertices rendered per frame
  133342. * @returns the total number of vertices rendered per frame
  133343. */
  133344. Scene.prototype.getTotalVertices = function () {
  133345. return this._totalVertices.current;
  133346. };
  133347. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  133348. /**
  133349. * Gets the performance counter for total vertices
  133350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  133351. */
  133352. get: function () {
  133353. return this._totalVertices;
  133354. },
  133355. enumerable: true,
  133356. configurable: true
  133357. });
  133358. /**
  133359. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  133360. * @returns the total number of active indices rendered per frame
  133361. */
  133362. Scene.prototype.getActiveIndices = function () {
  133363. return this._activeIndices.current;
  133364. };
  133365. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  133366. /**
  133367. * Gets the performance counter for active indices
  133368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  133369. */
  133370. get: function () {
  133371. return this._activeIndices;
  133372. },
  133373. enumerable: true,
  133374. configurable: true
  133375. });
  133376. /**
  133377. * Gets the total number of active particles rendered per frame
  133378. * @returns the total number of active particles rendered per frame
  133379. */
  133380. Scene.prototype.getActiveParticles = function () {
  133381. return this._activeParticles.current;
  133382. };
  133383. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  133384. /**
  133385. * Gets the performance counter for active particles
  133386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  133387. */
  133388. get: function () {
  133389. return this._activeParticles;
  133390. },
  133391. enumerable: true,
  133392. configurable: true
  133393. });
  133394. /**
  133395. * Gets the total number of active bones rendered per frame
  133396. * @returns the total number of active bones rendered per frame
  133397. */
  133398. Scene.prototype.getActiveBones = function () {
  133399. return this._activeBones.current;
  133400. };
  133401. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  133402. /**
  133403. * Gets the performance counter for active bones
  133404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  133405. */
  133406. get: function () {
  133407. return this._activeBones;
  133408. },
  133409. enumerable: true,
  133410. configurable: true
  133411. });
  133412. /**
  133413. * Gets the array of active meshes
  133414. * @returns an array of AbstractMesh
  133415. */
  133416. Scene.prototype.getActiveMeshes = function () {
  133417. return this._activeMeshes;
  133418. };
  133419. /**
  133420. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  133421. * @returns a number
  133422. */
  133423. Scene.prototype.getAnimationRatio = function () {
  133424. return this._animationRatio !== undefined ? this._animationRatio : 1;
  133425. };
  133426. /**
  133427. * Gets an unique Id for the current render phase
  133428. * @returns a number
  133429. */
  133430. Scene.prototype.getRenderId = function () {
  133431. return this._renderId;
  133432. };
  133433. /**
  133434. * Gets an unique Id for the current frame
  133435. * @returns a number
  133436. */
  133437. Scene.prototype.getFrameId = function () {
  133438. return this._frameId;
  133439. };
  133440. /** Call this function if you want to manually increment the render Id*/
  133441. Scene.prototype.incrementRenderId = function () {
  133442. this._renderId++;
  133443. };
  133444. Scene.prototype._updatePointerPosition = function (evt) {
  133445. var canvasRect = this._engine.getRenderingCanvasClientRect();
  133446. if (!canvasRect) {
  133447. return;
  133448. }
  133449. this._pointerX = evt.clientX - canvasRect.left;
  133450. this._pointerY = evt.clientY - canvasRect.top;
  133451. this._unTranslatedPointerX = this._pointerX;
  133452. this._unTranslatedPointerY = this._pointerY;
  133453. };
  133454. Scene.prototype._createUbo = function () {
  133455. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  133456. this._sceneUbo.addUniform("viewProjection", 16);
  133457. this._sceneUbo.addUniform("view", 16);
  133458. };
  133459. Scene.prototype._createAlternateUbo = function () {
  133460. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  133461. this._alternateSceneUbo.addUniform("viewProjection", 16);
  133462. this._alternateSceneUbo.addUniform("view", 16);
  133463. };
  133464. // Pointers handling
  133465. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  133466. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  133467. if (!pointerInfo.pickInfo.ray) {
  133468. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  133469. }
  133470. }
  133471. };
  133472. /**
  133473. * Use this method to simulate a pointer move on a mesh
  133474. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  133475. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  133476. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  133477. * @returns the current scene
  133478. */
  133479. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  133480. var evt = new PointerEvent("pointermove", pointerEventInit);
  133481. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  133482. return this;
  133483. }
  133484. return this._processPointerMove(pickResult, evt);
  133485. };
  133486. Scene.prototype._processPointerMove = function (pickResult, evt) {
  133487. var canvas = this._engine.getRenderingCanvas();
  133488. if (!canvas) {
  133489. return this;
  133490. }
  133491. // Restore pointer
  133492. canvas.style.cursor = this.defaultCursor;
  133493. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  133494. if (isMeshPicked) {
  133495. this.setPointerOverMesh(pickResult.pickedMesh);
  133496. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  133497. if (this._pointerOverMesh.actionManager.hoverCursor) {
  133498. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  133499. }
  133500. else {
  133501. canvas.style.cursor = this.hoverCursor;
  133502. }
  133503. }
  133504. }
  133505. else {
  133506. this.setPointerOverMesh(null);
  133507. }
  133508. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  133509. var step = _a[_i];
  133510. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  133511. }
  133512. if (pickResult) {
  133513. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  133514. if (this.onPointerMove) {
  133515. this.onPointerMove(evt, pickResult, type);
  133516. }
  133517. if (this.onPointerObservable.hasObservers()) {
  133518. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  133519. this._setRayOnPointerInfo(pi);
  133520. this.onPointerObservable.notifyObservers(pi, type);
  133521. }
  133522. }
  133523. return this;
  133524. };
  133525. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  133526. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  133527. if (pickResult) {
  133528. pi.ray = pickResult.ray;
  133529. }
  133530. this.onPrePointerObservable.notifyObservers(pi, type);
  133531. if (pi.skipOnPointerObservable) {
  133532. return true;
  133533. }
  133534. else {
  133535. return false;
  133536. }
  133537. };
  133538. /**
  133539. * Use this method to simulate a pointer down on a mesh
  133540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  133541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  133542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  133543. * @returns the current scene
  133544. */
  133545. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  133546. var evt = new PointerEvent("pointerdown", pointerEventInit);
  133547. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  133548. return this;
  133549. }
  133550. return this._processPointerDown(pickResult, evt);
  133551. };
  133552. Scene.prototype._processPointerDown = function (pickResult, evt) {
  133553. var _this = this;
  133554. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  133555. this._pickedDownMesh = pickResult.pickedMesh;
  133556. var actionManager = pickResult.pickedMesh.actionManager;
  133557. if (actionManager) {
  133558. if (actionManager.hasPickTriggers) {
  133559. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  133560. switch (evt.button) {
  133561. case 0:
  133562. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  133563. break;
  133564. case 1:
  133565. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  133566. break;
  133567. case 2:
  133568. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  133569. break;
  133570. }
  133571. }
  133572. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  133573. window.setTimeout(function () {
  133574. 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);
  133575. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  133576. if (_this._totalPointersPressed !== 0 &&
  133577. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  133578. !_this._isPointerSwiping()) {
  133579. _this._startingPointerTime = 0;
  133580. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  133581. }
  133582. }
  133583. }, Scene.LongPressDelay);
  133584. }
  133585. }
  133586. }
  133587. else {
  133588. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  133589. var step = _a[_i];
  133590. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  133591. }
  133592. }
  133593. if (pickResult) {
  133594. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  133595. if (this.onPointerDown) {
  133596. this.onPointerDown(evt, pickResult, type);
  133597. }
  133598. if (this.onPointerObservable.hasObservers()) {
  133599. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  133600. this._setRayOnPointerInfo(pi);
  133601. this.onPointerObservable.notifyObservers(pi, type);
  133602. }
  133603. }
  133604. return this;
  133605. };
  133606. /**
  133607. * Use this method to simulate a pointer up on a mesh
  133608. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  133609. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  133610. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  133611. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  133612. * @returns the current scene
  133613. */
  133614. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  133615. var evt = new PointerEvent("pointerup", pointerEventInit);
  133616. var clickInfo = new ClickInfo();
  133617. if (doubleTap) {
  133618. clickInfo.doubleClick = true;
  133619. }
  133620. else {
  133621. clickInfo.singleClick = true;
  133622. }
  133623. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  133624. return this;
  133625. }
  133626. return this._processPointerUp(pickResult, evt, clickInfo);
  133627. };
  133628. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  133629. if (pickResult && pickResult && pickResult.pickedMesh) {
  133630. this._pickedUpMesh = pickResult.pickedMesh;
  133631. if (this._pickedDownMesh === this._pickedUpMesh) {
  133632. if (this.onPointerPick) {
  133633. this.onPointerPick(evt, pickResult);
  133634. }
  133635. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  133636. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  133637. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  133638. this._setRayOnPointerInfo(pi);
  133639. this.onPointerObservable.notifyObservers(pi, type_1);
  133640. }
  133641. }
  133642. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  133643. if (actionManager && !clickInfo.ignore) {
  133644. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  133645. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  133646. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  133647. }
  133648. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  133649. if (clickInfo.doubleClick && doubleClickActionManager) {
  133650. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  133651. }
  133652. }
  133653. }
  133654. else {
  133655. if (!clickInfo.ignore) {
  133656. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  133657. var step = _a[_i];
  133658. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  133659. }
  133660. }
  133661. }
  133662. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  133663. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger);
  133664. if (pickedDownActionManager) {
  133665. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  133666. }
  133667. }
  133668. var type = 0;
  133669. if (this.onPointerObservable.hasObservers()) {
  133670. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  133671. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  133672. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  133673. }
  133674. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  133675. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  133676. }
  133677. if (type) {
  133678. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  133679. this._setRayOnPointerInfo(pi);
  133680. this.onPointerObservable.notifyObservers(pi, type);
  133681. }
  133682. }
  133683. if (!clickInfo.ignore) {
  133684. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  133685. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  133686. this._setRayOnPointerInfo(pi);
  133687. this.onPointerObservable.notifyObservers(pi, type);
  133688. }
  133689. }
  133690. if (this.onPointerUp && !clickInfo.ignore) {
  133691. this.onPointerUp(evt, pickResult, type);
  133692. }
  133693. return this;
  133694. };
  133695. /**
  133696. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  133697. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  133698. * @returns true if the pointer was captured
  133699. */
  133700. Scene.prototype.isPointerCaptured = function (pointerId) {
  133701. if (pointerId === void 0) { pointerId = 0; }
  133702. return this._pointerCaptures[pointerId];
  133703. };
  133704. /** @hidden */
  133705. Scene.prototype._isPointerSwiping = function () {
  133706. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  133707. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  133708. };
  133709. /**
  133710. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  133711. * @param attachUp defines if you want to attach events to pointerup
  133712. * @param attachDown defines if you want to attach events to pointerdown
  133713. * @param attachMove defines if you want to attach events to pointermove
  133714. */
  133715. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  133716. var _this = this;
  133717. if (attachUp === void 0) { attachUp = true; }
  133718. if (attachDown === void 0) { attachDown = true; }
  133719. if (attachMove === void 0) { attachMove = true; }
  133720. this._initActionManager = function (act, clickInfo) {
  133721. if (!_this._meshPickProceed) {
  133722. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  133723. _this._currentPickResult = pickResult;
  133724. if (pickResult) {
  133725. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  133726. }
  133727. _this._meshPickProceed = true;
  133728. }
  133729. return act;
  133730. };
  133731. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  133732. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  133733. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  133734. btn !== _this._previousButtonPressed) {
  133735. _this._doubleClickOccured = false;
  133736. clickInfo.singleClick = true;
  133737. clickInfo.ignore = false;
  133738. cb(clickInfo, _this._currentPickResult);
  133739. }
  133740. };
  133741. this._initClickEvent = function (obs1, obs2, evt, cb) {
  133742. var clickInfo = new ClickInfo();
  133743. _this._currentPickResult = null;
  133744. var act = null;
  133745. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  133746. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  133747. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  133748. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  133749. act = _this._initActionManager(act, clickInfo);
  133750. if (act) {
  133751. checkPicking = act.hasPickTriggers;
  133752. }
  133753. }
  133754. var needToIgnoreNext = false;
  133755. if (checkPicking) {
  133756. var btn = evt.button;
  133757. clickInfo.hasSwiped = _this._isPointerSwiping();
  133758. if (!clickInfo.hasSwiped) {
  133759. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  133760. if (!checkSingleClickImmediately) {
  133761. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  133762. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  133763. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  133764. act = _this._initActionManager(act, clickInfo);
  133765. if (act) {
  133766. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  133767. }
  133768. }
  133769. }
  133770. if (checkSingleClickImmediately) {
  133771. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  133772. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  133773. btn !== _this._previousButtonPressed) {
  133774. clickInfo.singleClick = true;
  133775. cb(clickInfo, _this._currentPickResult);
  133776. needToIgnoreNext = true;
  133777. }
  133778. }
  133779. // at least one double click is required to be check and exclusive double click is enabled
  133780. else {
  133781. // wait that no double click has been raised during the double click delay
  133782. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  133783. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  133784. }
  133785. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  133786. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  133787. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  133788. act = _this._initActionManager(act, clickInfo);
  133789. if (act) {
  133790. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  133791. }
  133792. }
  133793. if (checkDoubleClick) {
  133794. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  133795. if (btn === _this._previousButtonPressed &&
  133796. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  133797. !_this._doubleClickOccured) {
  133798. // pointer has not moved for 2 clicks, it's a double click
  133799. if (!clickInfo.hasSwiped &&
  133800. !_this._isPointerSwiping()) {
  133801. _this._previousStartingPointerTime = 0;
  133802. _this._doubleClickOccured = true;
  133803. clickInfo.doubleClick = true;
  133804. clickInfo.ignore = false;
  133805. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  133806. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  133807. }
  133808. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  133809. cb(clickInfo, _this._currentPickResult);
  133810. }
  133811. // if the two successive clicks are too far, it's just two simple clicks
  133812. else {
  133813. _this._doubleClickOccured = false;
  133814. _this._previousStartingPointerTime = _this._startingPointerTime;
  133815. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  133816. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  133817. _this._previousButtonPressed = btn;
  133818. if (Scene.ExclusiveDoubleClickMode) {
  133819. if (_this._previousDelayedSimpleClickTimeout) {
  133820. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  133821. }
  133822. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  133823. cb(clickInfo, _this._previousPickResult);
  133824. }
  133825. else {
  133826. cb(clickInfo, _this._currentPickResult);
  133827. }
  133828. }
  133829. needToIgnoreNext = true;
  133830. }
  133831. // just the first click of the double has been raised
  133832. else {
  133833. _this._doubleClickOccured = false;
  133834. _this._previousStartingPointerTime = _this._startingPointerTime;
  133835. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  133836. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  133837. _this._previousButtonPressed = btn;
  133838. }
  133839. }
  133840. }
  133841. }
  133842. if (!needToIgnoreNext) {
  133843. cb(clickInfo, _this._currentPickResult);
  133844. }
  133845. };
  133846. this._onPointerMove = function (evt) {
  133847. _this._updatePointerPosition(evt);
  133848. // PreObservable support
  133849. 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)) {
  133850. return;
  133851. }
  133852. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  133853. return;
  133854. }
  133855. if (!_this.pointerMovePredicate) {
  133856. _this.pointerMovePredicate = function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)) && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0)); };
  133857. }
  133858. // Meshes
  133859. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  133860. _this._processPointerMove(pickResult, evt);
  133861. };
  133862. this._onPointerDown = function (evt) {
  133863. _this._totalPointersPressed++;
  133864. _this._pickedDownMesh = null;
  133865. _this._meshPickProceed = false;
  133866. _this._updatePointerPosition(evt);
  133867. if (_this.preventDefaultOnPointerDown && canvas) {
  133868. evt.preventDefault();
  133869. canvas.focus();
  133870. }
  133871. _this._startingPointerPosition.x = _this._pointerX;
  133872. _this._startingPointerPosition.y = _this._pointerY;
  133873. _this._startingPointerTime = Date.now();
  133874. // PreObservable support
  133875. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  133876. return;
  133877. }
  133878. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  133879. return;
  133880. }
  133881. _this._pointerCaptures[evt.pointerId] = true;
  133882. if (!_this.pointerDownPredicate) {
  133883. _this.pointerDownPredicate = function (mesh) {
  133884. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  133885. };
  133886. }
  133887. // Meshes
  133888. _this._pickedDownMesh = null;
  133889. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  133890. _this._processPointerDown(pickResult, evt);
  133891. };
  133892. this._onPointerUp = function (evt) {
  133893. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  133894. return; // So we need to test it the pointer down was pressed before.
  133895. }
  133896. _this._totalPointersPressed--;
  133897. _this._pickedUpMesh = null;
  133898. _this._meshPickProceed = false;
  133899. _this._updatePointerPosition(evt);
  133900. if (_this.preventDefaultOnPointerUp && canvas) {
  133901. evt.preventDefault();
  133902. canvas.focus();
  133903. }
  133904. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  133905. // PreObservable support
  133906. if (_this.onPrePointerObservable.hasObservers()) {
  133907. if (!clickInfo.ignore) {
  133908. if (!clickInfo.hasSwiped) {
  133909. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  133910. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  133911. return;
  133912. }
  133913. }
  133914. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  133915. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  133916. return;
  133917. }
  133918. }
  133919. }
  133920. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  133921. return;
  133922. }
  133923. }
  133924. }
  133925. if (!_this._pointerCaptures[evt.pointerId]) {
  133926. return;
  133927. }
  133928. _this._pointerCaptures[evt.pointerId] = false;
  133929. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  133930. return;
  133931. }
  133932. if (!_this.pointerUpPredicate) {
  133933. _this.pointerUpPredicate = function (mesh) {
  133934. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  133935. };
  133936. }
  133937. // Meshes
  133938. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  133939. _this._initActionManager(null, clickInfo);
  133940. }
  133941. if (!pickResult) {
  133942. pickResult = _this._currentPickResult;
  133943. }
  133944. _this._processPointerUp(pickResult, evt, clickInfo);
  133945. _this._previousPickResult = _this._currentPickResult;
  133946. });
  133947. };
  133948. this._onKeyDown = function (evt) {
  133949. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  133950. if (_this.onPreKeyboardObservable.hasObservers()) {
  133951. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  133952. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  133953. if (pi.skipOnPointerObservable) {
  133954. return;
  133955. }
  133956. }
  133957. if (_this.onKeyboardObservable.hasObservers()) {
  133958. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  133959. _this.onKeyboardObservable.notifyObservers(pi, type);
  133960. }
  133961. if (_this.actionManager) {
  133962. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  133963. }
  133964. };
  133965. this._onKeyUp = function (evt) {
  133966. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  133967. if (_this.onPreKeyboardObservable.hasObservers()) {
  133968. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  133969. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  133970. if (pi.skipOnPointerObservable) {
  133971. return;
  133972. }
  133973. }
  133974. if (_this.onKeyboardObservable.hasObservers()) {
  133975. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  133976. _this.onKeyboardObservable.notifyObservers(pi, type);
  133977. }
  133978. if (_this.actionManager) {
  133979. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  133980. }
  133981. };
  133982. var engine = this.getEngine();
  133983. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  133984. if (!canvas) {
  133985. return;
  133986. }
  133987. canvas.addEventListener("keydown", _this._onKeyDown, false);
  133988. canvas.addEventListener("keyup", _this._onKeyUp, false);
  133989. });
  133990. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  133991. if (!canvas) {
  133992. return;
  133993. }
  133994. canvas.removeEventListener("keydown", _this._onKeyDown);
  133995. canvas.removeEventListener("keyup", _this._onKeyUp);
  133996. });
  133997. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  133998. var canvas = this._engine.getRenderingCanvas();
  133999. if (!canvas) {
  134000. return;
  134001. }
  134002. if (attachMove) {
  134003. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  134004. // Wheel
  134005. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  134006. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  134007. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  134008. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  134009. }
  134010. if (attachDown) {
  134011. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  134012. }
  134013. if (attachUp) {
  134014. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  134015. }
  134016. canvas.tabIndex = 1;
  134017. };
  134018. /** Detaches all event handlers*/
  134019. Scene.prototype.detachControl = function () {
  134020. var engine = this.getEngine();
  134021. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  134022. var canvas = engine.getRenderingCanvas();
  134023. if (!canvas) {
  134024. return;
  134025. }
  134026. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  134027. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  134028. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  134029. if (this._onCanvasBlurObserver) {
  134030. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  134031. }
  134032. if (this._onCanvasFocusObserver) {
  134033. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  134034. }
  134035. // Wheel
  134036. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  134037. // Keyboard
  134038. canvas.removeEventListener("keydown", this._onKeyDown);
  134039. canvas.removeEventListener("keyup", this._onKeyUp);
  134040. // Observables
  134041. this.onKeyboardObservable.clear();
  134042. this.onPreKeyboardObservable.clear();
  134043. this.onPointerObservable.clear();
  134044. this.onPrePointerObservable.clear();
  134045. };
  134046. /**
  134047. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  134048. * Delay loaded resources are not taking in account
  134049. * @return true if all required resources are ready
  134050. */
  134051. Scene.prototype.isReady = function () {
  134052. if (this._isDisposed) {
  134053. return false;
  134054. }
  134055. var index;
  134056. var engine = this.getEngine();
  134057. // Effects
  134058. if (!engine.areAllEffectsReady()) {
  134059. return false;
  134060. }
  134061. // Pending data
  134062. if (this._pendingData.length > 0) {
  134063. return false;
  134064. }
  134065. // Meshes
  134066. for (index = 0; index < this.meshes.length; index++) {
  134067. var mesh = this.meshes[index];
  134068. if (!mesh.isEnabled()) {
  134069. continue;
  134070. }
  134071. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  134072. continue;
  134073. }
  134074. if (!mesh.isReady(true)) {
  134075. return false;
  134076. }
  134077. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  134078. // Is Ready For Mesh
  134079. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  134080. var step = _a[_i];
  134081. if (!step.action(mesh, hardwareInstancedRendering)) {
  134082. return false;
  134083. }
  134084. }
  134085. }
  134086. // Geometries
  134087. for (index = 0; index < this.geometries.length; index++) {
  134088. var geometry = this.geometries[index];
  134089. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  134090. return false;
  134091. }
  134092. }
  134093. // Post-processes
  134094. if (this.activeCameras && this.activeCameras.length > 0) {
  134095. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  134096. var camera = _c[_b];
  134097. if (!camera.isReady(true)) {
  134098. return false;
  134099. }
  134100. }
  134101. }
  134102. else if (this.activeCamera) {
  134103. if (!this.activeCamera.isReady(true)) {
  134104. return false;
  134105. }
  134106. }
  134107. // Particles
  134108. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  134109. var particleSystem = _e[_d];
  134110. if (!particleSystem.isReady()) {
  134111. return false;
  134112. }
  134113. }
  134114. return true;
  134115. };
  134116. /** Resets all cached information relative to material (including effect and visibility) */
  134117. Scene.prototype.resetCachedMaterial = function () {
  134118. this._cachedMaterial = null;
  134119. this._cachedEffect = null;
  134120. this._cachedVisibility = null;
  134121. };
  134122. /**
  134123. * Registers a function to be called before every frame render
  134124. * @param func defines the function to register
  134125. */
  134126. Scene.prototype.registerBeforeRender = function (func) {
  134127. this.onBeforeRenderObservable.add(func);
  134128. };
  134129. /**
  134130. * Unregisters a function called before every frame render
  134131. * @param func defines the function to unregister
  134132. */
  134133. Scene.prototype.unregisterBeforeRender = function (func) {
  134134. this.onBeforeRenderObservable.removeCallback(func);
  134135. };
  134136. /**
  134137. * Registers a function to be called after every frame render
  134138. * @param func defines the function to register
  134139. */
  134140. Scene.prototype.registerAfterRender = function (func) {
  134141. this.onAfterRenderObservable.add(func);
  134142. };
  134143. /**
  134144. * Unregisters a function called after every frame render
  134145. * @param func defines the function to unregister
  134146. */
  134147. Scene.prototype.unregisterAfterRender = function (func) {
  134148. this.onAfterRenderObservable.removeCallback(func);
  134149. };
  134150. Scene.prototype._executeOnceBeforeRender = function (func) {
  134151. var _this = this;
  134152. var execFunc = function () {
  134153. func();
  134154. setTimeout(function () {
  134155. _this.unregisterBeforeRender(execFunc);
  134156. });
  134157. };
  134158. this.registerBeforeRender(execFunc);
  134159. };
  134160. /**
  134161. * The provided function will run before render once and will be disposed afterwards.
  134162. * A timeout delay can be provided so that the function will be executed in N ms.
  134163. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  134164. * @param func The function to be executed.
  134165. * @param timeout optional delay in ms
  134166. */
  134167. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  134168. var _this = this;
  134169. if (timeout !== undefined) {
  134170. setTimeout(function () {
  134171. _this._executeOnceBeforeRender(func);
  134172. }, timeout);
  134173. }
  134174. else {
  134175. this._executeOnceBeforeRender(func);
  134176. }
  134177. };
  134178. /** @hidden */
  134179. Scene.prototype._addPendingData = function (data) {
  134180. this._pendingData.push(data);
  134181. };
  134182. /** @hidden */
  134183. Scene.prototype._removePendingData = function (data) {
  134184. var wasLoading = this.isLoading;
  134185. var index = this._pendingData.indexOf(data);
  134186. if (index !== -1) {
  134187. this._pendingData.splice(index, 1);
  134188. }
  134189. if (wasLoading && !this.isLoading) {
  134190. this.onDataLoadedObservable.notifyObservers(this);
  134191. }
  134192. };
  134193. /**
  134194. * Returns the number of items waiting to be loaded
  134195. * @returns the number of items waiting to be loaded
  134196. */
  134197. Scene.prototype.getWaitingItemsCount = function () {
  134198. return this._pendingData.length;
  134199. };
  134200. Object.defineProperty(Scene.prototype, "isLoading", {
  134201. /**
  134202. * Returns a boolean indicating if the scene is still loading data
  134203. */
  134204. get: function () {
  134205. return this._pendingData.length > 0;
  134206. },
  134207. enumerable: true,
  134208. configurable: true
  134209. });
  134210. /**
  134211. * Registers a function to be executed when the scene is ready
  134212. * @param {Function} func - the function to be executed
  134213. */
  134214. Scene.prototype.executeWhenReady = function (func) {
  134215. var _this = this;
  134216. this.onReadyObservable.add(func);
  134217. if (this._executeWhenReadyTimeoutId !== -1) {
  134218. return;
  134219. }
  134220. this._executeWhenReadyTimeoutId = setTimeout(function () {
  134221. _this._checkIsReady();
  134222. }, 150);
  134223. };
  134224. /**
  134225. * Returns a promise that resolves when the scene is ready
  134226. * @returns A promise that resolves when the scene is ready
  134227. */
  134228. Scene.prototype.whenReadyAsync = function () {
  134229. var _this = this;
  134230. return new Promise(function (resolve) {
  134231. _this.executeWhenReady(function () {
  134232. resolve();
  134233. });
  134234. });
  134235. };
  134236. /** @hidden */
  134237. Scene.prototype._checkIsReady = function () {
  134238. var _this = this;
  134239. this._registerTransientComponents();
  134240. if (this.isReady()) {
  134241. this.onReadyObservable.notifyObservers(this);
  134242. this.onReadyObservable.clear();
  134243. this._executeWhenReadyTimeoutId = -1;
  134244. return;
  134245. }
  134246. this._executeWhenReadyTimeoutId = setTimeout(function () {
  134247. _this._checkIsReady();
  134248. }, 150);
  134249. };
  134250. Object.defineProperty(Scene.prototype, "animatables", {
  134251. /**
  134252. * Gets all animatable attached to the scene
  134253. */
  134254. get: function () {
  134255. return this._activeAnimatables;
  134256. },
  134257. enumerable: true,
  134258. configurable: true
  134259. });
  134260. /**
  134261. * Resets the last animation time frame.
  134262. * Useful to override when animations start running when loading a scene for the first time.
  134263. */
  134264. Scene.prototype.resetLastAnimationTimeFrame = function () {
  134265. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  134266. };
  134267. // Matrix
  134268. /** @hidden */
  134269. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  134270. this._useAlternateCameraConfiguration = active;
  134271. };
  134272. /**
  134273. * Gets the current view matrix
  134274. * @returns a Matrix
  134275. */
  134276. Scene.prototype.getViewMatrix = function () {
  134277. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  134278. };
  134279. /**
  134280. * Gets the current projection matrix
  134281. * @returns a Matrix
  134282. */
  134283. Scene.prototype.getProjectionMatrix = function () {
  134284. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  134285. };
  134286. /**
  134287. * Gets the current transform matrix
  134288. * @returns a Matrix made of View * Projection
  134289. */
  134290. Scene.prototype.getTransformMatrix = function () {
  134291. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  134292. };
  134293. /**
  134294. * Sets the current transform matrix
  134295. * @param view defines the View matrix to use
  134296. * @param projection defines the Projection matrix to use
  134297. */
  134298. Scene.prototype.setTransformMatrix = function (view, projection) {
  134299. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  134300. return;
  134301. }
  134302. this._viewUpdateFlag = view.updateFlag;
  134303. this._projectionUpdateFlag = projection.updateFlag;
  134304. this._viewMatrix = view;
  134305. this._projectionMatrix = projection;
  134306. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  134307. // Update frustum
  134308. if (!this._frustumPlanes) {
  134309. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  134310. }
  134311. else {
  134312. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  134313. }
  134314. if (this.activeCamera && this.activeCamera._alternateCamera) {
  134315. var otherCamera = this.activeCamera._alternateCamera;
  134316. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  134317. _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
  134318. }
  134319. if (this._sceneUbo.useUbo) {
  134320. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  134321. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  134322. this._sceneUbo.update();
  134323. }
  134324. };
  134325. /** @hidden */
  134326. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  134327. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  134328. return;
  134329. }
  134330. this._alternateViewUpdateFlag = view.updateFlag;
  134331. this._alternateProjectionUpdateFlag = projection.updateFlag;
  134332. this._alternateViewMatrix = view;
  134333. this._alternateProjectionMatrix = projection;
  134334. if (!this._alternateTransformMatrix) {
  134335. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  134336. }
  134337. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  134338. if (!this._alternateSceneUbo) {
  134339. this._createAlternateUbo();
  134340. }
  134341. if (this._alternateSceneUbo.useUbo) {
  134342. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  134343. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  134344. this._alternateSceneUbo.update();
  134345. }
  134346. };
  134347. /**
  134348. * Gets the uniform buffer used to store scene data
  134349. * @returns a UniformBuffer
  134350. */
  134351. Scene.prototype.getSceneUniformBuffer = function () {
  134352. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  134353. };
  134354. /**
  134355. * Gets an unique (relatively to the current scene) Id
  134356. * @returns an unique number for the scene
  134357. */
  134358. Scene.prototype.getUniqueId = function () {
  134359. var result = Scene._uniqueIdCounter;
  134360. Scene._uniqueIdCounter++;
  134361. return result;
  134362. };
  134363. /**
  134364. * Add a mesh to the list of scene's meshes
  134365. * @param newMesh defines the mesh to add
  134366. * @param recursive if all child meshes should also be added to the scene
  134367. */
  134368. Scene.prototype.addMesh = function (newMesh, recursive) {
  134369. var _this = this;
  134370. if (recursive === void 0) { recursive = false; }
  134371. this.meshes.push(newMesh);
  134372. newMesh._resyncLightSources();
  134373. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  134374. if (recursive) {
  134375. newMesh.getChildMeshes().forEach(function (m) {
  134376. _this.addMesh(m);
  134377. });
  134378. }
  134379. };
  134380. /**
  134381. * Remove a mesh for the list of scene's meshes
  134382. * @param toRemove defines the mesh to remove
  134383. * @param recursive if all child meshes should also be removed from the scene
  134384. * @returns the index where the mesh was in the mesh list
  134385. */
  134386. Scene.prototype.removeMesh = function (toRemove, recursive) {
  134387. var _this = this;
  134388. if (recursive === void 0) { recursive = false; }
  134389. var index = this.meshes.indexOf(toRemove);
  134390. if (index !== -1) {
  134391. // Remove from the scene if mesh found
  134392. this.meshes[index] = this.meshes[this.meshes.length - 1];
  134393. this.meshes.pop();
  134394. }
  134395. this.onMeshRemovedObservable.notifyObservers(toRemove);
  134396. if (recursive) {
  134397. toRemove.getChildMeshes().forEach(function (m) {
  134398. _this.removeMesh(m);
  134399. });
  134400. }
  134401. return index;
  134402. };
  134403. /**
  134404. * Add a transform node to the list of scene's transform nodes
  134405. * @param newTransformNode defines the transform node to add
  134406. */
  134407. Scene.prototype.addTransformNode = function (newTransformNode) {
  134408. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  134409. this.transformNodes.push(newTransformNode);
  134410. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  134411. };
  134412. /**
  134413. * Remove a transform node for the list of scene's transform nodes
  134414. * @param toRemove defines the transform node to remove
  134415. * @returns the index where the transform node was in the transform node list
  134416. */
  134417. Scene.prototype.removeTransformNode = function (toRemove) {
  134418. var index = toRemove._indexInSceneTransformNodesArray;
  134419. if (index !== -1) {
  134420. if (index !== this.transformNodes.length - 1) {
  134421. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  134422. this.transformNodes[index] = lastNode;
  134423. lastNode._indexInSceneTransformNodesArray = index;
  134424. }
  134425. toRemove._indexInSceneTransformNodesArray = -1;
  134426. this.transformNodes.pop();
  134427. }
  134428. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  134429. return index;
  134430. };
  134431. /**
  134432. * Remove a skeleton for the list of scene's skeletons
  134433. * @param toRemove defines the skeleton to remove
  134434. * @returns the index where the skeleton was in the skeleton list
  134435. */
  134436. Scene.prototype.removeSkeleton = function (toRemove) {
  134437. var index = this.skeletons.indexOf(toRemove);
  134438. if (index !== -1) {
  134439. // Remove from the scene if found
  134440. this.skeletons.splice(index, 1);
  134441. this.onSkeletonRemovedObservable.notifyObservers(toRemove);
  134442. }
  134443. return index;
  134444. };
  134445. /**
  134446. * Remove a morph target for the list of scene's morph targets
  134447. * @param toRemove defines the morph target to remove
  134448. * @returns the index where the morph target was in the morph target list
  134449. */
  134450. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  134451. var index = this.morphTargetManagers.indexOf(toRemove);
  134452. if (index !== -1) {
  134453. // Remove from the scene if found
  134454. this.morphTargetManagers.splice(index, 1);
  134455. }
  134456. return index;
  134457. };
  134458. /**
  134459. * Remove a light for the list of scene's lights
  134460. * @param toRemove defines the light to remove
  134461. * @returns the index where the light was in the light list
  134462. */
  134463. Scene.prototype.removeLight = function (toRemove) {
  134464. var index = this.lights.indexOf(toRemove);
  134465. if (index !== -1) {
  134466. // Remove from meshes
  134467. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  134468. var mesh = _a[_i];
  134469. mesh._removeLightSource(toRemove);
  134470. }
  134471. // Remove from the scene if mesh found
  134472. this.lights.splice(index, 1);
  134473. this.sortLightsByPriority();
  134474. }
  134475. this.onLightRemovedObservable.notifyObservers(toRemove);
  134476. return index;
  134477. };
  134478. /**
  134479. * Remove a camera for the list of scene's cameras
  134480. * @param toRemove defines the camera to remove
  134481. * @returns the index where the camera was in the camera list
  134482. */
  134483. Scene.prototype.removeCamera = function (toRemove) {
  134484. var index = this.cameras.indexOf(toRemove);
  134485. if (index !== -1) {
  134486. // Remove from the scene if mesh found
  134487. this.cameras.splice(index, 1);
  134488. }
  134489. // Remove from activeCameras
  134490. var index2 = this.activeCameras.indexOf(toRemove);
  134491. if (index2 !== -1) {
  134492. // Remove from the scene if mesh found
  134493. this.activeCameras.splice(index2, 1);
  134494. }
  134495. // Reset the activeCamera
  134496. if (this.activeCamera === toRemove) {
  134497. if (this.cameras.length > 0) {
  134498. this.activeCamera = this.cameras[0];
  134499. }
  134500. else {
  134501. this.activeCamera = null;
  134502. }
  134503. }
  134504. this.onCameraRemovedObservable.notifyObservers(toRemove);
  134505. return index;
  134506. };
  134507. /**
  134508. * Remove a particle system for the list of scene's particle systems
  134509. * @param toRemove defines the particle system to remove
  134510. * @returns the index where the particle system was in the particle system list
  134511. */
  134512. Scene.prototype.removeParticleSystem = function (toRemove) {
  134513. var index = this.particleSystems.indexOf(toRemove);
  134514. if (index !== -1) {
  134515. this.particleSystems.splice(index, 1);
  134516. }
  134517. return index;
  134518. };
  134519. /**
  134520. * Remove a animation for the list of scene's animations
  134521. * @param toRemove defines the animation to remove
  134522. * @returns the index where the animation was in the animation list
  134523. */
  134524. Scene.prototype.removeAnimation = function (toRemove) {
  134525. var index = this.animations.indexOf(toRemove);
  134526. if (index !== -1) {
  134527. this.animations.splice(index, 1);
  134528. }
  134529. return index;
  134530. };
  134531. /**
  134532. * Removes the given animation group from this scene.
  134533. * @param toRemove The animation group to remove
  134534. * @returns The index of the removed animation group
  134535. */
  134536. Scene.prototype.removeAnimationGroup = function (toRemove) {
  134537. var index = this.animationGroups.indexOf(toRemove);
  134538. if (index !== -1) {
  134539. this.animationGroups.splice(index, 1);
  134540. }
  134541. return index;
  134542. };
  134543. /**
  134544. * Removes the given multi-material from this scene.
  134545. * @param toRemove The multi-material to remove
  134546. * @returns The index of the removed multi-material
  134547. */
  134548. Scene.prototype.removeMultiMaterial = function (toRemove) {
  134549. var index = this.multiMaterials.indexOf(toRemove);
  134550. if (index !== -1) {
  134551. this.multiMaterials.splice(index, 1);
  134552. }
  134553. return index;
  134554. };
  134555. /**
  134556. * Removes the given material from this scene.
  134557. * @param toRemove The material to remove
  134558. * @returns The index of the removed material
  134559. */
  134560. Scene.prototype.removeMaterial = function (toRemove) {
  134561. var index = toRemove._indexInSceneMaterialArray;
  134562. if (index !== -1 && index < this.materials.length) {
  134563. if (index !== this.materials.length - 1) {
  134564. var lastMaterial = this.materials[this.materials.length - 1];
  134565. this.materials[index] = lastMaterial;
  134566. lastMaterial._indexInSceneMaterialArray = index;
  134567. }
  134568. toRemove._indexInSceneMaterialArray = -1;
  134569. this.materials.pop();
  134570. }
  134571. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  134572. return index;
  134573. };
  134574. /**
  134575. * Removes the given action manager from this scene.
  134576. * @param toRemove The action manager to remove
  134577. * @returns The index of the removed action manager
  134578. */
  134579. Scene.prototype.removeActionManager = function (toRemove) {
  134580. var index = this.actionManagers.indexOf(toRemove);
  134581. if (index !== -1) {
  134582. this.actionManagers.splice(index, 1);
  134583. }
  134584. return index;
  134585. };
  134586. /**
  134587. * Removes the given texture from this scene.
  134588. * @param toRemove The texture to remove
  134589. * @returns The index of the removed texture
  134590. */
  134591. Scene.prototype.removeTexture = function (toRemove) {
  134592. var index = this.textures.indexOf(toRemove);
  134593. if (index !== -1) {
  134594. this.textures.splice(index, 1);
  134595. }
  134596. this.onTextureRemovedObservable.notifyObservers(toRemove);
  134597. return index;
  134598. };
  134599. /**
  134600. * Adds the given light to this scene
  134601. * @param newLight The light to add
  134602. */
  134603. Scene.prototype.addLight = function (newLight) {
  134604. this.lights.push(newLight);
  134605. this.sortLightsByPriority();
  134606. // Add light to all meshes (To support if the light is removed and then readded)
  134607. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  134608. var mesh = _a[_i];
  134609. if (mesh._lightSources.indexOf(newLight) === -1) {
  134610. mesh._lightSources.push(newLight);
  134611. mesh._resyncLightSources();
  134612. }
  134613. }
  134614. this.onNewLightAddedObservable.notifyObservers(newLight);
  134615. };
  134616. /**
  134617. * Sorts the list list based on light priorities
  134618. */
  134619. Scene.prototype.sortLightsByPriority = function () {
  134620. if (this.requireLightSorting) {
  134621. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  134622. }
  134623. };
  134624. /**
  134625. * Adds the given camera to this scene
  134626. * @param newCamera The camera to add
  134627. */
  134628. Scene.prototype.addCamera = function (newCamera) {
  134629. this.cameras.push(newCamera);
  134630. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  134631. };
  134632. /**
  134633. * Adds the given skeleton to this scene
  134634. * @param newSkeleton The skeleton to add
  134635. */
  134636. Scene.prototype.addSkeleton = function (newSkeleton) {
  134637. this.skeletons.push(newSkeleton);
  134638. this.onNewSkeletonAddedObservable.notifyObservers(newSkeleton);
  134639. };
  134640. /**
  134641. * Adds the given particle system to this scene
  134642. * @param newParticleSystem The particle system to add
  134643. */
  134644. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  134645. this.particleSystems.push(newParticleSystem);
  134646. };
  134647. /**
  134648. * Adds the given animation to this scene
  134649. * @param newAnimation The animation to add
  134650. */
  134651. Scene.prototype.addAnimation = function (newAnimation) {
  134652. this.animations.push(newAnimation);
  134653. };
  134654. /**
  134655. * Adds the given animation group to this scene.
  134656. * @param newAnimationGroup The animation group to add
  134657. */
  134658. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  134659. this.animationGroups.push(newAnimationGroup);
  134660. };
  134661. /**
  134662. * Adds the given multi-material to this scene
  134663. * @param newMultiMaterial The multi-material to add
  134664. */
  134665. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  134666. this.multiMaterials.push(newMultiMaterial);
  134667. };
  134668. /**
  134669. * Adds the given material to this scene
  134670. * @param newMaterial The material to add
  134671. */
  134672. Scene.prototype.addMaterial = function (newMaterial) {
  134673. newMaterial._indexInSceneMaterialArray = this.materials.length;
  134674. this.materials.push(newMaterial);
  134675. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  134676. };
  134677. /**
  134678. * Adds the given morph target to this scene
  134679. * @param newMorphTargetManager The morph target to add
  134680. */
  134681. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  134682. this.morphTargetManagers.push(newMorphTargetManager);
  134683. };
  134684. /**
  134685. * Adds the given geometry to this scene
  134686. * @param newGeometry The geometry to add
  134687. */
  134688. Scene.prototype.addGeometry = function (newGeometry) {
  134689. if (this.geometriesByUniqueId) {
  134690. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  134691. }
  134692. this.geometries.push(newGeometry);
  134693. };
  134694. /**
  134695. * Adds the given action manager to this scene
  134696. * @param newActionManager The action manager to add
  134697. */
  134698. Scene.prototype.addActionManager = function (newActionManager) {
  134699. this.actionManagers.push(newActionManager);
  134700. };
  134701. /**
  134702. * Adds the given texture to this scene.
  134703. * @param newTexture The texture to add
  134704. */
  134705. Scene.prototype.addTexture = function (newTexture) {
  134706. this.textures.push(newTexture);
  134707. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  134708. };
  134709. /**
  134710. * Switch active camera
  134711. * @param newCamera defines the new active camera
  134712. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  134713. */
  134714. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  134715. if (attachControl === void 0) { attachControl = true; }
  134716. var canvas = this._engine.getRenderingCanvas();
  134717. if (!canvas) {
  134718. return;
  134719. }
  134720. if (this.activeCamera) {
  134721. this.activeCamera.detachControl(canvas);
  134722. }
  134723. this.activeCamera = newCamera;
  134724. if (attachControl) {
  134725. newCamera.attachControl(canvas);
  134726. }
  134727. };
  134728. /**
  134729. * sets the active camera of the scene using its ID
  134730. * @param id defines the camera's ID
  134731. * @return the new active camera or null if none found.
  134732. */
  134733. Scene.prototype.setActiveCameraByID = function (id) {
  134734. var camera = this.getCameraByID(id);
  134735. if (camera) {
  134736. this.activeCamera = camera;
  134737. return camera;
  134738. }
  134739. return null;
  134740. };
  134741. /**
  134742. * sets the active camera of the scene using its name
  134743. * @param name defines the camera's name
  134744. * @returns the new active camera or null if none found.
  134745. */
  134746. Scene.prototype.setActiveCameraByName = function (name) {
  134747. var camera = this.getCameraByName(name);
  134748. if (camera) {
  134749. this.activeCamera = camera;
  134750. return camera;
  134751. }
  134752. return null;
  134753. };
  134754. /**
  134755. * get an animation group using its name
  134756. * @param name defines the material's name
  134757. * @return the animation group or null if none found.
  134758. */
  134759. Scene.prototype.getAnimationGroupByName = function (name) {
  134760. for (var index = 0; index < this.animationGroups.length; index++) {
  134761. if (this.animationGroups[index].name === name) {
  134762. return this.animationGroups[index];
  134763. }
  134764. }
  134765. return null;
  134766. };
  134767. /**
  134768. * Get a material using its unique id
  134769. * @param uniqueId defines the material's unique id
  134770. * @return the material or null if none found.
  134771. */
  134772. Scene.prototype.getMaterialByUniqueID = function (uniqueId) {
  134773. for (var index = 0; index < this.materials.length; index++) {
  134774. if (this.materials[index].uniqueId === uniqueId) {
  134775. return this.materials[index];
  134776. }
  134777. }
  134778. return null;
  134779. };
  134780. /**
  134781. * get a material using its id
  134782. * @param id defines the material's ID
  134783. * @return the material or null if none found.
  134784. */
  134785. Scene.prototype.getMaterialByID = function (id) {
  134786. for (var index = 0; index < this.materials.length; index++) {
  134787. if (this.materials[index].id === id) {
  134788. return this.materials[index];
  134789. }
  134790. }
  134791. return null;
  134792. };
  134793. /**
  134794. * Gets a material using its name
  134795. * @param name defines the material's name
  134796. * @return the material or null if none found.
  134797. */
  134798. Scene.prototype.getMaterialByName = function (name) {
  134799. for (var index = 0; index < this.materials.length; index++) {
  134800. if (this.materials[index].name === name) {
  134801. return this.materials[index];
  134802. }
  134803. }
  134804. return null;
  134805. };
  134806. /**
  134807. * Gets a camera using its id
  134808. * @param id defines the id to look for
  134809. * @returns the camera or null if not found
  134810. */
  134811. Scene.prototype.getCameraByID = function (id) {
  134812. for (var index = 0; index < this.cameras.length; index++) {
  134813. if (this.cameras[index].id === id) {
  134814. return this.cameras[index];
  134815. }
  134816. }
  134817. return null;
  134818. };
  134819. /**
  134820. * Gets a camera using its unique id
  134821. * @param uniqueId defines the unique id to look for
  134822. * @returns the camera or null if not found
  134823. */
  134824. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  134825. for (var index = 0; index < this.cameras.length; index++) {
  134826. if (this.cameras[index].uniqueId === uniqueId) {
  134827. return this.cameras[index];
  134828. }
  134829. }
  134830. return null;
  134831. };
  134832. /**
  134833. * Gets a camera using its name
  134834. * @param name defines the camera's name
  134835. * @return the camera or null if none found.
  134836. */
  134837. Scene.prototype.getCameraByName = function (name) {
  134838. for (var index = 0; index < this.cameras.length; index++) {
  134839. if (this.cameras[index].name === name) {
  134840. return this.cameras[index];
  134841. }
  134842. }
  134843. return null;
  134844. };
  134845. /**
  134846. * Gets a bone using its id
  134847. * @param id defines the bone's id
  134848. * @return the bone or null if not found
  134849. */
  134850. Scene.prototype.getBoneByID = function (id) {
  134851. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  134852. var skeleton = this.skeletons[skeletonIndex];
  134853. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  134854. if (skeleton.bones[boneIndex].id === id) {
  134855. return skeleton.bones[boneIndex];
  134856. }
  134857. }
  134858. }
  134859. return null;
  134860. };
  134861. /**
  134862. * Gets a bone using its id
  134863. * @param name defines the bone's name
  134864. * @return the bone or null if not found
  134865. */
  134866. Scene.prototype.getBoneByName = function (name) {
  134867. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  134868. var skeleton = this.skeletons[skeletonIndex];
  134869. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  134870. if (skeleton.bones[boneIndex].name === name) {
  134871. return skeleton.bones[boneIndex];
  134872. }
  134873. }
  134874. }
  134875. return null;
  134876. };
  134877. /**
  134878. * Gets a light node using its name
  134879. * @param name defines the the light's name
  134880. * @return the light or null if none found.
  134881. */
  134882. Scene.prototype.getLightByName = function (name) {
  134883. for (var index = 0; index < this.lights.length; index++) {
  134884. if (this.lights[index].name === name) {
  134885. return this.lights[index];
  134886. }
  134887. }
  134888. return null;
  134889. };
  134890. /**
  134891. * Gets a light node using its id
  134892. * @param id defines the light's id
  134893. * @return the light or null if none found.
  134894. */
  134895. Scene.prototype.getLightByID = function (id) {
  134896. for (var index = 0; index < this.lights.length; index++) {
  134897. if (this.lights[index].id === id) {
  134898. return this.lights[index];
  134899. }
  134900. }
  134901. return null;
  134902. };
  134903. /**
  134904. * Gets a light node using its scene-generated unique ID
  134905. * @param uniqueId defines the light's unique id
  134906. * @return the light or null if none found.
  134907. */
  134908. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  134909. for (var index = 0; index < this.lights.length; index++) {
  134910. if (this.lights[index].uniqueId === uniqueId) {
  134911. return this.lights[index];
  134912. }
  134913. }
  134914. return null;
  134915. };
  134916. /**
  134917. * Gets a particle system by id
  134918. * @param id defines the particle system id
  134919. * @return the corresponding system or null if none found
  134920. */
  134921. Scene.prototype.getParticleSystemByID = function (id) {
  134922. for (var index = 0; index < this.particleSystems.length; index++) {
  134923. if (this.particleSystems[index].id === id) {
  134924. return this.particleSystems[index];
  134925. }
  134926. }
  134927. return null;
  134928. };
  134929. /**
  134930. * Gets a geometry using its ID
  134931. * @param id defines the geometry's id
  134932. * @return the geometry or null if none found.
  134933. */
  134934. Scene.prototype.getGeometryByID = function (id) {
  134935. for (var index = 0; index < this.geometries.length; index++) {
  134936. if (this.geometries[index].id === id) {
  134937. return this.geometries[index];
  134938. }
  134939. }
  134940. return null;
  134941. };
  134942. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  134943. if (this.geometriesByUniqueId) {
  134944. var index_1 = this.geometriesByUniqueId[uniqueId];
  134945. if (index_1 !== undefined) {
  134946. return this.geometries[index_1];
  134947. }
  134948. }
  134949. else {
  134950. for (var index = 0; index < this.geometries.length; index++) {
  134951. if (this.geometries[index].uniqueId === uniqueId) {
  134952. return this.geometries[index];
  134953. }
  134954. }
  134955. }
  134956. return null;
  134957. };
  134958. /**
  134959. * Add a new geometry to this scene
  134960. * @param geometry defines the geometry to be added to the scene.
  134961. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  134962. * @return a boolean defining if the geometry was added or not
  134963. */
  134964. Scene.prototype.pushGeometry = function (geometry, force) {
  134965. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  134966. return false;
  134967. }
  134968. this.addGeometry(geometry);
  134969. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  134970. return true;
  134971. };
  134972. /**
  134973. * Removes an existing geometry
  134974. * @param geometry defines the geometry to be removed from the scene
  134975. * @return a boolean defining if the geometry was removed or not
  134976. */
  134977. Scene.prototype.removeGeometry = function (geometry) {
  134978. var index;
  134979. if (this.geometriesByUniqueId) {
  134980. index = this.geometriesByUniqueId[geometry.uniqueId];
  134981. if (index === undefined) {
  134982. return false;
  134983. }
  134984. }
  134985. else {
  134986. index = this.geometries.indexOf(geometry);
  134987. if (index < 0) {
  134988. return false;
  134989. }
  134990. }
  134991. if (index !== this.geometries.length - 1) {
  134992. var lastGeometry = this.geometries[this.geometries.length - 1];
  134993. this.geometries[index] = lastGeometry;
  134994. if (this.geometriesByUniqueId) {
  134995. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  134996. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  134997. }
  134998. }
  134999. this.geometries.pop();
  135000. this.onGeometryRemovedObservable.notifyObservers(geometry);
  135001. return true;
  135002. };
  135003. /**
  135004. * Gets the list of geometries attached to the scene
  135005. * @returns an array of Geometry
  135006. */
  135007. Scene.prototype.getGeometries = function () {
  135008. return this.geometries;
  135009. };
  135010. /**
  135011. * Gets the first added mesh found of a given ID
  135012. * @param id defines the id to search for
  135013. * @return the mesh found or null if not found at all
  135014. */
  135015. Scene.prototype.getMeshByID = function (id) {
  135016. for (var index = 0; index < this.meshes.length; index++) {
  135017. if (this.meshes[index].id === id) {
  135018. return this.meshes[index];
  135019. }
  135020. }
  135021. return null;
  135022. };
  135023. /**
  135024. * Gets a list of meshes using their id
  135025. * @param id defines the id to search for
  135026. * @returns a list of meshes
  135027. */
  135028. Scene.prototype.getMeshesByID = function (id) {
  135029. return this.meshes.filter(function (m) {
  135030. return m.id === id;
  135031. });
  135032. };
  135033. /**
  135034. * Gets the first added transform node found of a given ID
  135035. * @param id defines the id to search for
  135036. * @return the found transform node or null if not found at all.
  135037. */
  135038. Scene.prototype.getTransformNodeByID = function (id) {
  135039. for (var index = 0; index < this.transformNodes.length; index++) {
  135040. if (this.transformNodes[index].id === id) {
  135041. return this.transformNodes[index];
  135042. }
  135043. }
  135044. return null;
  135045. };
  135046. /**
  135047. * Gets a transform node with its auto-generated unique id
  135048. * @param uniqueId efines the unique id to search for
  135049. * @return the found transform node or null if not found at all.
  135050. */
  135051. Scene.prototype.getTransformNodeByUniqueID = function (uniqueId) {
  135052. for (var index = 0; index < this.transformNodes.length; index++) {
  135053. if (this.transformNodes[index].uniqueId === uniqueId) {
  135054. return this.transformNodes[index];
  135055. }
  135056. }
  135057. return null;
  135058. };
  135059. /**
  135060. * Gets a list of transform nodes using their id
  135061. * @param id defines the id to search for
  135062. * @returns a list of transform nodes
  135063. */
  135064. Scene.prototype.getTransformNodesByID = function (id) {
  135065. return this.transformNodes.filter(function (m) {
  135066. return m.id === id;
  135067. });
  135068. };
  135069. /**
  135070. * Gets a mesh with its auto-generated unique id
  135071. * @param uniqueId defines the unique id to search for
  135072. * @return the found mesh or null if not found at all.
  135073. */
  135074. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  135075. for (var index = 0; index < this.meshes.length; index++) {
  135076. if (this.meshes[index].uniqueId === uniqueId) {
  135077. return this.meshes[index];
  135078. }
  135079. }
  135080. return null;
  135081. };
  135082. /**
  135083. * Gets a the last added mesh using a given id
  135084. * @param id defines the id to search for
  135085. * @return the found mesh or null if not found at all.
  135086. */
  135087. Scene.prototype.getLastMeshByID = function (id) {
  135088. for (var index = this.meshes.length - 1; index >= 0; index--) {
  135089. if (this.meshes[index].id === id) {
  135090. return this.meshes[index];
  135091. }
  135092. }
  135093. return null;
  135094. };
  135095. /**
  135096. * Gets a the last added node (Mesh, Camera, Light) using a given id
  135097. * @param id defines the id to search for
  135098. * @return the found node or null if not found at all
  135099. */
  135100. Scene.prototype.getLastEntryByID = function (id) {
  135101. var index;
  135102. for (index = this.meshes.length - 1; index >= 0; index--) {
  135103. if (this.meshes[index].id === id) {
  135104. return this.meshes[index];
  135105. }
  135106. }
  135107. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  135108. if (this.transformNodes[index].id === id) {
  135109. return this.transformNodes[index];
  135110. }
  135111. }
  135112. for (index = this.cameras.length - 1; index >= 0; index--) {
  135113. if (this.cameras[index].id === id) {
  135114. return this.cameras[index];
  135115. }
  135116. }
  135117. for (index = this.lights.length - 1; index >= 0; index--) {
  135118. if (this.lights[index].id === id) {
  135119. return this.lights[index];
  135120. }
  135121. }
  135122. return null;
  135123. };
  135124. /**
  135125. * Gets a node (Mesh, Camera, Light) using a given id
  135126. * @param id defines the id to search for
  135127. * @return the found node or null if not found at all
  135128. */
  135129. Scene.prototype.getNodeByID = function (id) {
  135130. var mesh = this.getMeshByID(id);
  135131. if (mesh) {
  135132. return mesh;
  135133. }
  135134. var transformNode = this.getTransformNodeByID(id);
  135135. if (transformNode) {
  135136. return transformNode;
  135137. }
  135138. var light = this.getLightByID(id);
  135139. if (light) {
  135140. return light;
  135141. }
  135142. var camera = this.getCameraByID(id);
  135143. if (camera) {
  135144. return camera;
  135145. }
  135146. var bone = this.getBoneByID(id);
  135147. if (bone) {
  135148. return bone;
  135149. }
  135150. return null;
  135151. };
  135152. /**
  135153. * Gets a node (Mesh, Camera, Light) using a given name
  135154. * @param name defines the name to search for
  135155. * @return the found node or null if not found at all.
  135156. */
  135157. Scene.prototype.getNodeByName = function (name) {
  135158. var mesh = this.getMeshByName(name);
  135159. if (mesh) {
  135160. return mesh;
  135161. }
  135162. var transformNode = this.getTransformNodeByName(name);
  135163. if (transformNode) {
  135164. return transformNode;
  135165. }
  135166. var light = this.getLightByName(name);
  135167. if (light) {
  135168. return light;
  135169. }
  135170. var camera = this.getCameraByName(name);
  135171. if (camera) {
  135172. return camera;
  135173. }
  135174. var bone = this.getBoneByName(name);
  135175. if (bone) {
  135176. return bone;
  135177. }
  135178. return null;
  135179. };
  135180. /**
  135181. * Gets a mesh using a given name
  135182. * @param name defines the name to search for
  135183. * @return the found mesh or null if not found at all.
  135184. */
  135185. Scene.prototype.getMeshByName = function (name) {
  135186. for (var index = 0; index < this.meshes.length; index++) {
  135187. if (this.meshes[index].name === name) {
  135188. return this.meshes[index];
  135189. }
  135190. }
  135191. return null;
  135192. };
  135193. /**
  135194. * Gets a transform node using a given name
  135195. * @param name defines the name to search for
  135196. * @return the found transform node or null if not found at all.
  135197. */
  135198. Scene.prototype.getTransformNodeByName = function (name) {
  135199. for (var index = 0; index < this.transformNodes.length; index++) {
  135200. if (this.transformNodes[index].name === name) {
  135201. return this.transformNodes[index];
  135202. }
  135203. }
  135204. return null;
  135205. };
  135206. /**
  135207. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  135208. * @param id defines the id to search for
  135209. * @return the found skeleton or null if not found at all.
  135210. */
  135211. Scene.prototype.getLastSkeletonByID = function (id) {
  135212. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  135213. if (this.skeletons[index].id === id) {
  135214. return this.skeletons[index];
  135215. }
  135216. }
  135217. return null;
  135218. };
  135219. /**
  135220. * Gets a skeleton using a given auto generated unique id
  135221. * @param uniqueId defines the unique id to search for
  135222. * @return the found skeleton or null if not found at all.
  135223. */
  135224. Scene.prototype.getSkeletonByUniqueId = function (uniqueId) {
  135225. for (var index = 0; index < this.skeletons.length; index++) {
  135226. if (this.skeletons[index].uniqueId === uniqueId) {
  135227. return this.skeletons[index];
  135228. }
  135229. }
  135230. return null;
  135231. };
  135232. /**
  135233. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  135234. * @param id defines the id to search for
  135235. * @return the found skeleton or null if not found at all.
  135236. */
  135237. Scene.prototype.getSkeletonById = function (id) {
  135238. for (var index = 0; index < this.skeletons.length; index++) {
  135239. if (this.skeletons[index].id === id) {
  135240. return this.skeletons[index];
  135241. }
  135242. }
  135243. return null;
  135244. };
  135245. /**
  135246. * Gets a skeleton using a given name
  135247. * @param name defines the name to search for
  135248. * @return the found skeleton or null if not found at all.
  135249. */
  135250. Scene.prototype.getSkeletonByName = function (name) {
  135251. for (var index = 0; index < this.skeletons.length; index++) {
  135252. if (this.skeletons[index].name === name) {
  135253. return this.skeletons[index];
  135254. }
  135255. }
  135256. return null;
  135257. };
  135258. /**
  135259. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  135260. * @param id defines the id to search for
  135261. * @return the found morph target manager or null if not found at all.
  135262. */
  135263. Scene.prototype.getMorphTargetManagerById = function (id) {
  135264. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  135265. if (this.morphTargetManagers[index].uniqueId === id) {
  135266. return this.morphTargetManagers[index];
  135267. }
  135268. }
  135269. return null;
  135270. };
  135271. /**
  135272. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  135273. * @param id defines the id to search for
  135274. * @return the found morph target or null if not found at all.
  135275. */
  135276. Scene.prototype.getMorphTargetById = function (id) {
  135277. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  135278. var morphTargetManager = this.morphTargetManagers[managerIndex];
  135279. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  135280. var target = morphTargetManager.getTarget(index);
  135281. if (target.id === id) {
  135282. return target;
  135283. }
  135284. }
  135285. }
  135286. return null;
  135287. };
  135288. /**
  135289. * Gets a boolean indicating if the given mesh is active
  135290. * @param mesh defines the mesh to look for
  135291. * @returns true if the mesh is in the active list
  135292. */
  135293. Scene.prototype.isActiveMesh = function (mesh) {
  135294. return (this._activeMeshes.indexOf(mesh) !== -1);
  135295. };
  135296. Object.defineProperty(Scene.prototype, "uid", {
  135297. /**
  135298. * Return a unique id as a string which can serve as an identifier for the scene
  135299. */
  135300. get: function () {
  135301. if (!this._uid) {
  135302. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  135303. }
  135304. return this._uid;
  135305. },
  135306. enumerable: true,
  135307. configurable: true
  135308. });
  135309. /**
  135310. * Add an externaly attached data from its key.
  135311. * This method call will fail and return false, if such key already exists.
  135312. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  135313. * @param key the unique key that identifies the data
  135314. * @param data the data object to associate to the key for this Engine instance
  135315. * @return true if no such key were already present and the data was added successfully, false otherwise
  135316. */
  135317. Scene.prototype.addExternalData = function (key, data) {
  135318. if (!this._externalData) {
  135319. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  135320. }
  135321. return this._externalData.add(key, data);
  135322. };
  135323. /**
  135324. * Get an externaly attached data from its key
  135325. * @param key the unique key that identifies the data
  135326. * @return the associated data, if present (can be null), or undefined if not present
  135327. */
  135328. Scene.prototype.getExternalData = function (key) {
  135329. if (!this._externalData) {
  135330. return null;
  135331. }
  135332. return this._externalData.get(key);
  135333. };
  135334. /**
  135335. * Get an externaly attached data from its key, create it using a factory if it's not already present
  135336. * @param key the unique key that identifies the data
  135337. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  135338. * @return the associated data, can be null if the factory returned null.
  135339. */
  135340. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  135341. if (!this._externalData) {
  135342. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  135343. }
  135344. return this._externalData.getOrAddWithFactory(key, factory);
  135345. };
  135346. /**
  135347. * Remove an externaly attached data from the Engine instance
  135348. * @param key the unique key that identifies the data
  135349. * @return true if the data was successfully removed, false if it doesn't exist
  135350. */
  135351. Scene.prototype.removeExternalData = function (key) {
  135352. return this._externalData.remove(key);
  135353. };
  135354. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  135355. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  135356. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  135357. var step = _a[_i];
  135358. step.action(mesh, subMesh);
  135359. }
  135360. var material = subMesh.getMaterial();
  135361. if (material !== null && material !== undefined) {
  135362. // Render targets
  135363. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  135364. if (this._processedMaterials.indexOf(material) === -1) {
  135365. this._processedMaterials.push(material);
  135366. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  135367. }
  135368. }
  135369. // Dispatch
  135370. this._activeIndices.addCount(subMesh.indexCount, false);
  135371. this._renderingManager.dispatch(subMesh, mesh, material);
  135372. }
  135373. }
  135374. };
  135375. /**
  135376. * Clear the processed materials smart array preventing retention point in material dispose.
  135377. */
  135378. Scene.prototype.freeProcessedMaterials = function () {
  135379. this._processedMaterials.dispose();
  135380. };
  135381. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  135382. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  135383. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  135384. * when disposing several meshes in a row or a hierarchy of meshes.
  135385. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  135386. */
  135387. get: function () {
  135388. return this._preventFreeActiveMeshesAndRenderingGroups;
  135389. },
  135390. set: function (value) {
  135391. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  135392. return;
  135393. }
  135394. if (value) {
  135395. this.freeActiveMeshes();
  135396. this.freeRenderingGroups();
  135397. }
  135398. this._preventFreeActiveMeshesAndRenderingGroups = value;
  135399. },
  135400. enumerable: true,
  135401. configurable: true
  135402. });
  135403. /**
  135404. * Clear the active meshes smart array preventing retention point in mesh dispose.
  135405. */
  135406. Scene.prototype.freeActiveMeshes = function () {
  135407. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  135408. return;
  135409. }
  135410. this._activeMeshes.dispose();
  135411. if (this.activeCamera && this.activeCamera._activeMeshes) {
  135412. this.activeCamera._activeMeshes.dispose();
  135413. }
  135414. if (this.activeCameras) {
  135415. for (var i = 0; i < this.activeCameras.length; i++) {
  135416. var activeCamera = this.activeCameras[i];
  135417. if (activeCamera && activeCamera._activeMeshes) {
  135418. activeCamera._activeMeshes.dispose();
  135419. }
  135420. }
  135421. }
  135422. };
  135423. /**
  135424. * Clear the info related to rendering groups preventing retention points during dispose.
  135425. */
  135426. Scene.prototype.freeRenderingGroups = function () {
  135427. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  135428. return;
  135429. }
  135430. if (this._renderingManager) {
  135431. this._renderingManager.freeRenderingGroups();
  135432. }
  135433. if (this.textures) {
  135434. for (var i = 0; i < this.textures.length; i++) {
  135435. var texture = this.textures[i];
  135436. if (texture && texture.renderList) {
  135437. texture.freeRenderingGroups();
  135438. }
  135439. }
  135440. }
  135441. };
  135442. /** @hidden */
  135443. Scene.prototype._isInIntermediateRendering = function () {
  135444. return this._intermediateRendering;
  135445. };
  135446. /**
  135447. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  135448. * @returns the current scene
  135449. */
  135450. Scene.prototype.freezeActiveMeshes = function () {
  135451. if (!this.activeCamera) {
  135452. return this;
  135453. }
  135454. if (!this._frustumPlanes) {
  135455. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  135456. }
  135457. this._evaluateActiveMeshes();
  135458. this._activeMeshesFrozen = true;
  135459. return this;
  135460. };
  135461. /**
  135462. * Use this function to restart evaluating active meshes on every frame
  135463. * @returns the current scene
  135464. */
  135465. Scene.prototype.unfreezeActiveMeshes = function () {
  135466. this._activeMeshesFrozen = false;
  135467. return this;
  135468. };
  135469. Scene.prototype._evaluateActiveMeshes = function () {
  135470. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  135471. return;
  135472. }
  135473. if (!this.activeCamera) {
  135474. return;
  135475. }
  135476. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  135477. this.activeCamera._activeMeshes.reset();
  135478. this._activeMeshes.reset();
  135479. this._renderingManager.reset();
  135480. this._processedMaterials.reset();
  135481. this._activeParticleSystems.reset();
  135482. this._activeSkeletons.reset();
  135483. this._softwareSkinnedMeshes.reset();
  135484. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  135485. var step = _a[_i];
  135486. step.action();
  135487. }
  135488. // Determine mesh candidates
  135489. var meshes = this.getActiveMeshCandidates();
  135490. // Check each mesh
  135491. var len = meshes.length;
  135492. for (var i = 0; i < len; i++) {
  135493. var mesh = meshes.data[i];
  135494. if (mesh.isBlocked) {
  135495. continue;
  135496. }
  135497. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  135498. if (!mesh.isReady() || !mesh.isEnabled()) {
  135499. continue;
  135500. }
  135501. mesh.computeWorldMatrix();
  135502. // Intersections
  135503. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  135504. this._meshesForIntersections.pushNoDuplicate(mesh);
  135505. }
  135506. // Switch to current LOD
  135507. var meshLOD = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  135508. if (meshLOD === undefined || meshLOD === null) {
  135509. continue;
  135510. }
  135511. mesh._preActivate();
  135512. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  135513. this._activeMeshes.push(mesh);
  135514. this.activeCamera._activeMeshes.push(mesh);
  135515. mesh._activate(this._renderId);
  135516. if (meshLOD !== mesh) {
  135517. meshLOD._activate(this._renderId);
  135518. }
  135519. this._activeMesh(mesh, meshLOD);
  135520. }
  135521. }
  135522. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  135523. // Particle systems
  135524. if (this.particlesEnabled) {
  135525. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  135526. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  135527. var particleSystem = this.particleSystems[particleIndex];
  135528. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  135529. continue;
  135530. }
  135531. var emitter = particleSystem.emitter;
  135532. if (!emitter.position || emitter.isEnabled()) {
  135533. this._activeParticleSystems.push(particleSystem);
  135534. particleSystem.animate();
  135535. this._renderingManager.dispatchParticles(particleSystem);
  135536. }
  135537. }
  135538. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  135539. }
  135540. };
  135541. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  135542. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  135543. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  135544. mesh.skeleton.prepare();
  135545. }
  135546. if (!mesh.computeBonesUsingShaders) {
  135547. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  135548. }
  135549. }
  135550. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  135551. var step = _a[_i];
  135552. step.action(sourceMesh, mesh);
  135553. }
  135554. if (mesh !== undefined && mesh !== null
  135555. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  135556. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  135557. var len = subMeshes.length;
  135558. for (var i = 0; i < len; i++) {
  135559. var subMesh = subMeshes.data[i];
  135560. this._evaluateSubMesh(subMesh, mesh);
  135561. }
  135562. }
  135563. };
  135564. /**
  135565. * Update the transform matrix to update from the current active camera
  135566. * @param force defines a boolean used to force the update even if cache is up to date
  135567. */
  135568. Scene.prototype.updateTransformMatrix = function (force) {
  135569. if (!this.activeCamera) {
  135570. return;
  135571. }
  135572. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  135573. };
  135574. /**
  135575. * 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)
  135576. * @param alternateCamera defines the camera to use
  135577. */
  135578. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  135579. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  135580. };
  135581. Scene.prototype._renderForCamera = function (camera, rigParent) {
  135582. if (camera && camera._skipRendering) {
  135583. return;
  135584. }
  135585. var engine = this._engine;
  135586. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  135587. this._activeCamera = camera;
  135588. if (!this.activeCamera) {
  135589. throw new Error("Active camera not set");
  135590. }
  135591. // Viewport
  135592. engine.setViewport(this.activeCamera.viewport);
  135593. // Camera
  135594. this.resetCachedMaterial();
  135595. this._renderId++;
  135596. this.updateTransformMatrix();
  135597. if (camera._alternateCamera) {
  135598. this.updateAlternateTransformMatrix(camera._alternateCamera);
  135599. this._alternateRendering = true;
  135600. }
  135601. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  135602. // Meshes
  135603. this._evaluateActiveMeshes();
  135604. // Software skinning
  135605. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  135606. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  135607. mesh.applySkeleton(mesh.skeleton);
  135608. }
  135609. // Render targets
  135610. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  135611. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  135612. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  135613. }
  135614. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  135615. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  135616. }
  135617. // Collects render targets from external components.
  135618. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  135619. var step = _a[_i];
  135620. step.action(this._renderTargets);
  135621. }
  135622. if (this.renderTargetsEnabled) {
  135623. this._intermediateRendering = true;
  135624. if (this._renderTargets.length > 0) {
  135625. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  135626. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  135627. var renderTarget = this._renderTargets.data[renderIndex];
  135628. if (renderTarget._shouldRender()) {
  135629. this._renderId++;
  135630. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  135631. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  135632. }
  135633. }
  135634. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  135635. this._renderId++;
  135636. }
  135637. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  135638. var step = _c[_b];
  135639. step.action(this.activeCamera);
  135640. }
  135641. this._intermediateRendering = false;
  135642. if (this.activeCamera.outputRenderTarget) {
  135643. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  135644. if (internalTexture) {
  135645. engine.bindFramebuffer(internalTexture);
  135646. }
  135647. else {
  135648. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  135649. }
  135650. }
  135651. else {
  135652. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  135653. }
  135654. }
  135655. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  135656. // Prepare Frame
  135657. if (this.postProcessManager) {
  135658. this.postProcessManager._prepareFrame();
  135659. }
  135660. // Before Camera Draw
  135661. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  135662. var step = _e[_d];
  135663. step.action(this.activeCamera);
  135664. }
  135665. // Render
  135666. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  135667. this._renderingManager.render(null, null, true, true);
  135668. this.onAfterDrawPhaseObservable.notifyObservers(this);
  135669. // After Camera Draw
  135670. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  135671. var step = _g[_f];
  135672. step.action(this.activeCamera);
  135673. }
  135674. // Finalize frame
  135675. if (this.postProcessManager) {
  135676. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  135677. }
  135678. // Reset some special arrays
  135679. this._renderTargets.reset();
  135680. this._alternateRendering = false;
  135681. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  135682. };
  135683. Scene.prototype._processSubCameras = function (camera) {
  135684. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  135685. this._renderForCamera(camera);
  135686. return;
  135687. }
  135688. // rig cameras
  135689. for (var index = 0; index < camera._rigCameras.length; index++) {
  135690. this._renderForCamera(camera._rigCameras[index], camera);
  135691. }
  135692. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  135693. this._activeCamera = camera;
  135694. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  135695. };
  135696. Scene.prototype._checkIntersections = function () {
  135697. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  135698. var sourceMesh = this._meshesForIntersections.data[index];
  135699. if (!sourceMesh.actionManager) {
  135700. continue;
  135701. }
  135702. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  135703. var action = sourceMesh.actionManager.actions[actionIndex];
  135704. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  135705. var parameters = action.getTriggerParameter();
  135706. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  135707. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  135708. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  135709. if (areIntersecting && currentIntersectionInProgress === -1) {
  135710. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  135711. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  135712. sourceMesh._intersectionsInProgress.push(otherMesh);
  135713. }
  135714. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  135715. sourceMesh._intersectionsInProgress.push(otherMesh);
  135716. }
  135717. }
  135718. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  135719. //They intersected, and now they don't.
  135720. //is this trigger an exit trigger? execute an event.
  135721. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  135722. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  135723. }
  135724. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  135725. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  135726. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  135727. return otherMesh === parameterMesh;
  135728. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  135729. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  135730. }
  135731. }
  135732. }
  135733. }
  135734. }
  135735. };
  135736. /** @hidden */
  135737. Scene.prototype._advancePhysicsEngineStep = function (step) {
  135738. // Do nothing. Code will be replaced if physics engine component is referenced
  135739. };
  135740. /** @hidden */
  135741. Scene.prototype._animate = function () {
  135742. // Nothing to do as long as Animatable have not been imported.
  135743. };
  135744. /**
  135745. * Render the scene
  135746. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  135747. */
  135748. Scene.prototype.render = function (updateCameras) {
  135749. if (updateCameras === void 0) { updateCameras = true; }
  135750. if (this.isDisposed) {
  135751. return;
  135752. }
  135753. this._frameId++;
  135754. // Register components that have been associated lately to the scene.
  135755. this._registerTransientComponents();
  135756. this._activeParticles.fetchNewFrame();
  135757. this._totalVertices.fetchNewFrame();
  135758. this._activeIndices.fetchNewFrame();
  135759. this._activeBones.fetchNewFrame();
  135760. this._meshesForIntersections.reset();
  135761. this.resetCachedMaterial();
  135762. this.onBeforeAnimationsObservable.notifyObservers(this);
  135763. // Actions
  135764. if (this.actionManager) {
  135765. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  135766. }
  135767. if (this._engine.isDeterministicLockStep()) {
  135768. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  135769. var defaultFPS = (60.0 / 1000.0);
  135770. var defaultFrameTime = this.getDeterministicFrameTime();
  135771. var stepsTaken = 0;
  135772. var maxSubSteps = this._engine.getLockstepMaxSteps();
  135773. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  135774. internalSteps = Math.min(internalSteps, maxSubSteps);
  135775. do {
  135776. this.onBeforeStepObservable.notifyObservers(this);
  135777. // Animations
  135778. this._animationRatio = defaultFrameTime * defaultFPS;
  135779. this._animate();
  135780. this.onAfterAnimationsObservable.notifyObservers(this);
  135781. // Physics
  135782. this._advancePhysicsEngineStep(defaultFrameTime);
  135783. this.onAfterStepObservable.notifyObservers(this);
  135784. this._currentStepId++;
  135785. stepsTaken++;
  135786. deltaTime -= defaultFrameTime;
  135787. } while (deltaTime > 0 && stepsTaken < internalSteps);
  135788. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  135789. }
  135790. else {
  135791. // Animations
  135792. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  135793. this._animationRatio = deltaTime * (60.0 / 1000.0);
  135794. this._animate();
  135795. this.onAfterAnimationsObservable.notifyObservers(this);
  135796. // Physics
  135797. this._advancePhysicsEngineStep(deltaTime);
  135798. }
  135799. // Before camera update steps
  135800. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  135801. var step = _a[_i];
  135802. step.action();
  135803. }
  135804. // Update Cameras
  135805. if (updateCameras) {
  135806. if (this.activeCameras.length > 0) {
  135807. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  135808. var camera = this.activeCameras[cameraIndex];
  135809. camera.update();
  135810. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  135811. // rig cameras
  135812. for (var index = 0; index < camera._rigCameras.length; index++) {
  135813. camera._rigCameras[index].update();
  135814. }
  135815. }
  135816. }
  135817. }
  135818. else if (this.activeCamera) {
  135819. this.activeCamera.update();
  135820. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  135821. // rig cameras
  135822. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  135823. this.activeCamera._rigCameras[index].update();
  135824. }
  135825. }
  135826. }
  135827. }
  135828. // Before render
  135829. this.onBeforeRenderObservable.notifyObservers(this);
  135830. // Customs render targets
  135831. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  135832. var engine = this.getEngine();
  135833. var currentActiveCamera = this.activeCamera;
  135834. if (this.renderTargetsEnabled) {
  135835. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  135836. this._intermediateRendering = true;
  135837. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  135838. var renderTarget = this.customRenderTargets[customIndex];
  135839. if (renderTarget._shouldRender()) {
  135840. this._renderId++;
  135841. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  135842. if (!this.activeCamera) {
  135843. throw new Error("Active camera not set");
  135844. }
  135845. // Viewport
  135846. engine.setViewport(this.activeCamera.viewport);
  135847. // Camera
  135848. this.updateTransformMatrix();
  135849. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  135850. }
  135851. }
  135852. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  135853. this._intermediateRendering = false;
  135854. this._renderId++;
  135855. }
  135856. // Restore back buffer
  135857. if (this.customRenderTargets.length > 0) {
  135858. engine.restoreDefaultFramebuffer();
  135859. }
  135860. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  135861. this.activeCamera = currentActiveCamera;
  135862. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  135863. var step = _c[_b];
  135864. step.action();
  135865. }
  135866. // Clear
  135867. if (this.autoClearDepthAndStencil || this.autoClear) {
  135868. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  135869. }
  135870. // Collects render targets from external components.
  135871. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  135872. var step = _e[_d];
  135873. step.action(this._renderTargets);
  135874. }
  135875. // Multi-cameras?
  135876. if (this.activeCameras.length > 0) {
  135877. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  135878. if (cameraIndex > 0) {
  135879. this._engine.clear(null, false, true, true);
  135880. }
  135881. this._processSubCameras(this.activeCameras[cameraIndex]);
  135882. }
  135883. }
  135884. else {
  135885. if (!this.activeCamera) {
  135886. throw new Error("No camera defined");
  135887. }
  135888. this._processSubCameras(this.activeCamera);
  135889. }
  135890. // Intersection checks
  135891. this._checkIntersections();
  135892. // Executes the after render stage actions.
  135893. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  135894. var step = _g[_f];
  135895. step.action();
  135896. }
  135897. // After render
  135898. if (this.afterRender) {
  135899. this.afterRender();
  135900. }
  135901. this.onAfterRenderObservable.notifyObservers(this);
  135902. // Cleaning
  135903. if (this._toBeDisposed.length) {
  135904. for (var index = 0; index < this._toBeDisposed.length; index++) {
  135905. var data = this._toBeDisposed[index];
  135906. if (data) {
  135907. data.dispose();
  135908. }
  135909. }
  135910. this._toBeDisposed = [];
  135911. }
  135912. if (this.dumpNextRenderTargets) {
  135913. this.dumpNextRenderTargets = false;
  135914. }
  135915. this._activeBones.addCount(0, true);
  135916. this._activeIndices.addCount(0, true);
  135917. this._activeParticles.addCount(0, true);
  135918. };
  135919. /**
  135920. * Freeze all materials
  135921. * A frozen material will not be updatable but should be faster to render
  135922. */
  135923. Scene.prototype.freezeMaterials = function () {
  135924. for (var i = 0; i < this.materials.length; i++) {
  135925. this.materials[i].freeze();
  135926. }
  135927. };
  135928. /**
  135929. * Unfreeze all materials
  135930. * A frozen material will not be updatable but should be faster to render
  135931. */
  135932. Scene.prototype.unfreezeMaterials = function () {
  135933. for (var i = 0; i < this.materials.length; i++) {
  135934. this.materials[i].unfreeze();
  135935. }
  135936. };
  135937. /**
  135938. * Releases all held ressources
  135939. */
  135940. Scene.prototype.dispose = function () {
  135941. this.beforeRender = null;
  135942. this.afterRender = null;
  135943. this.skeletons = [];
  135944. this.morphTargetManagers = [];
  135945. this._transientComponents = [];
  135946. this._isReadyForMeshStage.clear();
  135947. this._beforeEvaluateActiveMeshStage.clear();
  135948. this._evaluateSubMeshStage.clear();
  135949. this._activeMeshStage.clear();
  135950. this._cameraDrawRenderTargetStage.clear();
  135951. this._beforeCameraDrawStage.clear();
  135952. this._beforeRenderTargetDrawStage.clear();
  135953. this._beforeRenderingGroupDrawStage.clear();
  135954. this._beforeRenderingMeshStage.clear();
  135955. this._afterRenderingMeshStage.clear();
  135956. this._afterRenderingGroupDrawStage.clear();
  135957. this._afterCameraDrawStage.clear();
  135958. this._afterRenderTargetDrawStage.clear();
  135959. this._afterRenderStage.clear();
  135960. this._beforeCameraUpdateStage.clear();
  135961. this._beforeClearStage.clear();
  135962. this._gatherRenderTargetsStage.clear();
  135963. this._gatherActiveCameraRenderTargetsStage.clear();
  135964. this._pointerMoveStage.clear();
  135965. this._pointerDownStage.clear();
  135966. this._pointerUpStage.clear();
  135967. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  135968. var component = _a[_i];
  135969. component.dispose();
  135970. }
  135971. this.importedMeshesFiles = new Array();
  135972. this.stopAllAnimations();
  135973. this.resetCachedMaterial();
  135974. // Smart arrays
  135975. if (this.activeCamera) {
  135976. this.activeCamera._activeMeshes.dispose();
  135977. this.activeCamera = null;
  135978. }
  135979. this._activeMeshes.dispose();
  135980. this._renderingManager.dispose();
  135981. this._processedMaterials.dispose();
  135982. this._activeParticleSystems.dispose();
  135983. this._activeSkeletons.dispose();
  135984. this._softwareSkinnedMeshes.dispose();
  135985. this._renderTargets.dispose();
  135986. this._registeredForLateAnimationBindings.dispose();
  135987. this._meshesForIntersections.dispose();
  135988. this._toBeDisposed = [];
  135989. // Abort active requests
  135990. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  135991. var request = _c[_b];
  135992. request.abort();
  135993. }
  135994. // Events
  135995. this.onDisposeObservable.notifyObservers(this);
  135996. this.onDisposeObservable.clear();
  135997. this.onBeforeRenderObservable.clear();
  135998. this.onAfterRenderObservable.clear();
  135999. this.onBeforeRenderTargetsRenderObservable.clear();
  136000. this.onAfterRenderTargetsRenderObservable.clear();
  136001. this.onAfterStepObservable.clear();
  136002. this.onBeforeStepObservable.clear();
  136003. this.onBeforeActiveMeshesEvaluationObservable.clear();
  136004. this.onAfterActiveMeshesEvaluationObservable.clear();
  136005. this.onBeforeParticlesRenderingObservable.clear();
  136006. this.onAfterParticlesRenderingObservable.clear();
  136007. this.onBeforeDrawPhaseObservable.clear();
  136008. this.onAfterDrawPhaseObservable.clear();
  136009. this.onBeforeAnimationsObservable.clear();
  136010. this.onAfterAnimationsObservable.clear();
  136011. this.onDataLoadedObservable.clear();
  136012. this.onBeforeRenderingGroupObservable.clear();
  136013. this.onAfterRenderingGroupObservable.clear();
  136014. this.onMeshImportedObservable.clear();
  136015. this.onBeforeCameraRenderObservable.clear();
  136016. this.onAfterCameraRenderObservable.clear();
  136017. this.onReadyObservable.clear();
  136018. this.onNewCameraAddedObservable.clear();
  136019. this.onCameraRemovedObservable.clear();
  136020. this.onNewLightAddedObservable.clear();
  136021. this.onLightRemovedObservable.clear();
  136022. this.onNewGeometryAddedObservable.clear();
  136023. this.onGeometryRemovedObservable.clear();
  136024. this.onNewTransformNodeAddedObservable.clear();
  136025. this.onTransformNodeRemovedObservable.clear();
  136026. this.onNewMeshAddedObservable.clear();
  136027. this.onMeshRemovedObservable.clear();
  136028. this.onNewSkeletonAddedObservable.clear();
  136029. this.onSkeletonRemovedObservable.clear();
  136030. this.onNewMaterialAddedObservable.clear();
  136031. this.onMaterialRemovedObservable.clear();
  136032. this.onNewTextureAddedObservable.clear();
  136033. this.onTextureRemovedObservable.clear();
  136034. this.onPrePointerObservable.clear();
  136035. this.onPointerObservable.clear();
  136036. this.onPreKeyboardObservable.clear();
  136037. this.onKeyboardObservable.clear();
  136038. this.onActiveCameraChanged.clear();
  136039. this.detachControl();
  136040. // Detach cameras
  136041. var canvas = this._engine.getRenderingCanvas();
  136042. if (canvas) {
  136043. var index;
  136044. for (index = 0; index < this.cameras.length; index++) {
  136045. this.cameras[index].detachControl(canvas);
  136046. }
  136047. }
  136048. // Release animation groups
  136049. while (this.animationGroups.length) {
  136050. this.animationGroups[0].dispose();
  136051. }
  136052. // Release lights
  136053. while (this.lights.length) {
  136054. this.lights[0].dispose();
  136055. }
  136056. // Release meshes
  136057. while (this.meshes.length) {
  136058. this.meshes[0].dispose(true);
  136059. }
  136060. while (this.transformNodes.length) {
  136061. this.transformNodes[0].dispose(true);
  136062. }
  136063. // Release cameras
  136064. while (this.cameras.length) {
  136065. this.cameras[0].dispose();
  136066. }
  136067. // Release materials
  136068. if (this.defaultMaterial) {
  136069. this.defaultMaterial.dispose();
  136070. }
  136071. while (this.multiMaterials.length) {
  136072. this.multiMaterials[0].dispose();
  136073. }
  136074. while (this.materials.length) {
  136075. this.materials[0].dispose();
  136076. }
  136077. // Release particles
  136078. while (this.particleSystems.length) {
  136079. this.particleSystems[0].dispose();
  136080. }
  136081. // Release postProcesses
  136082. while (this.postProcesses.length) {
  136083. this.postProcesses[0].dispose();
  136084. }
  136085. // Release textures
  136086. while (this.textures.length) {
  136087. this.textures[0].dispose();
  136088. }
  136089. // Release UBO
  136090. this._sceneUbo.dispose();
  136091. if (this._alternateSceneUbo) {
  136092. this._alternateSceneUbo.dispose();
  136093. }
  136094. // Post-processes
  136095. this.postProcessManager.dispose();
  136096. // Remove from engine
  136097. index = this._engine.scenes.indexOf(this);
  136098. if (index > -1) {
  136099. this._engine.scenes.splice(index, 1);
  136100. }
  136101. this._engine.wipeCaches(true);
  136102. this._isDisposed = true;
  136103. };
  136104. Object.defineProperty(Scene.prototype, "isDisposed", {
  136105. /**
  136106. * Gets if the scene is already disposed
  136107. */
  136108. get: function () {
  136109. return this._isDisposed;
  136110. },
  136111. enumerable: true,
  136112. configurable: true
  136113. });
  136114. /**
  136115. * Call this function to reduce memory footprint of the scene.
  136116. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  136117. */
  136118. Scene.prototype.clearCachedVertexData = function () {
  136119. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  136120. var mesh = this.meshes[meshIndex];
  136121. var geometry = mesh.geometry;
  136122. if (geometry) {
  136123. geometry._indices = [];
  136124. for (var vbName in geometry._vertexBuffers) {
  136125. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  136126. continue;
  136127. }
  136128. geometry._vertexBuffers[vbName]._buffer._data = null;
  136129. }
  136130. }
  136131. }
  136132. };
  136133. /**
  136134. * This function will remove the local cached buffer data from texture.
  136135. * It will save memory but will prevent the texture from being rebuilt
  136136. */
  136137. Scene.prototype.cleanCachedTextureBuffer = function () {
  136138. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  136139. var baseTexture = _a[_i];
  136140. var buffer = baseTexture._buffer;
  136141. if (buffer) {
  136142. baseTexture._buffer = null;
  136143. }
  136144. }
  136145. };
  136146. /**
  136147. * Get the world extend vectors with an optional filter
  136148. *
  136149. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  136150. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  136151. */
  136152. Scene.prototype.getWorldExtends = function (filterPredicate) {
  136153. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  136154. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  136155. filterPredicate = filterPredicate || (function () { return true; });
  136156. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  136157. mesh.computeWorldMatrix(true);
  136158. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  136159. return;
  136160. }
  136161. var boundingInfo = mesh.getBoundingInfo();
  136162. var minBox = boundingInfo.boundingBox.minimumWorld;
  136163. var maxBox = boundingInfo.boundingBox.maximumWorld;
  136164. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  136165. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  136166. });
  136167. return {
  136168. min: min,
  136169. max: max
  136170. };
  136171. };
  136172. // Picking
  136173. /**
  136174. * Creates a ray that can be used to pick in the scene
  136175. * @param x defines the x coordinate of the origin (on-screen)
  136176. * @param y defines the y coordinate of the origin (on-screen)
  136177. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  136178. * @param camera defines the camera to use for the picking
  136179. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  136180. * @returns a Ray
  136181. */
  136182. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  136183. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  136184. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136185. };
  136186. /**
  136187. * Creates a ray that can be used to pick in the scene
  136188. * @param x defines the x coordinate of the origin (on-screen)
  136189. * @param y defines the y coordinate of the origin (on-screen)
  136190. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  136191. * @param result defines the ray where to store the picking ray
  136192. * @param camera defines the camera to use for the picking
  136193. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  136194. * @returns the current scene
  136195. */
  136196. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  136197. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  136198. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136199. };
  136200. /**
  136201. * Creates a ray that can be used to pick in the scene
  136202. * @param x defines the x coordinate of the origin (on-screen)
  136203. * @param y defines the y coordinate of the origin (on-screen)
  136204. * @param camera defines the camera to use for the picking
  136205. * @returns a Ray
  136206. */
  136207. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  136208. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136209. };
  136210. /**
  136211. * Creates a ray that can be used to pick in the scene
  136212. * @param x defines the x coordinate of the origin (on-screen)
  136213. * @param y defines the y coordinate of the origin (on-screen)
  136214. * @param result defines the ray where to store the picking ray
  136215. * @param camera defines the camera to use for the picking
  136216. * @returns the current scene
  136217. */
  136218. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  136219. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136220. };
  136221. /** Launch a ray to try to pick a mesh in the scene
  136222. * @param x position on screen
  136223. * @param y position on screen
  136224. * @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
  136225. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  136226. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  136227. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  136228. * @returns a PickingInfo
  136229. */
  136230. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  136231. // Dummy info if picking as not been imported
  136232. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  136233. pi._pickingUnavailable = true;
  136234. return pi;
  136235. };
  136236. /** Use the given ray to pick a mesh in the scene
  136237. * @param ray The ray to use to pick meshes
  136238. * @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
  136239. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  136240. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  136241. * @returns a PickingInfo
  136242. */
  136243. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  136244. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136245. };
  136246. /**
  136247. * Launch a ray to try to pick a mesh in the scene
  136248. * @param x X position on screen
  136249. * @param y Y position on screen
  136250. * @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
  136251. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  136252. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  136253. * @returns an array of PickingInfo
  136254. */
  136255. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  136256. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136257. };
  136258. /**
  136259. * Launch a ray to try to pick a mesh in the scene
  136260. * @param ray Ray to use
  136261. * @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
  136262. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  136263. * @returns an array of PickingInfo
  136264. */
  136265. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  136266. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  136267. };
  136268. /**
  136269. * Force the value of meshUnderPointer
  136270. * @param mesh defines the mesh to use
  136271. */
  136272. Scene.prototype.setPointerOverMesh = function (mesh) {
  136273. if (this._pointerOverMesh === mesh) {
  136274. return;
  136275. }
  136276. var actionManager;
  136277. if (this._pointerOverMesh) {
  136278. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger);
  136279. if (actionManager) {
  136280. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  136281. }
  136282. }
  136283. this._pointerOverMesh = mesh;
  136284. if (this._pointerOverMesh) {
  136285. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger);
  136286. if (actionManager) {
  136287. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  136288. }
  136289. }
  136290. };
  136291. /**
  136292. * Gets the mesh under the pointer
  136293. * @returns a Mesh or null if no mesh is under the pointer
  136294. */
  136295. Scene.prototype.getPointerOverMesh = function () {
  136296. return this._pointerOverMesh;
  136297. };
  136298. // Misc.
  136299. /** @hidden */
  136300. Scene.prototype._rebuildGeometries = function () {
  136301. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  136302. var geometry = _a[_i];
  136303. geometry._rebuild();
  136304. }
  136305. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  136306. var mesh = _c[_b];
  136307. mesh._rebuild();
  136308. }
  136309. if (this.postProcessManager) {
  136310. this.postProcessManager._rebuild();
  136311. }
  136312. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  136313. var component = _e[_d];
  136314. component.rebuild();
  136315. }
  136316. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  136317. var system = _g[_f];
  136318. system.rebuild();
  136319. }
  136320. };
  136321. /** @hidden */
  136322. Scene.prototype._rebuildTextures = function () {
  136323. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  136324. var texture = _a[_i];
  136325. texture._rebuild();
  136326. }
  136327. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  136328. };
  136329. // Tags
  136330. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  136331. if (tagsQuery === undefined) {
  136332. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  136333. return list;
  136334. }
  136335. var listByTags = [];
  136336. forEach = forEach || (function (item) { return; });
  136337. for (var i in list) {
  136338. var item = list[i];
  136339. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  136340. listByTags.push(item);
  136341. forEach(item);
  136342. }
  136343. }
  136344. return listByTags;
  136345. };
  136346. /**
  136347. * Get a list of meshes by tags
  136348. * @param tagsQuery defines the tags query to use
  136349. * @param forEach defines a predicate used to filter results
  136350. * @returns an array of Mesh
  136351. */
  136352. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  136353. return this._getByTags(this.meshes, tagsQuery, forEach);
  136354. };
  136355. /**
  136356. * Get a list of cameras by tags
  136357. * @param tagsQuery defines the tags query to use
  136358. * @param forEach defines a predicate used to filter results
  136359. * @returns an array of Camera
  136360. */
  136361. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  136362. return this._getByTags(this.cameras, tagsQuery, forEach);
  136363. };
  136364. /**
  136365. * Get a list of lights by tags
  136366. * @param tagsQuery defines the tags query to use
  136367. * @param forEach defines a predicate used to filter results
  136368. * @returns an array of Light
  136369. */
  136370. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  136371. return this._getByTags(this.lights, tagsQuery, forEach);
  136372. };
  136373. /**
  136374. * Get a list of materials by tags
  136375. * @param tagsQuery defines the tags query to use
  136376. * @param forEach defines a predicate used to filter results
  136377. * @returns an array of Material
  136378. */
  136379. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  136380. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  136381. };
  136382. /**
  136383. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  136384. * This allowed control for front to back rendering or reversly depending of the special needs.
  136385. *
  136386. * @param renderingGroupId The rendering group id corresponding to its index
  136387. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  136388. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  136389. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  136390. */
  136391. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  136392. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  136393. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  136394. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  136395. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  136396. };
  136397. /**
  136398. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  136399. *
  136400. * @param renderingGroupId The rendering group id corresponding to its index
  136401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  136402. * @param depth Automatically clears depth between groups if true and autoClear is true.
  136403. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  136404. */
  136405. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  136406. if (depth === void 0) { depth = true; }
  136407. if (stencil === void 0) { stencil = true; }
  136408. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  136409. };
  136410. /**
  136411. * Gets the current auto clear configuration for one rendering group of the rendering
  136412. * manager.
  136413. * @param index the rendering group index to get the information for
  136414. * @returns The auto clear setup for the requested rendering group
  136415. */
  136416. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  136417. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  136418. };
  136419. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  136420. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  136421. get: function () {
  136422. return this._blockMaterialDirtyMechanism;
  136423. },
  136424. set: function (value) {
  136425. if (this._blockMaterialDirtyMechanism === value) {
  136426. return;
  136427. }
  136428. this._blockMaterialDirtyMechanism = value;
  136429. if (!value) { // Do a complete update
  136430. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  136431. }
  136432. },
  136433. enumerable: true,
  136434. configurable: true
  136435. });
  136436. /**
  136437. * Will flag all materials as dirty to trigger new shader compilation
  136438. * @param flag defines the flag used to specify which material part must be marked as dirty
  136439. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  136440. */
  136441. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  136442. if (this._blockMaterialDirtyMechanism) {
  136443. return;
  136444. }
  136445. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  136446. var material = _a[_i];
  136447. if (predicate && !predicate(material)) {
  136448. continue;
  136449. }
  136450. material.markAsDirty(flag);
  136451. }
  136452. };
  136453. /** @hidden */
  136454. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  136455. var _this = this;
  136456. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  136457. this._activeRequests.push(request);
  136458. request.onCompleteObservable.add(function (request) {
  136459. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  136460. });
  136461. return request;
  136462. };
  136463. /** @hidden */
  136464. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  136465. var _this = this;
  136466. return new Promise(function (resolve, reject) {
  136467. _this._loadFile(url, function (data) {
  136468. resolve(data);
  136469. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  136470. reject(exception);
  136471. });
  136472. });
  136473. };
  136474. // Statics
  136475. Scene._uniqueIdCounter = 0;
  136476. /** The fog is deactivated */
  136477. Scene.FOGMODE_NONE = 0;
  136478. /** The fog density is following an exponential function */
  136479. Scene.FOGMODE_EXP = 1;
  136480. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  136481. Scene.FOGMODE_EXP2 = 2;
  136482. /** The fog density is following a linear function. */
  136483. Scene.FOGMODE_LINEAR = 3;
  136484. /**
  136485. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  136486. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136487. */
  136488. Scene.MinDeltaTime = 1.0;
  136489. /**
  136490. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  136491. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136492. */
  136493. Scene.MaxDeltaTime = 1000.0;
  136494. /** The distance in pixel that you have to move to prevent some events */
  136495. Scene.DragMovementThreshold = 10; // in pixels
  136496. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  136497. Scene.LongPressDelay = 500; // in milliseconds
  136498. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  136499. Scene.DoubleClickDelay = 300; // in milliseconds
  136500. /** If you need to check double click without raising a single click at first click, enable this flag */
  136501. Scene.ExclusiveDoubleClickMode = false;
  136502. return Scene;
  136503. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  136504. /***/ }),
  136505. /***/ "./sceneComponent.ts":
  136506. /*!***************************!*\
  136507. !*** ./sceneComponent.ts ***!
  136508. \***************************/
  136509. /*! exports provided: SceneComponentConstants, Stage */
  136510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136511. "use strict";
  136512. __webpack_require__.r(__webpack_exports__);
  136513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  136514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  136515. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136516. /**
  136517. * Groups all the scene component constants in one place to ease maintenance.
  136518. * @hidden
  136519. */
  136520. var SceneComponentConstants = /** @class */ (function () {
  136521. function SceneComponentConstants() {
  136522. }
  136523. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  136524. SceneComponentConstants.NAME_LAYER = "Layer";
  136525. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  136526. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  136527. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  136528. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  136529. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  136530. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  136531. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  136532. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  136533. SceneComponentConstants.NAME_SPRITE = "Sprite";
  136534. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  136535. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  136536. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  136537. SceneComponentConstants.NAME_OCTREE = "Octree";
  136538. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  136539. SceneComponentConstants.NAME_AUDIO = "Audio";
  136540. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  136541. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  136542. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  136543. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  136544. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  136545. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  136546. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  136547. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  136548. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  136549. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  136550. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  136551. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  136552. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  136553. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  136554. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  136555. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  136556. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  136557. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  136558. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  136559. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  136560. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  136561. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  136562. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  136563. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  136564. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  136565. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  136566. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  136567. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  136568. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  136569. return SceneComponentConstants;
  136570. }());
  136571. /**
  136572. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  136573. * @hidden
  136574. */
  136575. var Stage = /** @class */ (function (_super) {
  136576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  136577. /**
  136578. * Hide ctor from the rest of the world.
  136579. * @param items The items to add.
  136580. */
  136581. function Stage(items) {
  136582. return _super.apply(this, items) || this;
  136583. }
  136584. /**
  136585. * Creates a new Stage.
  136586. * @returns A new instance of a Stage
  136587. */
  136588. Stage.Create = function () {
  136589. return Object.create(Stage.prototype);
  136590. };
  136591. /**
  136592. * Registers a step in an ordered way in the targeted stage.
  136593. * @param index Defines the position to register the step in
  136594. * @param component Defines the component attached to the step
  136595. * @param action Defines the action to launch during the step
  136596. */
  136597. Stage.prototype.registerStep = function (index, component, action) {
  136598. var i = 0;
  136599. var maxIndex = Number.MAX_VALUE;
  136600. for (; i < this.length; i++) {
  136601. var step = this[i];
  136602. maxIndex = step.index;
  136603. if (index < maxIndex) {
  136604. break;
  136605. }
  136606. }
  136607. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  136608. };
  136609. /**
  136610. * Clears all the steps from the stage.
  136611. */
  136612. Stage.prototype.clear = function () {
  136613. this.length = 0;
  136614. };
  136615. return Stage;
  136616. }(Array));
  136617. /***/ })
  136618. /******/ });
  136619. });
  136620. //# sourceMappingURL=babylon.max.js.map